Skip to content

feat: add literal constraints to type signatures - #24201

Closed
getChan wants to merge 2 commits into
apache:mainfrom
getChan:feature/type-signature-argument-constraints
Closed

feat: add literal constraints to type signatures#24201
getChan wants to merge 2 commits into
apache:mainfrom
getChan:feature/type-signature-argument-constraints

Conversation

@getChan

@getChan getChan commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Some functions require particular arguments to be literal values. This requirement is currently enforced separately by each function, rather than being declared as part of the function signature.

What changes are included in this PR?

  • Adds ArgumentConstraint and TypeSignature::Constrained.
  • Validates literal constraints while logical expressions are analyzed and typed.
  • Declares the required literal arguments for arrow_cast, arrow_try_cast, and date_part.
  • Keeps expression constraints separate from Coercion.

Are these changes tested?

Yes.

  • Added a unit test covering accepted and rejected literal constraints.
  • Ran ./dev/rust_lint.sh.
  • Ran the existing DataFrame arrow_cast integration test.

Are there any user-facing changes?

Calls to constrained functions with non-literal arguments are rejected consistently during planning. This PR also adds public signature API types and therefore may require the api change label.

@github-actions github-actions Bot added logical-expr Logical plan and expressions optimizer Optimizer rules functions Changes to functions implementation auto detected api change Auto detected API change labels Aug 9, 2026
@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) and removed auto detected api change Auto detected API change labels Aug 9, 2026
@getChan getChan closed this Aug 9, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.80851% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.06%. Comparing base (b225ded) to head (16b4db1).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/expr-common/src/signature.rs 95.83% 1 Missing ⚠️
datafusion/expr/src/type_coercion/functions.rs 97.82% 1 Missing ⚠️
datafusion/optimizer/src/analyzer/type_coercion.rs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24201      +/-   ##
==========================================
- Coverage   81.06%   81.06%   -0.01%     
==========================================
  Files        1106     1106              
  Lines      381847   381936      +89     
  Branches   381847   381936      +89     
==========================================
+ Hits       309541   309613      +72     
- Misses      54036    54048      +12     
- Partials    18270    18275       +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

functions Changes to functions implementation logical-expr Logical plan and expressions optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A way to specify constant/scalar arguments in UDFs

2 participants