feat(bigquery): Support queryResultsFormat and compressionCodec in query_and_wait()

オープン
#18,047 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python
領域
api, data

調査の方向性

Client.query_and_wait() から開始し、次に BigQuery リクエストのペイロードについては _job_helpers.py、RowIterator と Arrow のパースについては table.py を追跡します。関連する PR 18027 と比較し、両方のオプションが受け付けられて API に送信されること、また圧縮された Arrow 結果が記載された to_arrow() と to_dataframe() のユースケースをサポートすることを確認してください。

索引モデルが issue の本文から書いたものです。

説明

api: bigquery priority: p3 type: feature request
Determine this is the right repository
  • I determined this is the correct repository in which to report this feature request.
Summary of the feature request
Feature Description

Add support for query_results_format (e.g., "ARROW") and compression_codec (e.g., "LZ4_FRAME") in Client.query_and_wait() and related job helper functions in google-cloud-bigquery.

Use Case & Problem Statement

Currently, Client.query_and_wait() executes a query and fetches results, but does not allow callers to request the underlying query results format as Apache Arrow streams or specify compression options directly during the fetch process.

For high-performance data processing pipelines using Apache Arrow or PyArrow, requesting query results in Arrow format with compression significantly reduces network payload size, deserialization overhead, and total query result fetch latency.

Proposed Solution
  1. Update google.cloud.bigquery.client.Client.query_and_wait() to accept optional parameters:
    • query_results_format: Optional string specifying result serialization format (e.g. "ARROW").
    • compression_codec: Optional string specifying compression algorithm
  2. Update underlying helper functions in _job_helpers.py to populate these options in the request payload sent to the BigQuery API.
  3. Update RowIterator and Arrow parsing logic in table.py to seamlessly handle Arrow record batch streams when query_results_format="ARROW" is specified.
Alternative Approaches Considered
  • Manually constructing custom QueryJob instances and extracting Arrow record batches post-execution, which requires boilerplate code and loses the convenience of query_and_wait().
Additional Context

Related PR: https://github.com/googleapis/google-cloud-python/pull/18027

Desired code experience

from google.cloud import bigquery

client = bigquery.Client()

query = "SELECT * FROM bigquery-public-data.usa_names.usa_1910_2013 LIMIT 10000"

Request query results directly in Apache Arrow format with LZ4_FRAME compression

results = client.query_and_wait(
query,
query_results_format="ARROW",
compression_codec="LZ4_FRAME",
)

Convert directly to PyArrow Table or Pandas DataFrame

arrow_table = results.to_arrow()
df = results.to_dataframe()

Expected results
  1. Client.query_and_wait() accepts query_results_format and compression_codec parameters.
  2. The BigQuery API receives these parameters in the job execution request.
  3. Query results are returned and parsed efficiently via compressed Apache Arrow streams into the resulting RowIterator / Arrow table without client errors.
API client name and version

No response

Use case

e.g. This feature would be useful in a scenario where I need to process large amounts of data efficiently.

Additional context

https://github.com/googleapis/google-cloud-python/pull/18027

主要言語
Python
スター
5.4k
フォーク
1.8k
平均マージ
2日 7時間
マージ済み PR(30日)
173

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

googleapis/google-cloud-python のほかの issue

googleapis/google-cloud-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。