Class CalciteAssert.AssertQuery

  • Direct Known Subclasses:
    CalciteAssert.NopAssertQuery
    Enclosing class:
    CalciteAssert

    public static class CalciteAssert.AssertQuery
    extends java.lang.Object
    Fluent interface for building a query to be tested.
    • Field Detail

      • sql

        private final java.lang.String sql
      • plan

        private java.lang.String plan
      • limit

        private int limit
      • materializationsEnabled

        private boolean materializationsEnabled
      • hooks

        private final java.util.List<org.apache.calcite.util.Pair<org.apache.calcite.runtime.Hook,​java.util.function.Consumer>> hooks
    • Method Detail

      • createConnection

        protected java.sql.Connection createConnection()
      • withConnection

        public final CalciteAssert.AssertQuery withConnection​(java.util.function.Consumer<java.sql.Connection> f)
        Performs an action using a connection, and closes the connection afterwards.
      • returns

        @Deprecated
        public final CalciteAssert.AssertQuery returns​(com.google.common.base.Function<java.sql.ResultSet,​java.lang.Void> checker)
        Deprecated.
      • returns

        protected CalciteAssert.AssertQuery returns​(java.lang.String sql,
                                                    java.util.function.Consumer<java.sql.ResultSet> checker)
      • failsAtValidation

        public CalciteAssert.AssertQuery failsAtValidation​(java.lang.String optionalMessage)
        Used to check whether a sql statement fails at the SQL Validation phase. More formally, it checks if a SqlValidatorException or CalciteException was thrown.
        Parameters:
        optionalMessage - An optional message to check for in the output stacktrace
      • convertMatches

        public CalciteAssert.AssertQuery convertMatches​(java.util.function.Function<org.apache.calcite.rel.RelNode,​java.lang.Void> checker)
      • substitutionMatches

        public CalciteAssert.AssertQuery substitutionMatches​(java.util.function.Function<org.apache.calcite.rel.RelNode,​java.lang.Void> checker)
      • explainMatches

        public final CalciteAssert.AssertQuery explainMatches​(java.lang.String extra,
                                                              java.util.function.Consumer<java.sql.ResultSet> checker)
      • ensurePlan

        private void ensurePlan​(java.util.function.Consumer<java.lang.Integer> checkUpdate)
      • setPlan

        private void setPlan​(java.lang.String plan)
      • queryContains

        public CalciteAssert.AssertQuery queryContains​(java.util.function.Consumer<java.util.List> predicate1)
        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.
      • limit

        public CalciteAssert.AssertQuery limit​(int limit)
        Sets a limit on the number of rows returned. -1 means no limit.
      • sameResultWithMaterializationsDisabled

        public void sameResultWithMaterializationsDisabled()
      • withHook

        @Deprecated
        public <T> CalciteAssert.AssertQuery withHook​(org.apache.calcite.runtime.Hook hook,
                                                      java.util.function.Function<T,​java.lang.Void> handler)
        Deprecated.
      • withHook

        public <T> CalciteAssert.AssertQuery withHook​(org.apache.calcite.runtime.Hook hook,
                                                      java.util.function.Consumer<T> handler)
        Adds a hook and a handler for that hook. Calcite will create a thread hook (by calling Hook.addThread(Consumer)) just before running the query, and remove the hook afterwards.
      • addHook

        private <T> void addHook​(org.apache.calcite.runtime.Hook hook,
                                 java.util.function.Consumer<T> handler)
      • withProperty

        public <V> CalciteAssert.AssertQuery withProperty​(org.apache.calcite.runtime.Hook hook,
                                                          V value)
        Adds a property hook.
      • withRel

        public CalciteAssert.AssertQuery withRel​(java.util.function.Function<org.apache.calcite.tools.RelBuilder,​org.apache.calcite.rel.RelNode> relFn)
        Adds a factory to create a RelNode query. This RelNode will be used instead of the SQL string.
      • forceDecorrelate

        private org.apache.calcite.tools.FrameworkConfig forceDecorrelate​(org.apache.calcite.tools.FrameworkConfig config)
        Creates a FrameworkConfig that does not decorrelate.