[ 
https://issues.apache.org/jira/browse/CALCITE-4495?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Hyde updated CALCITE-4495:
---------------------------------
    Description: 
Apologies. After spending an hour or so trying to write a simple repro for this 
I was unable to, so filing a bug for now so I have something to reference on my 
end.

There is a condition in which this code explodes, here's the traceback:
{noformat}
Java::JavaLang::IllegalArgumentException: 
com.google.common.base.Preconditions.checkArgument(com/google/common/base/Preconditions.java:128)
 
org.apache.calcite.rex.RexLiteral.<init>(org/apache/calcite/rex/RexLiteral.java:221)
 
org.apache.calcite.rex.RexBuilder.makeLiteral(org/apache/calcite/rex/RexBuilder.java:982)
 
org.apache.calcite.rex.RexBuilder.makeSearchArgumentLiteral(org/apache/calcite/rex/RexBuilder.java:1077)
 
org.apache.calcite.rex.RexSimplify$SargCollector.fix(org/apache/calcite/rex/RexSimplify.java:2719)
 
org.apache.calcite.rex.RexSimplify.lambda$simplifyAnd$4(org/apache/calcite/rex/RexSimplify.java:1335)
 java.util.ArrayList.forEach(java/util/ArrayList.java:1257)
 
org.apache.calcite.rex.RexSimplify.simplifyAnd(org/apache/calcite/rex/RexSimplify.java:1335)
 
org.apache.calcite.rex.RexSimplify.simplify(org/apache/calcite/rex/RexSimplify.java:274)
 
org.apache.calcite.rex.RexSimplify.simplifyUnknownAs(org/apache/calcite/rex/RexSimplify.java:243)
 
org.apache.calcite.rex.RexSimplify.simplifyUnknownAsFalse(org/apache/calcite/rex/RexSimplify.java:232)
 
org.apache.calcite.plan.SubstitutionVisitor.splitFilter(org/apache/calcite/plan/SubstitutionVisitor.java:307)
 
org.apache.calcite.rel.rules.materialize.MaterializedViewRule.computeCompensationPredicates(org/apache/calcite/rel/rules/materialize/MaterializedViewRule.java:834){noformat}
It has _something_ to do with trying to calling into `splitFilter` with an 
OR(SEARCH(x), IS_NULL(x)) and a IS_NOT_NULL(x), where x is an unknown type.

 

Here is my failed attempt to make a repro case (in Kotlin, again sorry):
{noformat}
@Test
fun testUnknownBadness() {
    val relBuilder = relBuilder()
    val unknownTypeFunc = object: SqlOperator("some_func", SqlKind.OTHER, 0, 
false, null, null, null) {
        override fun getSyntax(): SqlSyntax {
            return SqlSyntax.FUNCTION
        }

        override fun inferReturnType(opBinding: SqlOperatorBinding): 
RelDataType {
            return opBinding.typeFactory.createUnknownType()
        }
    }

    val boolFunc = object: SqlOperator("bool_func", SqlKind.OTHER, 0, false, 
ReturnTypes.BOOLEAN, null, null) {
        override fun getSyntax(): SqlSyntax {
            return SqlSyntax.FUNCTION
        }
    }
    relBuilder.values(listOf("age").toTypedArray(), 25)
    relBuilder.project(relBuilder.field("age"), 
relBuilder.call(unknownTypeFunc, relBuilder.field("age")))
    val ex = RexUtil.EXECUTOR
    val simpl = RexSimplify(relBuilder.rexBuilder, RelOptPredicateList.EMPTY, 
ex)
    SubstitutionVisitor.splitFilter(simpl,
        relBuilder.rexBuilder.makeCall(
            SqlStdOperatorTable.OR,
            relBuilder.call(SqlStdOperatorTable.IS_NULL, relBuilder.field(1)),
            relBuilder.call(boolFunc, relBuilder.field(1))
        ),
        relBuilder.call(SqlStdOperatorTable.IS_NOT_NULL, relBuilder.field(1)))
}
{noformat}
Chatting with [~julianhyde], we have the strong suspicion this relates to 
CALCITE-4446, though I can't say for sure because I'm unable to boil it down 
right now into something simple.

  was:
Apologies. After spending an hour or so trying to write a simple repro for this 
I was unable to, so filing a bug for now so I have something to reference on my 
end.

There is a condition in which this code explodes, here's the traceback:
{noformat}
Java::JavaLang::IllegalArgumentException: 
com.google.common.base.Preconditions.checkArgument(com/google/common/base/Preconditions.java:128)
 
org.apache.calcite.rex.RexLiteral.<init>(org/apache/calcite/rex/RexLiteral.java:221)
 
org.apache.calcite.rex.RexBuilder.makeLiteral(org/apache/calcite/rex/RexBuilder.java:982)
 
org.apache.calcite.rex.RexBuilder.makeSearchArgumentLiteral(org/apache/calcite/rex/RexBuilder.java:1077)
 
org.apache.calcite.rex.RexSimplify$SargCollector.fix(org/apache/calcite/rex/RexSimplify.java:2719)
 
org.apache.calcite.rex.RexSimplify.lambda$simplifyAnd$4(org/apache/calcite/rex/RexSimplify.java:1335)
 java.util.ArrayList.forEach(java/util/ArrayList.java:1257)
 
org.apache.calcite.rex.RexSimplify.simplifyAnd(org/apache/calcite/rex/RexSimplify.java:1335)
 
org.apache.calcite.rex.RexSimplify.simplify(org/apache/calcite/rex/RexSimplify.java:274)
 
org.apache.calcite.rex.RexSimplify.simplifyUnknownAs(org/apache/calcite/rex/RexSimplify.java:243)
 
org.apache.calcite.rex.RexSimplify.simplifyUnknownAsFalse(org/apache/calcite/rex/RexSimplify.java:232)
 
org.apache.calcite.plan.SubstitutionVisitor.splitFilter(org/apache/calcite/plan/SubstitutionVisitor.java:307)
 
org.apache.calcite.rel.rules.materialize.MaterializedViewRule.computeCompensationPredicates(org/apache/calcite/rel/rules/materialize/MaterializedViewRule.java:834){noformat}
It has _something_ to do with trying to calling into `splitFilter` with an 
OR(SEARCH\(x), IS_NULL\(x)) and a IS_NOT_NULL\(x), where x is an unknown type.

 

Here is my failed attempt to make a repro case (in Kotlin, again sorry):
{noformat}
@Test
fun testUnknownBadness() {
    val relBuilder = relBuilder()
    val unknownTypeFunc = object: SqlOperator("some_func", SqlKind.OTHER, 0, 
false, null, null, null) {
        override fun getSyntax(): SqlSyntax {
            return SqlSyntax.FUNCTION
        }

        override fun inferReturnType(opBinding: SqlOperatorBinding): 
RelDataType {
            return opBinding.typeFactory.createUnknownType()
        }
    }

    val boolFunc = object: SqlOperator("bool_func", SqlKind.OTHER, 0, false, 
ReturnTypes.BOOLEAN, null, null) {
        override fun getSyntax(): SqlSyntax {
            return SqlSyntax.FUNCTION
        }
    }
    relBuilder.values(listOf("age").toTypedArray(), 25)
    relBuilder.project(relBuilder.field("age"), 
relBuilder.call(unknownTypeFunc, relBuilder.field("age")))
    val ex = RexUtil.EXECUTOR
    val simpl = RexSimplify(relBuilder.rexBuilder, RelOptPredicateList.EMPTY, 
ex)
    SubstitutionVisitor.splitFilter(simpl,
        relBuilder.rexBuilder.makeCall(
            SqlStdOperatorTable.OR,
            relBuilder.call(SqlStdOperatorTable.IS_NULL, relBuilder.field(1)),
            relBuilder.call(boolFunc, relBuilder.field(1))
        ),
        relBuilder.call(SqlStdOperatorTable.IS_NOT_NULL, relBuilder.field(1)))
}
{noformat}
Chatting with [~julianhyde], we have the strong suspicion this relates to 
CALCITE-4446, though I can't say for sure because I'm unable to boil it down 
right now into something simple.


> Sarg simplification with IS_NULL and unknown type throws 
> IllegalArgumentException
> ---------------------------------------------------------------------------------
>
>                 Key: CALCITE-4495
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4495
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Steven Talbot
>            Priority: Major
>             Fix For: 1.27.0
>
>
> Apologies. After spending an hour or so trying to write a simple repro for 
> this I was unable to, so filing a bug for now so I have something to 
> reference on my end.
> There is a condition in which this code explodes, here's the traceback:
> {noformat}
> Java::JavaLang::IllegalArgumentException: 
> com.google.common.base.Preconditions.checkArgument(com/google/common/base/Preconditions.java:128)
>  
> org.apache.calcite.rex.RexLiteral.<init>(org/apache/calcite/rex/RexLiteral.java:221)
>  
> org.apache.calcite.rex.RexBuilder.makeLiteral(org/apache/calcite/rex/RexBuilder.java:982)
>  
> org.apache.calcite.rex.RexBuilder.makeSearchArgumentLiteral(org/apache/calcite/rex/RexBuilder.java:1077)
>  
> org.apache.calcite.rex.RexSimplify$SargCollector.fix(org/apache/calcite/rex/RexSimplify.java:2719)
>  
> org.apache.calcite.rex.RexSimplify.lambda$simplifyAnd$4(org/apache/calcite/rex/RexSimplify.java:1335)
>  java.util.ArrayList.forEach(java/util/ArrayList.java:1257)
>  
> org.apache.calcite.rex.RexSimplify.simplifyAnd(org/apache/calcite/rex/RexSimplify.java:1335)
>  
> org.apache.calcite.rex.RexSimplify.simplify(org/apache/calcite/rex/RexSimplify.java:274)
>  
> org.apache.calcite.rex.RexSimplify.simplifyUnknownAs(org/apache/calcite/rex/RexSimplify.java:243)
>  
> org.apache.calcite.rex.RexSimplify.simplifyUnknownAsFalse(org/apache/calcite/rex/RexSimplify.java:232)
>  
> org.apache.calcite.plan.SubstitutionVisitor.splitFilter(org/apache/calcite/plan/SubstitutionVisitor.java:307)
>  
> org.apache.calcite.rel.rules.materialize.MaterializedViewRule.computeCompensationPredicates(org/apache/calcite/rel/rules/materialize/MaterializedViewRule.java:834){noformat}
> It has _something_ to do with trying to calling into `splitFilter` with an 
> OR(SEARCH(x), IS_NULL(x)) and a IS_NOT_NULL(x), where x is an unknown type.
>  
> Here is my failed attempt to make a repro case (in Kotlin, again sorry):
> {noformat}
> @Test
> fun testUnknownBadness() {
>     val relBuilder = relBuilder()
>     val unknownTypeFunc = object: SqlOperator("some_func", SqlKind.OTHER, 0, 
> false, null, null, null) {
>         override fun getSyntax(): SqlSyntax {
>             return SqlSyntax.FUNCTION
>         }
>         override fun inferReturnType(opBinding: SqlOperatorBinding): 
> RelDataType {
>             return opBinding.typeFactory.createUnknownType()
>         }
>     }
>     val boolFunc = object: SqlOperator("bool_func", SqlKind.OTHER, 0, false, 
> ReturnTypes.BOOLEAN, null, null) {
>         override fun getSyntax(): SqlSyntax {
>             return SqlSyntax.FUNCTION
>         }
>     }
>     relBuilder.values(listOf("age").toTypedArray(), 25)
>     relBuilder.project(relBuilder.field("age"), 
> relBuilder.call(unknownTypeFunc, relBuilder.field("age")))
>     val ex = RexUtil.EXECUTOR
>     val simpl = RexSimplify(relBuilder.rexBuilder, RelOptPredicateList.EMPTY, 
> ex)
>     SubstitutionVisitor.splitFilter(simpl,
>         relBuilder.rexBuilder.makeCall(
>             SqlStdOperatorTable.OR,
>             relBuilder.call(SqlStdOperatorTable.IS_NULL, relBuilder.field(1)),
>             relBuilder.call(boolFunc, relBuilder.field(1))
>         ),
>         relBuilder.call(SqlStdOperatorTable.IS_NOT_NULL, relBuilder.field(1)))
> }
> {noformat}
> Chatting with [~julianhyde], we have the strong suspicion this relates to 
> CALCITE-4446, though I can't say for sure because I'm unable to boil it down 
> right now into something simple.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to