<div dir="ltr">Hello,<br><div><br></div><div>I am upgrading herddb dependency to calcite 1.20.0 and ran into an issue with calcite volcano planner. The query in question is &quot;SELECT MIN(n1) as mi, MAX(n1) as ma FROM tblspace1.tsql WHERE k1=&#39;no_results&#39; GROUP BY k1&quot;. The unit test in question is </div><div> <a href="https://github.com/diennea/herddb/blob/master/herddb-core/src/test/java/herddb/core/RawSQLTest.java#L1389">https://github.com/diennea/herddb/blob/master/herddb-core/src/test/java/herddb/core/RawSQLTest.java#L1389</a></div><div><br></div><div>The error I am getting is --</div><div>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, &#39;no_results&#39;)])]<br><br>        at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:235)<br>        at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:631)<br>        at herddb.sql.CalcitePlanner.runPlanner(CalcitePlanner.java:527)<br>        at herddb.sql.CalcitePlanner.translate(CalcitePlanner.java:293)<br>        at herddb.core.TestUtils.scan(TestUtils.java:70)<br>        at herddb.core.RawSQLTest.simpleMinMaxTest(RawSQLTest.java:1389)<br>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)<br>        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br>        at java.lang.reflect.Method.invoke(Method.java:497)<br>        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)<br>        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)<br>        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)<br>        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)<br>        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)<br>        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)<br>        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)<br>        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)<br>        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)<br>        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)<br>        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)<br>        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)<br>        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)<br>        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)<br>        at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)<br>        at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)<br>        at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)<br>        at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)<br>Caused by: java.lang.IllegalArgumentException: source #1 is already mapped to target #1<br>        at org.apache.calcite.util.mapping.Mappings$SurjectionWithInverse.set(Mappings.java:1326)<br>        at org.apache.calcite.rel.core.Project.getMapping(Project.java:279)<br>        at org.apache.calcite.rel.core.Project.getMapping(Project.java:250)<br>        at org.apache.calcite.rel.rules.ProjectTableScanRule.apply(ProjectTableScanRule.java:107)<br>        at org.apache.calcite.rel.rules.ProjectTableScanRule$2.onMatch(ProjectTableScanRule.java:83)<br>        at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:208)<br>        ... 27 more<br></div><div><br></div><div>What is the right approach to handle this? Can we file a bug with the calcite team.</div></div>