Repository navigation
fix(sql): CAST(NULL AS VARCHAR) answers NULL, not the text 'null' - #426
Merged
Merged
Conversation
…leg's reader is built once A NULL literal converted to any type now renders `null`. The literal is never `nullable`, so the VARCHAR arm wrapped it unguarded in `String.valueOf(null)` and Elasticsearch answered the TEXT "null": beside other columns since 0.23.0, and alone in the projection on main, where 0.23.0 answered NULL (measured on Elasticsearch 8.18.3). CAST(NULL AS INT) and every other target already answered NULL and are unchanged. A set-operation leg's slot built its reader twice, once to see whether it exists and once after its dates were routed; when routing changes nothing, which is every readable date, the first reader is the slot's. Answers are unchanged; arrow's plan-time typing does the work once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fupelaqu
marked this pull request as draft
October 17, 2026 17:30
fupelaqu
marked this pull request as ready for review
October 18, 2026 06:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CAST(NULL AS VARCHAR)answers NULL instead of the text'null'. A NULL literal converted to any type now rendersnull: the literal is nevernullable, so the VARCHAR arm wrapped it unguarded inString.valueOf(null).Behaviour (measured on Elasticsearch 8.18.3 through the gateway)
SELECT CAST(NULL AS VARCHAR) AS sv FROM t'null'(regression)SELECT n, CAST(NULL AS VARCHAR) AS sv, CAST(NULL AS INT) AS iv FROM tsv= text'null''null'CAST(NULL AS INT)(control)Every other cast is unchanged; set-operation answers are unchanged (the reader change only stops building the same reader twice).
Tests
CastConversionSpec: a NULL cast to VARCHAR, CHAR, TEXT, KEYWORD, INT, BIGINT, DOUBLE, REAL, BOOLEAN, DATE, TIME, TIMESTAMP and DATETIME rendersnull, alone and beside other columns; it failed on main withString.valueOf(null).DottedColumnSpec(shared testkit, every major's runner):CAST(NULL AS VARCHAR)answers NULL on every row route, alone and beside other columns.sql/test1,847 / 1,847,core/test1,259 / 1,259,es8java/testgreen (the two first-run failures were the new test's REPL harness, since moved, and a fresh-worktree resource ordering artefact that passes on rerun).community/test223 / 223 and its ES 8 views suite 20 / 20, with no change needed.+ compile, and its regression gate against arrow 264eac3 on the same jars: 0 violations. Its new test of theCAST(NULL AS VARCHAR)workaround needs this core.🤖 Generated with Claude Code