Skip to content
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

feat(isthmus): add support for scalar subqueries #353

Merged
merged 1 commit into from
Mar 26, 2025

Conversation

nielspardon
Copy link
Contributor

@nielspardon nielspardon commented Mar 24, 2025

Currently, the Substrait to Calcite mappings to not support scalar subqueries like the follow SQL example:

select 
  n_name 
from 
  tpch.tiny.nation 
where 
  n_regionkey = (
    select r_regionkey from tpch.tiny.region where r_name = 'EUROPE')

This PR adds support for mapping scalar subqueries from Substrait into Calcite and adds a test case showing that it works now.

Additionally:

  • it changes RelCreator to be created with a list of CREATE SQL statements to initialize the schema of the RelBuilder
  • the previous change requires RelCreator to extend SqlConverterBase so that we can reuse the registerCreateTables() method
  • in SubstraitExpressionConverterTest it gets the ExpressionRexConverter from SubstraitRelNodeConverter in order to make sure the ExpressionRexConverter is properly set up to parse sub queries using SubstraitRelNodeConverter

Copy link
Member

@vbarua vbarua left a comment

Choose a reason for hiding this comment

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

The conversion code looks good overall. I left some comments that will hopefully simplify the testing of this a little bit.

Copy link
Member

@vbarua vbarua left a comment

Choose a reason for hiding this comment

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

Left one comment with a simplification for the NamedStruct gatherer, but otherwise looks good to me.

@vbarua vbarua merged commit 5b12f9b into substrait-io:main Mar 26, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants