Issue discovered with Calcite master

2019-11-06 Thread Amit Chavan
Hello,

I have created a bug  https://issues.apache.org/jira/browse/CALCITE-3479 and
attached UT to reproduce this bug. This is in the current master.

Thanks,
Amit


[jira] [Created] (CALCITE-3479) Stack overflow error thrown when running join query

2019-11-06 Thread Amit Chavan (Jira)
Amit Chavan created CALCITE-3479:


 Summary: Stack overflow error thrown when running join query
 Key: CALCITE-3479
 URL: https://issues.apache.org/jira/browse/CALCITE-3479
 Project: Calcite
  Issue Type: Bug
Reporter: Amit Chavan


A unit test in our project is failing which is as below.

The query in question is 

"SELECT * FROM tblspace1.t1 t10, tblspace1.t2 t20 WHERE t20.n1 = 3 AND t10.n1 = 
3 AND t20.n1 = t10.n1"

I get a stack overflow error- 

-- Mid Plan-- Mid PlanLogicalProject(subset=[rel#19:Subset#4.ENUMERABLE.[]], 
k1=[$0], n1=[$1], s1=[$2], k2=[$3], n10=[$4], s2=[$5])  
LogicalFilter(subset=[rel#16:Subset#3.NONE.[]], condition=[AND(=($4, 3), =($1, 
3), =($4, $1))])    LogicalJoin(subset=[rel#14:Subset#2.NONE.[]], 
condition=[true], joinType=[inner])      
EnumerableTableScan(subset=[rel#11:Subset#0.ENUMERABLE.[]], table=[[tblspace1, 
t1]])      EnumerableTableScan(subset=[rel#12:Subset#1.ENUMERABLE.[]], 
table=[[tblspace1, t2]])

java.lang.StackOverflowError at 
org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:639)
 at 
org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:643)
 at 
org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:643)
 at 
org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:643)
 at 
org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:643)
 at 
org.apache.calcite.plan.volcano.RelSubset$CheapestPlanReplacer.visit(RelSubset.java:643)

 

Also attaching the UT code in the ticket



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


Re: Re: [ANNOUNCE] Danny Chan joins Calcite PMC

2019-10-30 Thread Amit Chavan
Congratulations, Danny !!

On Wed, Oct 30, 2019 at 3:14 PM Rui Wang  wrote:

> Congratulations! Well deserved!
>
>
> -Rui
>
> On Wed, Oct 30, 2019 at 3:04 PM Haisheng Yuan 
> wrote:
>
> > Congrats, Danny!
> >
> > - Haisheng
> >
> > --
> > 发件人:Peter Huang
> > 日 期:2019年10月31日 05:55:17
> > 收件人:
> > 主 题:Re: [ANNOUNCE] Danny Chan joins Calcite PMC
> >
> > Congratulations Danny!
> >
> > On Wed, Oct 30, 2019 at 2:22 PM Francis Chuang  >
> > wrote:
> >
> > > I'm pleased to announce that Danny has accepted an invitation to
> > > join the Calcite PMC. Danny has been a consistent and helpful
> > > figure in the Calcite community for which we are very grateful. We
> > > look forward to the continued contributions and support.
> > >
> > > Please join me in congratulating Danny!
> > >
> > > - Francis (on behalf of the Calcite PMC)
> > >
> >
> >
>


Re: Snapshot jars

2019-10-30 Thread Amit Chavan
 I see the job succeeded and snapshots are now being published.
Thanks for a quick turnaround on this Kevin.

On Wed, Oct 30, 2019 at 11:23 AM Kevin Risden  wrote:

> Latest https://builds.apache.org/job/Calcite-Promotion/ run succeeded now
> and looks like
>
> https://repository.apache.org/content/repositories/snapshots/org/apache/calcite/
> has
> been updated for current modules.
>
> Kevin Risden
>
>
> On Wed, Oct 30, 2019 at 2:09 PM Kevin Risden  wrote:
>
> > Looked at the config for the job, looks like the Calcite-Master build
> uses
> > Maven (latest). Updated the Calcite-Promotion job to match and removed
> the
> > outdated JDK 7 description.
> >
> > Kicked off a rebuild last after the config change and it is making
> > progress:
> >
> > https://builds.apache.org/job/Calcite-Promotion/378/
> >
> > Kevin Risden
> >
> >
> > On Wed, Oct 30, 2019 at 2:04 PM Kevin Risden  wrote:
> >
> >> In theory https://builds.apache.org/job/Calcite-Promotion/ should be
> >> based on the description of the job "Promotes SNAPSHOT builds of Calcite
> >> to the ASF Nexus."
> >>
> >> It looks like it has been broken for a long time (last success was July
> >> 2019)?
> >>
> >> Kevin Risden
> >>
> >>
> >> On Wed, Oct 30, 2019 at 1:49 PM Amit Chavan  wrote:
> >>
> >>> Hello,
> >>>
> >>> I was wondering if the snapshot jars are being pushed to
> >>> https://repository.apache.org/content/repositories/snapshots
> >>> <
> >>>
> https://repository.apache.org/content/repositories/snapshots/org/apache/calcite/
> >>> >.
> >>> The reason I am asking is we are building herddb with the latest
> Calcite
> >>> master and want to test it against the snapshot builds of calcite so we
> >>> know bug fixes that are being put in place for Calcite are working.
> >>>
> >>> Thanks,
> >>> Amit
> >>>
> >>
>


Snapshot jars

2019-10-30 Thread Amit Chavan
Hello,

I was wondering if the snapshot jars are being pushed to
https://repository.apache.org/content/repositories/snapshots
.
The reason I am asking is we are building herddb with the latest Calcite
master and want to test it against the snapshot builds of calcite so we
know bug fixes that are being put in place for Calcite are working.

Thanks,
Amit


Re: [ANNOUNCE] New committer: Muhammad Gelbana

2019-09-17 Thread Amit Chavan
Congratulations, Muhammad !!

On Tue, Sep 17, 2019 at 8:10 PM XING JIN  wrote:

> Congrats, Muhammad !
>
> 王炎林 <1989yanlinw...@163.com> 于2019年9月18日周三 上午10:38写道:
>
> > Congratulations, Muhammad!
> >
> >
> > Best,
> > Yanlin
> >
> >
> >
> >
> >
> >
> > At 2019-09-18 05:58:53, "Francis Chuang" 
> wrote:
> > >Apache Calcite's Project Management Committee (PMC) has invited Muhammad
> > >Gelbana to become a committer, and we are pleased to announce that he
> > >has accepted.
> > >
> > >Muhammad is an active contributor and has contributed numerous patches
> > >to Calcite. He has also been extremely active on the mailing list,
> > >helping out new users and participating in design discussions.
> > >
> > >Muhammad, welcome, thank you for your contributions, and we look forward
> > >your further interactions with the community! If you wish, please feel
> > >free to tell us more about yourself and what you are working on.
> > >
> > >Francis (on behalf of the Apache Calcite PMC)
> >
>


Re: Re: [ANNOUNCE] New committer: Julian Feinauer

2019-09-17 Thread Amit Chavan
Congrats, Julian !!

On Tue, Sep 17, 2019 at 8:12 PM XING JIN  wrote:

> Congrats, Julian !
> You are well deserved ~
>
> Haisheng Yuan  于2019年9月18日周三 上午10:38写道:
>
> > Congrats, Julian!
> >
> > - Haisheng
> >
> > --
> > 发件人:Chunwei Lei
> > 日 期:2019年09月18日 10:30:31
> > 收件人:
> > 主 题:Re: [ANNOUNCE] New committer: Julian Feinauer
> >
> > Congratulations, Julian!
> >
> >
> >
> > Best,
> > Chunwei
> >
> >
> > On Wed, Sep 18, 2019 at 9:24 AM Danny Chan  wrote:
> >
> > > Congratulations, Muhammad ! Welcome to join us ! Thanks for your huge
> > > contribution for the Match Recognize.
> > >
> > > Best,
> > > Danny Chan
> > > 在 2019年9月18日 +0800 AM5:55,Francis Chuang  >,写道:
> > > > Apache Calcite's Project Management Committee (PMC) has invited
> Julian
> > > > Feinauer to become a committer, and we are pleased to announce that
> he
> > > > has accepted.
> > > >
> > > > Julian is an active contributor to the Calcite code base and has been
> > > > active on the mailing list answering questions, participating in
> > > > discussions and voting for releases.
> > > >
> > > > Julian, welcome, thank you for your contributions, and we look
> forward
> > > > your further interactions with the community! If you wish, please
> feel
> > > > free to tell us more about yourself and what you are working on.
> > > >
> > > > Francis (on behalf of the Apache Calcite PMC)
> > >
> >
> >
>


Re: Potential bug in calcite 1.21

2019-09-14 Thread Amit Chavan
Hi Francis,

I created ticket https://issues.apache.org/jira/browse/CALCITE-3347
Let me know if you need additional details. I have also attached the UT in
the ticket to reproduce the issue.

-Amit

On Sat, Sep 14, 2019 at 4:57 PM Francis Chuang 
wrote:

> Hey Amit,
>
> Can you please open a ticket on Jira (issues.apache.org) and select
> Calcite as the project?
>
> Francis
>
> On 15/09/2019 8:54 am, Amit Chavan wrote:
> > Hello,
> >
> > I am reporting a bug that happens in calcite 1.21 release. I have a
> > query as below
> > String query = "SELECT * FROM tblspace1.tsql where n1=? and k1 in
> > (SELECT k1 FROM tblspace1.tsql where n1=?)";
> >
> > I am also attaching the unit test to reproduce this issue.  Should I
> > open a ticket as well?
> >
> > The filterJoinRule throws an exception --
> > java.lang.RuntimeException: Error while applying rule
> > FilterJoinRule:FilterJoinRule:filter, args
> >
> [rel#39:EnumerableFilter.ENUMERABLE.[](input=RelSubset#38,condition==($1,
> ?0)),
> >
> rel#176:EnumerableHashJoin.ENUMERABLE.[](left=RelSubset#17,right=RelSubset#73,condition==($0,
>
> > $3),joinType=semi)]
> > at
> >
> org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:235)
> > at
> >
> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:631)
> > at org.apache.calcite.TestCalcite.testQuery(TestCalcite.java:199)
> > at org.apache.calcite.TestCalcite.problem_with_1_21(TestCalcite.java:256)
> > 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:497)
> > at
> >
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> > at
> >
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> > at
> >
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> > at
> >
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> > at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> > at
> >
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> > at
> >
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> > at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
> > at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
> > at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
> > at
> >
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
> > at
> >
> com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
> > at
> >
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
> > at
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
> > Caused by: java.lang.IndexOutOfBoundsException: index (3) must be less
> > than size (3)
> > at
> >
> com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:310)
> > at
> >
> com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:293)
> > at
> >
> com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:67)
> > at
> >
> com.google.common.collect.Lists$TransformingRandomAccessList.get(Lists.java:627)
> > at
> >
> org.apache.calcite.rex.RexUtil$FixNullabilityShuttle.visitInputRef(RexUtil.java:2529)
> > at
> >
> org.apache.calcite.rex.RexUtil$FixNullabilityShuttle.visitInputRef(RexUtil.java:2518)
> > at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:112)
> > at org.apache.calcite.rex.RexShuttle.visitList(RexShuttle.java:149)
> > at org.apache.calcite.rex.RexShuttle.visitCall(RexShuttle.java:101)
> > at org.apache.calcite.rex.RexShuttle.visitCall(RexShuttle.java:34)
> > at org.apache.calcite.rex.RexCall.accept(RexCall.java:191)
> > at org.apache.calcite.rex.RexShuttle.apply(RexShuttle.java:277)
> > at org.apache.calcite.rex.RexShuttle.mutate(RexShuttle.java:239)
> > at org.apache.calcite.rex.RexShuttle.apply(RexShuttle.java:257)
> > at org.apache.calcite.rex.RexUtil.fixUp(RexUtil.java:1635)
> > at
> >
> org.apache.calcite.rel.rules.FilterJoinRule.perform(FilterJoinRule.java:284)
> > at
> >
> org.apache.calcite.rel.rules.FilterJoinRule$FilterIntoJoinRule.onMatch(FilterJoinRule.java:383)
> > at
> >
> org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:208)
> > ... 25 more
> >
> >
> >
>


[jira] [Created] (CALCITE-3347) FilterJoinRule throws exception in calcite 1.21. More details in description

2019-09-14 Thread Amit Chavan (Jira)
Amit Chavan created CALCITE-3347:


 Summary: FilterJoinRule throws exception in calcite 1.21. More 
details in description
 Key: CALCITE-3347
 URL: https://issues.apache.org/jira/browse/CALCITE-3347
 Project: Calcite
  Issue Type: Bug
Reporter: Amit Chavan
 Fix For: 1.21.0


I am reporting a bug that happens in calcite 1.21 release. I have a query as 
below 
String query = "SELECT * FROM tblspace1.tsql where n1=? and k1 in (SELECT k1 
FROM tblspace1.tsql where n1=?)";
 
I am also attaching the unit test to reproduce this issue.  Should I open a 
ticket as well? 
 
The filterJoinRule throws an exception --
java.lang.RuntimeException: Error while applying rule 
FilterJoinRule:FilterJoinRule:filter, args 
[rel#39:EnumerableFilter.ENUMERABLE.[](input=RelSubset#38,condition==($1, ?0)), 
rel#176:EnumerableHashJoin.ENUMERABLE.[](left=RelSubset#17,right=RelSubset#73,condition==($0,
 $3),joinType=semi)]
at 
org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:235)
at 
org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:631)
at org.apache.calcite.TestCalcite.testQuery(TestCalcite.java:199)
at org.apache.calcite.TestCalcite.problem_with_1_21(TestCalcite.java:256)
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:497)
at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at 
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at 
com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at 
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IndexOutOfBoundsException: index (3) must be less than 
size (3)
at 
com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:310)
at 
com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:293)
at 
com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:67)
at 
com.google.common.collect.Lists$TransformingRandomAccessList.get(Lists.java:627)
at 
org.apache.calcite.rex.RexUtil$FixNullabilityShuttle.visitInputRef(RexUtil.java:2529)
at 
org.apache.calcite.rex.RexUtil$FixNullabilityShuttle.visitInputRef(RexUtil.java:2518)
at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:112)
at org.apache.calcite.rex.RexShuttle.visitList(RexShuttle.java:149)
at org.apache.calcite.rex.RexShuttle.visitCall(RexShuttle.java:101)
at org.apache.calcite.rex.RexShuttle.visitCall(RexShuttle.java:34)
at org.apache.calcite.rex.RexCall.accept(RexCall.java:191)
at org.apache.calcite.rex.RexShuttle.apply(RexShuttle.java:277)
at org.apache.calcite.rex.RexShuttle.mutate(RexShuttle.java:239)
at org.apache.calcite.rex.RexShuttle.apply(RexShuttle.java:257)
at org.apache.calcite.rex.RexUtil.fixUp(RexUtil.java:1635)
at org.apache.calcite.rel.rules.FilterJoinRule.perform(FilterJoinRule.java:284)
at 
org.apache.calcite.rel.rules.FilterJoinRule$FilterIntoJoinRule.onMatch(FilterJoinRule.java:383)
at 
org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:208)
... 25 more
 
 



--
This message was sent by Atlassian Jira
(v8.3.2#803003)


Potential bug in calcite 1.21

2019-09-14 Thread Amit Chavan
Hello,

I am reporting a bug that happens in calcite 1.21 release. I have a query
as below
String query = "SELECT * FROM tblspace1.tsql where n1=? and k1 in (SELECT
k1 FROM tblspace1.tsql where n1=?)";

I am also attaching the unit test to reproduce this issue.  Should I open a
ticket as well?

The filterJoinRule throws an exception --
java.lang.RuntimeException: Error while applying rule
FilterJoinRule:FilterJoinRule:filter, args
[rel#39:EnumerableFilter.ENUMERABLE.[](input=RelSubset#38,condition==($1,
?0)),
rel#176:EnumerableHashJoin.ENUMERABLE.[](left=RelSubset#17,right=RelSubset#73,condition==($0,
$3),joinType=semi)]
at
org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:235)
at
org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:631)
at org.apache.calcite.TestCalcite.testQuery(TestCalcite.java:199)
at org.apache.calcite.TestCalcite.problem_with_1_21(TestCalcite.java:256)
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:497)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at
com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IndexOutOfBoundsException: index (3) must be less than
size (3)
at
com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:310)
at
com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:293)
at
com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:67)
at
com.google.common.collect.Lists$TransformingRandomAccessList.get(Lists.java:627)
at
org.apache.calcite.rex.RexUtil$FixNullabilityShuttle.visitInputRef(RexUtil.java:2529)
at
org.apache.calcite.rex.RexUtil$FixNullabilityShuttle.visitInputRef(RexUtil.java:2518)
at org.apache.calcite.rex.RexInputRef.accept(RexInputRef.java:112)
at org.apache.calcite.rex.RexShuttle.visitList(RexShuttle.java:149)
at org.apache.calcite.rex.RexShuttle.visitCall(RexShuttle.java:101)
at org.apache.calcite.rex.RexShuttle.visitCall(RexShuttle.java:34)
at org.apache.calcite.rex.RexCall.accept(RexCall.java:191)
at org.apache.calcite.rex.RexShuttle.apply(RexShuttle.java:277)
at org.apache.calcite.rex.RexShuttle.mutate(RexShuttle.java:239)
at org.apache.calcite.rex.RexShuttle.apply(RexShuttle.java:257)
at org.apache.calcite.rex.RexUtil.fixUp(RexUtil.java:1635)
at
org.apache.calcite.rel.rules.FilterJoinRule.perform(FilterJoinRule.java:284)
at
org.apache.calcite.rel.rules.FilterJoinRule$FilterIntoJoinRule.onMatch(FilterJoinRule.java:383)
at
org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:208)
... 25 more


TestCalcite.java
Description: application/ms-java


Re: [jira] [Created] (CALCITE-3229) UnsupportedOperationException for UPDATE with IN query

2019-08-05 Thread Amit Chavan
Thanks, Chunwei.

Is there anything you need me to do for this ticket? I have sent the UT
earlier. I can also work on the fix if needed. I will need some help to get
started. If there is any work you guys have for a newbie on the project
please send it my way.

On Sun, Aug 4, 2019 at 8:20 PM Chunwei Lei (JIRA)  wrote:

> Chunwei Lei created CALCITE-3229:
> 
>
>  Summary: UnsupportedOperationException for UPDATE with IN
> query
>  Key: CALCITE-3229
>  URL: https://issues.apache.org/jira/browse/CALCITE-3229
>  Project: Calcite
>   Issue Type: Bug
> Reporter: Chunwei Lei
>
>
> Query 2- "UPDATE tblspace1.table1 set n1=1000" + "WHERE k1 in (SELECT fk
> FROM tblspace1.table2 WHERE k2=?)" java.lang.UnsupportedOperationException:
> class org.apache.calcite.sql.SqlBasicCall: `K1` IN (SELECT `table2`.`fk` AS
> `FK` FROM `tblspace1`.`table2` AS `TABLE2` WHERE `table2`.`k2` = ?) at
> org.apache.calcite.util.Util.needToImplement(Util.java:967) at
> org.apache.calcite.sql.validate.SqlValidatorImpl.getValidatedNodeType(SqlValidatorImpl.java:1579)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter.findSubQueries(SqlToRelConverter.java:1802)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter.findSubQueries(SqlToRelConverter.java:1776)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter.replaceSubQueries(SqlToRelConverter.java:1011)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter.convertUpdate(SqlToRelConverter.java:3570)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3172)
> at
> org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:563)
> at org.apache.calcite.prepare.PlannerImpl.rel(PlannerImpl.java:254)
>
>
>
> From the thread [
> https://lists.apache.org/thread.html/67cb614ddd123a9092fdf37ace279eb563838b045a5554ad0005f030@%3Cdev.calcite.apache.org%3E
> ]
>
>
>
> --
> This message was sent by Atlassian JIRA
> (v7.6.14#76016)
>


Re: Some issues with release 1.20

2019-08-04 Thread Amit Chavan
Hi Julian,

I tested this against the latest master and still getting the same errors.
Here is the UT that I have written up that has the tests that reproduces
the errors. I will also attach to the ticket that chunwei wrote up

Thanks,
Amit

On Fri, Aug 2, 2019 at 12:17 PM Julian Hyde  wrote:

> Do you think you are running into
> https://issues.apache.org/jira/browse/CALCITE-3145 <
> https://issues.apache.org/jira/browse/CALCITE-3145>?
>
> > On Aug 2, 2019, at 2:00 AM, Chunwei Lei  wrote:
> >
> > Hi, Amit. Thank you for reporting this.
> >
> > I suggest you opening a jira to track this. Besides, it would be great if
> > you can provide more
> > details to reproduce these issues.
> >
> >
> >
> >
> > Best,
> > Chunwei
> >
> >
> > On Fri, Aug 2, 2019 at 10:22 AM Amit Chavan  wrote:
> >
> >> Hello,
> >>
> >> I wanted to see if I can get some help on issues I have noticed with
> >> calcite 1.20 release. These issues do not happen in the previous
> releases
> >> of calcite. I have confirmed that.
> >>
> >> Query -  "SELECT MIN(n1) as mi, MAX(n1) as ma FROM tblspace1.tsql WHERE
> >> k1='no_results' GROUP BY k1"
> >>
> >> java.lang.RuntimeException: Error while applying rule
> >> ProjectScanRule:interpreter, args
> >>
> [rel#264:EnumerableProject.ENUMERABLE.[](input=RelSubset#263,MI=$1,MA=$1),
> >> rel#317:EnumerableInterpreter.ENUMERABLE.[](input=RelSubset#291),
> >> rel#290:BindableTableScan.BINDABLE.[](table=[tblspace1,
> >> tsql],filters=[=($0, 'no_results')])]
> >>
> >>  at
> >>
> >>
> org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:235)
> >>  at
> >>
> >>
> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:631)
> >>  at herddb.sql.CalcitePlanner.runPlanner(CalcitePlanner.java:527)
> >>  at herddb.sql.CalcitePlanner.translate(CalcitePlanner.java:293)
> >>  at herddb.core.TestUtils.scan(TestUtils.java:70)
> >>  at herddb.core.RawSQLTest.simpleMinMaxTest(RawSQLTest.java:1389)
> >>  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:497)
> >>  at
> >>
> >>
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> >>  at
> >>
> >>
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> >>  at
> >>
> >>
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> >>  at
> >>
> >>
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> >>  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> >>  at
> >>
> >>
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> >>  at
> >>
> >>
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> >>  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> >>  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> >>  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> >>  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> >>  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
> >>  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
> >>  at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
> >>  at
> >>
> >>
> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
> >>  at
> >>
> >>
> com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
> >>  at
> >>
> >>
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
> >>  at
> >> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
> >> Caused by: java.lang.IllegalArgumentException: source #1 is already
> mapped
> >> to target #1
> >>  at
> >>
> >>
> org.apache.calcite.util.mapping.Mappings$SurjectionWithInverse.set(

Re: Some issues with release 1.20

2019-08-03 Thread Amit Chavan
Thanks, Chunwei.

I am able to reproduce both errors for both queries and here is the unit
test that has the code for it. Let me know if you need additional
information.


On Sat, Aug 3, 2019 at 4:59 PM Chunwei Lei  wrote:

> I spent some time on the first issue above. The following test can
> reproduce it.
>
>// FrameworksTest.java
>   @Test public void testMinMax() throws Exception {
> Table table = new TableImpl();
> final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
> SchemaPlus schema = rootSchema.add("x", new AbstractSchema());
> schema.add("MYTABLE", table);
> List traitDefs = new ArrayList<>();
> traitDefs.add(ConventionTraitDef.INSTANCE);
> traitDefs.add(RelDistributionTraitDef.INSTANCE);
> SqlParser.Config parserConfig =
> SqlParser.configBuilder(SqlParser.Config.DEFAULT)
> .setCaseSensitive(false)
> .build();
>
> final FrameworkConfig config = Frameworks.newConfigBuilder()
> .parserConfig(parserConfig)
> .defaultSchema(schema)
> .traitDefs(traitDefs)
> // define the rules you want to apply
> .ruleSets(
>
> RuleSets.ofList(AbstractConverter.ExpandConversionRule.INSTANCE,
> ProjectTableScanRule.INSTANCE))
> .programs(Programs.ofRules(Programs.RULE_SET))
> .build();
>
> executeQuery(config, " select min(id) as mi, max(id) as ma from mytable
> where id=1 group by id",
> CalciteSystemProperty.DEBUG.value());
>   }
>
> I opened a jira(CALCITE-322
> <https://issues.apache.org/jira/projects/CALCITE/issues/CALCITE-3228>8)
> for
> this. Besides, I found CALCITE-896
> <https://issues.apache.org/jira/browse/CALCITE-896> which improves
> AggregateRemoveRule causes this.
>
>
>
> Best,
> Chunwei
>
>
> On Sun, Aug 4, 2019 at 7:05 AM Amit Chavan  wrote:
>
> > Yes the table in question does implement the following interfaces -
> > private static class TableImpl extends AbstractTable
> > implements ModifiableTable, ScannableTable,
> > ProjectableFilterableTable
> >
> > I am putting together a project that has some unit tests that will show
> the
> > errors.
> >
> >
> > On Sat, Aug 3, 2019 at 7:05 AM Stamatis Zampetakis 
> > wrote:
> >
> > > I tried to reproduce the first problem related with
> ProjectTableScanRule
> > > with the current master but I didn't succeed. I assumed that the table
> in
> > > question implements the FilterableTable or ProjectableFilterableTable
> > > interface but I guess I am missing some other important parameters.
> > >
> > > On Fri, Aug 2, 2019 at 9:17 PM Julian Hyde  wrote:
> > >
> > > > Do you think you are running into
> > > > https://issues.apache.org/jira/browse/CALCITE-3145 <
> > > > https://issues.apache.org/jira/browse/CALCITE-3145>?
> > > >
> > > > > On Aug 2, 2019, at 2:00 AM, Chunwei Lei 
> > > wrote:
> > > > >
> > > > > Hi, Amit. Thank you for reporting this.
> > > > >
> > > > > I suggest you opening a jira to track this. Besides, it would be
> > great
> > > if
> > > > > you can provide more
> > > > > details to reproduce these issues.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Best,
> > > > > Chunwei
> > > > >
> > > > >
> > > > > On Fri, Aug 2, 2019 at 10:22 AM Amit Chavan 
> > > wrote:
> > > > >
> > > > >> Hello,
> > > > >>
> > > > >> I wanted to see if I can get some help on issues I have noticed
> with
> > > > >> calcite 1.20 release. These issues do not happen in the previous
> > > > releases
> > > > >> of calcite. I have confirmed that.
> > > > >>
> > > > >> Query -  "SELECT MIN(n1) as mi, MAX(n1) as ma FROM tblspace1.tsql
> > > WHERE
> > > > >> k1='no_results' GROUP BY k1"
> > > > >>
> > > > >> java.lang.RuntimeException: Error while applying rule
> > > > >> ProjectScanRule:interpreter, args
> > > > >>
> > > >
> > >
> >
> [rel#264:EnumerableProject.ENUMERABLE.[](input=RelSubset#263,MI=$1,MA=$1),
> > > > &g

Re: Some issues with release 1.20

2019-08-03 Thread Amit Chavan
Yes the table in question does implement the following interfaces -
private static class TableImpl extends AbstractTable
implements ModifiableTable, ScannableTable,
ProjectableFilterableTable

I am putting together a project that has some unit tests that will show the
errors.


On Sat, Aug 3, 2019 at 7:05 AM Stamatis Zampetakis 
wrote:

> I tried to reproduce the first problem related with ProjectTableScanRule
> with the current master but I didn't succeed. I assumed that the table in
> question implements the FilterableTable or ProjectableFilterableTable
> interface but I guess I am missing some other important parameters.
>
> On Fri, Aug 2, 2019 at 9:17 PM Julian Hyde  wrote:
>
> > Do you think you are running into
> > https://issues.apache.org/jira/browse/CALCITE-3145 <
> > https://issues.apache.org/jira/browse/CALCITE-3145>?
> >
> > > On Aug 2, 2019, at 2:00 AM, Chunwei Lei 
> wrote:
> > >
> > > Hi, Amit. Thank you for reporting this.
> > >
> > > I suggest you opening a jira to track this. Besides, it would be great
> if
> > > you can provide more
> > > details to reproduce these issues.
> > >
> > >
> > >
> > >
> > > Best,
> > > Chunwei
> > >
> > >
> > > On Fri, Aug 2, 2019 at 10:22 AM Amit Chavan 
> wrote:
> > >
> > >> Hello,
> > >>
> > >> I wanted to see if I can get some help on issues I have noticed with
> > >> calcite 1.20 release. These issues do not happen in the previous
> > releases
> > >> of calcite. I have confirmed that.
> > >>
> > >> Query -  "SELECT MIN(n1) as mi, MAX(n1) as ma FROM tblspace1.tsql
> WHERE
> > >> k1='no_results' GROUP BY k1"
> > >>
> > >> java.lang.RuntimeException: Error while applying rule
> > >> ProjectScanRule:interpreter, args
> > >>
> >
> [rel#264:EnumerableProject.ENUMERABLE.[](input=RelSubset#263,MI=$1,MA=$1),
> > >> rel#317:EnumerableInterpreter.ENUMERABLE.[](input=RelSubset#291),
> > >> rel#290:BindableTableScan.BINDABLE.[](table=[tblspace1,
> > >> tsql],filters=[=($0, 'no_results')])]
> > >>
> > >>  at
> > >>
> > >>
> >
> org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:235)
> > >>  at
> > >>
> > >>
> >
> org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:631)
> > >>  at herddb.sql.CalcitePlanner.runPlanner(CalcitePlanner.java:527)
> > >>  at herddb.sql.CalcitePlanner.translate(CalcitePlanner.java:293)
> > >>  at herddb.core.TestUtils.scan(TestUtils.java:70)
> > >>  at herddb.core.RawSQLTest.simpleMinMaxTest(RawSQLTest.java:1389)
> > >>  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:497)
> > >>  at
> > >>
> > >>
> >
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> > >>  at
> > >>
> > >>
> >
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> > >>  at
> > >>
> > >>
> >
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> > >>  at
> > >>
> > >>
> >
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> > >>  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> > >>  at
> > >>
> > >>
> >
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> > >>  at
> > >>
> > >>
> >
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> > >>  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> > >>  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> > >>  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> > >>  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> > >>  at org.junit.

Some issues with release 1.20

2019-08-01 Thread Amit Chavan
Hello,

I wanted to see if I can get some help on issues I have noticed with
calcite 1.20 release. These issues do not happen in the previous releases
of calcite. I have confirmed that.

Query -  "SELECT MIN(n1) as mi, MAX(n1) as ma FROM tblspace1.tsql WHERE
k1='no_results' GROUP BY k1"

java.lang.RuntimeException: Error while applying rule
ProjectScanRule:interpreter, args
[rel#264:EnumerableProject.ENUMERABLE.[](input=RelSubset#263,MI=$1,MA=$1),
rel#317:EnumerableInterpreter.ENUMERABLE.[](input=RelSubset#291),
rel#290:BindableTableScan.BINDABLE.[](table=[tblspace1,
tsql],filters=[=($0, 'no_results')])]

  at
org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:235)
  at
org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:631)
  at herddb.sql.CalcitePlanner.runPlanner(CalcitePlanner.java:527)
  at herddb.sql.CalcitePlanner.translate(CalcitePlanner.java:293)
  at herddb.core.TestUtils.scan(TestUtils.java:70)
  at herddb.core.RawSQLTest.simpleMinMaxTest(RawSQLTest.java:1389)
  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:497)
  at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
  at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
  at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
  at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
  at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
  at
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
  at
com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
  at
com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
  at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IllegalArgumentException: source #1 is already mapped
to target #1
  at
org.apache.calcite.util.mapping.Mappings$SurjectionWithInverse.set(Mappings.java:1326)
  at org.apache.calcite.rel.core.Project.getMapping(Project.java:279)
  at org.apache.calcite.rel.core.Project.getMapping(Project.java:250)
  at
org.apache.calcite.rel.rules.ProjectTableScanRule.apply(ProjectTableScanRule.java:107)
  at
org.apache.calcite.rel.rules.ProjectTableScanRule$2.onMatch(ProjectTableScanRule.java:83)
  at
org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:208)
  ... 27 more

Query 2-
"UPDATE tblspace1.table1 set n1=1000"
+ "WHERE k1 in (SELECT fk FROM tblspace1.table2 WHERE
k2=?)"

java.lang.UnsupportedOperationException: class
org.apache.calcite.sql.SqlBasicCall: `K1` IN (SELECT `table2`.`fk` AS `FK`
FROM `tblspace1`.`table2` AS `TABLE2`
WHERE `table2`.`k2` = ?)

at org.apache.calcite.util.Util.needToImplement(Util.java:967)
at
org.apache.calcite.sql.validate.SqlValidatorImpl.getValidatedNodeType(SqlValidatorImpl.java:1579)
at
org.apache.calcite.sql2rel.SqlToRelConverter.findSubQueries(SqlToRelConverter.java:1802)
at
org.apache.calcite.sql2rel.SqlToRelConverter.findSubQueries(SqlToRelConverter.java:1776)
at
org.apache.calcite.sql2rel.SqlToRelConverter.replaceSubQueries(SqlToRelConverter.java:1011)
at
org.apache.calcite.sql2rel.SqlToRelConverter.convertUpdate(SqlToRelConverter.java:3570)
at
org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3172)
at
org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:563)
at org.apache.calcite.prepare.PlannerImpl.rel(PlannerImpl.java:254)