samples(bigquery-storage): add Arrow query results samples for query_and_wait and read_rows - #18126
samples(bigquery-storage): add Arrow query results samples for query_and_wait and read_rows#18126alextolpin wants to merge 2 commits into
Conversation
|
Here is the summary of changes. You are about to add 2 region tags.
This comment is generated by snippet-bot.
|
There was a problem hiding this comment.
Code Review
This pull request introduces two new code snippets and their corresponding tests to demonstrate reading BigQuery query results in Apache Arrow format. Specifically, query_and_wait_arrow.py uses the query_and_wait method to fetch Arrow RecordBatches directly, while read_rows_query_job.py initiates a query job and streams the results using the BigQuery Storage Read API. A critical issue was identified in read_rows_query_job.py where the query job is started asynchronously, but the code immediately attempts to read from the stream without waiting for the job to complete. It is recommended to call job.result() to ensure the query finishes before reading.
|
From the |
| pyarrow===12.0.1; python_version == '3.7' | ||
| pyarrow===17.0.0; python_version == '3.8' | ||
| pyarrow==24.0.0; python_version >= '3.9' |
There was a problem hiding this comment.
3.9 is no longer supported. We can use pyarrow==24.0.0
| pyarrow===12.0.1; python_version == '3.7' | |
| pyarrow===17.0.0; python_version == '3.8' | |
| pyarrow==24.0.0; python_version >= '3.9' | |
| pyarrow===12.0.1; python_version == '3.7' | |
| pyarrow===17.0.0; python_version == '3.8' | |
| pyarrow==24.0.0 |
Description
Adds documentation code snippets and system tests demonstrating high-performance query result retrieval in Apache Arrow format with LZ4 compression using the BigQuery Storage API:
query_and_wait()with Arrow format & LZ4 frame compression (query_and_wait_arrow.py):client.query_and_wait()withquery_results_format=enums.QueryResultsFormat.ARROWandcompression_codec=enums.QueryResultsCompressionCodec.LZ4_FRAME.pyarrow.RecordBatchviaresults.to_arrow_iterable().[START bigquerystorage_query_and_wait_arrow].Direct
read_rowson query job default stream (read_rows_query_job.py):BigQueryReadClient.read_rowsagainst the job streamprojects/{project}/locations/{location}/jobs/{job_id}/streams/_default.pyarrow.ipc.[START bigquerystorage_read_rows_query_job].Tests & Dependencies:
query_and_wait_arrow_test.pyandread_rows_query_job_test.pyverifying batch iteration and schema types.pyarrowdependency pins tosamples/snippets/requirements.txt.Follow-up to #18027
Related to #18047
Checklist