Skip to content

Fix ambiguous column names in substrait conversion as a result of literals having the same name during conversion. #17299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

xanderbailey
Copy link

Which issue does this PR close?

#17294

  • Closes #.

Rationale for this change

Fix ambiguous column names in substrait conversion as a result of literals before and after a join being assigned the same name.

More information in the issue, but say you have a NULL literal before a join called "column1" and then you create a new NULL column after the join called column2, you would get an ambiguous column name errors like.

Error: SchemaError(AmbiguousReference { field: Column { relation: Some(Bare { table: "left" }), name: "UTF8(NULL)" } }, Some(""))

What changes are included in this PR?

Simply alias all literals as they're converted to have a UUID name.

Are these changes tested?

Yes.
Tested by using substrait-java with this query

./isthmus-cli/build/graal/isthmus --create "create table A (a int); create table B (a int, c int); create table C (a int, d int)" "select t.*, C.d, CAST(NULL AS VARCHAR) as e from (select a, CAST(NULL AS VARCHAR) as c from A UNION ALL select a, c from B) t LEFT JOIN C ON t.a = C.a"

Are there any user-facing changes?

@github-actions github-actions bot added the substrait Changes to the substrait crate label Aug 22, 2025
@xanderbailey xanderbailey force-pushed the xb/fix_literals_substrait branch from 198888f to d09586b Compare August 22, 2025 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
substrait Changes to the substrait crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants