Skip to content

feat: example on optimizing with calcite'#776

Open
mbwhite wants to merge 3 commits intosubstrait-io:mainfrom
mbwhite:optimization-example
Open

feat: example on optimizing with calcite'#776
mbwhite wants to merge 3 commits intosubstrait-io:mainfrom
mbwhite:optimization-example

Conversation

@mbwhite
Copy link
Copy Markdown
Contributor

@mbwhite mbwhite commented Mar 25, 2026

An example of how the ConverterProvider can be subclassed to inject custom calcite behaviour. In this case how the Calcite HepPlanner can be used to optimize the query plan before conversion to SQL.

note this is the cleanest way I could find to implement this.

* <p>This example follows the same structure as the "ToSql" example but shows how the
* ConverterProvider can be subclassed to update the Calcite configuration.
*
* <p>This case how the HepPlanner can be used to optimize the plan before it's conversion to SQL.
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.

Suggested change
* <p>This case how the HepPlanner can be used to optimize the plan before it's conversion to SQL.
* <p>This shows how the HepPlanner can be used to optimize the plan before it's conversion to SQL.

static final class OptimizingConverterProvider extends ConverterProvider {

/**
* Set of calcite rules to use.
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.

Suggested change
* Set of calcite rules to use.
* Set of Calcite rules to use.

.addRuleCollection(simplificationRules());

final RelOptPlanner hepPlanner = new HepPlanner(programBuilder.build());
// convert the substrait to the calcite relation tree
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.

Suggested change
// convert the substrait to the calcite relation tree
// convert the Substrait to the Calcite relation tree

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