Skip to content

fix(spark): return NULL from char for a NULL scalar argument - #26126

Merged
neilconway merged 1 commit into
apache:mainfrom
ranflarion:fix-spark-char-null-scalar
Oct 8, 2026
Merged

neilconway merged 1 commit into
apache:mainfrom
ranflarion:fix-spark-char-null-scalar

Conversation

@ranflarion

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

SELECT char(NULL::INT) fails with Execution error: The argument must be an Int64 array or scalar. where Spark returns NULL. NULL rows of an array argument already return NULL, only a NULL scalar argument reaches the error.

What changes are included in this PR?

spark_chr returns a NULL Utf8 scalar for a NULL Int64 scalar.

What is the testing strategy for this PR?

A char(NULL::INT) case in spark/string/char.slt, which fails on main with the error above.

Are there any user-facing changes?

char of a NULL scalar returns NULL instead of an error.

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) spark labels Oct 7, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.73%. Comparing base (1c43063) to head (55bf1e3).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #26126    +/-   ##
========================================
  Coverage   82.73%   82.73%            
========================================
  Files        1147     1147            
  Lines      449389   449541   +152     
  Branches   449389   449541   +152     
========================================
+ Hits       371788   371923   +135     
- Misses      54943    54944     +1     
- Partials    22658    22674    +16     

☔ 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.

@neilconway neilconway 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.

Thanks @ranflarion! lgtm.

I notice that we don't declare is_strict for char, or indeed any of the other Spark UDFs. That would be good to do at some point but is orthogonal.

@neilconway
neilconway added this pull request to the merge queue Oct 8, 2026
Merged via the queue into apache:main with commit 415f25d Oct 8, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

spark sqllogictest SQL Logic Tests (.slt) v56.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spark char fails on a NULL scalar argument

3 participants