Class CalciteAssert.AssertQuery
- Enclosing class:
CalciteAssert
-
Method Summary
Modifier and TypeMethodDescriptionconvertContains(String expected) Checks that when the query (which was set usingCalciteAssert.AssertThat.query(String)) is converted to a relational algebra expression matching the given string.convertMatches(Consumer<RelNode> checker) protected Connectionenable(boolean enabled) enableMaterializations(boolean materializationsEnabled) explainContains(String expected) explainHookContains(String expectedPlan) This enables to assert the optimized plan without issuing a separateexplain ...command.explainHookContains(SqlExplainLevel sqlExplainLevel, String expectedPlan) This enables to assert the optimized plan without issuing a separateexplain ...command.explainHookMatches(String expectedPlan) This enables to assert the optimized plan without issuing a separateexplain ...command.explainHookMatches(SqlExplainLevel sqlExplainLevel, org.hamcrest.Matcher<String> planMatcher) This enables to assert the optimized plan without issuing a separateexplain ...command.explainHookMatches(org.hamcrest.Matcher<String> planMatcher) This enables to assert the optimized plan without issuing a separateexplain ...command.explainMatches(String extra, Consumer<ResultSet> checker) Utility method so that one doesn't have to callfailsAtValidation(java.lang.String)withnull.failsAtValidation(@Nullable String optionalMessage) Used to check whether a sql statement fails at the SQL Validation phase.limit(int limit) Sets a limit on the number of rows returned.planContains(String expected) planHasSql(String expected) planUpdateHasSql(String expected, int count) queryContains(com.google.common.base.Function<List, Void> predicate1) Deprecated.queryContains(Consumer<List> predicate1) Runs the query and applies a checker to the generated third-party queries.protected CalciteAssert.AssertQuerySimilar toreturns(java.lang.String), but trims a few values before comparing.returnsCount(int expectedCount) returnsOrdered(String... lines) returnsStartingWith(String... lines) returnsUnordered(String... lines) returnsValue(String expected) runs()voidsubstitutionMatches(Consumer<RelNode> checker) updates(int count) Performs an action using a connection, and closes the connection afterward.Adds a hook and a handler for that hook.withProperty(Hook hook, V value) Adds a property hook.
-
Method Details
-
createConnection
-
withConnection
Performs an action using a connection, and closes the connection afterward. -
enable
-
returns
-
returns2
Similar toreturns(java.lang.String), but trims a few values before comparing. -
returnsValue
-
returnsCount
-
returns
-
updates
-
returns
-
returnsUnordered
-
returnsOrdered
-
returnsStartingWith
-
throws_
-
failsAtValidation
Used to check whether a sql statement fails at the SQL Validation phase. More formally, it checks if aSqlValidatorExceptionorCalciteExceptionwas thrown.- Parameters:
optionalMessage- An optional message to check for in the output stacktrace
-
failsAtValidation
Utility method so that one doesn't have to callfailsAtValidation(java.lang.String)withnull. -
runs
-
typeIs
-
convertContains
Checks that when the query (which was set usingCalciteAssert.AssertThat.query(String)) is converted to a relational algebra expression matching the given string. -
consumesPreparedStatement
public CalciteAssert.AssertQuery consumesPreparedStatement(CalciteAssert.PreparedStatementConsumer consumer) -
convertMatches
-
substitutionMatches
-
explainContains
-
explainHookContains
@API(since="1.22", status=EXPERIMENTAL) public CalciteAssert.AssertQuery explainHookContains(String expectedPlan) This enables to assert the optimized plan without issuing a separateexplain ...command. This is especially useful whenRelNodeis provided viaHook.STRING_TO_QUERYorCalciteAssert.AssertThat.withRel(Function).Note: this API does NOT trigger the query, so you need to use something like
returns(String), orreturnsUnordered(String...)to trigger query executionNote: prefer using
explainHookMatches(String)if you assert the full plan tree as it produces slightly cleaner messages- Parameters:
expectedPlan- expected execution plan. The plan is normalized to LF line endings- Returns:
- updated assert query
-
explainHookContains
@API(since="1.22", status=EXPERIMENTAL) public CalciteAssert.AssertQuery explainHookContains(SqlExplainLevel sqlExplainLevel, String expectedPlan) This enables to assert the optimized plan without issuing a separateexplain ...command. This is especially useful whenRelNodeis provided viaHook.STRING_TO_QUERYorCalciteAssert.AssertThat.withRel(Function).Note: this API does NOT trigger the query, so you need to use something like
returns(String), orreturnsUnordered(String...)to trigger query executionNote: prefer using
explainHookMatches(SqlExplainLevel, Matcher)if you assert the full plan tree as it produces slightly cleaner messages- Parameters:
sqlExplainLevel- the level of explain planexpectedPlan- expected execution plan. The plan is normalized to LF line endings- Returns:
- updated assert query
-
explainHookMatches
@API(since="1.22", status=EXPERIMENTAL) public CalciteAssert.AssertQuery explainHookMatches(String expectedPlan) This enables to assert the optimized plan without issuing a separateexplain ...command. This is especially useful whenRelNodeis provided viaHook.STRING_TO_QUERYorCalciteAssert.AssertThat.withRel(Function).Note: this API does NOT trigger the query, so you need to use something like
returns(String), orreturnsUnordered(String...)to trigger query execution.- Parameters:
expectedPlan- expected execution plan. The plan is normalized to LF line endings- Returns:
- updated assert query
-
explainHookMatches
@API(since="1.22", status=EXPERIMENTAL) public CalciteAssert.AssertQuery explainHookMatches(org.hamcrest.Matcher<String> planMatcher) This enables to assert the optimized plan without issuing a separateexplain ...command. This is especially useful whenRelNodeis provided viaHook.STRING_TO_QUERYorCalciteAssert.AssertThat.withRel(Function).Note: this API does NOT trigger the query, so you need to use something like
returns(String), orreturnsUnordered(String...)to trigger query execution.- Parameters:
planMatcher- execution plan matcher. The plan is normalized to LF line endings- Returns:
- updated assert query
-
explainHookMatches
@API(since="1.22", status=EXPERIMENTAL) public CalciteAssert.AssertQuery explainHookMatches(SqlExplainLevel sqlExplainLevel, org.hamcrest.Matcher<String> planMatcher) This enables to assert the optimized plan without issuing a separateexplain ...command. This is especially useful whenRelNodeis provided viaHook.STRING_TO_QUERYorCalciteAssert.AssertThat.withRel(Function).Note: this API does NOT trigger the query, so you need to use something like
returns(String), orreturnsUnordered(String...)to trigger query execution.- Parameters:
sqlExplainLevel- the level of explain planplanMatcher- execution plan matcher. The plan is normalized to LF line endings- Returns:
- updated assert query
-
explainMatches
-
planContains
-
planUpdateHasSql
-
planHasSql
-
queryContains
Runs the query and applies a checker to the generated third-party queries. The checker should throw to fail the test if it does not see what it wants. This method can be used to check whether a particular MongoDB or SQL query is generated, for instance. -
queryContains
@Deprecated public final CalciteAssert.AssertQuery queryContains(com.google.common.base.Function<List, Void> predicate1) Deprecated. -
limit
Sets a limit on the number of rows returned. -1 means no limit. -
sameResultWithMaterializationsDisabled
public void sameResultWithMaterializationsDisabled() -
enableMaterializations
-
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
Adds a property hook.
-
queryContains(Consumer).