Class MaterializationTest


  • public class MaterializationTest
    extends java.lang.Object
    Unit test for the materialized view rewrite mechanism. Each test has a query and one or more materializations (what Oracle calls materialized views) and checks that the materialization is used.
    • Field Detail

      • CONTAINS_M0

        private static final java.util.function.Consumer<java.sql.ResultSet> CONTAINS_M0
      • CONTAINS_LOCATIONS

        private static final java.util.function.Consumer<java.sql.ResultSet> CONTAINS_LOCATIONS
      • CASE_INSENSITIVE_LIST_COMPARATOR

        private static final com.google.common.collect.Ordering<java.lang.Iterable<java.lang.String>> CASE_INSENSITIVE_LIST_COMPARATOR
      • CASE_INSENSITIVE_LIST_LIST_COMPARATOR

        private static final com.google.common.collect.Ordering<java.lang.Iterable<java.util.List<java.lang.String>>> CASE_INSENSITIVE_LIST_LIST_COMPARATOR
      • HR_FKUK_SCHEMA

        private static final java.lang.String HR_FKUK_SCHEMA
      • HR_FKUK_MODEL

        private static final java.lang.String HR_FKUK_MODEL
      • typeFactory

        final org.apache.calcite.jdbc.JavaTypeFactoryImpl typeFactory
      • rexBuilder

        private final org.apache.calcite.rex.RexBuilder rexBuilder
      • simplify

        private final org.apache.calcite.rex.RexSimplify simplify
    • Constructor Detail

      • MaterializationTest

        public MaterializationTest()
    • Method Detail

      • testScan

        public void testScan()
      • testFilter

        public void testFilter()
      • testFilterQueryOnProjectView

        public void testFilterQueryOnProjectView()
      • checkMaterialize

        private void checkMaterialize​(java.lang.String materialize,
                                      java.lang.String query)
        Checks that a given query can use a materialized view with a given definition.
      • checkMaterializeWithRules

        private void checkMaterializeWithRules​(java.lang.String materialize,
                                               java.lang.String query,
                                               org.apache.calcite.tools.RuleSet rules)
        Checks that a given query can use a materialized view with a given definition.
      • checkMaterialize

        private void checkMaterialize​(java.lang.String materialize,
                                      java.lang.String query,
                                      java.lang.String model,
                                      java.util.function.Consumer<java.sql.ResultSet> explainChecker)
        Checks that a given query can use a materialized view with a given definition.
      • checkMaterialize

        private void checkMaterialize​(java.lang.String materialize,
                                      java.lang.String query,
                                      java.lang.String model,
                                      java.util.function.Consumer<java.sql.ResultSet> explainChecker,
                                      org.apache.calcite.tools.RuleSet rules)
      • checkThatMaterialize

        private CalciteAssert.AssertQuery checkThatMaterialize​(java.lang.String materialize,
                                                               java.lang.String query,
                                                               java.lang.String name,
                                                               boolean existing,
                                                               java.lang.String model,
                                                               java.util.function.Consumer<java.sql.ResultSet> explainChecker,
                                                               org.apache.calcite.tools.RuleSet rules)
        Checks that a given query can use a materialized view with a given definition.
      • checkNoMaterialize

        private void checkNoMaterialize​(java.lang.String materialize,
                                        java.lang.String query,
                                        java.lang.String model)
        Checks that a given query CAN NOT use a materialized view with a given definition.
      • testFilterQueryOnProjectView0

        public void testFilterQueryOnProjectView0()
        Runs the same test as testFilterQueryOnProjectView() but more concisely.
      • testFilterQueryOnProjectView1

        public void testFilterQueryOnProjectView1()
        As testFilterQueryOnProjectView() but with extra column in materialized view.
      • testFilterQueryOnProjectView2

        public void testFilterQueryOnProjectView2()
        As testFilterQueryOnProjectView() but with extra column in both materialized view and query.
      • testFilterQueryOnProjectView3

        public void testFilterQueryOnProjectView3()
      • testFilterQueryOnProjectView4

        public void testFilterQueryOnProjectView4()
        As testFilterQueryOnProjectView3() but materialized view cannot be used because it does not contain required expression.
      • testFilterQueryOnProjectView6

        public void testFilterQueryOnProjectView6()
        Cannot materialize because "name" is not projected in the MV.
      • testFilterQueryOnFilterView

        public void testFilterQueryOnFilterView()
      • testFilterQueryOnFilterView5

        public void testFilterQueryOnFilterView5()
        As testFilterQueryOnFilterView() but condition is stronger in query and columns selected are subset of columns in materialized view.
      • testFilterQueryOnFilterView6

        public void testFilterQueryOnFilterView6()
        As testFilterQueryOnFilterView() but condition is stronger in query and columns selected are subset of columns in materialized view.
      • testFilterQueryOnFilterView7

        public void testFilterQueryOnFilterView7()
        As testFilterQueryOnFilterView() but condition is stronger in query and columns selected are subset of columns in materialized view. Condition here is complex.
      • testFilterQueryOnFilterView8

        public void testFilterQueryOnFilterView8()
        As testFilterQueryOnFilterView() but condition is stronger in query. However, columns selected are not present in columns of materialized view, Hence should not use materialized view.
      • testFilterQueryOnFilterView10

        public void testFilterQueryOnFilterView10()
        As testFilterQueryOnFilterView() but condition currently has unsupported type being checked on query.
      • testFilterQueryOnFilterView11

        public void testFilterQueryOnFilterView11()
        As testFilterQueryOnFilterView() but condition is weaker in query and columns selected are subset of columns in materialized view. Condition here is complex.
      • testFilterQueryOnFilterView12

        public void testFilterQueryOnFilterView12()
        As testFilterQueryOnFilterView() but condition of query is stronger but is on the column not present in MV (salary).
      • testFilterQueryOnFilterView13

        public void testFilterQueryOnFilterView13()
        As testFilterQueryOnFilterView() but condition is weaker in query and columns selected are subset of columns in materialized view. Condition here is complex.
      • testFilterQueryOnFilterView14

        public void testFilterQueryOnFilterView14()
        As testFilterQueryOnFilterView7() but columns in materialized view are a permutation of columns in the query.
      • testAggregate

        public void testAggregate()
        Aggregation query at same level of aggregation as aggregation materialization.
      • testAggregateRollUp

        public void testAggregateRollUp()
        Aggregation query at coarser level of aggregation than aggregation materialization. Requires an additional aggregate to roll up. Note that COUNT is rolled up using SUM.
      • testAggregateProject

        public void testAggregateProject()
        Aggregation materialization with a project.
      • testSwapJoin

        public void testSwapJoin()
      • testOrderByQueryOnProjectView

        public void testOrderByQueryOnProjectView()
      • testOrderByQueryOnOrderByView

        public void testOrderByQueryOnOrderByView()
      • testDifferentColumnNames

        public void testDifferentColumnNames()
      • testDifferentType

        public void testDifferentType()
      • testPartialUnion

        public void testPartialUnion()
      • testNonDisjointUnion

        public void testNonDisjointUnion()
      • testMaterializationReferencesTableInOtherSchema

        public void testMaterializationReferencesTableInOtherSchema()
      • testSatisfiable

        public void testSatisfiable()
        Unit test for logic functions SubstitutionVisitor.mayBeSatisfiable(org.apache.calcite.rex.RexNode) and RexUtil.simplify(org.apache.calcite.rex.RexBuilder, org.apache.calcite.rex.RexNode).
      • checkNotSatisfiable

        private void checkNotSatisfiable​(org.apache.calcite.rex.RexNode e)
      • checkSatisfiable

        private void checkSatisfiable​(org.apache.calcite.rex.RexNode e,
                                      java.lang.String s)
      • testSplitFilter

        public void testSplitFilter()
      • testFilterGroupQueryOnStar

        public void testFilterGroupQueryOnStar()
        Tests a complicated star-join query on a complicated materialized star-join query. Some of the features:
        1. query joins in different order;
        2. query's join conditions are in where clause;
        3. query does not use all join tables (safe to omit them because they are many-to-mandatory-one joins);
        4. query is at higher granularity, therefore needs to roll up;
        5. query has a condition on one of the materialization's grouping columns.
      • testQueryOnStar

        public void testQueryOnStar()
        Simpler than testFilterGroupQueryOnStar(), tests a query on a materialization that is just a join.
      • testJoinOnUnionMaterialization

        public void testJoinOnUnionMaterialization()
        A materialization that is a join of a union cannot at present be converted to a star table and therefore cannot be recognized. This test checks that nothing unpleasant happens.
      • testJoinMaterialization

        public void testJoinMaterialization()
      • testJoinMaterialization3

        public void testJoinMaterialization3()
      • testUnionAll

        public void testUnionAll()
      • testAggregateMaterializationNoAggregateFuncs1

        public void testAggregateMaterializationNoAggregateFuncs1()
      • testAggregateMaterializationNoAggregateFuncs2

        public void testAggregateMaterializationNoAggregateFuncs2()
      • testAggregateMaterializationNoAggregateFuncs3

        public void testAggregateMaterializationNoAggregateFuncs3()
      • testAggregateMaterializationNoAggregateFuncs4

        public void testAggregateMaterializationNoAggregateFuncs4()
      • testAggregateMaterializationNoAggregateFuncs5

        public void testAggregateMaterializationNoAggregateFuncs5()
      • testAggregateMaterializationNoAggregateFuncs6

        public void testAggregateMaterializationNoAggregateFuncs6()
      • testAggregateMaterializationNoAggregateFuncs7

        public void testAggregateMaterializationNoAggregateFuncs7()
      • testAggregateMaterializationNoAggregateFuncs8

        public void testAggregateMaterializationNoAggregateFuncs8()
      • testAggregateMaterializationNoAggregateFuncs9

        public void testAggregateMaterializationNoAggregateFuncs9()
      • testAggregateMaterializationAggregateFuncs1

        public void testAggregateMaterializationAggregateFuncs1()
      • testAggregateMaterializationAggregateFuncs2

        public void testAggregateMaterializationAggregateFuncs2()
      • testAggregateMaterializationAggregateFuncs3

        public void testAggregateMaterializationAggregateFuncs3()
      • testAggregateMaterializationAggregateFuncs4

        public void testAggregateMaterializationAggregateFuncs4()
      • testAggregateMaterializationAggregateFuncs5

        public void testAggregateMaterializationAggregateFuncs5()
      • testAggregateMaterializationAggregateFuncs6

        public void testAggregateMaterializationAggregateFuncs6()
      • testAggregateMaterializationAggregateFuncs7

        public void testAggregateMaterializationAggregateFuncs7()
      • testAggregateMaterializationAggregateFuncs8

        public void testAggregateMaterializationAggregateFuncs8()
      • testAggregateMaterializationAggregateFuncs9

        public void testAggregateMaterializationAggregateFuncs9()
      • testAggregateMaterializationAggregateFuncs10

        public void testAggregateMaterializationAggregateFuncs10()
      • testAggregateMaterializationAggregateFuncs11

        public void testAggregateMaterializationAggregateFuncs11()
      • testAggregateMaterializationAggregateFuncs12

        public void testAggregateMaterializationAggregateFuncs12()
      • testAggregateMaterializationAggregateFuncs13

        public void testAggregateMaterializationAggregateFuncs13()
      • testAggregateMaterializationAggregateFuncs14

        public void testAggregateMaterializationAggregateFuncs14()
      • testAggregateMaterializationAggregateFuncs15

        public void testAggregateMaterializationAggregateFuncs15()
      • testAggregateMaterializationAggregateFuncs16

        public void testAggregateMaterializationAggregateFuncs16()
      • testAggregateMaterializationAggregateFuncs17

        public void testAggregateMaterializationAggregateFuncs17()
      • testAggregateMaterializationAggregateFuncs18

        public void testAggregateMaterializationAggregateFuncs18()
      • testAggregateMaterializationAggregateFuncs19

        public void testAggregateMaterializationAggregateFuncs19()
      • testJoinAggregateMaterializationNoAggregateFuncs1

        public void testJoinAggregateMaterializationNoAggregateFuncs1()
      • testJoinAggregateMaterializationNoAggregateFuncs2

        public void testJoinAggregateMaterializationNoAggregateFuncs2()
      • testJoinAggregateMaterializationNoAggregateFuncs3

        public void testJoinAggregateMaterializationNoAggregateFuncs3()
      • testJoinAggregateMaterializationNoAggregateFuncs4

        public void testJoinAggregateMaterializationNoAggregateFuncs4()
      • testJoinAggregateMaterializationNoAggregateFuncs5

        public void testJoinAggregateMaterializationNoAggregateFuncs5()
      • testJoinAggregateMaterializationNoAggregateFuncs6

        public void testJoinAggregateMaterializationNoAggregateFuncs6()
      • testJoinAggregateMaterializationNoAggregateFuncs7

        public void testJoinAggregateMaterializationNoAggregateFuncs7()
      • testJoinAggregateMaterializationNoAggregateFuncs8

        public void testJoinAggregateMaterializationNoAggregateFuncs8()
      • testJoinAggregateMaterializationNoAggregateFuncs9

        public void testJoinAggregateMaterializationNoAggregateFuncs9()
      • testJoinAggregateMaterializationNoAggregateFuncs10

        public void testJoinAggregateMaterializationNoAggregateFuncs10()
      • testJoinAggregateMaterializationAggregateFuncs1

        public void testJoinAggregateMaterializationAggregateFuncs1()
      • testJoinAggregateMaterializationAggregateFuncs2

        public void testJoinAggregateMaterializationAggregateFuncs2()
      • testJoinAggregateMaterializationAggregateFuncs3

        public void testJoinAggregateMaterializationAggregateFuncs3()
      • testJoinAggregateMaterializationAggregateFuncs4

        public void testJoinAggregateMaterializationAggregateFuncs4()
      • testJoinAggregateMaterializationAggregateFuncs5

        public void testJoinAggregateMaterializationAggregateFuncs5()
      • testJoinAggregateMaterializationAggregateFuncs6

        public void testJoinAggregateMaterializationAggregateFuncs6()
      • testJoinAggregateMaterializationAggregateFuncs7

        public void testJoinAggregateMaterializationAggregateFuncs7()
      • testJoinAggregateMaterializationAggregateFuncs8

        public void testJoinAggregateMaterializationAggregateFuncs8()
      • testJoinAggregateMaterializationAggregateFuncs9

        public void testJoinAggregateMaterializationAggregateFuncs9()
      • testJoinAggregateMaterializationAggregateFuncs10

        public void testJoinAggregateMaterializationAggregateFuncs10()
      • testJoinAggregateMaterializationAggregateFuncs11

        public void testJoinAggregateMaterializationAggregateFuncs11()
      • testJoinAggregateMaterializationAggregateFuncs12

        public void testJoinAggregateMaterializationAggregateFuncs12()
      • testJoinAggregateMaterializationAggregateFuncs13

        public void testJoinAggregateMaterializationAggregateFuncs13()
      • testJoinMaterialization4

        public void testJoinMaterialization4()
      • testJoinMaterialization5

        public void testJoinMaterialization5()
      • testJoinMaterialization6

        public void testJoinMaterialization6()
      • testJoinMaterialization7

        public void testJoinMaterialization7()
      • testJoinMaterialization8

        public void testJoinMaterialization8()
      • testJoinMaterialization9

        public void testJoinMaterialization9()
      • testJoinMaterialization10

        public void testJoinMaterialization10()
      • testJoinMaterialization11

        public void testJoinMaterialization11()
      • testJoinMaterializationUKFK1

        public void testJoinMaterializationUKFK1()
      • testJoinMaterializationUKFK2

        public void testJoinMaterializationUKFK2()
      • testJoinMaterializationUKFK3

        public void testJoinMaterializationUKFK3()
      • testJoinMaterializationUKFK4

        public void testJoinMaterializationUKFK4()
      • testJoinMaterializationUKFK5

        public void testJoinMaterializationUKFK5()
      • testJoinMaterializationUKFK6

        public void testJoinMaterializationUKFK6()
      • testJoinMaterializationUKFK7

        public void testJoinMaterializationUKFK7()
      • testJoinMaterializationUKFK8

        public void testJoinMaterializationUKFK8()
      • testJoinMaterializationUKFK9

        public void testJoinMaterializationUKFK9()
      • testViewMaterialization

        public void testViewMaterialization()
      • testSubQuery

        public void testSubQuery()
      • testTableModify

        public void testTableModify()
      • testViewSchemaPath

        public void testViewSchemaPath()
      • testSingleMaterializationMultiUsage

        public void testSingleMaterializationMultiUsage()
      • testMultiMaterializationMultiUsage

        public void testMultiMaterializationMultiUsage()
      • testMaterializationOnJoinQuery

        public void testMaterializationOnJoinQuery()
      • testMultiMaterializationOnJoinQuery

        public void testMultiMaterializationOnJoinQuery()
      • testAggregateMaterializationOnCountDistinctQuery1

        public void testAggregateMaterializationOnCountDistinctQuery1()
      • testAggregateMaterializationOnCountDistinctQuery2

        public void testAggregateMaterializationOnCountDistinctQuery2()
      • testAggregateMaterializationOnCountDistinctQuery3

        public void testAggregateMaterializationOnCountDistinctQuery3()
      • testAggregateMaterializationOnCountDistinctQuery4

        public void testAggregateMaterializationOnCountDistinctQuery4()
      • testMaterializationSubstitution

        public void testMaterializationSubstitution()
      • testMaterializationSubstitution2

        public void testMaterializationSubstitution2()
      • list3

        private static <E> java.util.List<java.util.List<java.util.List<E>>> list3​(E[][][] as)
      • list2

        private static <E> java.util.List<java.util.List<E>> list2​(E[][] as)