google-cloud-bigquery 3.26.0__tar.gz → 3.27.0__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 (153) hide show
  1. {google_cloud_bigquery-3.26.0/google_cloud_bigquery.egg-info → google_cloud_bigquery-3.27.0}/PKG-INFO +1 -1
  2. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/_pandas_helpers.py +99 -19
  3. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/client.py +19 -15
  4. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/version.py +1 -1
  5. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0/google_cloud_bigquery.egg-info}/PKG-INFO +1 -1
  6. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test__pandas_helpers.py +31 -0
  7. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/LICENSE +0 -0
  8. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/MANIFEST.in +0 -0
  9. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/README.rst +0 -0
  10. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/__init__.py +0 -0
  11. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/_helpers.py +0 -0
  12. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/_http.py +0 -0
  13. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/_job_helpers.py +0 -0
  14. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/_pyarrow_helpers.py +0 -0
  15. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/_tqdm_helpers.py +0 -0
  16. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/_versions_helpers.py +0 -0
  17. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/dataset.py +0 -0
  18. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/dbapi/__init__.py +0 -0
  19. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/dbapi/_helpers.py +0 -0
  20. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/dbapi/connection.py +0 -0
  21. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/dbapi/cursor.py +0 -0
  22. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/dbapi/exceptions.py +0 -0
  23. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/dbapi/types.py +0 -0
  24. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/encryption_configuration.py +0 -0
  25. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/enums.py +0 -0
  26. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/exceptions.py +0 -0
  27. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/external_config.py +0 -0
  28. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/format_options.py +0 -0
  29. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/iam.py +0 -0
  30. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/job/__init__.py +0 -0
  31. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/job/base.py +0 -0
  32. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/job/copy_.py +0 -0
  33. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/job/extract.py +0 -0
  34. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/job/load.py +0 -0
  35. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/job/query.py +0 -0
  36. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/magics/__init__.py +0 -0
  37. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/magics/line_arg_parser/__init__.py +0 -0
  38. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/magics/line_arg_parser/exceptions.py +0 -0
  39. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/magics/line_arg_parser/lexer.py +0 -0
  40. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/magics/line_arg_parser/parser.py +0 -0
  41. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/magics/line_arg_parser/visitors.py +0 -0
  42. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/magics/magics.py +0 -0
  43. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/model.py +0 -0
  44. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/opentelemetry_tracing.py +0 -0
  45. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/py.typed +0 -0
  46. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/query.py +0 -0
  47. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/retry.py +0 -0
  48. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/routine/__init__.py +0 -0
  49. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/routine/routine.py +0 -0
  50. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/schema.py +0 -0
  51. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/standard_sql.py +0 -0
  52. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery/table.py +0 -0
  53. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery_v2/__init__.py +0 -0
  54. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery_v2/types/__init__.py +0 -0
  55. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery_v2/types/encryption_config.py +0 -0
  56. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery_v2/types/model.py +0 -0
  57. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery_v2/types/model_reference.py +0 -0
  58. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery_v2/types/standard_sql.py +0 -0
  59. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google/cloud/bigquery_v2/types/table_reference.py +0 -0
  60. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google_cloud_bigquery.egg-info/SOURCES.txt +0 -0
  61. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google_cloud_bigquery.egg-info/dependency_links.txt +0 -0
  62. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google_cloud_bigquery.egg-info/not-zip-safe +0 -0
  63. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google_cloud_bigquery.egg-info/requires.txt +0 -0
  64. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/google_cloud_bigquery.egg-info/top_level.txt +0 -0
  65. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/setup.cfg +0 -0
  66. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/setup.py +0 -0
  67. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/__init__.py +0 -0
  68. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/data/characters.json +0 -0
  69. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/data/characters.jsonl +0 -0
  70. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/data/colors.avro +0 -0
  71. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/data/numeric_38_12.parquet +0 -0
  72. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/data/people.csv +0 -0
  73. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/data/scalars.csv +0 -0
  74. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/data/scalars.jsonl +0 -0
  75. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/data/scalars_extreme.jsonl +0 -0
  76. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/data/scalars_schema.json +0 -0
  77. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/data/scalars_schema_csv.json +0 -0
  78. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/data/schema.json +0 -0
  79. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/scrub_datasets.py +0 -0
  80. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/system/__init__.py +0 -0
  81. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/system/conftest.py +0 -0
  82. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/system/helpers.py +0 -0
  83. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/system/test_arrow.py +0 -0
  84. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/system/test_client.py +0 -0
  85. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/system/test_job_retry.py +0 -0
  86. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/system/test_list_rows.py +0 -0
  87. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/system/test_magics.py +0 -0
  88. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/system/test_pandas.py +0 -0
  89. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/system/test_query.py +0 -0
  90. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/system/test_structs.py +0 -0
  91. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/__init__.py +0 -0
  92. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/_helpers/__init__.py +0 -0
  93. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/_helpers/test_from_json.py +0 -0
  94. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/conftest.py +0 -0
  95. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/helpers.py +0 -0
  96. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/job/__init__.py +0 -0
  97. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/job/helpers.py +0 -0
  98. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/job/test_base.py +0 -0
  99. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/job/test_copy.py +0 -0
  100. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/job/test_extract.py +0 -0
  101. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/job/test_load.py +0 -0
  102. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/job/test_load_config.py +0 -0
  103. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/job/test_query.py +0 -0
  104. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/job/test_query_config.py +0 -0
  105. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/job/test_query_pandas.py +0 -0
  106. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/job/test_query_stats.py +0 -0
  107. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/line_arg_parser/__init__.py +0 -0
  108. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/line_arg_parser/test_lexer.py +0 -0
  109. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/line_arg_parser/test_parser.py +0 -0
  110. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/line_arg_parser/test_visitors.py +0 -0
  111. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/model/__init__.py +0 -0
  112. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/model/test_model.py +0 -0
  113. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/model/test_model_reference.py +0 -0
  114. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/routine/__init__.py +0 -0
  115. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/routine/test_remote_function_options.py +0 -0
  116. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/routine/test_routine.py +0 -0
  117. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/routine/test_routine_argument.py +0 -0
  118. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/routine/test_routine_reference.py +0 -0
  119. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test__helpers.py +0 -0
  120. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test__http.py +0 -0
  121. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test__job_helpers.py +0 -0
  122. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test__pyarrow_helpers.py +0 -0
  123. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test__versions_helpers.py +0 -0
  124. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_client.py +0 -0
  125. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_create_dataset.py +0 -0
  126. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_dataset.py +0 -0
  127. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_dbapi__helpers.py +0 -0
  128. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_dbapi_connection.py +0 -0
  129. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_dbapi_cursor.py +0 -0
  130. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_dbapi_types.py +0 -0
  131. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_delete_dataset.py +0 -0
  132. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_encryption_configuration.py +0 -0
  133. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_external_config.py +0 -0
  134. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_format_options.py +0 -0
  135. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_job_retry.py +0 -0
  136. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_legacy_types.py +0 -0
  137. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_list_datasets.py +0 -0
  138. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_list_jobs.py +0 -0
  139. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_list_models.py +0 -0
  140. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_list_projects.py +0 -0
  141. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_list_routines.py +0 -0
  142. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_list_tables.py +0 -0
  143. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_magics.py +0 -0
  144. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_opentelemetry_tracing.py +0 -0
  145. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_packaging.py +0 -0
  146. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_query.py +0 -0
  147. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_retry.py +0 -0
  148. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_schema.py +0 -0
  149. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_signature_compatibility.py +0 -0
  150. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_standard_sql_types.py +0 -0
  151. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_table.py +0 -0
  152. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_table_arrow.py +0 -0
  153. {google_cloud_bigquery-3.26.0 → google_cloud_bigquery-3.27.0}/tests/unit/test_table_pandas.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: google-cloud-bigquery
3
- Version: 3.26.0
3
+ Version: 3.27.0
4
4
  Summary: Google BigQuery API client library
5
5
  Home-page: https://github.com/googleapis/python-bigquery
6
6
  Author: Google LLC
@@ -21,13 +21,14 @@ from itertools import islice
21
21
  import logging
22
22
  import queue
23
23
  import warnings
24
- from typing import Any, Union
24
+ from typing import Any, Union, Optional, Callable, Generator, List
25
25
 
26
26
 
27
27
  from google.cloud.bigquery import _pyarrow_helpers
28
28
  from google.cloud.bigquery import _versions_helpers
29
29
  from google.cloud.bigquery import schema
30
30
 
31
+
31
32
  try:
32
33
  import pandas # type: ignore
33
34
 
@@ -75,7 +76,7 @@ else:
75
76
  _to_wkb = _to_wkb()
76
77
 
77
78
  try:
78
- from google.cloud.bigquery_storage import ArrowSerializationOptions
79
+ from google.cloud.bigquery_storage_v1.types import ArrowSerializationOptions
79
80
  except ImportError:
80
81
  _ARROW_COMPRESSION_SUPPORT = False
81
82
  else:
@@ -816,18 +817,54 @@ def _nowait(futures):
816
817
 
817
818
 
818
819
  def _download_table_bqstorage(
819
- project_id,
820
- table,
821
- bqstorage_client,
822
- preserve_order=False,
823
- selected_fields=None,
824
- page_to_item=None,
825
- max_queue_size=_MAX_QUEUE_SIZE_DEFAULT,
826
- ):
827
- """Use (faster, but billable) BQ Storage API to construct DataFrame."""
820
+ project_id: str,
821
+ table: Any,
822
+ bqstorage_client: Any,
823
+ preserve_order: bool = False,
824
+ selected_fields: Optional[List[Any]] = None,
825
+ page_to_item: Optional[Callable] = None,
826
+ max_queue_size: Any = _MAX_QUEUE_SIZE_DEFAULT,
827
+ max_stream_count: Optional[int] = None,
828
+ ) -> Generator[Any, None, None]:
829
+ """Downloads a BigQuery table using the BigQuery Storage API.
830
+
831
+ This method uses the faster, but potentially more expensive, BigQuery
832
+ Storage API to download a table as a Pandas DataFrame. It supports
833
+ parallel downloads and optional data transformations.
834
+
835
+ Args:
836
+ project_id (str): The ID of the Google Cloud project containing
837
+ the table.
838
+ table (Any): The BigQuery table to download.
839
+ bqstorage_client (Any): An
840
+ authenticated BigQuery Storage API client.
841
+ preserve_order (bool, optional): Whether to preserve the order
842
+ of the rows as they are read from BigQuery. If True this limits
843
+ the number of streams to one and overrides `max_stream_count`.
844
+ Defaults to False.
845
+ selected_fields (Optional[List[SchemaField]]):
846
+ A list of BigQuery schema fields to select for download. If None,
847
+ all fields are downloaded. Defaults to None.
848
+ page_to_item (Optional[Callable]): An optional callable
849
+ function that takes a page of data from the BigQuery Storage API
850
+ max_stream_count (Optional[int]): The maximum number of
851
+ concurrent streams to use for downloading data. If `preserve_order`
852
+ is True, the requested streams are limited to 1 regardless of the
853
+ `max_stream_count` value. If 0 or None, then the number of
854
+ requested streams will be unbounded. Defaults to None.
855
+
856
+ Yields:
857
+ pandas.DataFrame: Pandas DataFrames, one for each chunk of data
858
+ downloaded from BigQuery.
859
+
860
+ Raises:
861
+ ValueError: If attempting to read from a specific partition or snapshot.
862
+
863
+ Note:
864
+ This method requires the `google-cloud-bigquery-storage` library
865
+ to be installed.
866
+ """
828
867
 
829
- # Passing a BQ Storage client in implies that the BigQuery Storage library
830
- # is available and can be imported.
831
868
  from google.cloud import bigquery_storage
832
869
 
833
870
  if "$" in table.table_id:
@@ -837,10 +874,11 @@ def _download_table_bqstorage(
837
874
  if "@" in table.table_id:
838
875
  raise ValueError("Reading from a specific snapshot is not currently supported.")
839
876
 
840
- requested_streams = 1 if preserve_order else 0
877
+ requested_streams = determine_requested_streams(preserve_order, max_stream_count)
841
878
 
842
- requested_session = bigquery_storage.types.ReadSession(
843
- table=table.to_bqstorage(), data_format=bigquery_storage.types.DataFormat.ARROW
879
+ requested_session = bigquery_storage.types.stream.ReadSession(
880
+ table=table.to_bqstorage(),
881
+ data_format=bigquery_storage.types.stream.DataFormat.ARROW,
844
882
  )
845
883
  if selected_fields is not None:
846
884
  for field in selected_fields:
@@ -848,7 +886,8 @@ def _download_table_bqstorage(
848
886
 
849
887
  if _ARROW_COMPRESSION_SUPPORT:
850
888
  requested_session.read_options.arrow_serialization_options.buffer_compression = (
851
- ArrowSerializationOptions.CompressionCodec.LZ4_FRAME
889
+ # CompressionCodec(1) -> LZ4_FRAME
890
+ ArrowSerializationOptions.CompressionCodec(1)
852
891
  )
853
892
 
854
893
  session = bqstorage_client.create_read_session(
@@ -884,7 +923,7 @@ def _download_table_bqstorage(
884
923
  elif max_queue_size is None:
885
924
  max_queue_size = 0 # unbounded
886
925
 
887
- worker_queue = queue.Queue(maxsize=max_queue_size)
926
+ worker_queue: queue.Queue[int] = queue.Queue(maxsize=max_queue_size)
888
927
 
889
928
  with concurrent.futures.ThreadPoolExecutor(max_workers=total_streams) as pool:
890
929
  try:
@@ -910,7 +949,7 @@ def _download_table_bqstorage(
910
949
  # we want to block on the queue's get method, instead. This
911
950
  # prevents the queue from filling up, because the main thread
912
951
  # has smaller gaps in time between calls to the queue's get
913
- # method. For a detailed explaination, see:
952
+ # method. For a detailed explanation, see:
914
953
  # https://friendliness.dev/2019/06/18/python-nowait/
915
954
  done, not_done = _nowait(not_done)
916
955
  for future in done:
@@ -949,6 +988,7 @@ def download_arrow_bqstorage(
949
988
  preserve_order=False,
950
989
  selected_fields=None,
951
990
  max_queue_size=_MAX_QUEUE_SIZE_DEFAULT,
991
+ max_stream_count=None,
952
992
  ):
953
993
  return _download_table_bqstorage(
954
994
  project_id,
@@ -958,6 +998,7 @@ def download_arrow_bqstorage(
958
998
  selected_fields=selected_fields,
959
999
  page_to_item=_bqstorage_page_to_arrow,
960
1000
  max_queue_size=max_queue_size,
1001
+ max_stream_count=max_stream_count,
961
1002
  )
962
1003
 
963
1004
 
@@ -970,6 +1011,7 @@ def download_dataframe_bqstorage(
970
1011
  preserve_order=False,
971
1012
  selected_fields=None,
972
1013
  max_queue_size=_MAX_QUEUE_SIZE_DEFAULT,
1014
+ max_stream_count=None,
973
1015
  ):
974
1016
  page_to_item = functools.partial(_bqstorage_page_to_dataframe, column_names, dtypes)
975
1017
  return _download_table_bqstorage(
@@ -980,6 +1022,7 @@ def download_dataframe_bqstorage(
980
1022
  selected_fields=selected_fields,
981
1023
  page_to_item=page_to_item,
982
1024
  max_queue_size=max_queue_size,
1025
+ max_stream_count=max_stream_count,
983
1026
  )
984
1027
 
985
1028
 
@@ -1024,3 +1067,40 @@ def verify_pandas_imports():
1024
1067
  raise ValueError(_NO_PANDAS_ERROR) from pandas_import_exception
1025
1068
  if db_dtypes is None:
1026
1069
  raise ValueError(_NO_DB_TYPES_ERROR) from db_dtypes_import_exception
1070
+
1071
+
1072
+ def determine_requested_streams(
1073
+ preserve_order: bool,
1074
+ max_stream_count: Union[int, None],
1075
+ ) -> int:
1076
+ """Determines the value of requested_streams based on the values of
1077
+ `preserve_order` and `max_stream_count`.
1078
+
1079
+ Args:
1080
+ preserve_order (bool): Whether to preserve the order of streams. If True,
1081
+ this limits the number of streams to one. `preserve_order` takes
1082
+ precedence over `max_stream_count`.
1083
+ max_stream_count (Union[int, None]]): The maximum number of streams
1084
+ allowed. Must be a non-negative number or None, where None indicates
1085
+ the value is unset. NOTE: if `preserve_order` is also set, it takes
1086
+ precedence over `max_stream_count`, thus to ensure that `max_stream_count`
1087
+ is used, ensure that `preserve_order` is None.
1088
+
1089
+ Returns:
1090
+ (int) The appropriate value for requested_streams.
1091
+ """
1092
+
1093
+ if preserve_order:
1094
+ # If preserve order is set, it takes precendence.
1095
+ # Limit the requested streams to 1, to ensure that order
1096
+ # is preserved)
1097
+ return 1
1098
+
1099
+ elif max_stream_count is not None:
1100
+ # If preserve_order is not set, only then do we consider max_stream_count
1101
+ if max_stream_count <= -1:
1102
+ raise ValueError("max_stream_count must be non-negative OR None")
1103
+ return max_stream_count
1104
+
1105
+ # Default to zero requested streams (unbounded).
1106
+ return 0
@@ -328,6 +328,15 @@ class Client(ClientWithProject):
328
328
  ) -> str:
329
329
  """Get the email address of the project's BigQuery service account
330
330
 
331
+ Example:
332
+
333
+ .. code-block:: python
334
+
335
+ from google.cloud import bigquery
336
+ client = bigquery.Client()
337
+ client.get_service_account_email()
338
+ # returns an email similar to: my_service_account@my-project.iam.gserviceaccount.com
339
+
331
340
  Note:
332
341
  This is the service account that BigQuery uses to manage tables
333
342
  encrypted by a key in KMS.
@@ -345,13 +354,6 @@ class Client(ClientWithProject):
345
354
  str:
346
355
  service account email address
347
356
 
348
- Example:
349
-
350
- >>> from google.cloud import bigquery
351
- >>> client = bigquery.Client()
352
- >>> client.get_service_account_email()
353
- my_service_account@my-project.iam.gserviceaccount.com
354
-
355
357
  """
356
358
  if project is None:
357
359
  project = self.project
@@ -629,9 +631,19 @@ class Client(ClientWithProject):
629
631
  ) -> Dataset:
630
632
  """API call: create the dataset via a POST request.
631
633
 
634
+
632
635
  See
633
636
  https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets/insert
634
637
 
638
+ Example:
639
+
640
+ .. code-block:: python
641
+
642
+ from google.cloud import bigquery
643
+ client = bigquery.Client()
644
+ dataset = bigquery.Dataset('my_project.my_dataset')
645
+ dataset = client.create_dataset(dataset)
646
+
635
647
  Args:
636
648
  dataset (Union[ \
637
649
  google.cloud.bigquery.dataset.Dataset, \
@@ -658,14 +670,6 @@ class Client(ClientWithProject):
658
670
  Raises:
659
671
  google.cloud.exceptions.Conflict:
660
672
  If the dataset already exists.
661
-
662
- Example:
663
-
664
- >>> from google.cloud import bigquery
665
- >>> client = bigquery.Client()
666
- >>> dataset = bigquery.Dataset('my_project.my_dataset')
667
- >>> dataset = client.create_dataset(dataset)
668
-
669
673
  """
670
674
  dataset = self._dataset_from_arg(dataset)
671
675
  if isinstance(dataset, DatasetReference):
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- __version__ = "3.26.0"
15
+ __version__ = "3.27.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: google-cloud-bigquery
3
- Version: 3.26.0
3
+ Version: 3.27.0
4
4
  Summary: Google BigQuery API client library
5
5
  Home-page: https://github.com/googleapis/python-bigquery
6
6
  Author: Google LLC
@@ -18,6 +18,7 @@ import decimal
18
18
  import functools
19
19
  import operator
20
20
  import queue
21
+ from typing import Union
21
22
  from unittest import mock
22
23
  import warnings
23
24
 
@@ -46,6 +47,7 @@ from google.cloud.bigquery import exceptions
46
47
  from google.cloud.bigquery import _pyarrow_helpers
47
48
  from google.cloud.bigquery import _versions_helpers
48
49
  from google.cloud.bigquery import schema
50
+ from google.cloud.bigquery._pandas_helpers import determine_requested_streams
49
51
 
50
52
  pyarrow = _versions_helpers.PYARROW_VERSIONS.try_import()
51
53
 
@@ -2053,3 +2055,32 @@ def test_verify_pandas_imports_no_db_dtypes(module_under_test, monkeypatch):
2053
2055
  monkeypatch.setattr(module_under_test, "db_dtypes", None)
2054
2056
  with pytest.raises(ValueError, match="Please install the 'db-dtypes' package"):
2055
2057
  module_under_test.verify_pandas_imports()
2058
+
2059
+
2060
+ @pytest.mark.parametrize(
2061
+ "preserve_order, max_stream_count, expected_requested_streams",
2062
+ [
2063
+ # If preserve_order is set/True, it takes precedence:
2064
+ (True, 10, 1), # use 1
2065
+ (True, None, 1), # use 1
2066
+ # If preserve_order is not set check max_stream_count:
2067
+ (False, 10, 10), # max_stream_count (X) takes precedence
2068
+ (False, None, 0), # Unbounded (0) when both are unset
2069
+ ],
2070
+ )
2071
+ def test_determine_requested_streams(
2072
+ preserve_order: bool,
2073
+ max_stream_count: Union[int, None],
2074
+ expected_requested_streams: int,
2075
+ ):
2076
+ """Tests various combinations of preserve_order and max_stream_count."""
2077
+ actual_requested_streams = determine_requested_streams(
2078
+ preserve_order, max_stream_count
2079
+ )
2080
+ assert actual_requested_streams == expected_requested_streams
2081
+
2082
+
2083
+ def test_determine_requested_streams_invalid_max_stream_count():
2084
+ """Tests that a ValueError is raised if max_stream_count is negative."""
2085
+ with pytest.raises(ValueError):
2086
+ determine_requested_streams(preserve_order=False, max_stream_count=-1)