google-cloud-bigquery 3.17.2__tar.gz → 3.18.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 (151) hide show
  1. {google-cloud-bigquery-3.17.2/google_cloud_bigquery.egg-info → google-cloud-bigquery-3.18.0}/PKG-INFO +1 -1
  2. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/_job_helpers.py +1 -1
  3. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/_pandas_helpers.py +19 -0
  4. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/client.py +84 -90
  5. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/job/query.py +5 -0
  6. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/magics/magics.py +1 -1
  7. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/opentelemetry_tracing.py +1 -1
  8. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/version.py +1 -1
  9. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0/google_cloud_bigquery.egg-info}/PKG-INFO +1 -1
  10. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/system/test_pandas.py +12 -1
  11. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/system/test_query.py +1 -1
  12. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/job/test_query_stats.py +4 -0
  13. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test__job_helpers.py +3 -3
  14. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test__pandas_helpers.py +48 -17
  15. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_table.py +3 -0
  16. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/LICENSE +0 -0
  17. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/MANIFEST.in +0 -0
  18. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/README.rst +0 -0
  19. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/__init__.py +0 -0
  20. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/_helpers.py +0 -0
  21. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/_http.py +0 -0
  22. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/_pyarrow_helpers.py +0 -0
  23. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/_tqdm_helpers.py +0 -0
  24. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/_versions_helpers.py +0 -0
  25. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/dataset.py +0 -0
  26. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/dbapi/__init__.py +0 -0
  27. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/dbapi/_helpers.py +0 -0
  28. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/dbapi/connection.py +0 -0
  29. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/dbapi/cursor.py +0 -0
  30. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/dbapi/exceptions.py +0 -0
  31. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/dbapi/types.py +0 -0
  32. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/encryption_configuration.py +0 -0
  33. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/enums.py +0 -0
  34. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/exceptions.py +0 -0
  35. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/external_config.py +0 -0
  36. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/format_options.py +0 -0
  37. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/iam.py +0 -0
  38. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/job/__init__.py +0 -0
  39. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/job/base.py +0 -0
  40. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/job/copy_.py +0 -0
  41. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/job/extract.py +0 -0
  42. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/job/load.py +0 -0
  43. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/magics/__init__.py +0 -0
  44. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/magics/line_arg_parser/__init__.py +0 -0
  45. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/magics/line_arg_parser/exceptions.py +0 -0
  46. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/magics/line_arg_parser/lexer.py +0 -0
  47. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/magics/line_arg_parser/parser.py +0 -0
  48. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/magics/line_arg_parser/visitors.py +0 -0
  49. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/model.py +0 -0
  50. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/py.typed +0 -0
  51. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/query.py +0 -0
  52. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/retry.py +0 -0
  53. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/routine/__init__.py +0 -0
  54. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/routine/routine.py +0 -0
  55. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/schema.py +0 -0
  56. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/standard_sql.py +0 -0
  57. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery/table.py +0 -0
  58. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery_v2/__init__.py +0 -0
  59. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery_v2/types/__init__.py +0 -0
  60. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery_v2/types/encryption_config.py +0 -0
  61. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery_v2/types/model.py +0 -0
  62. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery_v2/types/model_reference.py +0 -0
  63. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery_v2/types/standard_sql.py +0 -0
  64. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google/cloud/bigquery_v2/types/table_reference.py +0 -0
  65. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google_cloud_bigquery.egg-info/SOURCES.txt +0 -0
  66. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google_cloud_bigquery.egg-info/dependency_links.txt +0 -0
  67. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google_cloud_bigquery.egg-info/not-zip-safe +0 -0
  68. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google_cloud_bigquery.egg-info/requires.txt +0 -0
  69. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/google_cloud_bigquery.egg-info/top_level.txt +0 -0
  70. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/setup.cfg +0 -0
  71. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/setup.py +0 -0
  72. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/__init__.py +0 -0
  73. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/data/characters.json +0 -0
  74. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/data/characters.jsonl +0 -0
  75. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/data/colors.avro +0 -0
  76. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/data/numeric_38_12.parquet +0 -0
  77. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/data/people.csv +0 -0
  78. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/data/scalars.jsonl +0 -0
  79. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/data/scalars_extreme.jsonl +0 -0
  80. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/data/scalars_schema.json +0 -0
  81. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/data/schema.json +0 -0
  82. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/scrub_datasets.py +0 -0
  83. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/system/__init__.py +0 -0
  84. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/system/conftest.py +0 -0
  85. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/system/helpers.py +0 -0
  86. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/system/test_arrow.py +0 -0
  87. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/system/test_client.py +0 -0
  88. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/system/test_job_retry.py +0 -0
  89. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/system/test_list_rows.py +0 -0
  90. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/system/test_magics.py +0 -0
  91. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/system/test_structs.py +0 -0
  92. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/__init__.py +0 -0
  93. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/_helpers/__init__.py +0 -0
  94. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/_helpers/test_from_json.py +0 -0
  95. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/conftest.py +0 -0
  96. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/helpers.py +0 -0
  97. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/job/__init__.py +0 -0
  98. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/job/helpers.py +0 -0
  99. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/job/test_base.py +0 -0
  100. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/job/test_copy.py +0 -0
  101. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/job/test_extract.py +0 -0
  102. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/job/test_load.py +0 -0
  103. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/job/test_load_config.py +0 -0
  104. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/job/test_query.py +0 -0
  105. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/job/test_query_config.py +0 -0
  106. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/job/test_query_pandas.py +0 -0
  107. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/line_arg_parser/__init__.py +0 -0
  108. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/line_arg_parser/test_lexer.py +0 -0
  109. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/line_arg_parser/test_parser.py +0 -0
  110. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/line_arg_parser/test_visitors.py +0 -0
  111. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/model/__init__.py +0 -0
  112. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/model/test_model.py +0 -0
  113. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/model/test_model_reference.py +0 -0
  114. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/routine/__init__.py +0 -0
  115. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/routine/test_remote_function_options.py +0 -0
  116. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/routine/test_routine.py +0 -0
  117. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/routine/test_routine_argument.py +0 -0
  118. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/routine/test_routine_reference.py +0 -0
  119. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test__helpers.py +0 -0
  120. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test__http.py +0 -0
  121. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test__pyarrow_helpers.py +0 -0
  122. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test__versions_helpers.py +0 -0
  123. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_client.py +0 -0
  124. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_create_dataset.py +0 -0
  125. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_dataset.py +0 -0
  126. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_dbapi__helpers.py +0 -0
  127. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_dbapi_connection.py +0 -0
  128. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_dbapi_cursor.py +0 -0
  129. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_dbapi_types.py +0 -0
  130. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_delete_dataset.py +0 -0
  131. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_encryption_configuration.py +0 -0
  132. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_external_config.py +0 -0
  133. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_format_options.py +0 -0
  134. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_job_retry.py +0 -0
  135. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_legacy_types.py +0 -0
  136. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_list_datasets.py +0 -0
  137. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_list_jobs.py +0 -0
  138. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_list_models.py +0 -0
  139. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_list_projects.py +0 -0
  140. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_list_routines.py +0 -0
  141. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_list_tables.py +0 -0
  142. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_magics.py +0 -0
  143. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_opentelemetry_tracing.py +0 -0
  144. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_packaging.py +0 -0
  145. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_query.py +0 -0
  146. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_retry.py +0 -0
  147. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_schema.py +0 -0
  148. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_signature_compatibility.py +0 -0
  149. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_standard_sql_types.py +0 -0
  150. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.0}/tests/unit/test_table_arrow.py +0 -0
  151. {google-cloud-bigquery-3.17.2 → google-cloud-bigquery-3.18.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.17.2
3
+ Version: 3.18.0
4
4
  Summary: Google BigQuery API client library
5
5
  Home-page: https://github.com/googleapis/python-bigquery
6
6
  Author: Google LLC
@@ -54,7 +54,7 @@ if TYPE_CHECKING: # pragma: NO COVER
54
54
 
55
55
 
56
56
  # The purpose of _TIMEOUT_BUFFER_MILLIS is to allow the server-side timeout to
57
- # happen before the client-side timeout. This is not strictly neccessary, as the
57
+ # happen before the client-side timeout. This is not strictly necessary, as the
58
58
  # client retries client-side timeouts, but the hope by making the server-side
59
59
  # timeout slightly shorter is that it can save the server from some unncessary
60
60
  # processing time.
@@ -958,6 +958,25 @@ def dataframe_to_json_generator(dataframe):
958
958
  # considered a NaN, however.
959
959
  if isinstance(is_nan, bool) and is_nan:
960
960
  continue
961
+
962
+ # Convert numpy types to corresponding Python types.
963
+ # https://stackoverflow.com/a/60441783/101923
964
+ if isinstance(value, numpy.bool_):
965
+ value = bool(value)
966
+ elif isinstance(
967
+ value,
968
+ (
969
+ numpy.int64,
970
+ numpy.int32,
971
+ numpy.int16,
972
+ numpy.int8,
973
+ numpy.uint64,
974
+ numpy.uint32,
975
+ numpy.uint16,
976
+ numpy.uint8,
977
+ ),
978
+ ):
979
+ value = int(value)
961
980
  output[column] = value
962
981
 
963
982
  yield output
@@ -1716,20 +1716,24 @@ class Client(ClientWithProject):
1716
1716
  :func:`~google.cloud.bigquery.client.Client.cancel_job` instead.
1717
1717
 
1718
1718
  Args:
1719
- job_id: Job or job identifier.
1720
-
1721
- Keyword Arguments:
1722
- project:
1719
+ job_id (Union[ \
1720
+ str, \
1721
+ LoadJob, \
1722
+ CopyJob, \
1723
+ ExtractJob, \
1724
+ QueryJob \
1725
+ ]): Job or job identifier.
1726
+ project (Optional[str]):
1723
1727
  ID of the project which owns the job (defaults to the client's project).
1724
- location:
1728
+ location (Optional[str]):
1725
1729
  Location where the job was run. Ignored if ``job_id`` is a job
1726
1730
  object.
1727
- retry:
1731
+ retry (Optional[google.api_core.retry.Retry]):
1728
1732
  How to retry the RPC.
1729
- timeout:
1733
+ timeout (Optional[float]):
1730
1734
  The number of seconds to wait for the underlying HTTP transport
1731
1735
  before using ``retry``.
1732
- not_found_ok:
1736
+ not_found_ok (Optional[bool]):
1733
1737
  Defaults to ``False``. If ``True``, ignore "not found" errors
1734
1738
  when deleting the job.
1735
1739
  """
@@ -1970,12 +1974,10 @@ class Client(ClientWithProject):
1970
1974
  timeout: TimeoutType = DEFAULT_TIMEOUT,
1971
1975
  ) -> Union[job.LoadJob, job.CopyJob, job.ExtractJob, job.QueryJob]:
1972
1976
  """Create a new job.
1977
+
1973
1978
  Args:
1974
1979
  job_config (dict): configuration job representation returned from the API.
1975
-
1976
- Keyword Arguments:
1977
- retry (Optional[google.api_core.retry.Retry]):
1978
- How to retry the RPC.
1980
+ retry (Optional[google.api_core.retry.Retry]): How to retry the RPC.
1979
1981
  timeout (Optional[float]):
1980
1982
  The number of seconds to wait for the underlying HTTP transport
1981
1983
  before using ``retry``.
@@ -2066,10 +2068,14 @@ class Client(ClientWithProject):
2066
2068
  https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/get
2067
2069
 
2068
2070
  Args:
2069
- job_id:
2071
+ job_id (Union[ \
2072
+ str, \
2073
+ job.LoadJob, \
2074
+ job.CopyJob, \
2075
+ job.ExtractJob, \
2076
+ job.QueryJob \
2077
+ ]):
2070
2078
  Job identifier.
2071
-
2072
- Keyword Arguments:
2073
2079
  project (Optional[str]):
2074
2080
  ID of the project which owns the job (defaults to the client's project).
2075
2081
  location (Optional[str]):
@@ -2137,8 +2143,6 @@ class Client(ClientWithProject):
2137
2143
  google.cloud.bigquery.job.ExtractJob, \
2138
2144
  google.cloud.bigquery.job.QueryJob \
2139
2145
  ]): Job identifier.
2140
-
2141
- Keyword Arguments:
2142
2146
  project (Optional[str]):
2143
2147
  ID of the project which owns the job (defaults to the client's project).
2144
2148
  location (Optional[str]):
@@ -2340,8 +2344,6 @@ class Client(ClientWithProject):
2340
2344
  in, this method attempts to create a table reference from a
2341
2345
  string using
2342
2346
  :func:`google.cloud.bigquery.table.TableReference.from_string`.
2343
-
2344
- Keyword Arguments:
2345
2347
  job_id (Optional[str]): Name of the job.
2346
2348
  job_id_prefix (Optional[str]):
2347
2349
  The user-provided prefix for a randomly generated job ID.
@@ -2415,39 +2417,42 @@ class Client(ClientWithProject):
2415
2417
  returns a :class:`~google.cloud.bigquery.job.LoadJob`.
2416
2418
 
2417
2419
  Args:
2418
- file_obj:
2420
+ file_obj (IO[bytes]):
2419
2421
  A file handle opened in binary mode for reading.
2420
- destination:
2422
+ destination (Union[Table, \
2423
+ TableReference, \
2424
+ TableListItem, \
2425
+ str \
2426
+ ]):
2421
2427
  Table into which data is to be loaded. If a string is passed
2422
2428
  in, this method attempts to create a table reference from a
2423
2429
  string using
2424
2430
  :func:`google.cloud.bigquery.table.TableReference.from_string`.
2425
-
2426
- Keyword Arguments:
2427
- rewind:
2431
+ rewind (Optional[bool]):
2428
2432
  If True, seek to the beginning of the file handle before
2429
- reading the file.
2430
- size:
2433
+ reading the file. Defaults to False.
2434
+ size (Optional[int]):
2431
2435
  The number of bytes to read from the file handle. If size is
2432
2436
  ``None`` or large, resumable upload will be used. Otherwise,
2433
2437
  multipart upload will be used.
2434
- num_retries: Number of upload retries. Defaults to 6.
2435
- job_id: Name of the job.
2436
- job_id_prefix:
2438
+ num_retries (Optional[int]): Number of upload retries. Defaults to 6.
2439
+ job_id (Optional[str]): Name of the job.
2440
+ job_id_prefix (Optional[str]):
2437
2441
  The user-provided prefix for a randomly generated job ID.
2438
2442
  This parameter will be ignored if a ``job_id`` is also given.
2439
- location:
2443
+ location (Optional[str]):
2440
2444
  Location where to run the job. Must match the location of the
2441
2445
  destination table.
2442
- project:
2446
+ project (Optional[str]):
2443
2447
  Project ID of the project of where to run the job. Defaults
2444
2448
  to the client's project.
2445
- job_config:
2449
+ job_config (Optional[LoadJobConfig]):
2446
2450
  Extra configuration options for the job.
2447
- timeout:
2451
+ timeout (Optional[float]):
2448
2452
  The number of seconds to wait for the underlying HTTP transport
2449
2453
  before using ``retry``. Depending on the retry strategy, a request
2450
2454
  may be repeated several times using the same timeout each time.
2455
+ Defaults to None.
2451
2456
 
2452
2457
  Can also be passed as a tuple (connect_timeout, read_timeout).
2453
2458
  See :meth:`requests.Session.request` documentation for details.
@@ -2535,9 +2540,13 @@ class Client(ClientWithProject):
2535
2540
  https://github.com/googleapis/python-bigquery/issues/19
2536
2541
 
2537
2542
  Args:
2538
- dataframe:
2543
+ dataframe (pandas.Dataframe):
2539
2544
  A :class:`~pandas.DataFrame` containing the data to load.
2540
- destination:
2545
+ destination (Union[ \
2546
+ Table, \
2547
+ TableReference, \
2548
+ str \
2549
+ ]):
2541
2550
  The destination table to use for loading the data. If it is an
2542
2551
  existing table, the schema of the :class:`~pandas.DataFrame`
2543
2552
  must match the schema of the destination table. If the table
@@ -2547,21 +2556,19 @@ class Client(ClientWithProject):
2547
2556
  If a string is passed in, this method attempts to create a
2548
2557
  table reference from a string using
2549
2558
  :func:`google.cloud.bigquery.table.TableReference.from_string`.
2550
-
2551
- Keyword Arguments:
2552
- num_retries: Number of upload retries.
2553
- job_id: Name of the job.
2554
- job_id_prefix:
2559
+ num_retries (Optional[int]): Number of upload retries. Defaults to 6.
2560
+ job_id (Optional[str]): Name of the job.
2561
+ job_id_prefix (Optional[str]):
2555
2562
  The user-provided prefix for a randomly generated
2556
2563
  job ID. This parameter will be ignored if a ``job_id`` is
2557
2564
  also given.
2558
- location:
2565
+ location (Optional[str]):
2559
2566
  Location where to run the job. Must match the location of the
2560
2567
  destination table.
2561
- project:
2568
+ project (Optional[str]):
2562
2569
  Project ID of the project of where to run the job. Defaults
2563
2570
  to the client's project.
2564
- job_config:
2571
+ job_config (Optional[LoadJobConfig]):
2565
2572
  Extra configuration options for the job.
2566
2573
 
2567
2574
  To override the default pandas data type conversions, supply
@@ -2578,9 +2585,10 @@ class Client(ClientWithProject):
2578
2585
  :attr:`~google.cloud.bigquery.job.SourceFormat.CSV` and
2579
2586
  :attr:`~google.cloud.bigquery.job.SourceFormat.PARQUET` are
2580
2587
  supported.
2581
- parquet_compression:
2588
+ parquet_compression (Optional[str]):
2582
2589
  [Beta] The compression method to use if intermittently
2583
2590
  serializing ``dataframe`` to a parquet file.
2591
+ Defaults to "snappy".
2584
2592
 
2585
2593
  The argument is directly passed as the ``compression``
2586
2594
  argument to the underlying ``pyarrow.parquet.write_table()``
@@ -2591,10 +2599,11 @@ class Client(ClientWithProject):
2591
2599
  passed as the ``compression`` argument to the underlying
2592
2600
  ``DataFrame.to_parquet()`` method.
2593
2601
  https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_parquet.html#pandas.DataFrame.to_parquet
2594
- timeout:
2602
+ timeout (Optional[flaot]):
2595
2603
  The number of seconds to wait for the underlying HTTP transport
2596
2604
  before using ``retry``. Depending on the retry strategy, a request may
2597
2605
  be repeated several times using the same timeout each time.
2606
+ Defaults to None.
2598
2607
 
2599
2608
  Can also be passed as a tuple (connect_timeout, read_timeout).
2600
2609
  See :meth:`requests.Session.request` documentation for details.
@@ -2784,32 +2793,36 @@ class Client(ClientWithProject):
2784
2793
  client = bigquery.Client()
2785
2794
  client.load_table_from_file(data_as_file, ...)
2786
2795
 
2787
- destination:
2796
+ destination (Union[ \
2797
+ Table, \
2798
+ TableReference, \
2799
+ TableListItem, \
2800
+ str \
2801
+ ]):
2788
2802
  Table into which data is to be loaded. If a string is passed
2789
2803
  in, this method attempts to create a table reference from a
2790
2804
  string using
2791
2805
  :func:`google.cloud.bigquery.table.TableReference.from_string`.
2792
-
2793
- Keyword Arguments:
2794
- num_retries: Number of upload retries.
2795
- job_id: Name of the job.
2796
- job_id_prefix:
2806
+ num_retries (Optional[int]): Number of upload retries. Defaults to 6.
2807
+ job_id (Optional[str]): Name of the job.
2808
+ job_id_prefix (Optional[str]):
2797
2809
  The user-provided prefix for a randomly generated job ID.
2798
2810
  This parameter will be ignored if a ``job_id`` is also given.
2799
- location:
2811
+ location (Optional[str]):
2800
2812
  Location where to run the job. Must match the location of the
2801
2813
  destination table.
2802
- project:
2814
+ project (Optional[str]):
2803
2815
  Project ID of the project of where to run the job. Defaults
2804
2816
  to the client's project.
2805
- job_config:
2817
+ job_config (Optional[LoadJobConfig]):
2806
2818
  Extra configuration options for the job. The ``source_format``
2807
2819
  setting is always set to
2808
2820
  :attr:`~google.cloud.bigquery.job.SourceFormat.NEWLINE_DELIMITED_JSON`.
2809
- timeout:
2821
+ timeout (Optional[float]):
2810
2822
  The number of seconds to wait for the underlying HTTP transport
2811
2823
  before using ``retry``. Depending on the retry strategy, a request may
2812
2824
  be repeated several times using the same timeout each time.
2825
+ Defaults to None.
2813
2826
 
2814
2827
  Can also be passed as a tuple (connect_timeout, read_timeout).
2815
2828
  See :meth:`requests.Session.request` documentation for details.
@@ -2885,23 +2898,19 @@ class Client(ClientWithProject):
2885
2898
  """Perform a resumable upload.
2886
2899
 
2887
2900
  Args:
2888
- stream: A bytes IO object open for reading.
2889
-
2890
- metadata: The metadata associated with the upload.
2891
-
2892
- num_retries:
2901
+ stream (IO[bytes]): A bytes IO object open for reading.
2902
+ metadata (Mapping[str, str]): The metadata associated with the upload.
2903
+ num_retries (int):
2893
2904
  Number of upload retries. (Deprecated: This
2894
2905
  argument will be removed in a future release.)
2895
-
2896
- timeout:
2906
+ timeout (Optional[float]):
2897
2907
  The number of seconds to wait for the underlying HTTP transport
2898
2908
  before using ``retry``. Depending on the retry strategy, a request may
2899
2909
  be repeated several times using the same timeout each time.
2900
2910
 
2901
2911
  Can also be passed as a tuple (connect_timeout, read_timeout).
2902
2912
  See :meth:`requests.Session.request` documentation for details.
2903
-
2904
- project:
2913
+ project (Optional[str]):
2905
2914
  Project ID of the project of where to run the upload. Defaults
2906
2915
  to the client's project.
2907
2916
 
@@ -2929,23 +2938,19 @@ class Client(ClientWithProject):
2929
2938
  """Initiate a resumable upload.
2930
2939
 
2931
2940
  Args:
2932
- stream: A bytes IO object open for reading.
2933
-
2934
- metadata: The metadata associated with the upload.
2935
-
2936
- num_retries:
2941
+ stream (IO[bytes]): A bytes IO object open for reading.
2942
+ metadata (Mapping[str, str]): The metadata associated with the upload.
2943
+ num_retries (int):
2937
2944
  Number of upload retries. (Deprecated: This
2938
2945
  argument will be removed in a future release.)
2939
-
2940
- timeout:
2946
+ timeout (Optional[float]):
2941
2947
  The number of seconds to wait for the underlying HTTP transport
2942
2948
  before using ``retry``. Depending on the retry strategy, a request may
2943
2949
  be repeated several times using the same timeout each time.
2944
2950
 
2945
2951
  Can also be passed as a tuple (connect_timeout, read_timeout).
2946
2952
  See :meth:`requests.Session.request` documentation for details.
2947
-
2948
- project:
2953
+ project (Optional[str]):
2949
2954
  Project ID of the project of where to run the upload. Defaults
2950
2955
  to the client's project.
2951
2956
 
@@ -3005,28 +3010,23 @@ class Client(ClientWithProject):
3005
3010
  """Perform a multipart upload.
3006
3011
 
3007
3012
  Args:
3008
- stream: A bytes IO object open for reading.
3009
-
3010
- metadata: The metadata associated with the upload.
3011
-
3012
- size:
3013
+ stream (IO[bytes]): A bytes IO object open for reading.
3014
+ metadata (Mapping[str, str]): The metadata associated with the upload.
3015
+ size (int):
3013
3016
  The number of bytes to be uploaded (which will be read
3014
3017
  from ``stream``). If not provided, the upload will be
3015
3018
  concluded once ``stream`` is exhausted (or :data:`None`).
3016
-
3017
- num_retries:
3019
+ num_retries (int):
3018
3020
  Number of upload retries. (Deprecated: This
3019
3021
  argument will be removed in a future release.)
3020
-
3021
- timeout:
3022
+ timeout (Optional[float]):
3022
3023
  The number of seconds to wait for the underlying HTTP transport
3023
3024
  before using ``retry``. Depending on the retry strategy, a request may
3024
3025
  be repeated several times using the same timeout each time.
3025
3026
 
3026
3027
  Can also be passed as a tuple (connect_timeout, read_timeout).
3027
3028
  See :meth:`requests.Session.request` documentation for details.
3028
-
3029
- project:
3029
+ project (Optional[str]):
3030
3030
  Project ID of the project of where to run the upload. Defaults
3031
3031
  to the client's project.
3032
3032
 
@@ -3118,8 +3118,6 @@ class Client(ClientWithProject):
3118
3118
  str, \
3119
3119
  ]):
3120
3120
  Table into which data is to be copied.
3121
-
3122
- Keyword Arguments:
3123
3121
  job_id (Optional[str]): The ID of the job.
3124
3122
  job_id_prefix (Optional[str]):
3125
3123
  The user-provided prefix for a randomly generated job ID.
@@ -3216,8 +3214,6 @@ class Client(ClientWithProject):
3216
3214
  URIs of Cloud Storage file(s) into which table data is to be
3217
3215
  extracted; in format
3218
3216
  ``gs://<bucket_name>/<object_name_or_glob>``.
3219
-
3220
- Keyword Arguments:
3221
3217
  job_id (Optional[str]): The ID of the job.
3222
3218
  job_id_prefix (Optional[str]):
3223
3219
  The user-provided prefix for a randomly generated job ID.
@@ -3306,8 +3302,6 @@ class Client(ClientWithProject):
3306
3302
  query (str):
3307
3303
  SQL query to be executed. Defaults to the standard SQL
3308
3304
  dialect. Use the ``job_config`` parameter to change dialects.
3309
-
3310
- Keyword Arguments:
3311
3305
  job_config (Optional[google.cloud.bigquery.job.QueryJobConfig]):
3312
3306
  Extra configuration options for the job.
3313
3307
  To override any options that were previously set in
@@ -2263,6 +2263,11 @@ class QueryPlanEntry(object):
2263
2263
  for step in self._properties.get("steps", [])
2264
2264
  ]
2265
2265
 
2266
+ @property
2267
+ def slot_ms(self):
2268
+ """Optional[int]: Slot-milliseconds used by the stage."""
2269
+ return _helpers._int_or_none(self._properties.get("slotMs"))
2270
+
2266
2271
 
2267
2272
  class TimelineEntry(object):
2268
2273
  """TimelineEntry represents progress of a query job at a particular
@@ -288,7 +288,7 @@ def _handle_error(error, destination_var=None):
288
288
 
289
289
  Args:
290
290
  error (Exception):
291
- An exception that ocurred during the query execution.
291
+ An exception that occurred during the query execution.
292
292
  destination_var (Optional[str]):
293
293
  The name of the IPython session variable to store the query job.
294
294
  """
@@ -90,7 +90,7 @@ def _get_final_span_attributes(attributes=None, client=None, job_ref=None):
90
90
  """Compiles attributes from: client, job_ref, user-provided attributes.
91
91
 
92
92
  Attributes from all of these sources are merged together. Note the
93
- attributes are added sequentially based on perceived order of precendence:
93
+ attributes are added sequentially based on perceived order of precedence:
94
94
  i.e. attributes added last may overwrite attributes added earlier.
95
95
 
96
96
  Args:
@@ -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.17.2"
15
+ __version__ = "3.18.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: google-cloud-bigquery
3
- Version: 3.17.2
3
+ Version: 3.18.0
4
4
  Summary: Google BigQuery API client library
5
5
  Home-page: https://github.com/googleapis/python-bigquery
6
6
  Author: Google LLC
@@ -835,7 +835,9 @@ def test_insert_rows_from_dataframe(bigquery_client, dataset_id):
835
835
  schema = [
836
836
  SF("float_col", "FLOAT", mode="REQUIRED"),
837
837
  SF("int_col", "INTEGER", mode="REQUIRED"),
838
+ SF("int64_col", "INTEGER", mode="NULLABLE"),
838
839
  SF("bool_col", "BOOLEAN", mode="REQUIRED"),
840
+ SF("boolean_col", "BOOLEAN", mode="NULLABLE"),
839
841
  SF("string_col", "STRING", mode="NULLABLE"),
840
842
  SF("date_col", "DATE", mode="NULLABLE"),
841
843
  SF("time_col", "TIME", mode="NULLABLE"),
@@ -898,6 +900,15 @@ def test_insert_rows_from_dataframe(bigquery_client, dataset_id):
898
900
  dataframe["date_col"] = dataframe["date_col"].astype("dbdate")
899
901
  dataframe["time_col"] = dataframe["time_col"].astype("dbtime")
900
902
 
903
+ # Support nullable integer and boolean dtypes.
904
+ # https://github.com/googleapis/python-bigquery/issues/1815
905
+ dataframe["int64_col"] = pandas.Series(
906
+ [-11, -22, pandas.NA, -44, -55, -66], dtype="Int64"
907
+ )
908
+ dataframe["boolean_col"] = pandas.Series(
909
+ [True, False, True, pandas.NA, True, False], dtype="boolean"
910
+ )
911
+
901
912
  table_id = f"{bigquery_client.project}.{dataset_id}.test_insert_rows_from_dataframe"
902
913
  table_arg = bigquery.Table(table_id, schema=schema)
903
914
  table = helpers.retry_403(bigquery_client.create_table)(table_arg)
@@ -910,7 +921,7 @@ def test_insert_rows_from_dataframe(bigquery_client, dataset_id):
910
921
  expected = [
911
922
  # Pandas often represents NULL values as NaN. Convert to None for
912
923
  # easier comparison.
913
- tuple(None if col != col else col for col in data_row)
924
+ tuple(None if pandas.isna(col) else col for col in data_row)
914
925
  for data_row in dataframe.itertuples(index=False)
915
926
  ]
916
927
 
@@ -477,7 +477,7 @@ def test_query_error_w_api_method_default(bigquery_client: bigquery.Client):
477
477
  """Test that an exception is not thrown until fetching the results.
478
478
 
479
479
  For backwards compatibility, jobs.insert is the default API method. With
480
- jobs.insert, a failed query job is "sucessfully" created. An exception is
480
+ jobs.insert, a failed query job is "successfully" created. An exception is
481
481
  thrown when fetching the results.
482
482
  """
483
483
 
@@ -261,6 +261,7 @@ class TestQueryPlanEntry(_Base):
261
261
  STATUS = "STATUS"
262
262
  SHUFFLE_OUTPUT_BYTES = 1024
263
263
  SHUFFLE_OUTPUT_BYTES_SPILLED = 1
264
+ SLOT_MS = 25
264
265
 
265
266
  START_RFC3339_MICROS = "2018-04-01T00:00:00.000000Z"
266
267
  END_RFC3339_MICROS = "2018-04-01T00:00:04.000000Z"
@@ -305,6 +306,7 @@ class TestQueryPlanEntry(_Base):
305
306
  self.assertIsNone(entry.shuffle_output_bytes)
306
307
  self.assertIsNone(entry.shuffle_output_bytes_spilled)
307
308
  self.assertEqual(entry.steps, [])
309
+ self.assertIsNone(entry.slot_ms)
308
310
 
309
311
  def test_from_api_repr_normal(self):
310
312
  from google.cloud.bigquery.job import QueryPlanEntryStep
@@ -348,6 +350,7 @@ class TestQueryPlanEntry(_Base):
348
350
  "substeps": TestQueryPlanEntryStep.SUBSTEPS,
349
351
  }
350
352
  ],
353
+ "slotMs": self.SLOT_MS,
351
354
  }
352
355
  klass = self._get_target_class()
353
356
 
@@ -366,6 +369,7 @@ class TestQueryPlanEntry(_Base):
366
369
  self.assertEqual(entry.records_written, self.RECORDS_WRITTEN)
367
370
  self.assertEqual(entry.status, self.STATUS)
368
371
  self.assertEqual(entry.steps, steps)
372
+ self.assertEqual(entry.slot_ms, self.SLOT_MS)
369
373
 
370
374
  def test_start(self):
371
375
  from google.cloud._helpers import _RFC3339_MICROS
@@ -711,7 +711,7 @@ def test_query_and_wait_caches_completed_query_results_one_page():
711
711
  {"f": [{"v": "Phred Phlyntstone"}, {"v": "32"}]},
712
712
  {"f": [{"v": "Bharney Rhubble"}, {"v": "33"}]},
713
713
  ],
714
- # Even though totalRows > len(rows), we should use the presense of a
714
+ # Even though totalRows > len(rows), we should use the presence of a
715
715
  # next page token to decide if there are any more pages.
716
716
  "totalRows": 8,
717
717
  }
@@ -828,7 +828,7 @@ def test_query_and_wait_caches_completed_query_results_more_pages():
828
828
  {"f": [{"v": "Phred Phlyntstone"}, {"v": "32"}]},
829
829
  {"f": [{"v": "Bharney Rhubble"}, {"v": "33"}]},
830
830
  ],
831
- # Even though totalRows <= len(rows), we should use the presense of a
831
+ # Even though totalRows <= len(rows), we should use the presence of a
832
832
  # next page token to decide if there are any more pages.
833
833
  "totalRows": 2,
834
834
  "pageToken": "page-2",
@@ -981,7 +981,7 @@ def test_query_and_wait_incomplete_query():
981
981
  {"f": [{"v": "Phred Phlyntstone"}, {"v": "32"}]},
982
982
  {"f": [{"v": "Bharney Rhubble"}, {"v": "33"}]},
983
983
  ],
984
- # Even though totalRows <= len(rows), we should use the presense of a
984
+ # Even though totalRows <= len(rows), we should use the presence of a
985
985
  # next page token to decide if there are any more pages.
986
986
  "totalRows": 2,
987
987
  "pageToken": "page-2",
@@ -808,29 +808,60 @@ def test_list_columns_and_indexes_with_named_index_same_as_column_name(
808
808
  @pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
809
809
  def test_dataframe_to_json_generator(module_under_test):
810
810
  utcnow = datetime.datetime.utcnow()
811
- df_data = collections.OrderedDict(
812
- [
813
- ("a_series", [pandas.NA, 2, 3, 4]),
814
- ("b_series", [0.1, float("NaN"), 0.3, 0.4]),
815
- ("c_series", ["a", "b", pandas.NA, "d"]),
816
- ("d_series", [utcnow, utcnow, utcnow, pandas.NaT]),
817
- ("e_series", [True, False, True, None]),
818
- ]
819
- )
820
811
  dataframe = pandas.DataFrame(
821
- df_data, index=pandas.Index([4, 5, 6, 7], name="a_index")
812
+ {
813
+ "a_series": [1, 2, 3, 4],
814
+ "b_series": [0.1, float("NaN"), 0.3, 0.4],
815
+ "c_series": ["a", "b", pandas.NA, "d"],
816
+ "d_series": [utcnow, utcnow, utcnow, pandas.NaT],
817
+ "e_series": [True, False, True, None],
818
+ # Support nullable dtypes.
819
+ # https://github.com/googleapis/python-bigquery/issues/1815
820
+ "boolean_series": pandas.Series(
821
+ [True, False, pandas.NA, False], dtype="boolean"
822
+ ),
823
+ "int64_series": pandas.Series([-1, pandas.NA, -3, -4], dtype="Int64"),
824
+ }
822
825
  )
823
826
 
824
- dataframe = dataframe.astype({"a_series": pandas.Int64Dtype()})
827
+ # Index is not included, even if it is not the default and has a name.
828
+ dataframe = dataframe.rename(index=lambda idx: idx + 4)
829
+ dataframe.index.name = "a_index"
825
830
 
826
- rows = module_under_test.dataframe_to_json_generator(dataframe)
831
+ rows = list(module_under_test.dataframe_to_json_generator(dataframe))
827
832
  expected = [
828
- {"b_series": 0.1, "c_series": "a", "d_series": utcnow, "e_series": True},
829
- {"a_series": 2, "c_series": "b", "d_series": utcnow, "e_series": False},
830
- {"a_series": 3, "b_series": 0.3, "d_series": utcnow, "e_series": True},
831
- {"a_series": 4, "b_series": 0.4, "c_series": "d"},
833
+ {
834
+ "a_series": 1,
835
+ "b_series": 0.1,
836
+ "c_series": "a",
837
+ "d_series": utcnow,
838
+ "e_series": True,
839
+ "boolean_series": True,
840
+ "int64_series": -1,
841
+ },
842
+ {
843
+ "a_series": 2,
844
+ "c_series": "b",
845
+ "d_series": utcnow,
846
+ "e_series": False,
847
+ "boolean_series": False,
848
+ },
849
+ {
850
+ "a_series": 3,
851
+ "b_series": 0.3,
852
+ "d_series": utcnow,
853
+ "e_series": True,
854
+ "int64_series": -3,
855
+ },
856
+ {
857
+ "a_series": 4,
858
+ "b_series": 0.4,
859
+ "c_series": "d",
860
+ "boolean_series": False,
861
+ "int64_series": -4,
862
+ },
832
863
  ]
833
- assert list(rows) == expected
864
+ assert rows == expected
834
865
 
835
866
 
836
867
  @pytest.mark.skipif(pandas is None, reason="Requires `pandas`")
@@ -3285,6 +3285,9 @@ class TestRowIterator(unittest.TestCase):
3285
3285
  # Don't close the client if it was passed in.
3286
3286
  bqstorage_client._transport.grpc_channel.close.assert_not_called()
3287
3287
 
3288
+ @unittest.skipIf(
3289
+ bigquery_storage is None, "Requires `google-cloud-bigquery-storage`"
3290
+ )
3288
3291
  @unittest.skipIf(pandas is None, "Requires `pandas`")
3289
3292
  def test_to_dataframe_iterable_w_bqstorage_max_results_warning(self):
3290
3293
  from google.cloud.bigquery import schema