@SuppressWarnings({
    "nullness" // TODO(https://github.com/apache/beam/issues/20497)
  })
  public static TableReference parseTableUrn(String tableUrn) {
    Matcher match = BigQueryIO.TABLE_URN_SPEC.matcher(tableUrn);
    if (!match.matches()) {
      throw new IllegalArgumentException(
          "Table reference is not in projects/[project_id]/datasets/[dataset_id]/tables/[table_id] "
              + "format: "
              + tableUrn);
    }

    TableReference ref = new TableReference();
    ref.setProjectId(match.group("PROJECT"));

    return ref.setDatasetId(match.group("DATASET")).setTableId(match.group("TABLE"));
  }
@Test
  public void testTableUrnParsing() {
    TableReference ref =
        BigQueryHelpers.parseTableUrn("projects/my-project/datasets/data_set/tables/table_name");
    assertEquals("my-project", ref.getProjectId());
    assertEquals("data_set", ref.getDatasetId());
    assertEquals("table_name", ref.getTableId());
  }