Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
b4040c6
feat: add `time` and `date` dtypes
tswast Sep 21, 2021
2393641
chore: add license headers to __init__.py files
tswast Sep 21, 2021
8f7fe00
chore: fail samples nox session if python version is missing (#17)
gcf-owl-bot[bot] Sep 30, 2021
e104b89
chore(python): Add kokoro configs for python 3.10 samples testing (#26)
gcf-owl-bot[bot] Oct 9, 2021
fc653d2
feat: rename dbtime and dbdate dtypes to avoid future conflicts with …
tswast Oct 14, 2021
a604e56
docs: add how-to guide and include API reference (#33)
tswast Oct 14, 2021
e5c6019
chore(samples): Add check for tests in directory (#54)
gcf-owl-bot[bot] Jan 11, 2022
0ea0a03
chore(python): Noxfile recognizes that tests can live in a folder (#58)
gcf-owl-bot[bot] Jan 19, 2022
366f815
chore(deps): update all dependencies (#68)
renovate-bot Feb 28, 2022
0a5d994
chore: Adding support for pytest-xdist and pytest-parallel (#76)
gcf-owl-bot[bot] Mar 4, 2022
12f870d
chore(deps): update dependency pytest to v7.1.0 (#80)
renovate-bot Mar 13, 2022
0f63bdb
chore(deps): update dependency pytest to v7.1.1 (#83)
renovate-bot Mar 18, 2022
b625a30
chore(python): use black==22.3.0 (#96)
gcf-owl-bot[bot] Mar 29, 2022
39f17f8
chore(python): add nox session to sort python imports (#102)
gcf-owl-bot[bot] Apr 21, 2022
0bf2571
chore(deps): update dependency pytest to v7.1.2 (#105)
renovate-bot Apr 25, 2022
805981d
fix: require python 3.7+ (#125)
gcf-owl-bot[bot] Jul 14, 2022
b052c0d
chore(deps): update dependency pytest to v7.1.3 (#144)
renovate-bot Sep 6, 2022
f7d60e3
chore: detect samples tests in nested directories (#146)
gcf-owl-bot[bot] Sep 13, 2022
272fe91
chore(deps): update dependency pytest to v7.2.0 (#151)
renovate-bot Oct 26, 2022
b42c336
chore(python): drop flake8-import-order in samples noxfile (#156)
gcf-owl-bot[bot] Nov 27, 2022
37543c1
chore(python): add support for python 3.11 (#168)
gcf-owl-bot[bot] Jan 6, 2023
ff1923d
chore(deps): update dependency pytest to v7.2.1 (#170)
renovate-bot Jan 30, 2023
1bea21e
chore(deps): update dependency pytest to v7.2.2 (#174)
renovate-bot Mar 4, 2023
fd04398
chore(deps): update dependency pytest to v7.3.1 (#184)
renovate-bot Apr 18, 2023
6733c57
chore(deps): update dependency pytest to v7.3.2 (#188)
renovate-bot Jun 13, 2023
d7cfa6f
chore(deps): update dependency pytest to v7.4.0 (#191)
renovate-bot Jul 5, 2023
d40c13e
chore(deps): update all dependencies (#209)
renovate-bot Nov 8, 2023
373d223
chore(deps): update all dependencies (#221)
renovate-bot Nov 8, 2023
c60e59d
feat: Add support for Python 3.12 (#223)
gcf-owl-bot[bot] Dec 1, 2023
507757b
chore(deps): update dependency pytest to v7.4.4 (#235)
renovate-bot Jan 19, 2024
91b5d72
chore(deps): update dependency pytest to v8 (#239)
renovate-bot Feb 5, 2024
16e3db9
chore(deps): update dependency pytest to v8.0.1 (#243)
renovate-bot Feb 20, 2024
95ec38c
chore(deps): update dependency pytest to v8.0.2 (#247)
renovate-bot Feb 26, 2024
bad7998
chore(deps): update dependency pytest to v8.1.1 (#251)
renovate-bot Mar 13, 2024
31b47a7
testing: use arbitrary equality for pinned pytest version (#262)
Linchin Apr 3, 2024
f851905
chore: format code files with nox (#281)
chelsea-lin Jul 8, 2024
c23bc24
chore(deps): update all dependencies (#290)
renovate-bot Sep 20, 2024
c454c0d
build: use multiScm for Kokoro release builds (#294)
gcf-owl-bot[bot] Nov 12, 2024
74d18b5
deps!: Drop support for Python 3.7 and 3.8 (AI Experiment) (#337)
chalmerlowe May 7, 2025
5336318
test: updates python versions and sets owlbot excludes (#367)
chalmerlowe Jun 13, 2025
34baee3
chore(deps): update dependency pytest to v8.4.1 (#368)
renovate-bot Aug 1, 2025
eb61401
chore(deps): update all dependencies (#373)
renovate-bot Sep 8, 2025
43f7f5c
feat: Add support for Python 3.14 (#380)
daniel-sanche Dec 12, 2025
7999039
Merge remote-tracking branch 'migration/main' into python-db-dtypes-p…
Linchin Feb 3, 2026
63a4fbc
correct header
Linchin Feb 3, 2026
d4eb1bb
add noxconfig.py
Linchin Feb 3, 2026
79e8aff
delete noxfile.py
Linchin Feb 3, 2026
7ac946e
add
Linchin Feb 3, 2026
365c40a
lint
Linchin Feb 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions bigquery/python-db-dtypes-pandas/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Empty file.
13 changes: 13 additions & 0 deletions bigquery/python-db-dtypes-pandas/snippets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
42 changes: 42 additions & 0 deletions bigquery/python-db-dtypes-pandas/snippets/noxconfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Default TEST_CONFIG_OVERRIDE for python repos.

# You can copy this file into your directory, then it will be imported from
# the noxfile.py.

# The source of truth:
# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py

TEST_CONFIG_OVERRIDE = {
# You can opt out from the test for specific Python versions.
"ignored_versions": ["2.7", "3.7", "3.8"],
# Old samples are opted out of enforcing Python type hints
# All new samples should feature them
"enforce_type_hints": True,
# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
# to use your own Cloud project.
"gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
# If you need to use a specific version of pip,
# change pip_version_override to the string representation
# of the version number, for example, "20.2.4"
"pip_version_override": None,
# A dictionary you want to inject into your test. Don't put any
# secrets here. These values will override predefined values.
"envs": {},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


def pandas_date_and_time():
# [START bigquery_pandas_date_create]

import datetime

import pandas as pd

import db_dtypes # noqa import to register dtypes

dates = pd.Series([datetime.date(2021, 9, 17), "2021-9-18"], dtype="dbdate")

# [END bigquery_pandas_date_create]
# [START bigquery_pandas_date_as_datetime]

datetimes = dates.astype("datetime64")

# [END bigquery_pandas_date_as_datetime]
# [START bigquery_pandas_date_sub]

dates2 = pd.Series(["2021-1-1", "2021-1-2"], dtype="dbdate")
diffs = dates - dates2

# [END bigquery_pandas_date_sub]
# [START bigquery_pandas_date_add_offset]

do = pd.DateOffset(days=1)
after = dates + do
before = dates - do

# [END bigquery_pandas_date_add_offset]
# [START bigquery_pandas_time_create]

times = pd.Series([datetime.time(1, 2, 3, 456789), "12:00:00.6"], dtype="dbtime")

# [END bigquery_pandas_time_create]
# [START bigquery_pandas_time_as_timedelta]

timedeltas = times.astype("timedelta64")

# [END bigquery_pandas_time_as_timedelta]

# Combine datetime64 and timedelta64 to confirm adding dates and times are
# equivalent.
combined0 = datetimes + timedeltas

# [START bigquery_pandas_combine_date_time]

combined = dates + times

# [END bigquery_pandas_combine_date_time]

return (
dates,
datetimes,
dates2,
diffs,
do,
after,
before,
times,
timedeltas,
combined,
combined0,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import datetime

import numpy as np
from pandas import Timestamp


def test_pandas_date_and_time():
from .pandas_date_and_time import pandas_date_and_time

(
dates,
_,
dates2,
diffs,
do,
after,
before,
times,
_,
combined,
combined0,
) = pandas_date_and_time()

assert str(dates.dtype) == "dbdate"
assert list(dates) == [datetime.date(2021, 9, 17), datetime.date(2021, 9, 18)]

assert np.array_equal(
diffs,
dates.astype("datetime64") - dates2.astype("datetime64"),
)

assert np.array_equal(after, dates.astype("object") + do)
assert np.array_equal(before, dates.astype("object") - do)

assert str(times.dtype) == "dbtime"
assert list(times) == [
datetime.time(1, 2, 3, 456789),
datetime.time(12, 0, 0, 600000),
]

for c in combined0, combined:
assert str(c.dtype) == "datetime64[ns]"
assert list(c) == [
Timestamp("2021-09-17 01:02:03.456789"),
Timestamp("2021-09-18 12:00:00.600000"),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest==8.4.2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Pinning pytest to an exact patch version (8.4.2) can be overly restrictive. It's generally recommended to use a more flexible version specifier (e.g., pytest>=8.4.2,<9 or pytest~=8.4.2) to allow for minor bug fixes and security updates without requiring manual intervention, unless there's a specific compatibility issue that necessitates this exact pin.

pytest~=8.4.2

4 changes: 4 additions & 0 deletions bigquery/python-db-dtypes-pandas/snippets/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
db-dtypes
numpy
pandas
pyarrow