[ 
https://issues.apache.org/jira/browse/HIVE-24763?focusedWorklogId=550618&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-550618
 ]

ASF GitHub Bot logged work on HIVE-24763:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Feb/21 08:00
            Start Date: 10/Feb/21 08:00
    Worklog Time Spent: 10m 
      Work Description: kasakrisz opened a new pull request #1966:
URL: https://github.com/apache/hive/pull/1966


   ### What changes were proposed in this pull request?
   During incremental materialized view rebuild CBO plain is transformed from 
an insert over write plan to a merge into plan if MV definition contains 
aggregate. During this transformation the union operator is replaced with a 
right outer join of the union branches and the join keys are coming from the 
aggregate keys. When building the join expressions the key equality checks are 
concatenated by `AND` operators. Building of `AND` expressions are throws 
AssertionError when only one operand/aggregate key/join key exists.
   
   ### Why are the changes needed?
   Check the number of expressions before creating the `AND` expression and 
return use expression itself as the root of the join expression if only one 
expression exists.
   
   ### Does this PR introduce _any_ user-facing change?
   No.
   
   ### How was this patch tested?
   ```
   mvn test -Dtest.output.overwrite -DskipSparkTests 
-Dtest=TestMiniLlapLocalCliDriver 
-Dqfile=materialized_view_create_rewrite_one_key_gby.q,materialized_view_create_rewrite_4.q
 -pl itests/qtest -Pitests
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

            Worklog Id:     (was: 550618)
    Remaining Estimate: 0h
            Time Spent: 10m

> Incremental rebuild of Materialized view fails
> ----------------------------------------------
>
>                 Key: HIVE-24763
>                 URL: https://issues.apache.org/jira/browse/HIVE-24763
>             Project: Hive
>          Issue Type: Bug
>          Components: Materialized views
>            Reporter: Krisztian Kasa
>            Assignee: Krisztian Kasa
>            Priority: Major
>         Attachments: repro.q
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> AssertionError is thrown when Materialized view definition contains aggregate 
> operator with only one key:
> {code}
> CREATE MATERIALIZED VIEW cmv_mat_view_n5 TBLPROPERTIES 
> ('transactional'='true') AS
>   SELECT cmv_basetable_n5.a, sum(cmv_basetable_2_n2.d)
>   FROM cmv_basetable_n5 JOIN cmv_basetable_2_n2 ON (cmv_basetable_n5.a = 
> cmv_basetable_2_n2.a)
>   WHERE cmv_basetable_2_n2.c > 10.0
>   GROUP BY cmv_basetable_n5.a;
> ...
> ALTER MATERIALIZED VIEW cmv_mat_view_n5 REBUILD;
> {code}
> {code}
> java.lang.AssertionError: wrong operand count 1 for AND
>       at org.apache.calcite.util.Litmus$1.fail(Litmus.java:31)
>       at 
> org.apache.calcite.sql.SqlBinaryOperator.validRexOperands(SqlBinaryOperator.java:219)
>       at org.apache.calcite.rex.RexCall.<init>(RexCall.java:86)
>       at org.apache.calcite.rex.RexBuilder.makeCall(RexBuilder.java:251)
>       at 
> org.apache.hadoop.hive.ql.optimizer.calcite.rules.views.HiveAggregateIncrementalRewritingRule.onMatch(HiveAggregateIncrementalRewritingRule.java:124)
>       at 
> org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:319)
>       at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:560)
>       at 
> org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:419)
>       at 
> org.apache.calcite.plan.hep.HepPlanner.executeInstruction(HepPlanner.java:256)
>       at 
> org.apache.calcite.plan.hep.HepInstruction$RuleInstance.execute(HepInstruction.java:127)
>       at 
> org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:215)
>       at 
> org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:202)
>       at 
> org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.executeProgram(CalcitePlanner.java:2715)
>       at 
> org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.executeProgram(CalcitePlanner.java:2681)
>       at 
> org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.applyMaterializedViewRewriting(CalcitePlanner.java:2318)
>       at 
> org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.apply(CalcitePlanner.java:1934)
>       at 
> org.apache.hadoop.hive.ql.parse.CalcitePlanner$CalcitePlannerAction.apply(CalcitePlanner.java:1810)
>       at 
> org.apache.calcite.tools.Frameworks.lambda$withPlanner$0(Frameworks.java:130)
>       at 
> org.apache.calcite.prepare.CalcitePrepareImpl.perform(CalcitePrepareImpl.java:915)
>       at org.apache.calcite.tools.Frameworks.withPrepare(Frameworks.java:179)
>       at org.apache.calcite.tools.Frameworks.withPlanner(Frameworks.java:125)
>       at 
> org.apache.hadoop.hive.ql.parse.CalcitePlanner.logicalPlan(CalcitePlanner.java:1571)
>       at 
> org.apache.hadoop.hive.ql.parse.CalcitePlanner.genOPTree(CalcitePlanner.java:562)
>       at 
> org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:12538)
>       at 
> org.apache.hadoop.hive.ql.parse.CalcitePlanner.analyzeInternal(CalcitePlanner.java:456)
>       at 
> org.apache.hadoop.hive.ql.ddl.view.materialized.alter.rebuild.AlterMaterializedViewRebuildAnalyzer.analyzeInternal(AlterMaterializedViewRebuildAnalyzer.java:89)
>       at 
> org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:315)
>       at 
> org.apache.hadoop.hive.ql.parse.ExplainSemanticAnalyzer.analyzeInternal(ExplainSemanticAnalyzer.java:171)
>       at 
> org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:315)
>       at org.apache.hadoop.hive.ql.Compiler.analyze(Compiler.java:223)
>       at org.apache.hadoop.hive.ql.Compiler.compile(Compiler.java:104)
>       at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:492)
>       at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:445)
>       at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:409)
>       at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:403)
>       at 
> org.apache.hadoop.hive.ql.reexec.ReExecDriver.compileAndRespond(ReExecDriver.java:125)
>       at 
> org.apache.hadoop.hive.ql.reexec.ReExecDriver.run(ReExecDriver.java:229)
>       at 
> org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:258)
>       at org.apache.hadoop.hive.cli.CliDriver.processCmd1(CliDriver.java:203)
>       at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:129)
>       at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:424)
>       at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:355)
>       at 
> org.apache.hadoop.hive.ql.QTestUtil.executeClientInternal(QTestUtil.java:744)
>       at org.apache.hadoop.hive.ql.QTestUtil.executeClient(QTestUtil.java:714)
>       at 
> org.apache.hadoop.hive.cli.control.CoreCliDriver.runTest(CoreCliDriver.java:170)
>       at 
> org.apache.hadoop.hive.cli.control.CliAdapter.runTest(CliAdapter.java:157)
>       at 
> org.apache.hadoop.hive.cli.TestMiniLlapLocalCliDriver.testCliDriver(TestMiniLlapLocalCliDriver.java:62)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:498)
>       at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
>       at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>       at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
>       at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>       at 
> org.apache.hadoop.hive.cli.control.CliAdapter$2$1.evaluate(CliAdapter.java:135)
>       at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
>       at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
>       at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
>       at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
>       at org.junit.runners.Suite.runChild(Suite.java:128)
>       at org.junit.runners.Suite.runChild(Suite.java:27)
>       at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
>       at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
>       at 
> org.apache.hadoop.hive.cli.control.CliAdapter$1$1.evaluate(CliAdapter.java:95)
>       at org.junit.rules.RunRules.evaluate(RunRules.java:20)
>       at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
>       at 
> org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
>       at 
> org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:273)
>       at 
> org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
>       at 
> org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
>       at 
> org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:377)
>       at 
> org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:138)
>       at 
> org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:465)
>       at 
> org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:451)
> {code}
> See attached *repro.q* for full details of reproducing the issue.



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

Reply via email to