Skip to content

fix: validate temporal display formats - #26045

Open
mikamikasuki wants to merge 1 commit into
apache:mainfrom
mikamikasuki:fix/24909-invalid-format
Open

mikamikasuki wants to merge 1 commit into
apache:mainfrom
mikamikasuki:fix/24909-invalid-format

Conversation

@mikamikasuki

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

An invalid temporal display format such as '%' can reach Arrow's table formatter and panic when the DataFusion CLI renders a time value. Invalid formats should return a configuration error before rendering.

What changes are included in this PR?

Validate configured date, datetime, timestamp, timestamp-with-timezone, and time formats when converting DataFusion format options to Arrow format options. Invalid values now return a configuration error that identifies the datafusion.format.* setting.

What is the testing strategy for this PR?

Added invalid_temporal_format_is_rejected_before_rendering, covering all five settings and confirming defaults remain valid. The CLI reproducer now returns a configuration error instead of panicking. The datafusion-common test suite, extended workspace tests, full workspace Clippy with -D warnings, formatting, and git diff --check passed.

Are there any user-facing changes?

Invalid temporal format settings now return a clear configuration error instead of panicking while query results are rendered.

@github-actions github-actions Bot added the common Related to common crate label Oct 5, 2026
] {
if let Some(format) = format {
chrono::format::StrftimeItems::new(format)
.parse()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for fixing the formatting panic. Could we also validate that each format is compatible with the temporal type before accepting it? StrftimeItems::parse() checks syntax only, so this still panics:

SET datafusion.format.time_format = '%Y';
SELECT TIME '12:00:00';

this results in a Display implementation returned an error unexpectedly.
date_format='%H' with a DATE and timestamp_format='%+' with a timezone-free TIMESTAMP also panic.

Extensions, TableOptions,
};

#[test]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A formatting check against the corresponding Chrono temporal type (e.g. DelayedFormat::write_to) would catch these cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An invalid datafusion.format.*_format string panics when results are printed

2 participants