Skip to content

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

Merged
vbarua merged 1 commit into
substrait-io:mainfrom
nielspardon:par-subquery
Mar 26, 2025
Merged

vbarua merged 1 commit into
substrait-io:mainfrom
nielspardon:par-subquery

Conversation

@nielspardon

@nielspardon nielspardon commented Mar 24, 2025 •

Copy link
Copy Markdown
Member

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

@vbarua vbarua left a comment

Copy link
Copy Markdown
Member

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.

Comment thread isthmus/src/test/java/io/substrait/isthmus/RelCreator.java Outdated
Comment thread isthmus/src/test/java/io/substrait/isthmus/SubstraitExpressionConverterTest.java Outdated
Comment thread isthmus/src/test/java/io/substrait/isthmus/SubstraitExpressionConverterTest.java Outdated
Comment thread isthmus/src/test/java/io/substrait/isthmus/SubstraitExpressionConverterTest.java Outdated
Comment thread isthmus/src/main/java/io/substrait/isthmus/SubstraitToCalcite.java Outdated

@vbarua vbarua left a comment •

Copy link
Copy Markdown
Member

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.

Signed-off-by: Niels Pardon <par@zurich.ibm.com>
@vbarua
vbarua merged commit 5b12f9b into substrait-io:main Mar 26, 2025
@nielspardon
nielspardon deleted the par-subquery branch April 7, 2025 12:41
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