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
FieldsModifier and TypeFieldDescriptionstatic final TryThreadLocal<RelDataTypeSystem>Assign a type system object to this thread-local, pass the name of the field as theCalciteConnectionProperty.TYPE_SYSTEMproperty, and any connection you make in the same thread will use your type system. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidassertExceptionIsThrown(SqlTestFactory factory, StringAndPos sap, @Nullable String expectedMsgPattern) Checks that a query is valid, or, if invalid, throws the right message at the right location.voidassertExceptionIsThrown(SqlTestFactory factory, StringAndPos sap, @Nullable String expectedMsgPattern, boolean runtime) voidcheck(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.voidcheckAggFails(SqlTestFactory factory, String expr, String[] inputValues, String expectedError, boolean runtime) Tests that an aggregate expression fails at run time.voidcheckFails(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, validateAndThenMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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_SYSTEMproperty, 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:SqlTesterTests that a SQL query returns a result of expected type and value. Checking of type and value are abstracted usingSqlTester.TypeCheckerandSqlTester.ResultCheckerfunctors.- Specified by:
checkin interfaceSqlTester- Overrides:
checkin 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:SqlTesterTests that a scalar SQL expression fails at run time.- Specified by:
checkFailsin interfaceSqlTester- Overrides:
checkFailsin 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:SqlTesterTests that an aggregate expression fails at run time.- Specified by:
checkAggFailsin interfaceSqlTester- Overrides:
checkAggFailsin 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:SqlTesterChecks that a query is valid, or, if invalid, throws the right message at the right location.If
expectedMsgPatternis null, the query must succeed.If
expectedMsgPatternis not null, the query must fail, and give an error location of (expectedLine, expectedColumn) through (expectedEndLine, expectedEndColumn).- Specified by:
assertExceptionIsThrownin interfaceSqlTester- Overrides:
assertExceptionIsThrownin 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)
-