fix(starrocks): unwrap CLONE_EXPR and cast FE-narrowed builtins to their declared type - #1704
Draft
aocsa wants to merge 1 commit into
Draft
fix(starrocks): unwrap CLONE_EXPR and cast FE-narrowed builtins to their declared type#1704aocsa wants to merge 1 commit into
aocsa wants to merge 1 commit into
Conversation
…eir declared type The FE wraps a duplicated column reference in CLONE_EXPR (TPC-H q01 reads l_extendedprice in two products); the node has no value semantics, so the translator now returns its child unchanged instead of refusing the fragment. year/month/day/length/char_length return BIGINT through DuckDB while the FE declares SMALLINT/TINYINT/INT slots, and the next hop's schema guard refused the wider column; they are now cast back to the declared type via cast_to. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Sep 3, 2026
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.
Description
Two expression-translator fixes the multi-CN branch needed to run TPC-H. Both stand alone from the translator stack.
CLONE_EXPR. TPC-H q01's projection reads
l_extendedpricetwice, in two products. The FE'sCloneDuplicateColRefRulewraps the second use inCLONE_EXPRbecause the BE has no copy-on-write. The translator had no arm for it and refused the whole fragment as an unsupported expression. The node has no value semantics, so the newtranslate_clonereturns the child unchanged. I chose not to re-cast it to its declared type. The type is the child's by construction, and a cast would re-narrow a product the arithmetic path already lowered to FP64, so the cloned column would differ from the uncloned one the FE says it equals.FE-narrowed builtins.
year,month,day,lengthandchar_lengthbind through DuckDB, where they return BIGINT. The FE declares SMALLINT, TINYINT, TINYINT, INT and INT. When the fragment's row crosses an exchange, the receiver declares its stream from the FE slots and the hop's schema guard refuses the BIGINT column.translate_function_callnow wraps those five calls in a throwing cast back to the declared type through the newcast_tohelper. The scalar function itself states the BIGINT the engine produces. The binder elides a cast to a type the expression already has, so the cast costs nothing where the two agree.How I tested it. On a GB200 box (aarch64) I ran the CI trio: cargo fmt, clippy with warnings as errors, and the CN test suite without the engine feature. All 176 tests pass, 5 of them new.
Changes sit in
experimental/starrocks/crates/starrocks-plan-translator, four files.type_mapper::i64_typeis new.lib.rsgains one row in the expression table.Five new tests in
tests/translate.rs, among themclone_expr_is_transparent,fe_narrowed_functions_cast_to_declared_return_typeandmatching_return_type_function_stays_cast_free.Not handled. Other FE-narrowed builtins are not in the match; add them as they show up. Aggregates and slot resolution are untouched.
Checklist
References
aocsa/feat/pin-table-cn; independent of the translator stack (T1 to T4), which can merge in any order relative to this PR.