[ https://issues.apache.org/jira/browse/CALCITE-2946?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16799453#comment-16799453 ]
Jesus Camacho Rodriguez commented on CALCITE-2946: -------------------------------------------------- This is very similar to CALCITE-2192. An Aggregate may not be created if expression is known to produce one row at most: https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/tools/RelBuilder.java#L1434 However, the Aggregate may prune columns in the expression. Fix is similar, a Project should be created. I still need to find a simple repro for Calcite. > Calcite assertion error when UDF returns null > --------------------------------------------- > > Key: CALCITE-2946 > URL: https://issues.apache.org/jira/browse/CALCITE-2946 > Project: Calcite > Issue Type: Bug > Components: core > Reporter: Prasanth Jayachandran > Assignee: Jesus Camacho Rodriguez > Priority: Major > > Calcite throws the following error when UDFs return null. > "current_authorizer()" for example can return null if authorizer is disabled. > {code:java} > org.apache.hive.service.cli.HiveSQLException: Error running query: > java.lang.AssertionError: Cannot add expression of different type to set: > set type is RecordType(CHAR(7) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" NOT NULL $f0, VARCHAR(2147483647) CHARACTER SET > "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f1, VARCHAR(2147483647) > CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f2, > VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" $f3, VARCHAR(2147483647) CHARACTER SET "UTF-16LE" > COLLATE "ISO-8859-1$en_US$primary" $f4, VARCHAR(2147483647) CHARACTER SET > "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f5, VARCHAR(2147483647) > CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f6, > VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" $f7, VARCHAR(2147483647) CHARACTER SET "UTF-16LE" > COLLATE "ISO-8859-1$en_US$primary" $f8, VARCHAR(2147483647) CHARACTER SET > "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f9, CHAR(2) CHARACTER SET > "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" NOT NULL $f10, > VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" $f11) NOT NULL > expression type is RecordType(CHAR(7) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" NOT NULL $f0, CHAR(7) CHARACTER SET "UTF-16LE" > COLLATE "ISO-8859-1$en_US$primary" NOT NULL $f1, VARCHAR(2147483647) > CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f2, > VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" $f3, VARCHAR(2147483647) CHARACTER SET "UTF-16LE" > COLLATE "ISO-8859-1$en_US$primary" $f4, VARCHAR(2147483647) CHARACTER SET > "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f5, VARCHAR(2147483647) > CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f6, > VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" $f7, VARCHAR(2147483647) CHARACTER SET "UTF-16LE" > COLLATE "ISO-8859-1$en_US$primary" $f8, VARCHAR(2147483647) CHARACTER SET > "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f9, CHAR(2) CHARACTER SET > "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" NOT NULL $f10, > VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" $f11) NOT NULL > set is rel#784:HiveAggregate.HIVE.[](input=HepRelVertex#783,group={0, 1, 2, > 3, 4, 5, 6, 7, 8, 9, 10, 11}) > expression is HiveProject#829 > at > org.apache.hive.service.cli.operation.SQLOperation.prepare(SQLOperation.java:210) > at > org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork$1.run(SQLOperation.java:322) > at java.security.AccessController.doPrivileged(Native Method) > at javax.security.auth.Subject.doAs(Subject.java:422) > at > org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1730) > at > org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork.run(SQLOperation.java:342) > at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) > at java.lang.Thread.run(Thread.java:748) > Caused by: java.lang.AssertionError: Cannot add expression of different type > to set: > set type is RecordType(CHAR(7) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" NOT NULL $f0, VARCHAR(2147483647) CHARACTER SET > "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f1, VARCHAR(2147483647) > CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f2, > VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" $f3, VARCHAR(2147483647) CHARACTER SET "UTF-16LE" > COLLATE "ISO-8859-1$en_US$primary" $f4, VARCHAR(2147483647) CHARACTER SET > "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f5, VARCHAR(2147483647) > CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f6, > VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" $f7, VARCHAR(2147483647) CHARACTER SET "UTF-16LE" > COLLATE "ISO-8859-1$en_US$primary" $f8, VARCHAR(2147483647) CHARACTER SET > "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f9, CHAR(2) CHARACTER SET > "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" NOT NULL $f10, > VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" $f11) NOT NULL > expression type is RecordType(CHAR(7) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" NOT NULL $f0, CHAR(7) CHARACTER SET "UTF-16LE" > COLLATE "ISO-8859-1$en_US$primary" NOT NULL $f1, VARCHAR(2147483647) > CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f2, > VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" $f3, VARCHAR(2147483647) CHARACTER SET "UTF-16LE" > COLLATE "ISO-8859-1$en_US$primary" $f4, VARCHAR(2147483647) CHARACTER SET > "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f5, VARCHAR(2147483647) > CHARACTER SET "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f6, > VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" $f7, VARCHAR(2147483647) CHARACTER SET "UTF-16LE" > COLLATE "ISO-8859-1$en_US$primary" $f8, VARCHAR(2147483647) CHARACTER SET > "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" $f9, CHAR(2) CHARACTER SET > "UTF-16LE" COLLATE "ISO-8859-1$en_US$primary" NOT NULL $f10, > VARCHAR(2147483647) CHARACTER SET "UTF-16LE" COLLATE > "ISO-8859-1$en_US$primary" $f11) NOT NULL > set is rel#784:HiveAggregate.HIVE.[](input=HepRelVertex#783,group={0, 1, 2, > 3, 4, 5, 6, 7, 8, 9, 10, 11}) > expression is HiveProject#829 > at > org.apache.calcite.plan.RelOptUtil.verifyTypeEquivalence(RelOptUtil.java:411) > at org.apache.calcite.plan.hep.HepRuleCall.transformTo(HepRuleCall.java:57) > at org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:234) > at > org.apache.calcite.rel.rules.AggregateProjectPullUpConstantsRule.onMatch(AggregateProjectPullUpConstantsRule.java:189) > at > org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:321) > at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:561) > at org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:420) > at > org.apache.calcite.plan.hep.HepPlanner.executeInstruction(HepPlanner.java:285) > at > org.apache.calcite.plan.hep.HepInstruction$RuleCollection.execute(HepInstruction.java:74) > at org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:216) > at org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:203) > at > org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.hepPlan(CalcitePlanner.java:2383) > at > org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.applyPreJoinOrderingTransforms(CalcitePlanner.java:2108) > at > org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.apply(CalcitePlanner.java:1793) > at > org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.apply(CalcitePlanner.java:1689) > at org.apache.calcite.tools.Frameworks$1.apply(Frameworks.java:118) > at > org.apache.calcite.prepare.CalcitePrepareImpl.perform(CalcitePrepareImpl.java:1052) > at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:154) > at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:111) > at > org.apache.hadoop.hive.ql.parse.CalcitePlanner.logicalPlan(CalcitePlanner.java:1450) > at > org.apache.hadoop.hive.ql.parse.CalcitePlanner.genOPTree(CalcitePlanner.java:482) > at > org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:12316) > at > org.apache.hadoop.hive.ql.parse.CalcitePlanner.analyzeInternal(CalcitePlanner.java:362) > at > org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:289) > at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:666) > at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1881) > at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:1828) > at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:1823) > at > org.apache.hadoop.hive.ql.reexec.ReExecDriver.compileAndRespond(ReExecDriver.java:126) > at > org.apache.hive.service.cli.operation.SQLOperation.prepare(SQLOperation.java:197) > ... 12 more{code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)