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/03/22 19:24:16 UTC

[GitHub] [beam] chunyang commented on a change in pull request #17153: [BEAM-14112] Avoid storing a generator in _CustomBigQuerySource

chunyang commented on a change in pull request #17153:
URL: https://github.com/apache/beam/pull/17153#discussion_r832546377



##########
File path: sdks/python/apache_beam/io/gcp/bigquery.py
##########
@@ -657,6 +658,22 @@ def reader(self, test_bigquery_client=None):
         kms_key=self.kms_key)
 
 
+class _BigQueryExportResult:
+  def __init__(self, schema, metadata_list):
+    self.schema = schema
+    self.metadata_list = metadata_list
+
+  # Store schema as JSON string since TableSchema objects cannot be pickled.
+  @property
+  @functools.lru_cache()
+  def schema(self):
+    return bigquery_tools.parse_table_schema_from_json(self._schema)
+
+  @schema.setter
+  def schema(self, value):
+    self._schema = json.dumps(bigquery_tools.table_schema_to_dict(value))

Review comment:
       Are there any guarantees that `json.dumps(bigquery_tools.table_schema_to_dict(x))` and `bigquery_tools.parse_table_schema_from_json(x)` are reciprocal functions?




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