Sergey Nuyanzin created CALCITE-7939:
----------------------------------------

             Summary:  Non-flat AND/OR conditions cause AssertionError in 
Filter when created by FilterProjectTransposeRule or RelBuilder.filter
                 Key: CALCITE-7939
                 URL: https://issues.apache.org/jira/browse/CALCITE-7939
             Project: Calcite
          Issue Type: Bug
          Components: core
            Reporter: Sergey Nuyanzin


When a Filter references a Project column that is defined as an {{OR}} (or 
{{AND}}), {{FilterProjectTransposeRule}} replaces the column with its 
expression. The resulting condition can be non-flat, for example {{OR(OR(a, b), 
c)}}, and it fails as:
{noformat}


java.lang.AssertionError: RexUtil.isFlat should be true for condition 
OR(OR(>($5, 1000), >($6, 100)), >($0, 7000))
        at org.apache.calcite.rel.core.Filter.<init>(Filter.java:90)
        at 
org.apache.calcite.rel.logical.LogicalFilter.copy(LogicalFilter.java:153)
        at 
org.apache.calcite.rel.rules.FilterProjectTransposeRule.onMatch(FilterProjectTransposeRule.java:190)
{noformat}

example of SQL
{code:sql}

SELECT * FROM (
  SELECT sal > 1000 OR comm > 100 AS p, empno FROM emp)
WHERE p OR empno > 7000
{code}
with {{CoreRules.FILTER_PROJECT_TRANSPOSE}}.

The same failure happens in {{RelBuilder.filter}} when simplification is 
disabled and the condition contains nested {{AND}}/{{OR}}, for example in 
{{CalcSplitRule}} after {{CalcMergeRule}}.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to