Skip to content

Conversation

@xanderbailey
Copy link
Contributor

@xanderbailey xanderbailey commented Dec 5, 2025

Which issue does this PR close?

Rationale for this change

As previously discussed in #17299. This continues to be a bit of a thorn for expressions that are the same on the left and the right side of the of a join leading to ambiguous references.

Downside here is that it makes the plan less readable which is why I thought it would be better if this was a config that users can opt into to make things more stable. Having said that in my experience the plans created via substrait are super hard to read anyway. If you have a deeply nested CAST statement for example then the name that appears in the plan is unintelligible anyway.

What changes are included in this PR?

Adds substrait_alias_all_expressions config which applies a UUID alias to all expressions during substrait conversion.

Are these changes tested?

Yes

Are there any user-facing changes?

@github-actions github-actions bot added substrait Changes to the substrait crate common Related to common crate labels Dec 5, 2025
}

#[tokio::test]
async fn alias_all_expressions_flag() -> Result<()> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to take ideas on the best way to write this test but I wanted to show that the UUIDs actually light up correctly.

@xanderbailey xanderbailey changed the title Allow flag to alias all prjected substrait expressions with a UUID Allow flag to alias all projected substrait expressions with a UUID Dec 5, 2025
@xanderbailey xanderbailey force-pushed the xb/allow_uuid_alias_for_all_substrait_expressions branch from 5541990 to 1f51265 Compare December 5, 2025 21:05
@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Dec 10, 2025
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Dec 10, 2025
@xanderbailey
Copy link
Contributor Author

@LiaCastaneda thought you might have some ideas here

@LiaCastaneda
Copy link
Contributor

👋 Sorry for the late reply,
I think this fixes all the issues once for all, however I'm wondering if maybe it would be worth it to make this fix in the name tracker instead? as suggested in #17508. From my understanding what would have to be done is basically track two fields which are the schema name and the qualified name.
cc @dd-annarose since you were looking into this.

@xanderbailey
Copy link
Contributor Author

I'm happy if there's a better route forward we're just looking for a quick fix without having to fork the whole substrait conversation.

@xanderbailey
Copy link
Contributor Author

Had a go at the fix here #19856

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate documentation Improvements or additions to documentation sqllogictest SQL Logic Tests (.slt) substrait Changes to the substrait crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expressions from left and right of a join can fail planning during substrait converstion if their name is the same

2 participants