Skip to content

Commit 5686794

Browse files
authored
Merge branch 'main' into feat-374142081-add-source-column-match
2 parents 3b39fc3 + 7d31828 commit 5686794

21 files changed

+325
-14
lines changed

google/cloud/bigquery/_job_helpers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ def do_query():
560560
num_dml_affected_rows=query_results.num_dml_affected_rows,
561561
query=query,
562562
total_bytes_processed=query_results.total_bytes_processed,
563+
slot_millis=query_results.slot_millis,
563564
)
564565

565566
if job_retry is not None:

google/cloud/bigquery/client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4144,6 +4144,7 @@ def _list_rows_from_query_results(
41444144
num_dml_affected_rows: Optional[int] = None,
41454145
query: Optional[str] = None,
41464146
total_bytes_processed: Optional[int] = None,
4147+
slot_millis: Optional[int] = None,
41474148
) -> RowIterator:
41484149
"""List the rows of a completed query.
41494150
See
@@ -4195,6 +4196,8 @@ def _list_rows_from_query_results(
41954196
The query text used.
41964197
total_bytes_processed (Optional[int]):
41974198
total bytes processed from job statistics, if present.
4199+
slot_millis (Optional[int]):
4200+
Number of slot ms the user is actually billed for.
41984201
41994202
Returns:
42004203
google.cloud.bigquery.table.RowIterator:
@@ -4234,6 +4237,7 @@ def _list_rows_from_query_results(
42344237
num_dml_affected_rows=num_dml_affected_rows,
42354238
query=query,
42364239
total_bytes_processed=total_bytes_processed,
4240+
slot_millis=slot_millis,
42374241
)
42384242
return row_iterator
42394243

google/cloud/bigquery/external_config.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,37 @@ def schema(self, value):
882882
prop = {"fields": [field.to_api_repr() for field in value]}
883883
self._properties["schema"] = prop
884884

885+
@property
886+
def date_format(self) -> Optional[str]:
887+
"""Optional[str]: Format used to parse DATE values. Supports C-style and SQL-style values.
888+
889+
See:
890+
https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#ExternalDataConfiguration.FIELDS.date_format
891+
"""
892+
result = self._properties.get("dateFormat")
893+
return typing.cast(str, result)
894+
895+
@date_format.setter
896+
def date_format(self, value: Optional[str]):
897+
self._properties["dateFormat"] = value
898+
899+
@property
900+
def time_zone(self) -> Optional[str]:
901+
"""Optional[str]: Time zone used when parsing timestamp values that do not
902+
have specific time zone information (e.g. 2024-04-20 12:34:56). The expected
903+
format is an IANA timezone string (e.g. America/Los_Angeles).
904+
905+
See:
906+
https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#ExternalDataConfiguration.FIELDS.time_zone
907+
"""
908+
909+
result = self._properties.get("timeZone")
910+
return typing.cast(str, result)
911+
912+
@time_zone.setter
913+
def time_zone(self, value: Optional[str]):
914+
self._properties["timeZone"] = value
915+
885916
@property
886917
def connection_id(self):
887918
"""Optional[str]: [Experimental] ID of a BigQuery Connection API

google/cloud/bigquery/job/load.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,33 @@ def source_column_match(self, value: Optional[SourceColumnMatch]):
582582
)
583583
self._set_sub_prop("sourceColumnMatch", value.value if value else None)
584584

585+
@property
586+
def date_format(self) -> Optional[str]:
587+
"""Optional[str]: Date format used for parsing DATE values.
588+
589+
See:
590+
https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationLoad.FIELDS.date_format
591+
"""
592+
return self._get_sub_prop("dateFormat")
593+
594+
@date_format.setter
595+
def date_format(self, value: Optional[str]):
596+
self._set_sub_prop("dateFormat", value)
597+
598+
@property
599+
def time_zone(self) -> Optional[str]:
600+
"""Optional[str]: Default time zone that will apply when parsing timestamp
601+
values that have no specific time zone.
602+
603+
See:
604+
https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationLoad.FIELDS.time_zone
605+
"""
606+
return self._get_sub_prop("timeZone")
607+
608+
@time_zone.setter
609+
def time_zone(self, value: Optional[str]):
610+
self._set_sub_prop("timeZone", value)
611+
585612
@property
586613
def time_partitioning(self):
587614
"""Optional[google.cloud.bigquery.table.TimePartitioning]: Specifies time-based
@@ -930,6 +957,20 @@ def source_column_match(self):
930957
"""
931958
return self.configuration.source_column_match
932959

960+
@property
961+
def date_format(self):
962+
"""See
963+
:attr:`google.cloud.bigquery.job.LoadJobConfig.date_format`.
964+
"""
965+
return self.configuration.date_format
966+
967+
@property
968+
def time_zone(self):
969+
"""See
970+
:attr:`google.cloud.bigquery.job.LoadJobConfig.time_zone`.
971+
"""
972+
return self.configuration.time_zone
973+
933974
@property
934975
def schema_update_options(self):
935976
"""See

google/cloud/bigquery/job/query.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,7 @@ def is_job_done():
17661766
num_dml_affected_rows=self._query_results.num_dml_affected_rows,
17671767
query=self.query,
17681768
total_bytes_processed=self.total_bytes_processed,
1769+
slot_millis=self.slot_millis,
17691770
**list_rows_kwargs,
17701771
)
17711772
rows._preserve_order = _contains_order_by(self.query)

google/cloud/bigquery/query.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,20 @@ def total_bytes_processed(self):
12821282
if total_bytes_processed is not None:
12831283
return int(total_bytes_processed)
12841284

1285+
@property
1286+
def slot_millis(self):
1287+
"""Total number of slot ms the user is actually billed for.
1288+
1289+
See:
1290+
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query#body.QueryResponse.FIELDS.slot_millis
1291+
1292+
Returns:
1293+
Optional[int]: Count generated on the server (None until set by the server).
1294+
"""
1295+
slot_millis = self._properties.get("totalSlotMs")
1296+
if slot_millis is not None:
1297+
return int(slot_millis)
1298+
12851299
@property
12861300
def num_dml_affected_rows(self):
12871301
"""Total number of rows affected by a DML query.

google/cloud/bigquery/table.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,6 +1812,7 @@ def __init__(
18121812
num_dml_affected_rows: Optional[int] = None,
18131813
query: Optional[str] = None,
18141814
total_bytes_processed: Optional[int] = None,
1815+
slot_millis: Optional[int] = None,
18151816
):
18161817
super(RowIterator, self).__init__(
18171818
client,
@@ -1841,6 +1842,7 @@ def __init__(
18411842
self._num_dml_affected_rows = num_dml_affected_rows
18421843
self._query = query
18431844
self._total_bytes_processed = total_bytes_processed
1845+
self._slot_millis = slot_millis
18441846

18451847
@property
18461848
def _billing_project(self) -> Optional[str]:
@@ -1898,6 +1900,11 @@ def total_bytes_processed(self) -> Optional[int]:
18981900
"""total bytes processed from job statistics, if present."""
18991901
return self._total_bytes_processed
19001902

1903+
@property
1904+
def slot_millis(self) -> Optional[int]:
1905+
"""Number of slot ms the user is actually billed for."""
1906+
return self._slot_millis
1907+
19011908
def _is_almost_completely_cached(self):
19021909
"""Check if all results are completely cached.
19031910
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
google-cloud-testutils==1.6.4
22
pytest==8.4.1
33
mock==5.2.0
4-
pytest-xdist==3.7.0
4+
pytest-xdist==3.8.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pytest==8.4.1
22
mock==5.2.0
3-
pytest-xdist==3.7.0
3+
pytest-xdist==3.8.0

samples/geography/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
attrs==25.3.0
2-
certifi==2025.6.15
2+
certifi==2025.7.9
33
cffi==1.17.1
44
charset-normalizer==3.4.2
55
click===8.1.8; python_version == '3.9'
@@ -24,7 +24,7 @@ idna==3.10
2424
munch==4.0.0
2525
mypy-extensions==1.1.0
2626
packaging==25.0
27-
pandas==2.3.0
27+
pandas==2.3.1
2828
proto-plus==1.26.1
2929
pyarrow==20.0.0
3030
pyasn1==0.6.1
@@ -39,6 +39,6 @@ rsa==4.9.1
3939
Shapely===2.0.7; python_version == '3.9'
4040
Shapely==2.1.1; python_version >= '3.10'
4141
six==1.17.0
42-
typing-extensions==4.14.0
42+
typing-extensions==4.14.1
4343
typing-inspect==0.9.0
4444
urllib3==2.5.0

0 commit comments

Comments
 (0)