Class RexProgramTest


  • public class RexProgramTest
    extends RexProgramBuilderBase
    Unit tests for RexProgram and RexProgramBuilder.
    • Constructor Detail

      • RexProgramTest

        public RexProgramTest()
        Creates a RexProgramTest.
    • Method Detail

      • checkCnf

        private void checkCnf​(org.apache.calcite.rex.RexNode node,
                              java.lang.String expected)
      • checkThresholdCnf

        private void checkThresholdCnf​(org.apache.calcite.rex.RexNode node,
                                       int threshold,
                                       java.lang.String expected)
      • checkPullFactorsUnchanged

        private void checkPullFactorsUnchanged​(org.apache.calcite.rex.RexNode node)
      • checkPullFactors

        private void checkPullFactors​(org.apache.calcite.rex.RexNode node,
                                      java.lang.String expected)
      • assertNode

        private void assertNode​(java.lang.String message,
                                java.lang.String expected,
                                org.apache.calcite.rex.RexNode node)
        Asserts that given node has expected string representation with account of node type
        Parameters:
        message - extra message that clarifies where the node came from
        expected - expected string representation of the node
        node - node to check
      • checkSimplify

        private void checkSimplify​(org.apache.calcite.rex.RexNode node,
                                   java.lang.String expected)
        Simplifies an expression and checks that the result is as expected.
      • checkSimplifyUnchanged

        private void checkSimplifyUnchanged​(org.apache.calcite.rex.RexNode node)
        Simplifies an expression and checks that the result is unchanged.
      • checkSimplify2

        private void checkSimplify2​(org.apache.calcite.rex.RexNode node,
                                    java.lang.String expected,
                                    java.lang.String expectedFalse)
        Simplifies an expression and checks the result if unknowns remain unknown, or if unknown becomes false. If the result is the same, use checkSimplify(RexNode, String).
        Parameters:
        node - Expression to simplify
        expected - Expected simplification
        expectedFalse - Expected simplification, if unknown is to be treated as false
      • checkSimplify3

        private void checkSimplify3​(org.apache.calcite.rex.RexNode node,
                                    java.lang.String expected,
                                    java.lang.String expectedFalse,
                                    java.lang.String expectedTrue)
      • checkSimplify3_

        private void checkSimplify3_​(org.apache.calcite.rex.RexNode node,
                                     java.lang.String expected,
                                     java.lang.String expectedFalse,
                                     java.lang.String expectedTrue)
      • checkSimplifyFilter

        private void checkSimplifyFilter​(org.apache.calcite.rex.RexNode node,
                                         java.lang.String expected)
      • checkSimplifyFilter

        private void checkSimplifyFilter​(org.apache.calcite.rex.RexNode node,
                                         org.apache.calcite.plan.RelOptPredicateList predicates,
                                         java.lang.String expected)
      • nodeCount

        private static int nodeCount​(org.apache.calcite.rex.RexNode node)
        Returns the number of nodes (including leaves) in a Rex tree.
      • testBuildProgram

        public void testBuildProgram()
        Tests construction of a RexProgram.
      • testNormalize

        public void testNormalize()
        Tests construction and normalization of a RexProgram.
      • testElimDups

        public void testElimDups()
        Tests construction and normalization of a RexProgram.
      • testSimplifyCondition

        public void testSimplifyCondition()
        Tests how the condition is simplified.
      • testSimplifyCondition2

        public void testSimplifyCondition2()
        Tests how the condition is simplified.
      • testDuplicateAnd

        public void testDuplicateAnd()
        Checks translation of AND(x, x).
      • createProg

        private org.apache.calcite.rex.RexProgramBuilder createProg​(int variant)
        Creates a program, depending on variant:
        1. select (x + y) + (x + 1) as a, (x + x) as b from t(x, y)
        2. select (x + y) + (x + 1) as a, (x + (x + 1)) as b from t(x, y)
        3. select (x + y) + (x + 1) as a, (x + x) as b from t(x, y) where ((x + y) > 1) and ((x + y) > 1)
        4. select (x + y) + (x + 1) as a, (x + x) as b from t(x, y) where not case when x + 1 > 5 then true when y is null then null else false end
      • testStrong

        public void testStrong()
        Unit test for Strong.
      • xAndNotX

        public void xAndNotX()
      • testLosslessCast

        public void testLosslessCast()
        Unit test for RexUtil.isLosslessCast(RexNode).
      • removeRedundantCast

        public void removeRedundantCast()
      • testNoCommonReturnTypeFails

        public void testNoCommonReturnTypeFails()
      • testCnf

        public void testCnf()
        Unit test for RexUtil.toCnf(org.apache.calcite.rex.RexBuilder, org.apache.calcite.rex.RexNode).
      • testCnfExponential

        public void testCnfExponential()
        Tests formulas of various sizes whose size is exponential when converted to CNF.
      • checkExponentialCnf

        private void checkExponentialCnf​(int n)
      • testPullFactors

        public void testPullFactors()
        Unit test for RexUtil.pullFactors(org.apache.calcite.rex.RexBuilder, org.apache.calcite.rex.RexNode).
      • testSimplify

        public void testSimplify()
      • simplifyStrong

        public void simplifyStrong()
      • testSimplifyFilter

        public void testSimplifyFilter()
      • testSimplifyAndPush

        public void testSimplifyAndPush()
      • testSimplifyOrTerms

        public void testSimplifyOrTerms()
      • testSimplifyNotAnd

        public void testSimplifyNotAnd()
      • testSimplifyUnknown

        public void testSimplifyUnknown()
      • testSimplifyAnd3

        public void testSimplifyAnd3()
      • fieldAccessEqualsHashCode

        public void fieldAccessEqualsHashCode()
      • testSimplifyDynamicParam

        public void testSimplifyDynamicParam()
      • testSimplifyCaseNullableBoolean

        public void testSimplifyCaseNullableBoolean()
      • testSimplifyRecurseIntoArithmetics

        public void testSimplifyRecurseIntoArithmetics()
      • testSimplifyCaseBranchesCollapse

        public void testSimplifyCaseBranchesCollapse()
      • testSimplifyCaseBranchesCollapse2

        public void testSimplifyCaseBranchesCollapse2()
      • testSimplifyCaseNullableVarChar

        public void testSimplifyCaseNullableVarChar()
      • testSimplifyCaseCasting

        public void testSimplifyCaseCasting()
      • testSimplifyCaseAndNotSimplicationIsInAction

        public void testSimplifyCaseAndNotSimplicationIsInAction()
      • testSimplifyCaseBranchRemovalStrengthensType

        public void testSimplifyCaseBranchRemovalStrengthensType()
      • testSimplifyCaseCompaction

        public void testSimplifyCaseCompaction()
      • testSimplifyCaseCompaction2

        public void testSimplifyCaseCompaction2()
      • testSimplifyCaseCompactionDiv

        public void testSimplifyCaseCompactionDiv()
      • testSimplifyCaseDiv1

        public void testSimplifyCaseDiv1()
        Tests a CASE value branch that contains division.
      • testSimplifyCaseDiv2

        public void testSimplifyCaseDiv2()
        Tests a CASE condition that contains division,
      • testSimplifyCaseFirstBranchIsSafe

        public void testSimplifyCaseFirstBranchIsSafe()
      • testPushNotIntoCase

        public void testPushNotIntoCase()
      • testNotRecursion

        public void testNotRecursion()
      • testSimplifyAnd

        public void testSimplifyAnd()
      • testSimplifyIsNotNull

        public void testSimplifyIsNotNull()
      • checkSimplifyDynamicParam

        public void checkSimplifyDynamicParam()
      • testSimplifyCastLiteral

        public void testSimplifyCastLiteral()
      • testCastLiteral

        public void testCastLiteral()
      • testSimplifyCastLiteral2

        public void testSimplifyCastLiteral2()
      • testSimplifyCastLiteral3

        public void testSimplifyCastLiteral3()
      • testRemovalOfNullabilityWideningCast

        public void testRemovalOfNullabilityWideningCast()
      • testCompareTimestampWithTimeZone

        public void testCompareTimestampWithTimeZone()
      • testSimplifyLiterals

        public void testSimplifyLiterals()
      • testBooleanComparisions

        public void testBooleanComparisions()
      • testSimpleDynamicVars

        public void testSimpleDynamicVars()
      • assertTypeAndToString

        private void assertTypeAndToString​(org.apache.calcite.rex.RexNode rexNode,
                                           java.lang.String representation,
                                           java.lang.String type)
      • testIsDeterministic

        public void testIsDeterministic()
      • testConstantMap

        public void testConstantMap()
      • notDistinct

        public void notDistinct()
      • simplifyNull

        public void simplifyNull()
      • getString

        private static java.lang.String getString​(com.google.common.collect.ImmutableMap<org.apache.calcite.rex.RexNode,​org.apache.calcite.rex.RexNode> map)
        Converts a map to a string, sorting on the string representation of its keys.
      • testSimplifyFalse

        public void testSimplifyFalse()
      • testSimplifyNot

        public void testSimplifyNot()
      • testSimplifyAndNot

        public void testSimplifyAndNot()
      • testSimplifyOrNot

        public void testSimplifyOrNot()
      • simplify

        private org.apache.calcite.rex.RexNode simplify​(org.apache.calcite.rex.RexNode e)
      • testInterpreter

        public void testInterpreter()
      • testIsNullRecursion

        public void testIsNullRecursion()
      • testRedundantIsTrue

        public void testRedundantIsTrue()
      • testRedundantIsFalse

        public void testRedundantIsFalse()
      • testRedundantIsNotTrue

        public void testRedundantIsNotTrue()
      • testRedundantIsNotFalse

        public void testRedundantIsNotFalse()
      • testIsAlwaysTrueAndFalseNotXisNullisNotNullisFalse

        public void testIsAlwaysTrueAndFalseNotXisNullisNotNullisFalse()
      • testIsAlwaysTrueAndFalseXisNullisNotNullisTrue

        public void testIsAlwaysTrueAndFalseXisNullisNotNullisTrue()
      • testIsAlwaysTrueAndFalseNotXisNullisNotNullisTrue

        public void testIsAlwaysTrueAndFalseNotXisNullisNotNullisTrue()
      • testIsAlwaysTrueAndFalseNotXisNullisNotNullisNotTrue

        public void testIsAlwaysTrueAndFalseNotXisNullisNotNullisNotTrue()
      • testIsAlwaysTrueAndFalseXisNullisNotNull

        public void testIsAlwaysTrueAndFalseXisNullisNotNull()
      • testIsAlwaysTrueAndFalseXisNotNullisNotNull

        public void testIsAlwaysTrueAndFalseXisNotNullisNotNull()
      • testIsAlwaysTrueAndFalseXisNullisNull

        public void testIsAlwaysTrueAndFalseXisNullisNull()
      • testIsAlwaysTrueAndFalseXisNotNullisNull

        public void testIsAlwaysTrueAndFalseXisNotNullisNull()
      • testIsAlwaysTrueAndFalseXisNullisNotNullisNotFalse

        public void testIsAlwaysTrueAndFalseXisNullisNotNullisNotFalse()
      • testIsAlwaysTrueAndFalseXisNullisNotNullisNotTrue

        public void testIsAlwaysTrueAndFalseXisNullisNotNullisNotTrue()
      • checkIs

        private void checkIs​(org.apache.calcite.rex.RexNode e,
                             boolean expected)
        Checks that RexNode.isAlwaysTrue(), RexNode.isAlwaysTrue() and RexSimplify agree that an expression reduces to true or false.
      • eval

        private java.lang.Comparable eval​(org.apache.calcite.rex.RexNode e)
      • testIsNullSimplificationWithUnaryPlus

        public void testIsNullSimplificationWithUnaryPlus()
      • testIsNullSimplificationWithIsDistinctFrom

        public void testIsNullSimplificationWithIsDistinctFrom()