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_query_params_* code samples to pass query_parameters to QueryJobConfig constructor #9596

Closed
3 tasks
tswast opened this issue Nov 4, 2019 · 1 comment · Fixed by #9974
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

@tswast
Copy link
Contributor

tswast commented Nov 4, 2019

Is your feature request related to a problem? Please describe.

The code samples for using query parameters are a bit hard to follow because they create several temporary variables.

query_params = [
bigquery.ScalarQueryParameter("corpus", "STRING", "romeoandjuliet"),
bigquery.ScalarQueryParameter("min_word_count", "INT64", 250),
]
job_config = bigquery.QueryJobConfig()
job_config.query_parameters = query_params

The code samples are still in snippets.py. Ideally these samples would be moved to the samples/ directory.

The code samples supply a location argument for queries, even though this can now be autodetected for queries in all regions.

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

  • Move any bigquery_query_params_... samples to the samples/ directory.
  • Remove the location argument from the query() method in the moved code samples
  • Use the query_parameters argument in the constructor to QueryJobConfig (added in BigQuery: Add properties to job config constructors #6397).
job_config = bigquery.QueryJobConfig(
    query_parameters=[
        bigquery.ScalarQueryParameter("corpus", "STRING", "romeoandjuliet"),
        bigquery.ScalarQueryParameter("min_word_count", "INT64", 250),
    ],
)

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.

Reported by customer in internal issue 143862711.

@tswast tswast added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. api: bigquery Issues related to the BigQuery API. labels Nov 4, 2019
@emar-kar
Copy link
Contributor

emar-kar commented Nov 4, 2019

Since I’m already working with the snippets refactoring #9495, I assume this should be assigned to me as well.

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