Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BigQuery: refactor bigquery_load_* code samples to pass parameters to LoadJobConfig constructor #9907

Closed
2 tasks
emar-kar opened this issue Dec 3, 2019 · 1 comment
Assignees
Labels
api: bigquery Issues related to the BigQuery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@emar-kar
Copy link
Contributor

emar-kar commented Dec 3, 2019

Is your feature request related to a problem? Please describe.
Related to #9596. Since query_parameters will be passed directly into the QueryJobConfig constructor I assume the same should be applied to the parameters in LoadJobConfig constructor as well. I consider that it will help to simplify and optimize the code of the request.

job_config = bigquery.LoadJobConfig()
job_config.source_format = bigquery.SourceFormat.CSV
job_config.skip_leading_rows = 1
job_config.autodetect = True

job_config = bigquery.LoadJobConfig()
job_config.schema = [
bigquery.SchemaField("name", "STRING"),
bigquery.SchemaField("post_abbr", "STRING"),
]
job_config.skip_leading_rows = 1
# The source format defaults to CSV, so the line below is optional.
job_config.source_format = bigquery.SourceFormat.CSV

Describe the solution you'd like
A clear and concise description of what you want to happen.

  • Move any LoadJobConfig snippets into the samples folder
  • Unify the LoadJobConfig constructor initialization same way as in 9495

e.g.,

job_config = bigquery.LoadJobConfig(
        schema=[
            bigquery.SchemaField("name", "STRING"),
            bigquery.SchemaField("post_abbr", "STRING"),
            bigquery.SchemaField("date", "DATE"),
        ],
        skip_leading_rows=1,
        time_partitioning=bigquery.TimePartitioning(
            type_=bigquery.TimePartitioningType.DAY,
            field="date",  # Name of the column to use for partitioning.
            expiration_ms=7776000000,  # 90 days.
        ),
    )

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
N/A
Additional context
Add any other context or screenshots about the feature request here.
N/A

@emar-kar emar-kar added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. api: bigquery Issues related to the BigQuery API. labels Dec 3, 2019
@emar-kar emar-kar self-assigned this Dec 3, 2019
@emar-kar
Copy link
Contributor Author

emar-kar commented Dec 3, 2019

@tswast, please comment

@emar-kar emar-kar changed the title BigQuery: refactor bigquery_load_params_* code samples to pass load_parameters to LoadJobConfig constructor BigQuery: refactor bigquery_load_params_* code samples to pass parameters into LoadJobConfig constructor Dec 3, 2019
@emar-kar emar-kar changed the title BigQuery: refactor bigquery_load_params_* code samples to pass parameters into LoadJobConfig constructor BigQuery: refactor bigquery_load_* code samples to pass load_parameters to LoadJobConfig constructor Dec 3, 2019
@emar-kar emar-kar changed the title BigQuery: refactor bigquery_load_* code samples to pass load_parameters to LoadJobConfig constructor BigQuery: refactor bigquery_load_* code samples to pass parameters to LoadJobConfig constructor Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

2 participants