Skip to content

Display DATE and TIME transform scalars - #2491

Merged
rolandwalker merged 1 commit into
dbcli:mainfrom
leninworld:fix-date-time-transform-scalars-issue-2490
Dec 2, 2026
Merged

rolandwalker merged 1 commit into
dbcli:mainfrom
leninworld:fix-date-time-transform-scalars-issue-2490

Conversation

@leninworld

Copy link
Copy Markdown
Contributor

This PR fixes issue #2490.

Description

A .| transform that returns a single DATE or TIME value, such as SELECT d FROM t .| df['d'].max(), printed "Nothing could be displayed for return type: <class 'datetime.date'>" (or datetime.time). DATETIME, TIMESTAMP and TIME-as-timedelta values already showed as a one-row table.

_is_coerceable_scalarish() listed datetime.datetime and datetime.timedelta but not datetime.date or datetime.time, the types mycli's decoders produce for DATE and TIME columns. This change adds those two types, so these scalars take the same path as the other scalars and show as a one-row table.

Tests in mycli_test/pytests/test_polars_transform.py:

  • test_run_polars_transform_coerces_temporal_scalar_to_dataframe: max() over date, time, datetime and timedelta values with real Polars.
  • test_run_polars_transform_coerces_cursor_temporal_scalar_to_dataframe: the same through a mocked Cursor with FIELD_TYPE.DATE and FIELD_TYPE.TIME (the explicit-schema path real results take), including a NULL row.

The date and time cases fail on main and pass with the change. Locally (Python 3.12, polars 2.1.0): pytest mycli_test/pytests 3714 passed, 88 skipped, 7 xfailed; ruff check, ruff format and mypy --install-types . clean. The behave tests need a MySQL server and were not run.

Fixes #2490

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the mycli/AUTHORS.txt file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

@rolandwalker

Copy link
Copy Markdown
Contributor

Lovely thank you!

@rolandwalker
rolandwalker merged commit 218b8a2 into dbcli:main Dec 2, 2026
@leninworld

Copy link
Copy Markdown
Contributor Author

Lovely thank you!

Thank you @rolandwalker

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.

.| transform shows "Nothing could be displayed" for a DATE or TIME result

2 participants