pyarrow-bigquery 0.7.2__tar.gz → 0.7.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/PKG-INFO +5 -1
  2. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/README.md +4 -0
  3. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/pyproject.toml +1 -1
  4. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/read.py +26 -5
  5. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/Cargo.lock +0 -0
  6. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/Cargo.toml +0 -0
  7. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/build.rs +0 -0
  8. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/api/annotations.proto +0 -0
  9. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/api/client.proto +0 -0
  10. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/api/field_behavior.proto +0 -0
  11. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/api/http.proto +0 -0
  12. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/api/launch_stage.proto +0 -0
  13. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/api/resource.proto +0 -0
  14. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/api/routing.proto +0 -0
  15. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/cloud/bigquery/storage/v1/annotations.proto +0 -0
  16. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/cloud/bigquery/storage/v1/arrow.proto +0 -0
  17. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/cloud/bigquery/storage/v1/avro.proto +0 -0
  18. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/cloud/bigquery/storage/v1/protobuf.proto +0 -0
  19. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/cloud/bigquery/storage/v1/storage.proto +0 -0
  20. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/cloud/bigquery/storage/v1/stream.proto +0 -0
  21. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/cloud/bigquery/storage/v1/table.proto +0 -0
  22. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/proto/google/rpc/status.proto +0 -0
  23. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/src/lib.rs +0 -0
  24. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/src/proto.rs +0 -0
  25. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/src/reader.rs +0 -0
  26. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/rust/target/CACHEDIR.TAG +0 -0
  27. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/__init__.py +0 -0
  28. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/exchange/__init__.py +0 -0
  29. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/exchange/arrow_ipc.py +0 -0
  30. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/exchange/base.py +0 -0
  31. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/exchange/feather.py +0 -0
  32. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/exchange/memory.py +0 -0
  33. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/exchange/shared_dict.py +0 -0
  34. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/exchange/shared_memory.py +0 -0
  35. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/some_itertools.py +0 -0
  36. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/write/__init__.py +0 -0
  37. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/write/pa_to_bq.py +0 -0
  38. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/write/pa_to_pb.py +0 -0
  39. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/write/type_mapping.py +0 -0
  40. {pyarrow_bigquery-0.7.2 → pyarrow_bigquery-0.7.3}/src/pyarrow/bigquery/write/upload.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyarrow-bigquery
3
- Version: 0.7.2
3
+ Version: 0.7.3
4
4
  Requires-Dist: google-cloud-bigquery>=3.10.0,<5
5
5
  Requires-Dist: google-cloud-bigquery-storage>=2.18.0,<3
6
6
  Requires-Dist: pyarrow
@@ -161,6 +161,10 @@ table = bq.read_table(
161
161
 
162
162
  The same options work on `reader`, `read_query`, and `reader_query`.
163
163
 
164
+ When `row_restrictions` (or the table itself) matches no rows, `read_table` and
165
+ `read_query` return a zero-row `pa.Table` that still carries the BigQuery
166
+ schema, so downstream code can rely on the columns being present.
167
+
164
168
  ### Query location and large results
165
169
 
166
170
  Pass `location` when the query must run in a specific region. For very large query outputs, materialize into a temporary table and read via the Storage API:
@@ -147,6 +147,10 @@ table = bq.read_table(
147
147
 
148
148
  The same options work on `reader`, `read_query`, and `reader_query`.
149
149
 
150
+ When `row_restrictions` (or the table itself) matches no rows, `read_table` and
151
+ `read_query` return a zero-row `pa.Table` that still carries the BigQuery
152
+ schema, so downstream code can rely on the columns being present.
153
+
150
154
  ### Query location and large results
151
155
 
152
156
  Pass `location` when the query must run in a specific region. For very large query outputs, materialize into a temporary table and read via the Storage API:
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "pyarrow-bigquery"
7
- version = "0.7.2"
7
+ version = "0.7.3"
8
8
  description = "An extension library to write to and read from BigQuery tables as PyArrow tables."
9
9
  authors = [{ name = "Sebastian Pawluś" }]
10
10
  readme = "README.md"
@@ -312,8 +312,11 @@ class reader:
312
312
 
313
313
  self.workers_done = 0
314
314
 
315
- assert self.streams, "No streams to read, Table might be empty"
316
-
315
+ # BigQuery returns zero streams when `row_restrictions` (or the table
316
+ # itself) matches no rows. The read session still carries the table
317
+ # schema, so we keep `self.schema` and simply start no workers; the
318
+ # reader then yields nothing and callers can fall back to an empty
319
+ # table that preserves the schema.
317
320
  self.actual_worker_count = min(self.worker_count, len(self.streams))
318
321
 
319
322
  logger.debug(
@@ -321,7 +324,12 @@ class reader:
321
324
  )
322
325
  logger.debug(f"Actual worker count: {self.actual_worker_count}")
323
326
 
324
- for read_streams in some_itertools.to_split(self.streams, self.actual_worker_count):
327
+ worker_splits = (
328
+ some_itertools.to_split(self.streams, self.actual_worker_count)
329
+ if self.actual_worker_count
330
+ else ()
331
+ )
332
+ for read_streams in worker_splits:
325
333
  worker = self.worker_type(
326
334
  target=_stream_worker,
327
335
  args=(
@@ -387,6 +395,9 @@ class reader:
387
395
  raise RuntimeError(f"Unexpected BigQuery read worker message: {(kind, payload)!r}")
388
396
 
389
397
  def _next_python(self):
398
+ if self.actual_worker_count == 0:
399
+ # No streams were created (empty result set); nothing to yield.
400
+ raise StopIteration
390
401
  while True:
391
402
  try:
392
403
  element = self.queue_results.get(timeout=_QUEUE_GET_TIMEOUT)
@@ -557,7 +568,13 @@ def read_table(
557
568
  compression=compression,
558
569
  engine=engine,
559
570
  ) as r:
560
- return pa.concat_tables(r)
571
+ tables = list(r)
572
+ if tables:
573
+ return pa.concat_tables(tables)
574
+ # Empty result set (e.g. a `row_restrictions` that matches no rows).
575
+ # Return a zero-row table that still carries the BigQuery schema
576
+ # instead of raising or dropping the schema.
577
+ return r.schema.empty_table()
561
578
 
562
579
 
563
580
  def read_query(
@@ -589,4 +606,8 @@ def read_query(
589
606
  compression=compression,
590
607
  engine=engine,
591
608
  ) as r:
592
- return pa.concat_tables(r)
609
+ tables = list(r)
610
+ if tables:
611
+ return pa.concat_tables(tables)
612
+ # Empty result set: preserve the schema with a zero-row table.
613
+ return r.schema.empty_table()