Package org.apache.calcite.test
Interface SqlToRelTestBase.Tester
-
- All Known Implementing Classes:
SqlToRelTestBase.TesterImpl
- Enclosing class:
- SqlToRelTestBase
public static interface SqlToRelTestBase.Tester
Helper class which contains default implementations of methods used for running sql-to-rel conversion tests.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
assertConvertsTo(java.lang.String sql, java.lang.String plan)
Checks that a SQL statement converts to a given plan.void
assertConvertsTo(java.lang.String sql, java.lang.String plan, boolean trim)
Checks that a SQL statement converts to a given plan, optionally trimming columns that are not needed.org.apache.calcite.rel.RelRoot
convertSqlToRel(java.lang.String sql)
Converts a SQL string to aRelNode
tree.org.apache.calcite.prepare.Prepare.CatalogReader
createCatalogReader(org.apache.calcite.rel.type.RelDataTypeFactory typeFactory)
Factory method for aPrepare.CatalogReader
.org.apache.calcite.plan.RelOptPlanner
createPlanner()
org.apache.calcite.sql.validate.SqlValidator
createValidator(org.apache.calcite.sql.validate.SqlValidatorCatalogReader catalogReader, org.apache.calcite.rel.type.RelDataTypeFactory typeFactory)
Factory method to create aSqlValidator
.org.apache.calcite.sql.validate.SqlConformance
getConformance()
Returns the SQL dialect to test.DiffRepository
getDiffRepos()
Returns the diff repository.org.apache.calcite.sql.SqlOperatorTable
getOperatorTable()
Returns theSqlOperatorTable
to use.org.apache.calcite.sql.validate.SqlValidator
getValidator()
Returns the validator.boolean
isLateDecorrelate()
org.apache.calcite.sql.SqlNode
parseQuery(java.lang.String sql)
SqlToRelTestBase.Tester
withCatalogReaderFactory(SqlTestFactory.MockCatalogReaderFactory factory)
SqlToRelTestBase.Tester
withClusterFactory(java.util.function.Function<org.apache.calcite.plan.RelOptCluster,org.apache.calcite.plan.RelOptCluster> function)
SqlToRelTestBase.Tester
withConfig(org.apache.calcite.sql2rel.SqlToRelConverter.Config config)
Returns a tester that optionally uses aSqlToRelConverter.Config
.SqlToRelTestBase.Tester
withConformance(org.apache.calcite.sql.validate.SqlConformance conformance)
Returns a tester with aSqlConformance
.SqlToRelTestBase.Tester
withContext(org.apache.calcite.plan.Context context)
Returns a tester that uses a given context.SqlToRelTestBase.Tester
withDecorrelation(boolean enable)
Returns a tester that optionally decorrelates queries.SqlToRelTestBase.Tester
withExpand(boolean expand)
Returns a tester that optionally expands sub-queries.SqlToRelTestBase.Tester
withLateDecorrelation(boolean enable)
Returns a tester that optionally decorrelates queries after planner rules have fired.SqlToRelTestBase.Tester
withTrim(boolean enable)
Returns a tester that optionally trims unused fields.
-
-
-
Method Detail
-
convertSqlToRel
org.apache.calcite.rel.RelRoot convertSqlToRel(java.lang.String sql)
Converts a SQL string to aRelNode
tree.- Parameters:
sql
- SQL statement- Returns:
- Relational expression, never null
-
parseQuery
org.apache.calcite.sql.SqlNode parseQuery(java.lang.String sql) throws java.lang.Exception
- Throws:
java.lang.Exception
-
createValidator
org.apache.calcite.sql.validate.SqlValidator createValidator(org.apache.calcite.sql.validate.SqlValidatorCatalogReader catalogReader, org.apache.calcite.rel.type.RelDataTypeFactory typeFactory)
Factory method to create aSqlValidator
.
-
createCatalogReader
org.apache.calcite.prepare.Prepare.CatalogReader createCatalogReader(org.apache.calcite.rel.type.RelDataTypeFactory typeFactory)
Factory method for aPrepare.CatalogReader
.
-
createPlanner
org.apache.calcite.plan.RelOptPlanner createPlanner()
-
getOperatorTable
org.apache.calcite.sql.SqlOperatorTable getOperatorTable()
Returns theSqlOperatorTable
to use.
-
getConformance
org.apache.calcite.sql.validate.SqlConformance getConformance()
Returns the SQL dialect to test.
-
assertConvertsTo
void assertConvertsTo(java.lang.String sql, java.lang.String plan)
Checks that a SQL statement converts to a given plan.- Parameters:
sql
- SQL queryplan
- Expected plan
-
assertConvertsTo
void assertConvertsTo(java.lang.String sql, java.lang.String plan, boolean trim)
Checks that a SQL statement converts to a given plan, optionally trimming columns that are not needed.- Parameters:
sql
- SQL queryplan
- Expected plantrim
- Whether to trim columns that are not needed
-
getDiffRepos
DiffRepository getDiffRepos()
Returns the diff repository.- Returns:
- Diff repository
-
getValidator
org.apache.calcite.sql.validate.SqlValidator getValidator()
Returns the validator.- Returns:
- Validator
-
withDecorrelation
SqlToRelTestBase.Tester withDecorrelation(boolean enable)
Returns a tester that optionally decorrelates queries.
-
withLateDecorrelation
SqlToRelTestBase.Tester withLateDecorrelation(boolean enable)
Returns a tester that optionally decorrelates queries after planner rules have fired.
-
withExpand
SqlToRelTestBase.Tester withExpand(boolean expand)
Returns a tester that optionally expands sub-queries. Ifexpand
is false, the plan contains aRexSubQuery
for each sub-query.- See Also:
Prepare.THREAD_EXPAND
-
withConfig
SqlToRelTestBase.Tester withConfig(org.apache.calcite.sql2rel.SqlToRelConverter.Config config)
Returns a tester that optionally uses aSqlToRelConverter.Config
.
-
withConformance
SqlToRelTestBase.Tester withConformance(org.apache.calcite.sql.validate.SqlConformance conformance)
Returns a tester with aSqlConformance
.
-
withCatalogReaderFactory
SqlToRelTestBase.Tester withCatalogReaderFactory(SqlTestFactory.MockCatalogReaderFactory factory)
-
withTrim
SqlToRelTestBase.Tester withTrim(boolean enable)
Returns a tester that optionally trims unused fields.
-
withClusterFactory
SqlToRelTestBase.Tester withClusterFactory(java.util.function.Function<org.apache.calcite.plan.RelOptCluster,org.apache.calcite.plan.RelOptCluster> function)
-
isLateDecorrelate
boolean isLateDecorrelate()
-
withContext
SqlToRelTestBase.Tester withContext(org.apache.calcite.plan.Context context)
Returns a tester that uses a given context.
-
-