-
Notifications
You must be signed in to change notification settings - Fork 322
Closed
Labels
api: bigqueryIssues related to the googleapis/python-bigquery API.Issues related to the googleapis/python-bigquery API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- OS type and version: macOS Big Sur 11.6.1
- Python version:
3.9.7 - pip version:
21.3.1 google-cloud-bigqueryversion:2.29.0
Description
Prior versions of google-cloud-bigquery (2.3.1) allowed SchemaField instantiation based on an existing SchemaField __repr__.
Use Case
- System generates list of
SchemaFieldand passes it through a Jinja template as part of building hundreds of Airflow DAGs. - Jinja prints
__repr__from theSchemaFieldinto the templated.py. - Airflow picks up the
.pyfiles and executes them. - Execution results in the below error.
Code example
In version 2.3.1
from google.cloud.bigquery import SchemaField
from google.cloud import bigquery
bigquery.__version__
'2.3.1'
# This works
field = SchemaField('name', 'STRING', 'REQUIRED', 'Name')
field.__repr__()
"SchemaField('name', 'STRING', 'REQUIRED', 'Name', (), ())"
# Jinja prints ^^ to a .py file
# When the file is executed the SchemaField is created without issueVersion 2.29.0:
from google.cloud.bigquery import SchemaField
from google.cloud import bigquery
bigquery.__version__
'2.29.0'
# This raises an error for the tuple in the last field
field = SchemaField('name', 'STRING', 'REQUIRED', 'Name')
field.__repr__()
"SchemaField('name', 'STRING', 'REQUIRED', 'Name', (), ())"
# Jinja prints ^^ to a .py file
# When the file is executed, an error is raised:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/wes.roach/.pyenv/versions/upgr-dbt/lib/python3.9/site-packages/google/cloud/bigquery/schema.py", line 125, in __init__
policy_tags.to_api_repr() if policy_tags is not None else None
AttributeError: 'tuple' object has no attribute 'to_api_repr'Setting the policy_tags to None still results in ().
field = SchemaField('name', 'STRING', 'REQUIRED', 'Name', (), None)
field.__repr__()
"SchemaField('name', 'STRING', 'REQUIRED', 'Name', (), ())"Metadata
Metadata
Assignees
Labels
api: bigqueryIssues related to the googleapis/python-bigquery API.Issues related to the googleapis/python-bigquery API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.