nikitagrover19 commented on code in PR #39160:
URL: https://github.com/apache/beam/pull/39160#discussion_r3563490008


##########
sdks/python/apache_beam/io/gcp/bigquery.py:
##########
@@ -2937,6 +2937,13 @@ class ReadFromBigQuery(PTransform):
       PCollection with a schema and yielding Beam Rows via the option
       `BEAM_ROW`. For more information on schemas, see
       
https://beam.apache.org/documentation/programming-guide/#what-is-a-schema)
+    query_output_schema: Required when output_type is 'BEAM_ROW' and a query
+      is specified. A BigQuery schema describing the query result columns,
+      since the schema cannot be auto-derived from an existing table when
+      using a query. Accepts the same formats as WriteToBigQuery's schema
+      parameter: a dict like
+      ``{'fields': [{'name': 'col', 'type': 'STRING', 'mode': 'NULLABLE'}]}``,
+      a JSON string, or a TableSchema object.

Review Comment:
   Added four tests in `bigquery_schema_tools_test.py` covering this. Also 
fixed a bug Gemini caught - `query_output_schema` was being passed raw to 
`convert_to_usertype`, which would crash at runtime if it was a dict or JSON 
string. Added `get_dict_table_schema()` normalization first, same as 
`WriteToBigQuery` does. Missing field and extra field both fail loudly with a 
`TypeError`. Type mismatch passes through silently — documented that in 
`test_query_schema_type_mismatch_not_validated` as a known limitation, 
consistent with the existing table-based path.



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