Skip to content

[Python] Support pandas 3 in tests and allow pandas<4 - #1030

Merged
PatrickJin-db merged 4 commits into
delta-io:mainfrom
PatrickJin-db:fix-issue-916
Nov 10, 2026
Merged

PatrickJin-db merged 4 commits into
delta-io:mainfrom
PatrickJin-db:fix-issue-916

Conversation

@PatrickJin-db

@PatrickJin-db PatrickJin-db commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #916.

Why

pandas 3 changed several defaults, and the Python tests were written against the pandas 2 ones:

  • Timestamps: pd.Timestamp literals now default to microsecond resolution. The legacy reader returns the nanosecond resolution of the INT96 timestamps stored in the test parquet files.
  • Strings: string data now defaults to the str dtype instead of object. This applies both to test expectations and to pyarrow's Table.to_pandas().
  • Nulls: assert_frame_equal no longer treats None and NaN as equal when it compares an object column with a float column.
  • concat: pd.concat no longer ignores all-NA object placeholder columns. Columns that older files don't have (added with pdf[col] = None) now come back as object instead of float.

Pandas dtypes are best effort. The docs and docstrings make no promise about them, and the add-column tests already used check_dtype=False. So this PR compares pandas results with the same leniency, after making nulls comparable. Arrow schema assertions stay strict, because Arrow types follow the Delta schema. Library code is unchanged.

The pandas bound goes up to <4.0.0, and the matching requires-dist specifier in uv.lock is updated to match. uv.lock is re-resolved so that pandas 3.0.6 is locked for Python >= 3.11 (pandas 3 requires it) and pandas 2.3.3 for Python 3.10. No other package version changes.

Test plan

Ran the full Python suite, including integration tests against a local TestDeltaSharingServer:

  • pandas 2.3.3: 216 passed, 1 skipped
  • pandas 3.0.6, installed from the lock on Python 3.11 (uv export --frozen): 216 passed, 1 skipped (before this change: 26 failed, 190 passed, 1 skipped)
  • black --line-length 100 --check delta_sharing/tests/: clean
  • uv lock --check --offline: passes

The existing CI matrix covers both versions through the lock: the Python 3.10 job tests pandas 2.3.3 and the Python 3.11 job tests pandas 3.0.6, with no workflow changes.

This pull request and its description were written by Isaac.

linzhou-db
linzhou-db previously approved these changes Nov 6, 2026
PatrickJin-db and others added 4 commits November 9, 2026 22:13
Fixes delta-io#916.

pandas 3 changes several defaults that the Python tests relied on:
- pd.Timestamp literals are inferred at microsecond resolution, while the
  legacy reader returns the nanosecond resolution of the INT96 timestamps
  in the test parquet files.
- String data defaults to the `str` dtype instead of `object`, both for
  literals in test expectations and for pyarrow's Table.to_pandas().
- None and NaN no longer compare equal in assert_frame_equal when an
  object column is compared against a float column.
- pd.concat no longer ignores all-NA object placeholder columns, so
  columns missing from older files (added with `pdf[col] = None`) come
  back as object instead of float.

Pandas dtypes are best effort: neither the docs nor the docstrings
promise them, and the add-column tests already used check_dtype=False.
The tests now compare pandas results with that leniency (nulls
normalized), while Arrow schema assertions stay strict because Arrow
types follow the Delta schema. The library code is unchanged.

Raise the pandas bound to <4.0.0 and update the matching requires-dist
specifier in uv.lock. The locked pandas stays 2.3.3, so CI keeps
testing pandas 2 only.

Signed-off-by: Patrick Jin <patrick.jin@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
uv.lock pins pandas 2.3.3, so CI only exercised pandas 2 even though
pyproject.toml now allows pandas<4. Add a Python 3.11 job that installs
the latest pandas 3 on top of the locked environment, keeping the
existing locked jobs. UV_NO_SYNC stops `uv run` from reinstalling the
locked pandas before the tests run.

Co-authored-by: Isaac <no-reply@databricks.com>
Signed-off-by: Patrick Jin <patrick.jin@databricks.com>
Re-resolve pandas in uv.lock (`uv lock --upgrade-package pandas`) now that
the pandas bound allows 3.x. pandas 3 requires Python >= 3.11, so the lock
forks: pandas 3.0.6 for Python >= 3.11 and pandas 2.3.3 for Python 3.10.

Only pandas changes. pandas 3 declares tzdata only for win32/emscripten and
drops the pytz dependency, which splits the resolution markers by
sys_platform. numpy and every other locked version are unchanged.

Signed-off-by: Patrick Jin <patrick.jin@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
This reverts commit 065a8ee. uv.lock now provides pandas 3 for Python 3.11+
and pandas 2.3.3 for Python 3.10, so the existing 3.10 and 3.11 matrix jobs
test pandas 2 and pandas 3 without the extra matrix entry, pandas install
step, or UV_NO_SYNC override.

Signed-off-by: Patrick Jin <patrick.jin@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@PatrickJin-db
PatrickJin-db merged commit 1ed0285 into delta-io:main Nov 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tests fail on pandas 3.0.0+

2 participants