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 Detail

      • convertSqlToRel

        org.apache.calcite.rel.RelRoot convertSqlToRel​(java.lang.String sql)
        Converts a SQL string to a RelNode 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 a SqlValidator.
      • createCatalogReader

        org.apache.calcite.prepare.Prepare.CatalogReader createCatalogReader​(org.apache.calcite.rel.type.RelDataTypeFactory typeFactory)
        Factory method for a Prepare.CatalogReader.
      • createPlanner

        org.apache.calcite.plan.RelOptPlanner createPlanner()
      • getOperatorTable

        org.apache.calcite.sql.SqlOperatorTable getOperatorTable()
        Returns the SqlOperatorTable 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 query
        plan - 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 query
        plan - Expected plan
        trim - 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. If expand is false, the plan contains a RexSubQuery 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 a SqlToRelConverter.Config.
      • withConformance

        SqlToRelTestBase.Tester withConformance​(org.apache.calcite.sql.validate.SqlConformance conformance)
        Returns a tester with a SqlConformance.
      • 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.