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

protected static class SqlOperatorTest.TesterImpl extends AbstractSqlTester
Implementation of SqlTester based on a JDBC connection.
  • Field Details

  • 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 using SqlTester.TypeChecker and SqlTester.ResultChecker functors.
      Specified by:
      check in interface SqlTester
      Overrides:
      check in class AbstractSqlTester
      Parameters:
      factory - Factory
      query - SQL query
      typeChecker - Checks whether the result is the expected type
      parameterChecker - Checks whether the parameters are of expected types
      resultChecker - 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 interface SqlTester
      Overrides:
      checkFails in class AbstractSqlTester
      Parameters:
      factory - Factory
      sap - SQL scalar expression
      expectedError - 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 interface SqlTester
      Overrides:
      checkAggFails in class AbstractSqlTester
      Parameters:
      factory - Factory
      expr - An aggregate expression
      inputValues - Array of input values
      expectedError - Pattern for expected error
      runtime - 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 interface SqlTester
      Overrides:
      assertExceptionIsThrown in class AbstractSqlTester
      Parameters:
      factory - Factory
      sap - SQL statement
      expectedMsgPattern - If this parameter is null the query must be
    • assertExceptionIsThrown

      public void assertExceptionIsThrown(SqlTestFactory factory, StringAndPos sap, @Nullable String expectedMsgPattern, boolean runtime)