Skip to content

Conversation

@nielspardon
Copy link
Member

@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
@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