Package org.apache.calcite.test
Class SqlOperatorTest.TesterImpl
java.lang.Object
org.apache.calcite.sql.test.AbstractSqlTester
org.apache.calcite.test.SqlOperatorTest.TesterImpl
- All Implemented Interfaces:
AutoCloseable
,SqlTester
- Enclosing class:
SqlOperatorTest
Implementation of
SqlTester
based on a
JDBC connection.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.calcite.sql.test.SqlTester
SqlTester.ParameterChecker, SqlTester.ResultChecker, SqlTester.TypeChecker, SqlTester.ValidatedNodeConsumer, SqlTester.ValidatedNodeFunction<R>, SqlTester.VmName
-
Field Summary
Modifier and TypeFieldDescriptionstatic final TryThreadLocal<RelDataTypeSystem>
Assign a type system object to this thread-local, pass the name of the field as theCalciteConnectionProperty.TYPE_SYSTEM
property, and any connection you make in the same thread will use your type system. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
assertExceptionIsThrown
(SqlTestFactory factory, StringAndPos sap, @Nullable String expectedMsgPattern) Checks that a query is valid, or, if invalid, throws the right message at the right location.void
assertExceptionIsThrown
(SqlTestFactory factory, StringAndPos sap, @Nullable String expectedMsgPattern, boolean runtime) void
check
(SqlTestFactory factory, String query, SqlTester.TypeChecker typeChecker, SqlTester.ParameterChecker parameterChecker, SqlTester.ResultChecker resultChecker) Tests that a SQL query returns a result of expected type and value.void
checkAggFails
(SqlTestFactory factory, String expr, String[] inputValues, String expectedError, boolean runtime) Tests that an aggregate expression fails at run time.void
checkFails
(SqlTestFactory factory, StringAndPos sap, String expectedError, boolean runtime) Tests that a scalar SQL expression fails at run time.Methods inherited from class org.apache.calcite.sql.test.AbstractSqlTester
assertConvertsTo, buildQuery, buildQuery2, buildQueryAgg, checkAgg, checkColumnType, checkParseEx, checkQueryFails, checkWinAgg, close, convertSqlToRel2, createFieldTrimmer, forEachQuery, getColumnType, getResultType, parseExpression, parseQuery, setFor, trimRelNode, validateAndApply, validateAndThen
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.calcite.sql.test.SqlTester
check, checkFails, convertSqlToRel
-
Field Details
-
THREAD_TYPE_SYSTEM
Assign a type system object to this thread-local, pass the name of the field as theCalciteConnectionProperty.TYPE_SYSTEM
property, and any connection you make in the same thread will use your type system.
-
-
Constructor Details
-
TesterImpl
public TesterImpl()
-
-
Method Details
-
check
public void check(SqlTestFactory factory, String query, SqlTester.TypeChecker typeChecker, SqlTester.ParameterChecker parameterChecker, SqlTester.ResultChecker resultChecker) Description copied from interface:SqlTester
Tests that a SQL query returns a result of expected type and value. Checking of type and value are abstracted usingSqlTester.TypeChecker
andSqlTester.ResultChecker
functors.- Specified by:
check
in interfaceSqlTester
- Overrides:
check
in classAbstractSqlTester
- Parameters:
factory
- Factoryquery
- SQL querytypeChecker
- Checks whether the result is the expected typeparameterChecker
- Checks whether the parameters are of expected typesresultChecker
- Checks whether the result has the expected value
-
checkFails
public void checkFails(SqlTestFactory factory, StringAndPos sap, String expectedError, boolean runtime) Description copied from interface:SqlTester
Tests that a scalar SQL expression fails at run time.- Specified by:
checkFails
in interfaceSqlTester
- Overrides:
checkFails
in classAbstractSqlTester
- Parameters:
factory
- Factorysap
- SQL scalar expressionexpectedError
- Pattern for expected error. If !runtime, must include an error location.runtime
- If true, must fail at runtime; if false, must fail at validate time
-
checkAggFails
public void checkAggFails(SqlTestFactory factory, String expr, String[] inputValues, String expectedError, boolean runtime) Description copied from interface:SqlTester
Tests that an aggregate expression fails at run time.- Specified by:
checkAggFails
in interfaceSqlTester
- Overrides:
checkAggFails
in classAbstractSqlTester
- Parameters:
factory
- Factoryexpr
- An aggregate expressioninputValues
- Array of input valuesexpectedError
- Pattern for expected errorruntime
- If true, must fail at runtime; if false, must fail at validate time
-
assertExceptionIsThrown
public void assertExceptionIsThrown(SqlTestFactory factory, StringAndPos sap, @Nullable String expectedMsgPattern) Description copied from interface:SqlTester
Checks that a query is valid, or, if invalid, throws the right message at the right location.If
expectedMsgPattern
is null, the query must succeed.If
expectedMsgPattern
is not null, the query must fail, and give an error location of (expectedLine, expectedColumn) through (expectedEndLine, expectedEndColumn).- Specified by:
assertExceptionIsThrown
in interfaceSqlTester
- Overrides:
assertExceptionIsThrown
in classAbstractSqlTester
- Parameters:
factory
- Factorysap
- SQL statementexpectedMsgPattern
- If this parameter is null the query must be
-
assertExceptionIsThrown
public void assertExceptionIsThrown(SqlTestFactory factory, StringAndPos sap, @Nullable String expectedMsgPattern, boolean runtime)
-