Skip to content

fix: validate date_format at SET time - #27663

Open
zuccamia wants to merge 2 commits into
apache:mainfrom
zuccamia:validate-date-format-at-set
Open

zuccamia wants to merge 2 commits into
apache:mainfrom
zuccamia:validate-date-format-at-set

Conversation

@zuccamia

Copy link
Copy Markdown

Important

Fork CI setup: For pull requests from a fork to main, enable workflows in your fork's Actions tab before you push.
See the fork CI setup guide.

Which issue does this PR close?

Rationale for this change

Since #26045, SET still accepts a bad format, and then every query printed as a table fails until the option is reset:

> SET datafusion.format.date_format = '%H';
> SELECT 'ok';
Invalid or Unsupported Configuration: Invalid datafusion.format.date_format: format is incompatible with its temporal type

What changes are included in this PR?

Following #24545 / #25788:

  • Add ConfigDateFormat, which runs the fix: validate temporal display formats #26045 date check at SET time.
  • Change FormatOptions::date_format from Option<String> to
    Option<ConfigDateFormat>. A rejected value keeps the previous one.
  • Add an entry to the 57.0.0 upgrade guide.

What is the testing strategy for this PR?

  • New cases in set_variable.slt and a unit test for %, %Q and %H.
  • The two date_format cases in fix: validate temporal display formats #26045's test moved to the new unit test, since an invalid date_format can no longer be constructed.

Are there any user-facing changes?

Yes. An invalid date_format is now rejected at SET time.
FormatOptions::date_format is a public field, so this is an API change. Could a maintainer add the api change label?

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) common Related to common crate labels Nov 22, 2026
Add `ConfigDateFormat`, which runs the date part of the apache#26045 check when the
option is set, so an invalid format is rejected immediately instead of breaking
query printed as a table later.

Part of apache#17498
@zuccamia
zuccamia force-pushed the validate-date-format-at-set branch from 91dcc61 to 170b836 Compare November 25, 2026 20:39
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Nov 25, 2026
@zuccamia
zuccamia force-pushed the validate-date-format-at-set branch from 170b836 to 1f98d68 Compare November 25, 2026 20:43
@zuccamia
zuccamia marked this pull request as ready for review November 25, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate documentation Improvements or additions to documentation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant