Skip to content

fix: Validate duration format at SET time - #24545

Open
subhramit wants to merge 2 commits into
apache:mainfrom
subhramit:validate-config-duration-format
Open

fix: Validate duration format at SET time#24545
subhramit wants to merge 2 commits into
apache:mainfrom
subhramit:validate-config-duration-format

Conversation

@subhramit

@subhramit subhramit commented Aug 20, 2026

Copy link
Copy Markdown

Which issue does this PR close?

Part of #17498

Rationale for this change

datafusion.format.duration_format is documented as accepting "pretty" or "ISO8601", but invalid values such as "milliseconds" are currently accepted by SET and only rejected later when the value is actually used to format output.

So validating and rejecting invalid values at SET time to give users immediate feedback.

What changes are included in this PR?

  • Add a validated ConfigDurationFormat enum in datafusion/common/src/config.rs
  • Change format.duration_format from String to ConfigDurationFormat
  • Move duration-format validation out of TryFrom<&FormatOptions> and into config parsing / SET handling
  • Convert the validated config value into arrow::util::display::DurationFormat via From<ConfigDurationFormat>

Are these changes tested?

Yes. The change is covered by datafusion/sqllogictest/test_files/set_variable.slt. It tests that:

  • SET datafusion.format.duration_format = milliseconds fails immediately
  • existing valid values such as ISO8601 and PRETTY continue to work

Ran cargo test --profile=ci --test sqllogictests -- set_variable.slt to confirm it passes, and also ran cargo test -p datafusion-cli and cargo test -p datafusion to check for any related regressions (there are none).

Are there any user-facing changes?

Yes. Users now get an immediate configuration error when setting datafusion.format.duration_format to an invalid value, instead of seeing a later failure when formatting output.

This also changes a public config field type from String to ConfigDurationFormat, so it should likely carry the api change label (I would request any maintainer to add this).

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) common Related to common crate labels Aug 20, 2026
@subhramit

subhramit commented Aug 20, 2026

Copy link
Copy Markdown
Author

cc'ing @Jefffrey, @2010YOUY01, @alamb
/ @xudong963, @comphead / @kosiew for CI run approvals :)

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.32%. Comparing base (8332cfa) to head (c1ebf68).

Files with missing lines Patch % Lines
datafusion/common/src/config.rs 96.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24545      +/-   ##
==========================================
- Coverage   81.32%   81.32%   -0.01%     
==========================================
  Files        1117     1117              
  Lines      396269   396289      +20     
  Branches   396269   396289      +20     
==========================================
+ Hits       322260   322275      +15     
  Misses      55186    55186              
- Partials    18823    18828       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

common Related to common crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants