Skip to content

minor: validate config default_null_ordering when setting it - #24400

Open
shinzoxD wants to merge 1 commit into
apache:mainfrom
shinzoxD:fix/validate-default-null-ordering
Open

minor: validate config default_null_ordering when setting it#24400
shinzoxD wants to merge 1 commit into
apache:mainfrom
shinzoxD:fix/validate-default-null-ordering

Conversation

@shinzoxD

Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

SET datafusion.sql_parser.default_null_ordering accepted any string. Invalid values such as nulls_mx or an empty string succeeded and later silently fell back to nulls_max when planning ORDER BY.

That is the same class of bug as explain.format in #17498: the option documents a fixed set of values, but the config store is a free-form string.

What changes are included in this PR?

  • Move NullOrdering into datafusion-common and use it as the type of SqlParserOptions::default_null_ordering.
  • Reject unknown values at SET time, with an error that lists the valid options (nulls_max, nulls_min, nulls_first, nulls_last).
  • Keep datafusion_sql::planner::NullOrdering as a re-export so existing planner call sites keep compiling.
  • Leave the previous valid value in place when a SET is rejected.

This is intentionally scoped to one option, following the review guidance on #17498 to land these as smaller PRs.

Are these changes tested?

Yes.

  • cargo test -p datafusion-common default_null_ordering
  • cargo test -p datafusion-sqllogictest --test sqllogictests -- set_variable
  • cargo check -p datafusion --lib
  • cargo fmt on the touched Rust files

Coverage includes valid values, case-insensitive input, typo rejection, empty-string rejection, and RESET back to nulls_max.

Are there any user-facing changes?

Yes.

  • Invalid SET datafusion.sql_parser.default_null_ordering values now fail immediately instead of being stored and later treated as nulls_max.
  • SqlParserOptions::default_null_ordering is now NullOrdering rather than String. NullOrdering remains available from datafusion_sql::planner.

`datafusion.sql_parser.default_null_ordering` documented four valid
values but stored a free-form string. Invalid values were accepted at
SET time and later silently fell back to `nulls_max`.

Store the option as a typed `NullOrdering` enum so unknown values are
rejected immediately, matching other enum-like config options.
Copilot AI lite review requested due to automatic review settings August 15, 2026 21:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added sql SQL Planner core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) common Related to common crate labels Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate core Core DataFusion crate sql SQL Planner sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants