github-actions[bot] commented on code in PR #41564:
URL: https://github.com/apache/beam/pull/41564#discussion_r4658617160


##########
sdks/python/apache_beam/yaml/yaml_join.py:
##########
@@ -57,20 +57,34 @@ def _validate_type(type, pcolls):
         f'it must be one of the following: "inner", "outer", "left", "right"')
 
 
+def _extract_field_names(pcoll):
+  element_type = getattr(pcoll, 'element_type', None)
+  if element_type is None or element_type is Any:
+    return None
+  try:
+    from apache_beam.typehints.schemas import named_fields_from_element_type
+    return {name for name, _ in named_fields_from_element_type(element_type)}
+  except Exception:
+    pass
+  raw_fields = getattr(element_type, '_fields', None)
+  if raw_fields:
+    if all(isinstance(field, tuple) for field in raw_fields):

Review Comment:
   **🟡 Medium**: `_get_fields` catches `(TypeError, ValueError)` and returns 
`set()` when a `PCollection`'s `element_type` does not have a statically known 
schema (e.g., `Any`). While this gracefully skips column existence checks in 
`_validate_equalities`, it changes the behavior of `_SqlJoinTransform` (lines 
200-203): previously `named_fields_from_element_type` would raise a `TypeError` 
or `ValueError` during expansion if the schema was unknown, whereas now 
`all_fields` will be `{name: []}` and `_validate_fields(..., fields=None)` will 
return `{}` without raising an error, resulting in an invalid SQL query 
(`SELECT  FROM ...`) with no selected columns. Consider either letting 
`_SqlJoinTransform` call `named_fields_from_element_type` directly (so 
unschematized inputs fail fast with a clear schema error) or raising a 
`ValueError` when `_get_fields` returns an empty set in `_SqlJoinTransform`.



-- 
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