You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/07/26 15:54:11 UTC

[GitHub] [beam] TheMichaelHu opened a new pull request, #22452: Update BigQuery URI validation to allow more valid URIs through

TheMichaelHu opened a new pull request, #22452:
URL: https://github.com/apache/beam/pull/22452

   For Issue: #22451
   
   Update BigQuery URI validation for fully qualified table names to align more with documenation:
   - Support a wider range of characters for table names
   - Allow either `proj:dataset.table` or `proj.dataset.table` format
   - More rigorous validation of project id
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] [**Choose reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and mention them in a comment (`R: @username`).
    - [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
   
   To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   ------------------------------------------------------------------------------------------------
   [![Build python source distribution and wheels](https://github.com/apache/beam/workflows/Build%20python%20source%20distribution%20and%20wheels/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python tests](https://github.com/apache/beam/workflows/Python%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java tests](https://github.com/apache/beam/workflows/Java%20Tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] github-actions[bot] commented on pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #22452:
URL: https://github.com/apache/beam/pull/22452#issuecomment-1195723159

   Assigning reviewers. If you would like to opt out of this review, comment `assign to next reviewer`:
   
   R: @ryanthompson591 for label python.
   R: @ahmedabu98 for label io.
   
   Available commands:
   - `stop reviewer notifications` - opt out of the automated review tooling
   - `remind me after tests pass` - tag the comment author after tests pass
   - `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
   
   The PR bot will only process comments in the main thread (not review comments).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] TheMichaelHu commented on pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
TheMichaelHu commented on PR #22452:
URL: https://github.com/apache/beam/pull/22452#issuecomment-1202722329

   Run Python 3.8 PostCommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] TheMichaelHu commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
TheMichaelHu commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r934678068


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'([a-z0-9.-]+:)?[a-z][a-z0-9-]{4,28}[a-z0-9]'

Review Comment:
   It's the regex we use for the AutoML Tables product. `([a-z0-9.-]+:)?` handles domain-scoped projects, and `[a-z][a-z0-9-]{4,28}[a-z0-9]` is the most straightforward way to satisfy https://cloud.google.com/resource-manager/docs/creating-managing-projects#before_you_begin:
   
   - Must be 6 to 30 characters in length.
   - Can only contain lowercase letters, numbers, and hyphens.
   - Must start with a letter.
   - Cannot end with a hyphen.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] tvalentyn commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
tvalentyn commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r933594627


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -254,11 +258,10 @@ def parse_table_reference(table, dataset=None, project=None):
   # table argument will contain a full table reference instead of just a
   # table name.
   if dataset is None:
-    regex = re.compile(
-        r'''^((?P<project>.+):)?(?P<dataset>\w+)\.
-            (?P<table>[-\w\$]+(\s+\-*\w+)*)$''',
-        re.X)
-    match = regex.match(table)
+    pattern = (
+        f'((?P<project>{_PROJECT_PATTERN})[:\\.])?'

Review Comment:
   is a dot an allowed delimiter after project ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] ahmedabu98 commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
ahmedabu98 commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r930462456


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -254,11 +258,11 @@ def parse_table_reference(table, dataset=None, project=None):
   # table argument will contain a full table reference instead of just a
   # table name.
   if dataset is None:
-    regex = re.compile(
-        r'''^((?P<project>.+):)?(?P<dataset>\w+)\.
-            (?P<table>[-\w\$]+(\s+\-*\w+)*)$''',
-        re.X)
-    match = regex.match(table)
+    pattern = (
+        f'(?P<project>{_PROJECT_PATTERN})'
+        f'[:\\.](?P<dataset>{_DATASET_PATTERN})'
+        f'[:\\.](?P<table>{_TABLE_PATTERN})')

Review Comment:
   Current regex of `^((?P<project>.+):)?(?P<dataset>\w+)\.(?P<table>[-\w\$]+(\s+\-*\w+)*)$` doesn't include `:` after dataset. Line 264 would introduce it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] tvalentyn merged pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
tvalentyn merged PR #22452:
URL: https://github.com/apache/beam/pull/22452


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] TheMichaelHu commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
TheMichaelHu commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r931566621


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -254,11 +258,11 @@ def parse_table_reference(table, dataset=None, project=None):
   # table argument will contain a full table reference instead of just a
   # table name.
   if dataset is None:
-    regex = re.compile(
-        r'''^((?P<project>.+):)?(?P<dataset>\w+)\.
-            (?P<table>[-\w\$]+(\s+\-*\w+)*)$''',
-        re.X)
-    match = regex.match(table)
+    pattern = (
+        f'(?P<project>{_PROJECT_PATTERN})'
+        f'[:\\.](?P<dataset>{_DATASET_PATTERN})'
+        f'[:\\.](?P<table>{_TABLE_PATTERN})')

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] codecov[bot] commented on pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #22452:
URL: https://github.com/apache/beam/pull/22452#issuecomment-1198184364

   # [Codecov](https://codecov.io/gh/apache/beam/pull/22452?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#22452](https://codecov.io/gh/apache/beam/pull/22452?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (3999f66) into [master](https://codecov.io/gh/apache/beam/commit/5141ad8790a57e2fa62af607f32736e3eed399e3?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (5141ad8) will **decrease** coverage by `0.00%`.
   > The diff coverage is `100.00%`.
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #22452      +/-   ##
   ==========================================
   - Coverage   74.17%   74.17%   -0.01%     
   ==========================================
     Files         706      706              
     Lines       93226    93232       +6     
   ==========================================
   - Hits        69153    69151       -2     
   - Misses      22805    22813       +8     
     Partials     1268     1268              
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | python | `83.53% <100.00%> (-0.02%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/beam/pull/22452?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [sdks/python/apache\_beam/io/gcp/bigquery.py](https://codecov.io/gh/apache/beam/pull/22452/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0vaW8vZ2NwL2JpZ3F1ZXJ5LnB5) | `70.37% <ø> (ø)` | |
   | [sdks/python/apache\_beam/io/gcp/bigquery\_tools.py](https://codecov.io/gh/apache/beam/pull/22452/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0vaW8vZ2NwL2JpZ3F1ZXJ5X3Rvb2xzLnB5) | `85.73% <100.00%> (+0.05%)` | :arrow_up: |
   | [sdks/python/apache\_beam/utils/interactive\_utils.py](https://codecov.io/gh/apache/beam/pull/22452/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0vdXRpbHMvaW50ZXJhY3RpdmVfdXRpbHMucHk=) | `95.12% <0.00%> (-2.44%)` | :arrow_down: |
   | [sdks/python/apache\_beam/io/source\_test\_utils.py](https://codecov.io/gh/apache/beam/pull/22452/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0vaW8vc291cmNlX3Rlc3RfdXRpbHMucHk=) | `88.01% <0.00%> (-1.39%)` | :arrow_down: |
   | [...beam/testing/load\_tests/load\_test\_metrics\_utils.py](https://codecov.io/gh/apache/beam/pull/22452/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0vdGVzdGluZy9sb2FkX3Rlc3RzL2xvYWRfdGVzdF9tZXRyaWNzX3V0aWxzLnB5) | `34.07% <0.00%> (-0.39%)` | :arrow_down: |
   | [sdks/python/apache\_beam/runners/common.py](https://codecov.io/gh/apache/beam/pull/22452/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0vcnVubmVycy9jb21tb24ucHk=) | `88.59% <0.00%> (-0.25%)` | :arrow_down: |
   | [setup.py](https://codecov.io/gh/apache/beam/pull/22452/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2V0dXAucHk=) | `0.00% <0.00%> (ø)` | |
   | [...s/python/apache\_beam/runners/portability/stager.py](https://codecov.io/gh/apache/beam/pull/22452/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0vcnVubmVycy9wb3J0YWJpbGl0eS9zdGFnZXIucHk=) | `85.54% <0.00%> (ø)` | |
   | [...on/apache\_beam/examples/complete/juliaset/setup.py](https://codecov.io/gh/apache/beam/pull/22452/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0vZXhhbXBsZXMvY29tcGxldGUvanVsaWFzZXQvc2V0dXAucHk=) | `0.00% <0.00%> (ø)` | |
   | [.../python/apache\_beam/typehints/trivial\_inference.py](https://codecov.io/gh/apache/beam/pull/22452/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2Rrcy9weXRob24vYXBhY2hlX2JlYW0vdHlwZWhpbnRzL3RyaXZpYWxfaW5mZXJlbmNlLnB5) | `96.41% <0.00%> (+0.29%)` | :arrow_up: |
   
   Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] TheMichaelHu commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
TheMichaelHu commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r934678068


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'([a-z0-9.-]+:)?[a-z][a-z0-9-]{4,28}[a-z0-9]'

Review Comment:
   It's the regex we use for the AutoML Tables product. `([a-z0-9.-]+:)?` handles domain-scoped projects, and `[a-z][a-z0-9-]{4,28}[a-z0-9]` is the most straightforward way to satisfy https://cloud.google.com/resource-manager/docs/creating-managing-projects#before_you_begin:
   
   - Must be 6 to 30 characters in length.
   - Can only contain lowercase letters, numbers, and hyphens.
   - Must start with a letter.
   - Cannot end with a hyphen.
   
   btw, I'm okay with keeping the project id regex as relaxed is it was before. Main goal of this PR was to support all valid table names.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] TheMichaelHu commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
TheMichaelHu commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r930399363


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'[a-z][a-z0-9-]{4,28}[a-z0-9]'

Review Comment:
   > Must be 6 to 30 characters in length.
   
   I missed that the regex was supposed to allow project_id to be optional, running again with that change.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] ahmedabu98 commented on pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
ahmedabu98 commented on PR #22452:
URL: https://github.com/apache/beam/pull/22452#issuecomment-1197420193

   Rest of the code looks good to me, tests are failing though. Maybe double check regex logic.
   
   R: @robertwb I saw you reviewed regex in #22167. Does something stand out to you here?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] tvalentyn commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
tvalentyn commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r937110583


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'([a-z0-9.-]+:)?[a-z][a-z0-9-]{4,28}[a-z0-9]'
+_DATASET_PATTERN = r'\w{1,1024}'
+_TABLE_PATTERN = r'[\p{L}\p{M}\p{N}\p{Pc}\p{Pd}\p{Zs}$]{1,1024}'

Review Comment:
   Thanks for the above explanation. Could you  please explain the regex for `_TABLE_PATTERN` ? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] TheMichaelHu commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
TheMichaelHu commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r930414964


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'[a-z][a-z0-9-]{4,28}[a-z0-9]'
+_DATASET_PATTERN = r'\w{1,1024}'
+_TABLE_PATTERN = r'[\p{L}\p{M}\p{N}\p{Pc}\p{Pd}\p{Zs}]{1,1024}'

Review Comment:
   Good catch!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] TheMichaelHu commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
TheMichaelHu commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r934678068


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'([a-z0-9.-]+:)?[a-z][a-z0-9-]{4,28}[a-z0-9]'

Review Comment:
   It's the regex we use for the AutoML Tables product. `([a-z0-9.-]+:)?` handles domain-scoped projects, and `[a-z][a-z0-9-]{4,28}[a-z0-9]` is the most straightforward way to satisfy https://cloud.google.com/resource-manager/docs/creating-managing-projects#before_you_begin:
   
   - Must be 6 to 30 characters in length.
   - Can only contain lowercase letters, numbers, and hyphens.
   - Must start with a letter.
   - Cannot end with a hyphen.
   
   btw, I'm okay with keeping the project id regex as relaxed is it was before. Main goal of this PR was to relax the regex for table names.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] tvalentyn commented on pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
tvalentyn commented on PR #22452:
URL: https://github.com/apache/beam/pull/22452#issuecomment-1208761759

   LGTM


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] tvalentyn commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
tvalentyn commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r933596100


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -254,11 +258,10 @@ def parse_table_reference(table, dataset=None, project=None):
   # table argument will contain a full table reference instead of just a
   # table name.
   if dataset is None:
-    regex = re.compile(
-        r'''^((?P<project>.+):)?(?P<dataset>\w+)\.
-            (?P<table>[-\w\$]+(\s+\-*\w+)*)$''',
-        re.X)
-    match = regex.match(table)
+    pattern = (
+        f'((?P<project>{_PROJECT_PATTERN})[:\\.])?'

Review Comment:
   is it a common convention elsewhere?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] tvalentyn commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
tvalentyn commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r933595468


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'([a-z0-9.-]+:)?[a-z][a-z0-9-]{4,28}[a-z0-9]'

Review Comment:
   did these pattern come from some codebase or constructed manually?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] TheMichaelHu commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
TheMichaelHu commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r937832601


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'([a-z0-9.-]+:)?[a-z][a-z0-9-]{4,28}[a-z0-9]'

Review Comment:
   sgtm, removed length restrictions for project id



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] tvalentyn commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
tvalentyn commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r940779592


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'([a-z0-9.-]+:)?[a-z][a-z0-9-]{4,28}[a-z0-9]'
+_DATASET_PATTERN = r'\w{1,1024}'
+_TABLE_PATTERN = r'[\p{L}\p{M}\p{N}\p{Pc}\p{Pd}\p{Zs}$]{1,1024}'

Review Comment:
   Would you mind adding this link or the comment here in a follow-up PR? Thank you. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] tvalentyn commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
tvalentyn commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r937098502


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'([a-z0-9.-]+:)?[a-z][a-z0-9-]{4,28}[a-z0-9]'

Review Comment:
   I think I would refrain from imposing length restrictions on project id it may change in the future, but SDK will not. WDYT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] TheMichaelHu commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
TheMichaelHu commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r937826519


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'([a-z0-9.-]+:)?[a-z][a-z0-9-]{4,28}[a-z0-9]'
+_DATASET_PATTERN = r'\w{1,1024}'
+_TABLE_PATTERN = r'[\p{L}\p{M}\p{N}\p{Pc}\p{Pd}\p{Zs}$]{1,1024}'

Review Comment:
   > Contain Unicode characters in category L (letter), M (mark), N (number), Pc (connector, including underscore), Pd (dash), Zs (space). 
   
   from https://cloud.google.com/bigquery/docs/tables#table_naming
   
   The `$` is to also add support for table partitions.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] TheMichaelHu commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
TheMichaelHu commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r934678068


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'([a-z0-9.-]+:)?[a-z][a-z0-9-]{4,28}[a-z0-9]'

Review Comment:
   It's the regex we use for the AutoML Tables product. `([a-z0-9.-]+:)?` handles domain-scoped projects, and `[a-z][a-z0-9-]{4,28}[a-z0-9]` is the most straightforward way to satisfy https://cloud.google.com/resource-manager/docs/creating-managing-projects#before_you_begin:
   
   - Must be 6 to 30 characters in length.
   - Can only contain lowercase letters, numbers, and hyphens.
   - Must start with a letter.
   - Cannot end with a hyphen.
   
   btw, I'm okay with keeping the project id regex as relaxed as it was before. Main goal of this PR was to support all valid table names.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] TheMichaelHu commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
TheMichaelHu commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r934674008


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -254,11 +258,10 @@ def parse_table_reference(table, dataset=None, project=None):
   # table argument will contain a full table reference instead of just a
   # table name.
   if dataset is None:
-    regex = re.compile(
-        r'''^((?P<project>.+):)?(?P<dataset>\w+)\.
-            (?P<table>[-\w\$]+(\s+\-*\w+)*)$''',
-        re.X)
-    match = regex.match(table)
+    pattern = (
+        f'((?P<project>{_PROJECT_PATTERN})[:\\.])?'

Review Comment:
   dot is actually the only accepted delimiter after project, colon is invalid. https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#table_path
   
   I'm keeping colon as valid here for backwards compatibility.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] ahmedabu98 commented on pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
ahmedabu98 commented on PR #22452:
URL: https://github.com/apache/beam/pull/22452#issuecomment-1198339926

   Run Python 3.8 PostCommit


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] TheMichaelHu commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
TheMichaelHu commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r930416017


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -254,11 +258,11 @@ def parse_table_reference(table, dataset=None, project=None):
   # table argument will contain a full table reference instead of just a
   # table name.
   if dataset is None:
-    regex = re.compile(
-        r'''^((?P<project>.+):)?(?P<dataset>\w+)\.
-            (?P<table>[-\w\$]+(\s+\-*\w+)*)$''',
-        re.X)
-    match = regex.match(table)
+    pattern = (
+        f'(?P<project>{_PROJECT_PATTERN})'
+        f'[:\\.](?P<dataset>{_DATASET_PATTERN})'
+        f'[:\\.](?P<table>{_TABLE_PATTERN})')

Review Comment:
   Nope, it only allows `.` for table paths. For this not to be a breaking change we'll need to continue supporting `:` after the project. I have no strong opinions about allowing `:` after the dataset, seemed more consistant.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] ahmedabu98 commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
ahmedabu98 commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r930360989


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'[a-z][a-z0-9-]{4,28}[a-z0-9]'

Review Comment:
   I suspect this is why precommits are failing: https://ci-beam.apache.org/job/beam_PreCommit_Python_Commit/24179/testReport/



##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -254,11 +258,11 @@ def parse_table_reference(table, dataset=None, project=None):
   # table argument will contain a full table reference instead of just a
   # table name.
   if dataset is None:
-    regex = re.compile(
-        r'''^((?P<project>.+):)?(?P<dataset>\w+)\.
-            (?P<table>[-\w\$]+(\s+\-*\w+)*)$''',
-        re.X)
-    match = regex.match(table)
+    pattern = (
+        f'(?P<project>{_PROJECT_PATTERN})'
+        f'[:\\.](?P<dataset>{_DATASET_PATTERN})'
+        f'[:\\.](?P<table>{_TABLE_PATTERN})')

Review Comment:
   Glad to see you're allowing for the dot in `project.dataset` too.
   
   Does BigQuery allow the colon operator in between `dataset` and `table`? AFAIK it should be dot operator.



##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'[a-z][a-z0-9-]{4,28}[a-z0-9]'

Review Comment:
   Minimum project character requirement is 4, see [here](https://cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project). As it is now the minimum is 6. Perhaps the lower end of the range could be 2.



##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'[a-z][a-z0-9-]{4,28}[a-z0-9]'
+_DATASET_PATTERN = r'\w{1,1024}'
+_TABLE_PATTERN = r'[\p{L}\p{M}\p{N}\p{Pc}\p{Pd}\p{Zs}]{1,1024}'

Review Comment:
   Does this include the partition character `$`? This is needed when user is specifying a table partition, see https://cloud.google.com/bigquery/docs/managing-partitioned-table-data#partition_decorators.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] TheMichaelHu commented on a diff in pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
TheMichaelHu commented on code in PR #22452:
URL: https://github.com/apache/beam/pull/22452#discussion_r930399363


##########
sdks/python/apache_beam/io/gcp/bigquery_tools.py:
##########
@@ -101,6 +101,10 @@
 # Timeout for a BQ streaming insert RPC. Set to a maximum of 2 minutes.
 BQ_STREAMING_INSERT_TIMEOUT_SEC = 120
 
+_PROJECT_PATTERN = r'[a-z][a-z0-9-]{4,28}[a-z0-9]'

Review Comment:
   > Must be 6 to 30 characters in length.
   
   I missed that the regex was supposed to allow project_id to be optional, running again with that change. In this case, we check `{4,28}` because the first and last characters have different patterns (must begin with a letter and can't end with a hyphen).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] github-actions[bot] commented on pull request #22452: Update BigQuery URI validation to allow more valid URIs through

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #22452:
URL: https://github.com/apache/beam/pull/22452#issuecomment-1197421386

   Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org