Mihai Budiu created CALCITE-6286:
------------------------------------
Summary: Optimizing ARRAY_INSERT expression causes an assertion
failure
Key: CALCITE-6286
URL: https://issues.apache.org/jira/browse/CALCITE-6286
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.36.0
Reporter: Mihai Budiu
The following RelOptRulesTest causes an assertion failure:
{code:java}
@Test void testArrayRepeat() {
sql("SELECT array_repeat(123, null)")
.withFactory(
t -> t.withOperatorTable(
opTab ->
SqlLibraryOperatorTableFactory.INSTANCE.getOperatorTable(
SqlLibrary.STANDARD, SqlLibrary.SPARK)))
.withRule(CoreRules.PROJECT_REDUCE_EXPRESSIONS).checkUnchanged();
}
{code}
The assertion failure is:
{code}
java.lang.AssertionError: Cannot add expression of different type to set:
set type is RecordType(INTEGER NOT NULL ARRAY NOT NULL EXPR$0) NOT NULL
expression type is RecordType(INTEGER NOT NULL ARRAY EXPR$0) NOT NULL
set is rel#4:LogicalProject.(input=HepRelVertex#3,exprs=[ARRAY_REPEAT(123,
null:DECIMAL(19, 9))])
expression is LogicalProject(EXPR$0=[null:INTEGER NOT NULL ARRAY])
LogicalValues(tuples=[[{ 0 }]])
Type mismatch:
rowtype of original rel: RecordType(INTEGER NOT NULL ARRAY NOT NULL EXPR$0) NOT
NULL
rowtype of new rel: RecordType(INTEGER NOT NULL ARRAY EXPR$0) NOT NULL
Difference:
EXPR$0: INTEGER NOT NULL ARRAY NOT NULL -> INTEGER NOT NULL ARRAY
at
org.apache.calcite.plan.RelOptUtil.verifyTypeEquivalence(RelOptUtil.java:419)
at
org.apache.calcite.plan.hep.HepRuleCall.transformTo(HepRuleCall.java:60)
at
org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:273)
at
org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:288)
at
org.apache.calcite.rel.rules.ReduceExpressionsRule$ProjectReduceExpressionsRule.onMatch(ReduceExpressionsRule.java:317)
at
org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:337)
{code}
This suggests that the type inferred for ARRAY_INSERT is incorrect.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)