damccorm commented on code in PR #41465:
URL: https://github.com/apache/beam/pull/41465#discussion_r4671565886


##########
sdks/python/apache_beam/transforms/enrichment_handlers/bigquery.py:
##########
@@ -29,14 +34,370 @@
 from apache_beam.pvalue import Row
 from apache_beam.transforms.enrichment import EnrichmentSourceHandler
 
-QueryFn = Callable[[beam.Row], str]
+__all__ = ['BigQueryEnrichmentHandler']
+
+QueryFn = Callable[[beam.Row], Union[str, tuple[str, Sequence[Any]]]]
 ConditionValueFn = Callable[[beam.Row], list[Any]]
+PlaceholderRenderer = Callable[[str, str, bool], str]
 
 _LOGGER = logging.getLogger(__name__)
 
+MAX_BQ_QUERY_PARAMETERS = 10000
+
+SIMPLE_IDENTIFIER_PATTERN = re.compile(r'^[A-Za-z_][A-Za-z0-9_]*$')
+_SIMPLE_IDENTIFIER_PREFIX = re.compile(r'[A-Za-z_][A-Za-z0-9_]*')
+_SYS_VAR_PREFIX = re.compile(r'[A-Za-z_][A-Za-z0-9_.]*')
+_TABLE_SEGMENT = (
+    r'(?:`(?:[A-Za-z0-9_:$-]+\.)*[A-Za-z0-9_:$-]+`|[A-Za-z0-9_:$-]+)')
+TABLE_NAME_PATTERN = re.compile(rf'^{_TABLE_SEGMENT}(?:\.{_TABLE_SEGMENT})*$')
+_COLUMN_SEGMENT = r'(?:`[A-Za-z_][A-Za-z0-9_]*`|[A-Za-z_][A-Za-z0-9_]*)'
+COLUMN_NAME_PATTERN = re.compile(
+    rf'^(?:\*|{_COLUMN_SEGMENT}(?:\.{_COLUMN_SEGMENT})*)$')
+
+
+def validate_bigquery_identifier(

Review Comment:
   I'd recommend skipping identifier validation on `table_name` and 
`column_names` here. Those are static pipeline construction args rather than 
per-element data, and strict ASCII regexes like `COLUMN_NAME_PATTERN` / 
`TABLE_NAME_PATTERN` risk breaking valid existing pipelines (for example, 
`column_names` using aliases or expressions like `col AS alias`, or BigQuery 
table names with non-ASCII characters or spaces inside backticks).



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to