Skip to content

Commit

Permalink
Cherry Pick #32178: Loose BigQuery GCP project ID regex restrictions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kberezin-nshl authored Aug 26, 2024
1 parent 57d5ab5 commit 37d41fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,12 @@ public class BigQueryIO {
static final JsonFactory JSON_FACTORY = Transport.getJsonFactory();

/**
* Project IDs must contain 6-63 lowercase letters, digits, or dashes. IDs must start with a
* letter and may not end with a dash. This regex isn't exact - this allows for patterns that
* would be rejected by the service, but this is sufficient for basic parsing of table references.
* Formally, project IDs must contain 6-63 lowercase letters, digits, or dashes, must start with a
* letter and may not end with a dash. This regex is used for basic parsing of table references
* rather than validation purpose, e.g. it allows looser restriction for testing on mock
* resources. It may allow for patterns that would be rejected by the service
*/
private static final String PROJECT_ID_REGEXP = "[a-z][-a-z0-9:.]{4,61}[a-z0-9]";
private static final String PROJECT_ID_REGEXP = "[a-z][-a-z0-9:.]{0,61}[a-z0-9]";

/** Regular expression that matches Dataset IDs. */
private static final String DATASET_REGEXP = "[-\\w.]{1,1024}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public void testTableUrnParsing() {
public void testTableParsing_validPatterns() {
BigQueryHelpers.parseTableSpec("a123-456:foo_bar.d");
BigQueryHelpers.parseTableSpec("a12345:b.c");
BigQueryHelpers.parseTableSpec("a1:b.c");
BigQueryHelpers.parseTableSpec("b12345.c");
}

Expand Down

0 comments on commit 37d41fd

Please sign in to comment.