Repository navigation
fix(core): a NULL literal in a set operation declares its column's type for every leg - #473
Merged
Merged
Conversation
…pe for every leg (SCHEMA-18) Story SCHEMA-18. Reviewed: r0:clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fupelaqu
marked this pull request as ready for review
November 23, 2026 22:28
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
In a set operation, a branch that projects a NULL literal (
SELECT NULL AS k … UNION SELECT n AS k …) declared no type at that position.SetOperationValues.legSchemasgave the leg no slot there, because the leg reader of a NULL literal reads nothing.Core's own
runalready answers the column's type: the set-operation rule says a NULL literal takes the other branches' type (documentation/sql/dql_statements.md). The Arrow engine (Flight SQL, ADBC, the JDBC JOIN path) typed that leg from its own description instead, so the column came back as text:3arrived as"3". When the NULL branch had rows, the NULL itself was written as the text[null]. DuckDB answers the sibling's type.Change
legSlotgives a NULL-literal position a slot typed as the column's set-operation result,MultiSearch.columnTypes(...).result: the same function core's set-operation typing already uses. Its reader answers null for every row and is shared.ANYor a field-lessSTRUCTat any depth, or isNUMERIC/TEMPORAL.REALandVARBINARYget one.VARCHAR, as before.runpath,legReaders, the converters andResultSchemaare unchanged. No signature or case-class change.Visible changes
Measured on the Arrow engine's own code (leg typing, then DuckDB) over 240 cells: an empty and a non-empty NULL branch,
UNION ALL/UNION/INTERSECT/EXCEPT, NULL first and second, every column family. Each cell is compared with main:Utf8).[null](bytes0x5b6e756c6c5din a binary column).STRUCTthat holds a date field. Main failed with a DuckDB conversion error.Cost
Warm medians, main and branch interleaved.
legSchemas, once per statement), ceiling ≤ main + 1.0 µs and ≤ ×1.05 (≤ ×1.03 for a statement without a NULL position). Measured in one JVM with main's and the branch's compiled core in two class loaders, alternating the first side per sample, 21 samples × 3 rounds. The verdict uses the within-round paired statistic:Testing
core/test1749 / 0: newSetOperationNullSlotSpec, theSetOperationLegSchemasSpecpin moved to the oracle, and a consumer smoke update.+ compilepasses on 2.12 and 2.13.JavaClientNullSlotSpec), 151 / 0.Elasticsearch versions
ES 8.18.3 locally; ES 6.8, 7.17 and 9.0 run in CI.
After merge
Once a core snapshot carrying this change is published, downstream unit tests that pin the old untyped NULL must move to DuckDB's values. Downstream main code needs no change.
Release note
[null].Recorded, not fixed
None.
🤖 Generated with Claude Code