Package org.apache.calcite.test
Class RelOptFixture
java.lang.Object
org.apache.calcite.test.RelOptFixture
A fixture for testing planner rules.
It provides a fluent API so that you can write tests by chaining method calls.
A fixture is immutable. If you have two test cases that require a similar set up (for example, the same SQL expression and set of planner rules), it is safe to use the same fixture object as a starting point for both tests.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
check()
Checks the plan for a SQL statement before/after executing a given rule, with an optional pre-program specified bywithPre(HepProgram)
to prepare the tree.void
Checks that the plan is the same before and after executing a given planner.Returns the diff repository, checking that it is not null.toRel()
withAfter
(BiFunction<RelOptFixture, RelNode, RelNode> transform) withBefore
(BiFunction<RelOptFixture, RelNode, RelNode> transform) withConfig
(UnaryOperator<SqlToRelConverter.Config> transform) withConformance
(SqlConformance conformance) withContext
(UnaryOperator<Context> transform) withDecorrelate
(boolean decorrelate) withDiffRepos
(DiffRepository diffRepos) withExpand
(boolean expand) withFactory
(UnaryOperator<SqlTestFactory> transform) <T> RelOptFixture
Adds a hook and a handler for that hook.withInSubQueryThreshold
(int inSubQueryThreshold) withLateDecorrelate
(boolean lateDecorrelate) withPlanner
(RelOptPlanner planner) withPre
(HepProgram preProgram) withPreRule
(RelOptRule... rules) withProgram
(HepProgram program) <V> RelOptFixture
withProperty
(Hook hook, V value) withRelBuilderConfig
(UnaryOperator<RelBuilder.Config> transform) withRelBuilderSimplify
(boolean simplify) withRelSupplier
(org.apache.calcite.test.RelSupplier relSupplier) withRule
(RelOptRule... rules) withTrim
(boolean trim) withVolcanoPlanner
(boolean topDown) withVolcanoPlanner
(boolean topDown, Consumer<VolcanoPlanner> init)
-
Method Details
-
withDiffRepos
-
withRelSupplier
-
sql
-
withBefore
-
withAfter
-
withDynamicTable
-
withFactory
-
withPre
-
withPreRule
-
withPlanner
-
withProgram
-
withRule
-
withHook
Adds a hook and a handler for that hook. Calcite will create a thread hook (by callingHook.addThread(Consumer)
) just before running the query, and remove the hook afterwards. -
withProperty
-
withRelBuilderSimplify
-
withExpand
-
withInSubQueryThreshold
-
withConfig
-
withRelBuilderConfig
-
withLateDecorrelate
-
withDecorrelate
-
withTrim
-
withCatalogReaderFactory
-
withConformance
-
withContext
-
toRel
-
check
public void check()Checks the plan for a SQL statement before/after executing a given rule, with an optional pre-program specified bywithPre(HepProgram)
to prepare the tree. -
checkUnchanged
public void checkUnchanged()Checks that the plan is the same before and after executing a given planner. Useful for checking circumstances where rules should not fire. -
withVolcanoPlanner
-
withVolcanoPlanner
-
withSubQueryRules
-
diffRepos
Returns the diff repository, checking that it is not null. (It is allowed to be null because some tests that don't use a diff repository.)
-