Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sdks/python/apache_beam/io/gcp/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -2764,6 +2764,9 @@ def expand(self, input):

class ConvertToBeamRows(PTransform):
def __init__(self, schema, dynamic_destinations):
if not isinstance(schema,
(bigquery.TableSchema, bigquery.TableFieldSchema)):
schema = bigquery_tools.get_bq_tableschema(schema)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need remove the lines in beam_row_from_dict?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or beam_row_from_dict is used elsewhere, so we should keep it. Just a thought.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could remove it but
beam_row_from_dict is publicly used method so removing this if would be potentially breaking change.

Comment on lines +2767 to +2769
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This is a good optimization to parse the schema once at transform construction. This change makes the schema parsing logic inside bigquery_tools.beam_row_from_dict redundant. To improve maintainability and prevent confusion, consider removing the redundant check from beam_row_from_dict as part of this PR or in a follow-up change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good bot

self.schema = schema
self.dynamic_destinations = dynamic_destinations

Expand Down
Loading