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

Krisztian Kasa updated HIVE-29506:
----------------------------------
    Description: 
Repro steps
{code}
set hive.support.concurrency=true;
set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;

-- To create a HiveValues operator before decorrelation automatic query rewrite 
with
-- materialized views is used.
-- All tables must be transactional to trigger automatic query rewrite.
create table mv_source (any_col int) stored as orc TBLPROPERTIES 
('transactional'='true');
create table t1 (a int, b int) stored as orc TBLPROPERTIES 
('transactional'='true');
create table t2 (a int, b int) stored as orc TBLPROPERTIES 
('transactional'='true');

-- At least one materialized view must exist.
create materialized view any_mv as
select any_col from mv_source where any_col > 20;

-- Automatic query rewrite traverses the plan and recreates the HiveFilter 
using RelBuilder.
-- If the condition is always false, it replaces the filter with HiveValues.
explain cbo
select * from t1 where 1 = 2
union
select * from t1
where exists (select a from t2 where t1.a > 10)
;
{code}
{code}
 java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1
        at 
java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
        at 
java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
        at 
java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
        at java.base/java.util.Objects.checkIndex(Objects.java:385)
        at java.base/java.util.ArrayList.get(ArrayList.java:427)
        at 
org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter$RexVisitor.visitInputRef(ASTConverter.java:846)
        at 
org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter$RexVisitor.visitInputRef(ASTConverter.java:801)
        at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:113)
        at 
org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter.addRefToBuilder(ASTConverter.java:415)
        at 
org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter.convert(ASTConverter.java:318)
        at 
org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter.convert(ASTConverter.java:136)
        at 
org.apache.hadoop.hive.ql.parse.CalcitePlanner.genOPTree(CalcitePlanner.java:610)
        at 
org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:13223)
        at 
org.apache.hadoop.hive.ql.parse.CalcitePlanner.analyzeInternal(CalcitePlanner.java:481)
        at 
org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:358)
        at 
org.apache.hadoop.hive.ql.parse.ExplainSemanticAnalyzer.analyzeInternal(ExplainSemanticAnalyzer.java:187)
        at 
org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:358)
        at org.apache.hadoop.hive.ql.Compiler.analyze(Compiler.java:224)
        at org.apache.hadoop.hive.ql.Compiler.compile(Compiler.java:109)
        at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:503)
        at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:455)
        at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:419)
        at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:413)
        at 
org.apache.hadoop.hive.ql.reexec.ReExecDriver.compileAndRespond(ReExecDriver.java:126)
        at 
org.apache.hadoop.hive.ql.reexec.ReExecDriver.run(ReExecDriver.java:234)
        at 
org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:259)
        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:430)
        at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:358)
        at 
org.apache.hadoop.hive.ql.QTestUtil.executeClientInternal(QTestUtil.java:760)
        at org.apache.hadoop.hive.ql.QTestUtil.executeClient(QTestUtil.java:730)
        at 
org.apache.hadoop.hive.cli.control.CoreCliDriver.runTest(CoreCliDriver.java:115)
        at 
org.apache.hadoop.hive.cli.control.CliAdapter.runTest(CliAdapter.java:139)
        at 
org.apache.hadoop.hive.cli.TestMiniLlapLocalCliDriver.testCliDriver(TestMiniLlapLocalCliDriver.java:62)
        at 
java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        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:118)
        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:89)
        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:316)
        at 
org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:240)
        at 
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:214)
        at 
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:155)
        at 
org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
        at 
org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
        at 
org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
        at 
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
{code}


  was:
Repro steps
{code}
set hive.support.concurrency=true;
set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;

-- To create a HiveValues operator before decorrelation automatic query rewrite 
with
-- materialized views is used.
-- All tables must be transactional to trigger automatic query rewrite.
create table mv_source (any_col int) stored as orc TBLPROPERTIES 
('transactional'='true');
create table t1 (a int, b int) stored as orc TBLPROPERTIES 
('transactional'='true');
create table t2 (a int, b int) stored as orc TBLPROPERTIES 
('transactional'='true');

-- At least one materialized view must exist.
create materialized view any_mv as
select any_col from mv_source where any_col > 20;

-- Automatic query rewrite traverses the plan and recreates the HiveFilter 
using RelBuilder.
-- If the condition is always false, it replaces the filter with HiveValues.
explain cbo
select * from t1 where 1 = 2
union
select * from t1
where exists (select a from t2 where t1.a > 10)
;
{code}


> HiveRelDecorrelator fails to decorrelate plan with Values operator
> ------------------------------------------------------------------
>
>                 Key: HIVE-29506
>                 URL: https://issues.apache.org/jira/browse/HIVE-29506
>             Project: Hive
>          Issue Type: Bug
>          Components: CBO
>            Reporter: Krisztian Kasa
>            Priority: Major
>              Labels: pull-request-available
>
> Repro steps
> {code}
> set hive.support.concurrency=true;
> set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
> -- To create a HiveValues operator before decorrelation automatic query 
> rewrite with
> -- materialized views is used.
> -- All tables must be transactional to trigger automatic query rewrite.
> create table mv_source (any_col int) stored as orc TBLPROPERTIES 
> ('transactional'='true');
> create table t1 (a int, b int) stored as orc TBLPROPERTIES 
> ('transactional'='true');
> create table t2 (a int, b int) stored as orc TBLPROPERTIES 
> ('transactional'='true');
> -- At least one materialized view must exist.
> create materialized view any_mv as
> select any_col from mv_source where any_col > 20;
> -- Automatic query rewrite traverses the plan and recreates the HiveFilter 
> using RelBuilder.
> -- If the condition is always false, it replaces the filter with HiveValues.
> explain cbo
> select * from t1 where 1 = 2
> union
> select * from t1
> where exists (select a from t2 where t1.a > 10)
> ;
> {code}
> {code}
>  java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1
>       at 
> java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
>       at 
> java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
>       at 
> java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
>       at java.base/java.util.Objects.checkIndex(Objects.java:385)
>       at java.base/java.util.ArrayList.get(ArrayList.java:427)
>       at 
> org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter$RexVisitor.visitInputRef(ASTConverter.java:846)
>       at 
> org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter$RexVisitor.visitInputRef(ASTConverter.java:801)
>       at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:113)
>       at 
> org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter.addRefToBuilder(ASTConverter.java:415)
>       at 
> org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter.convert(ASTConverter.java:318)
>       at 
> org.apache.hadoop.hive.ql.optimizer.calcite.translator.ASTConverter.convert(ASTConverter.java:136)
>       at 
> org.apache.hadoop.hive.ql.parse.CalcitePlanner.genOPTree(CalcitePlanner.java:610)
>       at 
> org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:13223)
>       at 
> org.apache.hadoop.hive.ql.parse.CalcitePlanner.analyzeInternal(CalcitePlanner.java:481)
>       at 
> org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:358)
>       at 
> org.apache.hadoop.hive.ql.parse.ExplainSemanticAnalyzer.analyzeInternal(ExplainSemanticAnalyzer.java:187)
>       at 
> org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:358)
>       at org.apache.hadoop.hive.ql.Compiler.analyze(Compiler.java:224)
>       at org.apache.hadoop.hive.ql.Compiler.compile(Compiler.java:109)
>       at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:503)
>       at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:455)
>       at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:419)
>       at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:413)
>       at 
> org.apache.hadoop.hive.ql.reexec.ReExecDriver.compileAndRespond(ReExecDriver.java:126)
>       at 
> org.apache.hadoop.hive.ql.reexec.ReExecDriver.run(ReExecDriver.java:234)
>       at 
> org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:259)
>       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:430)
>       at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:358)
>       at 
> org.apache.hadoop.hive.ql.QTestUtil.executeClientInternal(QTestUtil.java:760)
>       at org.apache.hadoop.hive.ql.QTestUtil.executeClient(QTestUtil.java:730)
>       at 
> org.apache.hadoop.hive.cli.control.CoreCliDriver.runTest(CoreCliDriver.java:115)
>       at 
> org.apache.hadoop.hive.cli.control.CliAdapter.runTest(CliAdapter.java:139)
>       at 
> org.apache.hadoop.hive.cli.TestMiniLlapLocalCliDriver.testCliDriver(TestMiniLlapLocalCliDriver.java:62)
>       at 
> java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
>       at java.base/java.lang.reflect.Method.invoke(Method.java:580)
>       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:118)
>       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:89)
>       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:316)
>       at 
> org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:240)
>       at 
> org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:214)
>       at 
> org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:155)
>       at 
> org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:385)
>       at 
> org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:162)
>       at 
> org.apache.maven.surefire.booter.ForkedBooter.run(ForkedBooter.java:507)
>       at 
> org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:495)
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to