[jira] [Closed] (CALCITE-3543) JDBC adapter converts count with single column to count star

2019-12-16 Thread Wang Weidong (Jira)


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

Wang Weidong closed CALCITE-3543.
-
Resolution: Not A Problem

> JDBC adapter converts count with single column to count star
> 
>
> Key: CALCITE-3543
> URL: https://issues.apache.org/jira/browse/CALCITE-3543
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>
> JDBC adapter converts count with single column to count star which is not 
> equivalent.
> See the test case as follow
> {code:java}
>   @Test public void testSelectQueryWithCountSingleColumn() {
> final String query = "select \"product_id\", count(\"product_id\")\n" +
> "from \"product\"\n" +
> "group by \"product_id\"";
> final String expected = "SELECT \"product_id\", COUNT(\"product_id\")\n" +
> "FROM \"foodmart\".\"product\"\n" +
> "GROUP BY \"product_id\"";
> sql(query).ok(expected);
>   }
> {code}
> An error occurred after executing of this test case as follows
> {code:java}
> java.lang.AssertionError: 
> Expected: is "SELECT \"product_id\", COUNT(\"product_id\")\nFROM 
> \"foodmart\".\"product\"\nGROUP BY \"product_id\""
>  but: was "SELECT \"product_id\", COUNT(*)\nFROM 
> \"foodmart\".\"product\"\nGROUP BY \"product_id\""
>   at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
>   at org.junit.Assert.assertThat(Assert.java:956)
>   at org.junit.Assert.assertThat(Assert.java:923)
>   at 
> org.apache.calcite.rel.rel2sql.RelToSqlConverterTest$Sql.ok(RelToSqlConverterTest.java:4419)
>   at 
> org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.testSelectQueryWithCountSingleColumn(RelToSqlConverterTest.java:398)
>   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: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 org.junit.runner.JUnitCore.run(JUnitCore.java:115)
>   at 
> org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43)
>   at 
> java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
>   at 
> java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
>   at java.util.Iterator.forEachRemaining(Iterator.java:116)
>   at 
> java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>   at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
>   at 
> java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
>   at 
> java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
>   at 
> java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
>   at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>   at 
> java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
>   at 
> org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:82)
>   at 
> org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:73)
>   at 
> org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
>   at 
> org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
>   at 
> 

[jira] [Commented] (CALCITE-3543) JDBC adapter converts count with single column to count star

2019-12-16 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16997366#comment-16997366
 ] 

Wang Weidong commented on CALCITE-3543:
---

[~donnyzone][~amaliujia] I've read and debugged the source code of calcite, and 
found that only counting with a column which is not nullable will be converted 
to counting star, we can see this in the method 
org.apache.calcite.rex.RexBuilder#nullableArgs.So this is not a bug, and I will 
close it.

> JDBC adapter converts count with single column to count star
> 
>
> Key: CALCITE-3543
> URL: https://issues.apache.org/jira/browse/CALCITE-3543
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>
> JDBC adapter converts count with single column to count star which is not 
> equivalent.
> See the test case as follow
> {code:java}
>   @Test public void testSelectQueryWithCountSingleColumn() {
> final String query = "select \"product_id\", count(\"product_id\")\n" +
> "from \"product\"\n" +
> "group by \"product_id\"";
> final String expected = "SELECT \"product_id\", COUNT(\"product_id\")\n" +
> "FROM \"foodmart\".\"product\"\n" +
> "GROUP BY \"product_id\"";
> sql(query).ok(expected);
>   }
> {code}
> An error occurred after executing of this test case as follows
> {code:java}
> java.lang.AssertionError: 
> Expected: is "SELECT \"product_id\", COUNT(\"product_id\")\nFROM 
> \"foodmart\".\"product\"\nGROUP BY \"product_id\""
>  but: was "SELECT \"product_id\", COUNT(*)\nFROM 
> \"foodmart\".\"product\"\nGROUP BY \"product_id\""
>   at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
>   at org.junit.Assert.assertThat(Assert.java:956)
>   at org.junit.Assert.assertThat(Assert.java:923)
>   at 
> org.apache.calcite.rel.rel2sql.RelToSqlConverterTest$Sql.ok(RelToSqlConverterTest.java:4419)
>   at 
> org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.testSelectQueryWithCountSingleColumn(RelToSqlConverterTest.java:398)
>   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: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 org.junit.runner.JUnitCore.run(JUnitCore.java:115)
>   at 
> org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43)
>   at 
> java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
>   at 
> java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
>   at java.util.Iterator.forEachRemaining(Iterator.java:116)
>   at 
> java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>   at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
>   at 
> java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
>   at 
> java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
>   at 
> java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
>   at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>   at 
> java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
>   at 
> org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:82)
>   at 
> 

[jira] [Commented] (CALCITE-3543) JDBC adapter converts count with single column to count star

2019-11-29 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16984955#comment-16984955
 ] 

Wang Weidong commented on CALCITE-3543:
---

[~donnyzone] Yes,  I will check other places about sql converting with start 
during fix this bug. You can also pay attention about that when you are idle.

> JDBC adapter converts count with single column to count star
> 
>
> Key: CALCITE-3543
> URL: https://issues.apache.org/jira/browse/CALCITE-3543
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Priority: Major
>
> JDBC adapter converts count with single column to count star which is not 
> equivalent.
> See the test case as follow
> {code:java}
>   @Test public void testSelectQueryWithCountSingleColumn() {
> final String query = "select \"product_id\", count(\"product_id\")\n" +
> "from \"product\"\n" +
> "group by \"product_id\"";
> final String expected = "SELECT \"product_id\", COUNT(\"product_id\")\n" +
> "FROM \"foodmart\".\"product\"\n" +
> "GROUP BY \"product_id\"";
> sql(query).ok(expected);
>   }
> {code}
> An error occurred after executing of this test case as follows
> {code:java}
> java.lang.AssertionError: 
> Expected: is "SELECT \"product_id\", COUNT(\"product_id\")\nFROM 
> \"foodmart\".\"product\"\nGROUP BY \"product_id\""
>  but: was "SELECT \"product_id\", COUNT(*)\nFROM 
> \"foodmart\".\"product\"\nGROUP BY \"product_id\""
>   at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
>   at org.junit.Assert.assertThat(Assert.java:956)
>   at org.junit.Assert.assertThat(Assert.java:923)
>   at 
> org.apache.calcite.rel.rel2sql.RelToSqlConverterTest$Sql.ok(RelToSqlConverterTest.java:4419)
>   at 
> org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.testSelectQueryWithCountSingleColumn(RelToSqlConverterTest.java:398)
>   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: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 org.junit.runner.JUnitCore.run(JUnitCore.java:115)
>   at 
> org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43)
>   at 
> java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
>   at 
> java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
>   at java.util.Iterator.forEachRemaining(Iterator.java:116)
>   at 
> java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>   at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
>   at 
> java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
>   at 
> java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
>   at 
> java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
>   at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>   at 
> java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
>   at 
> org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:82)
>   at 
> org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:73)
>   at 
> org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
>   at 
> 

[jira] [Commented] (CALCITE-3543) JDBC adapter converts count with single column to count star

2019-11-29 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3543?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16984950#comment-16984950
 ] 

Wang Weidong commented on CALCITE-3543:
---

[~amaliujia] Yes, I want to fix it next week.

> JDBC adapter converts count with single column to count star
> 
>
> Key: CALCITE-3543
> URL: https://issues.apache.org/jira/browse/CALCITE-3543
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Priority: Major
>
> JDBC adapter converts count with single column to count star which is not 
> equivalent.
> See the test case as follow
> {code:java}
>   @Test public void testSelectQueryWithCountSingleColumn() {
> final String query = "select \"product_id\", count(\"product_id\")\n" +
> "from \"product\"\n" +
> "group by \"product_id\"";
> final String expected = "SELECT \"product_id\", COUNT(\"product_id\")\n" +
> "FROM \"foodmart\".\"product\"\n" +
> "GROUP BY \"product_id\"";
> sql(query).ok(expected);
>   }
> {code}
> An error occurred after executing of this test case as follows
> {code:java}
> java.lang.AssertionError: 
> Expected: is "SELECT \"product_id\", COUNT(\"product_id\")\nFROM 
> \"foodmart\".\"product\"\nGROUP BY \"product_id\""
>  but: was "SELECT \"product_id\", COUNT(*)\nFROM 
> \"foodmart\".\"product\"\nGROUP BY \"product_id\""
>   at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
>   at org.junit.Assert.assertThat(Assert.java:956)
>   at org.junit.Assert.assertThat(Assert.java:923)
>   at 
> org.apache.calcite.rel.rel2sql.RelToSqlConverterTest$Sql.ok(RelToSqlConverterTest.java:4419)
>   at 
> org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.testSelectQueryWithCountSingleColumn(RelToSqlConverterTest.java:398)
>   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: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 org.junit.runner.JUnitCore.run(JUnitCore.java:115)
>   at 
> org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43)
>   at 
> java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
>   at 
> java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
>   at java.util.Iterator.forEachRemaining(Iterator.java:116)
>   at 
> java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
>   at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
>   at 
> java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
>   at 
> java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
>   at 
> java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
>   at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
>   at 
> java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
>   at 
> org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:82)
>   at 
> org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:73)
>   at 
> org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
>   at 
> org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
>   at 
> 

[jira] [Created] (CALCITE-3543) JDBC adapter converts count with single column to count star

2019-11-27 Thread Wang Weidong (Jira)
Wang Weidong created CALCITE-3543:
-

 Summary: JDBC adapter converts count with single column to count 
star
 Key: CALCITE-3543
 URL: https://issues.apache.org/jira/browse/CALCITE-3543
 Project: Calcite
  Issue Type: Bug
  Components: core
Affects Versions: 1.21.0
Reporter: Wang Weidong


JDBC adapter converts count with single column to count star which is not 
equivalent.
See the test case as follow

{code:java}
  @Test public void testSelectQueryWithCountSingleColumn() {
final String query = "select \"product_id\", count(\"product_id\")\n" +
"from \"product\"\n" +
"group by \"product_id\"";
final String expected = "SELECT \"product_id\", COUNT(\"product_id\")\n" +
"FROM \"foodmart\".\"product\"\n" +
"GROUP BY \"product_id\"";
sql(query).ok(expected);
  }
{code}

An error occurred after executing of this test case as follows

{code:java}
java.lang.AssertionError: 
Expected: is "SELECT \"product_id\", COUNT(\"product_id\")\nFROM 
\"foodmart\".\"product\"\nGROUP BY \"product_id\""
 but: was "SELECT \"product_id\", COUNT(*)\nFROM 
\"foodmart\".\"product\"\nGROUP BY \"product_id\""
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
at org.junit.Assert.assertThat(Assert.java:956)
at org.junit.Assert.assertThat(Assert.java:923)
at 
org.apache.calcite.rel.rel2sql.RelToSqlConverterTest$Sql.ok(RelToSqlConverterTest.java:4419)
at 
org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.testSelectQueryWithCountSingleColumn(RelToSqlConverterTest.java:398)
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: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 org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at 
org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43)
at 
java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at 
java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at 
java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at 
java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at 
java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at 
java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at 
java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
at 
org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:82)
at 
org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:73)
at 
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
at 
org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
at 
org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
at 
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
at 
org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
at 

[jira] [Commented] (CALCITE-3466) JDBC adapter dropped group by statement in subquery

2019-11-26 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16982409#comment-16982409
 ] 

Wang Weidong commented on CALCITE-3466:
---

[~julianhyde] [~yanlin-Lynn] Hi, I've submit a pr, could you make for me?

> JDBC adapter dropped group by statement in subquery
> ---
>
> Key: CALCITE-3466
> URL: https://issues.apache.org/jira/browse/CALCITE-3466
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0, 1.22.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.22.0
>
> Attachments: screenshot-1.png
>
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> While convert RelNode to SqlNode, the "group by" statement in subquery was 
> dropped unexpectedly. For example,
> original sql is:
> {code:sql}
> select a, avg(c1) from 
> (
> select a,sum(d),b as c1 from t group by b,a
> ) as t 
> group by a
> {code}
> RelNode converted by SqlNode is 
> {code:sql}
> LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
>   LogicalProject(A=[$1], C1=[$0])
> LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
>   LogicalProject(B=[$1], A=[$0], D=[$3])
> EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
> {code}
> And then convert this RelNode to SqlNode, the sql of SqlNode is like this:
> {code:sql}
> SELECT `A`, AVG(`B`)
> FROM `T`
> GROUP BY `A`
> {code}
> We can find that "group by" in subquery was dropped which may cause SqlNode 
> converted by RelNode being not equivalent to RelNode.
> After debugging, I've found code 
> at 
> https://github.com/apache/calcite/blob/aa98c1575762718b238af8ddd44a390607de7602/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java#L333
>  
> calls org.apache.calcite.rel.rel2sql.SqlImplementor.Builder#setGroupBy 
> without judge whether "group by" already exists.
> Finally, I think in this case, the main select and sub-select shouldn't be 
> merged.



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


[jira] [Comment Edited] (CALCITE-3466) JDBC adapter dropped group by statement in subquery

2019-11-26 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16982409#comment-16982409
 ] 

Wang Weidong edited comment on CALCITE-3466 at 11/26/19 12:00 PM:
--

[~julianhyde] [~yanlin-Lynn] Hi, I've submitted a pr, could you make for me?


was (Author: wangweidong):
[~julianhyde] [~yanlin-Lynn] Hi, I've submit a pr, could you make for me?

> JDBC adapter dropped group by statement in subquery
> ---
>
> Key: CALCITE-3466
> URL: https://issues.apache.org/jira/browse/CALCITE-3466
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0, 1.22.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.22.0
>
> Attachments: screenshot-1.png
>
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> While convert RelNode to SqlNode, the "group by" statement in subquery was 
> dropped unexpectedly. For example,
> original sql is:
> {code:sql}
> select a, avg(c1) from 
> (
> select a,sum(d),b as c1 from t group by b,a
> ) as t 
> group by a
> {code}
> RelNode converted by SqlNode is 
> {code:sql}
> LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
>   LogicalProject(A=[$1], C1=[$0])
> LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
>   LogicalProject(B=[$1], A=[$0], D=[$3])
> EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
> {code}
> And then convert this RelNode to SqlNode, the sql of SqlNode is like this:
> {code:sql}
> SELECT `A`, AVG(`B`)
> FROM `T`
> GROUP BY `A`
> {code}
> We can find that "group by" in subquery was dropped which may cause SqlNode 
> converted by RelNode being not equivalent to RelNode.
> After debugging, I've found code 
> at 
> https://github.com/apache/calcite/blob/aa98c1575762718b238af8ddd44a390607de7602/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java#L333
>  
> calls org.apache.calcite.rel.rel2sql.SqlImplementor.Builder#setGroupBy 
> without judge whether "group by" already exists.
> Finally, I think in this case, the main select and sub-select shouldn't be 
> merged.



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


[jira] [Closed] (CALCITE-3532) SqlValidator throws exception with message of db not found while table not existed

2019-11-24 Thread Wang Weidong (Jira)


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

Wang Weidong closed CALCITE-3532.
-
Resolution: Invalid

> SqlValidator throws exception with message of db not found while table not 
> existed
> --
>
> Key: CALCITE-3532
> URL: https://issues.apache.org/jira/browse/CALCITE-3532
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Priority: Major
>
> I found that if a SqlNode of a sql with an not existed table is validated, an 
> exception with message of db not found while table not existed will be thrown 
> even though the db is existed.
> For instance, when validate the SqlNode of this sql 
> {code:sql}
> select * from db1.t
> {code}
> in which db1 is existed and t is not existed in db1.
> An exception was thrown with stack trace as follows
> {code:java}
> org.apache.calcite.runtime.CalciteContextException: From line 1, column 15 to 
> line 1, column 19: Object 'db1' not found
>   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>   at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>   at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
>   at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
>   at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:824)
>   at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:809)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4934)
>   at 
> org.apache.calcite.sql.validate.IdentifierNamespace.resolveImpl(IdentifierNamespace.java:172)
>   at 
> org.apache.calcite.sql.validate.IdentifierNamespace.validateImpl(IdentifierNamespace.java:177)
>   at 
> org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1004)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:964)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3122)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3104)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3376)
>   at 
> org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
>   at 
> org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1004)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:964)
>   at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:216)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:939)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:646)
>   at 
> com.alipay.smartsql.vtable.parser.validate.DefaultSqlValidator.validate(DefaultSqlValidator.java:52)
> {code}
> I found that the cause of this problem may be the process at 
> https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/validate/IdentifierNamespace.java#L180
> which only produces message of the first component of table path when throws 
> exception.
> Can we fix this problem? 



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


[jira] [Commented] (CALCITE-3532) SqlValidator throws exception with message of db not found while table not existed

2019-11-24 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16981289#comment-16981289
 ] 

Wang Weidong commented on CALCITE-3532:
---

[~amaliujia] I've found that this problem was caused by my own applications, 
thus I will close this issue, thanks. 

> SqlValidator throws exception with message of db not found while table not 
> existed
> --
>
> Key: CALCITE-3532
> URL: https://issues.apache.org/jira/browse/CALCITE-3532
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Priority: Major
>
> I found that if a SqlNode of a sql with an not existed table is validated, an 
> exception with message of db not found while table not existed will be thrown 
> even though the db is existed.
> For instance, when validate the SqlNode of this sql 
> {code:sql}
> select * from db1.t
> {code}
> in which db1 is existed and t is not existed in db1.
> An exception was thrown with stack trace as follows
> {code:java}
> org.apache.calcite.runtime.CalciteContextException: From line 1, column 15 to 
> line 1, column 19: Object 'db1' not found
>   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>   at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>   at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
>   at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
>   at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:824)
>   at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:809)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4934)
>   at 
> org.apache.calcite.sql.validate.IdentifierNamespace.resolveImpl(IdentifierNamespace.java:172)
>   at 
> org.apache.calcite.sql.validate.IdentifierNamespace.validateImpl(IdentifierNamespace.java:177)
>   at 
> org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1004)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:964)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3122)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3104)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3376)
>   at 
> org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
>   at 
> org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1004)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:964)
>   at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:216)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:939)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:646)
>   at 
> com.alipay.smartsql.vtable.parser.validate.DefaultSqlValidator.validate(DefaultSqlValidator.java:52)
> {code}
> I found that the cause of this problem may be the process at 
> https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/validate/IdentifierNamespace.java#L180
> which only produces message of the first component of table path when throws 
> exception.
> Can we fix this problem? 



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


[jira] [Updated] (CALCITE-3532) SqlValidator throws exception with message of db not found while table not existed

2019-11-22 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3532:
--
Description: 
I found that if a SqlNode of a sql with an not existed table is validated, an 
exception with message of db not found while table not existed will be thrown 
even though the db is existed.
For instance, when validate the SqlNode of this sql 
{code:sql}
select * from db1.t
{code}
in which db1 is existed and t is not existed in db1.
An exception was thrown with stack trace as follows

{code:java}
org.apache.calcite.runtime.CalciteContextException: From line 1, column 15 to 
line 1, column 19: Object 'db1' not found
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at 
org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:824)
at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:809)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4934)
at 
org.apache.calcite.sql.validate.IdentifierNamespace.resolveImpl(IdentifierNamespace.java:172)
at 
org.apache.calcite.sql.validate.IdentifierNamespace.validateImpl(IdentifierNamespace.java:177)
at 
org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1004)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:964)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3122)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3104)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3376)
at 
org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
at 
org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1004)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:964)
at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:216)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:939)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:646)
at 
com.alipay.smartsql.vtable.parser.validate.DefaultSqlValidator.validate(DefaultSqlValidator.java:52)
{code}

I found that the cause of this problem may be the process at 
https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/validate/IdentifierNamespace.java#L180
which only produces message of the first component of table path when throws 
exception.

Can we fix this problem? 


  was:
I found that if a SqlNode of a sql with an not existed table is validated, an 
exception with message of db not found while table not existed will be thrown 
even though the db is existed.
For instance, when validate the SqlNode of this sql 
{code:sql}
select * from db1.t
{code}
in which db1 is existed and t is not existed in db1.
An exception was thrown with stack trace as follows

{code:java}
org.apache.calcite.runtime.CalciteContextException: From line 1, column 15 to 
line 1, column 19: Object 'db1' not found
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at 
org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:824)
at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:809)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4934)
at 
org.apache.calcite.sql.validate.IdentifierNamespace.resolveImpl(IdentifierNamespace.java:172)
at 
org.apache.calcite.sql.validate.IdentifierNamespace.validateImpl(IdentifierNamespace.java:177)
at 
org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
at 

[jira] [Updated] (CALCITE-3532) SqlValidator throws exception with message of db not found while table not existed

2019-11-22 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3532:
--
Description: 
I found that if a SqlNode of a sql with an not existed table is validated, an 
exception with message of db not found while table not existed will be thrown 
even though the db is existed.
For instance, when validate the SqlNode of this sql 
{code:sql}
select * from db1.t
{code}
in which db1 is existed and t is not existed in db1.
An exception was thrown with stack trace as follows

{code:java}
org.apache.calcite.runtime.CalciteContextException: From line 1, column 15 to 
line 1, column 19: Object 'db1' not found
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at 
org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:824)
at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:809)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4934)
at 
org.apache.calcite.sql.validate.IdentifierNamespace.resolveImpl(IdentifierNamespace.java:172)
at 
org.apache.calcite.sql.validate.IdentifierNamespace.validateImpl(IdentifierNamespace.java:177)
at 
org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1004)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:964)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3122)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3104)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3376)
at 
org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
at 
org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1004)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:964)
at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:216)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:939)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:646)
at 
com.alipay.smartsql.vtable.parser.validate.DefaultSqlValidator.validate(DefaultSqlValidator.java:52)
{code}


  was:I found that if a SqlNode of a sql with an not existed table is 
validated, 


> SqlValidator throws exception with message of db not found while table not 
> existed
> --
>
> Key: CALCITE-3532
> URL: https://issues.apache.org/jira/browse/CALCITE-3532
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Priority: Major
>
> I found that if a SqlNode of a sql with an not existed table is validated, an 
> exception with message of db not found while table not existed will be thrown 
> even though the db is existed.
> For instance, when validate the SqlNode of this sql 
> {code:sql}
> select * from db1.t
> {code}
> in which db1 is existed and t is not existed in db1.
> An exception was thrown with stack trace as follows
> {code:java}
> org.apache.calcite.runtime.CalciteContextException: From line 1, column 15 to 
> line 1, column 19: Object 'db1' not found
>   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>   at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>   at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>   at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
>   at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
>   at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:824)
>   at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:809)
>   at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4934)
>   at 
> 

[jira] [Updated] (CALCITE-3532) SqlValidator throws exception with message of db not found while table not existed

2019-11-22 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3532:
--
Description: I found that if a SqlNode of a sql with an not existed table 
is validated, 

> SqlValidator throws exception with message of db not found while table not 
> existed
> --
>
> Key: CALCITE-3532
> URL: https://issues.apache.org/jira/browse/CALCITE-3532
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Priority: Major
>
> I found that if a SqlNode of a sql with an not existed table is validated, 



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


[jira] [Created] (CALCITE-3532) SqlValidator throws exception with message of db not found while table not existed

2019-11-22 Thread Wang Weidong (Jira)
Wang Weidong created CALCITE-3532:
-

 Summary: SqlValidator throws exception with message of db not 
found while table not existed
 Key: CALCITE-3532
 URL: https://issues.apache.org/jira/browse/CALCITE-3532
 Project: Calcite
  Issue Type: Bug
  Components: core
Affects Versions: 1.21.0
Reporter: Wang Weidong






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


[jira] [Assigned] (CALCITE-3466) JDBC adapter dropped group by statement in subquery

2019-11-19 Thread Wang Weidong (Jira)


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

Wang Weidong reassigned CALCITE-3466:
-

Assignee: Wang Weidong

> JDBC adapter dropped group by statement in subquery
> ---
>
> Key: CALCITE-3466
> URL: https://issues.apache.org/jira/browse/CALCITE-3466
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0, 1.22.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
> Fix For: 1.22.0
>
> Attachments: screenshot-1.png
>
>
> While convert RelNode to SqlNode, the "group by" statement in subquery was 
> dropped unexpectedly. For example,
> original sql is:
> {code:sql}
> select a, avg(c1) from 
> (
> select a,sum(d),b as c1 from t group by b,a
> ) as t 
> group by a
> {code}
> RelNode converted by SqlNode is 
> {code:sql}
> LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
>   LogicalProject(A=[$1], C1=[$0])
> LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
>   LogicalProject(B=[$1], A=[$0], D=[$3])
> EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
> {code}
> And then convert this RelNode to SqlNode, the sql of SqlNode is like this:
> {code:sql}
> SELECT `A`, AVG(`B`)
> FROM `T`
> GROUP BY `A`
> {code}
> We can find that "group by" in subquery was dropped which may cause SqlNode 
> converted by RelNode being not equivalent to RelNode.
> After debugging, I've found code 
> at 
> https://github.com/apache/calcite/blob/aa98c1575762718b238af8ddd44a390607de7602/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java#L333
>  
> calls org.apache.calcite.rel.rel2sql.SqlImplementor.Builder#setGroupBy 
> without judge whether "group by" already exists.
> Finally, I think in this case, the main select and sub-select shouldn't be 
> merged.



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


[jira] [Commented] (CALCITE-3466) JDBC adapter dropped group by statement in subquery

2019-11-19 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16978043#comment-16978043
 ] 

Wang Weidong commented on CALCITE-3466:
---

Is there anyone who wants to fix this bug? I will fix it later if nobody 
replies.

> JDBC adapter dropped group by statement in subquery
> ---
>
> Key: CALCITE-3466
> URL: https://issues.apache.org/jira/browse/CALCITE-3466
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0, 1.22.0
>Reporter: Wang Weidong
>Priority: Major
> Fix For: 1.22.0
>
> Attachments: screenshot-1.png
>
>
> While convert RelNode to SqlNode, the "group by" statement in subquery was 
> dropped unexpectedly. For example,
> original sql is:
> {code:sql}
> select a, avg(c1) from 
> (
> select a,sum(d),b as c1 from t group by b,a
> ) as t 
> group by a
> {code}
> RelNode converted by SqlNode is 
> {code:sql}
> LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
>   LogicalProject(A=[$1], C1=[$0])
> LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
>   LogicalProject(B=[$1], A=[$0], D=[$3])
> EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
> {code}
> And then convert this RelNode to SqlNode, the sql of SqlNode is like this:
> {code:sql}
> SELECT `A`, AVG(`B`)
> FROM `T`
> GROUP BY `A`
> {code}
> We can find that "group by" in subquery was dropped which may cause SqlNode 
> converted by RelNode being not equivalent to RelNode.
> After debugging, I've found code 
> at 
> https://github.com/apache/calcite/blob/aa98c1575762718b238af8ddd44a390607de7602/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java#L333
>  
> calls org.apache.calcite.rel.rel2sql.SqlImplementor.Builder#setGroupBy 
> without judge whether "group by" already exists.
> Finally, I think in this case, the main select and sub-select shouldn't be 
> merged.



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


[jira] [Commented] (CALCITE-3466) JDBC adapter dropped group by statement in subquery

2019-11-01 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16964631#comment-16964631
 ] 

Wang Weidong commented on CALCITE-3466:
---

Hi, [~yanlin-Lynn]
I don't agree with your deduction. We can see this case in mysql.
 !screenshot-1.png! 
The result of these two sqls if not the same.

> JDBC adapter dropped group by statement in subquery
> ---
>
> Key: CALCITE-3466
> URL: https://issues.apache.org/jira/browse/CALCITE-3466
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0, 1.22.0
>Reporter: Wang Weidong
>Priority: Major
> Fix For: 1.22.0
>
> Attachments: screenshot-1.png
>
>
> While convert RelNode to SqlNode, the "group by" statement in subquery was 
> dropped unexpectedly. For example,
> original sql is:
> {code:sql}
> select a, avg(c1) from 
> (
> select a,sum(d),b as c1 from t group by b,a
> ) as t 
> group by a
> {code}
> RelNode converted by SqlNode is 
> {code:sql}
> LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
>   LogicalProject(A=[$1], C1=[$0])
> LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
>   LogicalProject(B=[$1], A=[$0], D=[$3])
> EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
> {code}
> And then convert this RelNode to SqlNode, the sql of SqlNode is like this:
> {code:sql}
> SELECT `A`, AVG(`B`)
> FROM `T`
> GROUP BY `A`
> {code}
> We can find that "group by" in subquery was dropped which may cause SqlNode 
> converted by RelNode being not equivalent to RelNode.
> After debugging, I've found code 
> at 
> https://github.com/apache/calcite/blob/aa98c1575762718b238af8ddd44a390607de7602/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java#L333
>  
> calls org.apache.calcite.rel.rel2sql.SqlImplementor.Builder#setGroupBy 
> without judge whether "group by" already exists.
> Finally, I think in this case, the main select and sub-select shouldn't be 
> merged.



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


[jira] [Updated] (CALCITE-3466) JDBC adapter dropped group by statement in subquery

2019-11-01 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3466:
--
Attachment: screenshot-1.png

> JDBC adapter dropped group by statement in subquery
> ---
>
> Key: CALCITE-3466
> URL: https://issues.apache.org/jira/browse/CALCITE-3466
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0, 1.22.0
>Reporter: Wang Weidong
>Priority: Major
> Fix For: 1.22.0
>
> Attachments: screenshot-1.png
>
>
> While convert RelNode to SqlNode, the "group by" statement in subquery was 
> dropped unexpectedly. For example,
> original sql is:
> {code:sql}
> select a, avg(c1) from 
> (
> select a,sum(d),b as c1 from t group by b,a
> ) as t 
> group by a
> {code}
> RelNode converted by SqlNode is 
> {code:sql}
> LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
>   LogicalProject(A=[$1], C1=[$0])
> LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
>   LogicalProject(B=[$1], A=[$0], D=[$3])
> EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
> {code}
> And then convert this RelNode to SqlNode, the sql of SqlNode is like this:
> {code:sql}
> SELECT `A`, AVG(`B`)
> FROM `T`
> GROUP BY `A`
> {code}
> We can find that "group by" in subquery was dropped which may cause SqlNode 
> converted by RelNode being not equivalent to RelNode.
> After debugging, I've found code 
> at 
> https://github.com/apache/calcite/blob/aa98c1575762718b238af8ddd44a390607de7602/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java#L333
>  
> calls org.apache.calcite.rel.rel2sql.SqlImplementor.Builder#setGroupBy 
> without judge whether "group by" already exists.
> Finally, I think in this case, the main select and sub-select shouldn't be 
> merged.



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


[jira] [Updated] (CALCITE-3466) JDBC adapter dropped group by statement in subquery

2019-10-31 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3466:
--
Description: 
While convert RelNode to SqlNode, the "group by" statement in subquery was 
dropped unexpectedly. For example,
original sql is:

{code:sql}
select a, avg(c1) from 
(
select a,sum(d),b as c1 from t group by b,a
) as t 
group by a
{code}

RelNode converted by SqlNode is 

{code:sql}
LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
  LogicalProject(A=[$1], C1=[$0])
LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
  LogicalProject(B=[$1], A=[$0], D=[$3])
EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
{code}

And then convert this RelNode to SqlNode, the sql of SqlNode is like this:

{code:sql}
SELECT `A`, AVG(`B`)
FROM `T`
GROUP BY `A`
{code}

We can find that "group by" in subquery was dropped which may cause SqlNode 
converted by RelNode being not equivalent to RelNode.

After debugging, I've found code 
at 
https://github.com/apache/calcite/blob/aa98c1575762718b238af8ddd44a390607de7602/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java#L333
 
calls org.apache.calcite.rel.rel2sql.SqlImplementor.Builder#setGroupBy without 
judge whether "group by" already exists.
Finally, I think in this case, the main select and sub-select shouldn't be 
merged.



  was:
While convert RelNode to SqlNode, the "group by" statement in subquery was 
dropped unexpectedly. For example,
original sql is:

{code:sql}
select a, avg(c1) from 
(
select a,sum(d),b as c1 from t group by b,a
) as t 
group by a
{code}

RelNode converted by SqlNode is 

{code:sql}
LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
  LogicalProject(A=[$1], C1=[$0])
LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
  LogicalProject(B=[$1], A=[$0], D=[$3])
EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
{code}

And then convert this RelNode to SqlNode, the sql of SqlNode is like this:

{code:sql}
SELECT `A`, AVG(`B`)
FROM `T`
GROUP BY `A`
{code}

We can find that "group by" in subquery was dropped which may cause SqlNode 
converted by RelNode being not equivalent to RelNode.




> JDBC adapter dropped group by statement in subquery
> ---
>
> Key: CALCITE-3466
> URL: https://issues.apache.org/jira/browse/CALCITE-3466
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0, 1.22.0
>Reporter: Wang Weidong
>Priority: Major
> Fix For: 1.22.0
>
>
> While convert RelNode to SqlNode, the "group by" statement in subquery was 
> dropped unexpectedly. For example,
> original sql is:
> {code:sql}
> select a, avg(c1) from 
> (
> select a,sum(d),b as c1 from t group by b,a
> ) as t 
> group by a
> {code}
> RelNode converted by SqlNode is 
> {code:sql}
> LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
>   LogicalProject(A=[$1], C1=[$0])
> LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
>   LogicalProject(B=[$1], A=[$0], D=[$3])
> EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
> {code}
> And then convert this RelNode to SqlNode, the sql of SqlNode is like this:
> {code:sql}
> SELECT `A`, AVG(`B`)
> FROM `T`
> GROUP BY `A`
> {code}
> We can find that "group by" in subquery was dropped which may cause SqlNode 
> converted by RelNode being not equivalent to RelNode.
> After debugging, I've found code 
> at 
> https://github.com/apache/calcite/blob/aa98c1575762718b238af8ddd44a390607de7602/core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java#L333
>  
> calls org.apache.calcite.rel.rel2sql.SqlImplementor.Builder#setGroupBy 
> without judge whether "group by" already exists.
> Finally, I think in this case, the main select and sub-select shouldn't be 
> merged.



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


[jira] [Updated] (CALCITE-3466) JDBC adapter dropped group by statement in subquery

2019-10-31 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3466:
--
Description: 
While convert RelNode to SqlNode, the "group by" statement in subquery was 
dropped unexpectedly. For example,
original sql is:

{code:sql}
select a, avg(c1) from 
(
select a,sum(d),b as c1 from t group by b,a
) as t 
group by a
{code}

RelNode converted by SqlNode is 

{code:sql}
LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
  LogicalProject(A=[$1], C1=[$0])
LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
  LogicalProject(B=[$1], A=[$0], D=[$3])
EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
{code}

And then convert this RelNode to SqlNode, the sql of SqlNode is like this:

{code:sql}
SELECT `A`, AVG(`B`)
FROM `T`
GROUP BY `A`
{code}

We can find that "group by" in subquery was dropped which may cause SqlNode 
converted by RelNode being not equivalent to RelNode.



  was:
While convert RelNode to SqlNode, the "group by" statement in subquery was 
dropped unexpectedly. For example,
original sql is:

{code:sql}
select a, avg(c1) from (select a,sum(d),b as c1 from t_testProjectMerge group 
by b,a) as t group by a
{code}

RelNode converted by SqlNode is 

{code:sql}
LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
  LogicalProject(A=[$1], C1=[$0])
LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
  LogicalProject(B=[$1], A=[$0], D=[$3])
EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
{code}

_


> JDBC adapter dropped group by statement in subquery
> ---
>
> Key: CALCITE-3466
> URL: https://issues.apache.org/jira/browse/CALCITE-3466
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0, 1.22.0
>Reporter: Wang Weidong
>Priority: Major
> Fix For: 1.22.0
>
>
> While convert RelNode to SqlNode, the "group by" statement in subquery was 
> dropped unexpectedly. For example,
> original sql is:
> {code:sql}
> select a, avg(c1) from 
> (
> select a,sum(d),b as c1 from t group by b,a
> ) as t 
> group by a
> {code}
> RelNode converted by SqlNode is 
> {code:sql}
> LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
>   LogicalProject(A=[$1], C1=[$0])
> LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
>   LogicalProject(B=[$1], A=[$0], D=[$3])
> EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
> {code}
> And then convert this RelNode to SqlNode, the sql of SqlNode is like this:
> {code:sql}
> SELECT `A`, AVG(`B`)
> FROM `T`
> GROUP BY `A`
> {code}
> We can find that "group by" in subquery was dropped which may cause SqlNode 
> converted by RelNode being not equivalent to RelNode.



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


[jira] [Updated] (CALCITE-3466) JDBC adapter dropped group by statement in subquery

2019-10-31 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3466:
--
Description: 
While convert RelNode to SqlNode, the "group by" statement in subquery was 
dropped unexpectedly. For example,
original sql is:

{code:sql}
select a, avg(c1) from (select a,sum(d),b as c1 from t_testProjectMerge group 
by b,a) as t group by a
{code}

RelNode converted by SqlNode is 

{code:txt}
_LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
  LogicalProject(A=[$1], C1=[$0])
LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
  LogicalProject(B=[$1], A=[$0], D=[$3])
EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
{code}

_

  was:
While convert RelNode to SqlNode, the "group by" statement in subquery was 
dropped unexpectedly. For example,
original sql is:

{code:sql}
select a, avg(c1) from (select a,sum(d),b as c1 from t_testProjectMerge group 
by b,a) as t group by a
{code}

RelNode converted by SqlNode is 

{code:text}
_LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
  LogicalProject(A=[$1], C1=[$0])
LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
  LogicalProject(B=[$1], A=[$0], D=[$3])
EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
{code}

_


> JDBC adapter dropped group by statement in subquery
> ---
>
> Key: CALCITE-3466
> URL: https://issues.apache.org/jira/browse/CALCITE-3466
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0, 1.22.0
>Reporter: Wang Weidong
>Priority: Major
> Fix For: 1.22.0
>
>
> While convert RelNode to SqlNode, the "group by" statement in subquery was 
> dropped unexpectedly. For example,
> original sql is:
> {code:sql}
> select a, avg(c1) from (select a,sum(d),b as c1 from t_testProjectMerge group 
> by b,a) as t group by a
> {code}
> RelNode converted by SqlNode is 
> {code:txt}
> _LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
>   LogicalProject(A=[$1], C1=[$0])
> LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
>   LogicalProject(B=[$1], A=[$0], D=[$3])
> EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
> {code}
> _



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


[jira] [Updated] (CALCITE-3466) JDBC adapter dropped group by statement in subquery

2019-10-31 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3466:
--
Description: 
While convert RelNode to SqlNode, the "group by" statement in subquery was 
dropped unexpectedly. For example,
original sql is:

{code:sql}
select a, avg(c1) from (select a,sum(d),b as c1 from t_testProjectMerge group 
by b,a) as t group by a
{code}

RelNode converted by SqlNode is 

{code:sql}
LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
  LogicalProject(A=[$1], C1=[$0])
LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
  LogicalProject(B=[$1], A=[$0], D=[$3])
EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
{code}

_

  was:
While convert RelNode to SqlNode, the "group by" statement in subquery was 
dropped unexpectedly. For example,
original sql is:

{code:sql}
select a, avg(c1) from (select a,sum(d),b as c1 from t_testProjectMerge group 
by b,a) as t group by a
{code}

RelNode converted by SqlNode is 

{code:txt}
_LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
  LogicalProject(A=[$1], C1=[$0])
LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
  LogicalProject(B=[$1], A=[$0], D=[$3])
EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
{code}

_


> JDBC adapter dropped group by statement in subquery
> ---
>
> Key: CALCITE-3466
> URL: https://issues.apache.org/jira/browse/CALCITE-3466
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0, 1.22.0
>Reporter: Wang Weidong
>Priority: Major
> Fix For: 1.22.0
>
>
> While convert RelNode to SqlNode, the "group by" statement in subquery was 
> dropped unexpectedly. For example,
> original sql is:
> {code:sql}
> select a, avg(c1) from (select a,sum(d),b as c1 from t_testProjectMerge group 
> by b,a) as t group by a
> {code}
> RelNode converted by SqlNode is 
> {code:sql}
> LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
>   LogicalProject(A=[$1], C1=[$0])
> LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
>   LogicalProject(B=[$1], A=[$0], D=[$3])
> EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
> {code}
> _



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


[jira] [Updated] (CALCITE-3466) JDBC adapter dropped group by statement in subquery

2019-10-31 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3466:
--
Description: 
While convert RelNode to SqlNode, the "group by" statement in subquery was 
dropped unexpectedly. For example,
original sql is:

{code:sql}
select a, avg(c1) from (select a,sum(d),b as c1 from t_testProjectMerge group 
by b,a) as t group by a
{code}

RelNode converted by SqlNode is 

{code:text}
_LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
  LogicalProject(A=[$1], C1=[$0])
LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
  LogicalProject(B=[$1], A=[$0], D=[$3])
EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
{code}

_

  was:
While convert RelNode to SqlNode, the "group by" statement in subquery was 
dropped unexpectedly. For example,
original sql is:
_select a, avg(c1) from (select a,sum(d),b as c1 from t_testProjectMerge group 
by b,a) as t group by a_
RelNode converted by SqlNode is 
_LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
  LogicalProject(A=[$1], C1=[$0])
LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
  LogicalProject(B=[$1], A=[$0], D=[$3])
EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
_


> JDBC adapter dropped group by statement in subquery
> ---
>
> Key: CALCITE-3466
> URL: https://issues.apache.org/jira/browse/CALCITE-3466
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0, 1.22.0
>Reporter: Wang Weidong
>Priority: Major
> Fix For: 1.22.0
>
>
> While convert RelNode to SqlNode, the "group by" statement in subquery was 
> dropped unexpectedly. For example,
> original sql is:
> {code:sql}
> select a, avg(c1) from (select a,sum(d),b as c1 from t_testProjectMerge group 
> by b,a) as t group by a
> {code}
> RelNode converted by SqlNode is 
> {code:text}
> _LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
>   LogicalProject(A=[$1], C1=[$0])
> LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
>   LogicalProject(B=[$1], A=[$0], D=[$3])
> EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
> {code}
> _



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


[jira] [Created] (CALCITE-3466) JDBC adapter dropped group by statement in subquery

2019-10-31 Thread Wang Weidong (Jira)
Wang Weidong created CALCITE-3466:
-

 Summary: JDBC adapter dropped group by statement in subquery
 Key: CALCITE-3466
 URL: https://issues.apache.org/jira/browse/CALCITE-3466
 Project: Calcite
  Issue Type: Bug
  Components: core
Affects Versions: 1.21.0, 1.22.0
Reporter: Wang Weidong
 Fix For: 1.22.0


While convert RelNode to SqlNode, the "group by" statement in subquery was 
dropped unexpectedly. For example,
original sql is:
_select a, avg(c1) from (select a,sum(d),b as c1 from t_testProjectMerge group 
by b,a) as t group by a_
RelNode converted by SqlNode is 
_LogicalAggregate(group=[{0}], EXPR$1=[AVG($1)])
  LogicalProject(A=[$1], C1=[$0])
LogicalAggregate(group=[{0, 1}], EXPR$1=[SUM($2)])
  LogicalProject(B=[$1], A=[$0], D=[$3])
EnumerableTableScan(table=[[T_TESTPROJECTMERGE]])
_



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


[jira] [Commented] (CALCITE-3299) Replace star identifier as select list of if no operands given while in the method "createCall"

2019-10-31 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3299?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16963700#comment-16963700
 ] 

Wang Weidong commented on CALCITE-3299:
---

Anyone response this issue? 

> Replace star identifier as select list of  if no operands given while in the 
> method "createCall"
> 
>
> Key: CALCITE-3299
> URL: https://issues.apache.org/jira/browse/CALCITE-3299
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>
> h4. Procedure to reproduce the problem:
>  - create table {{~^t^~}}
>  - parse query  ^{{~select * from t~}}^ to SqlNode
>  - convert SqlNode to RelNode
>  - convert RelNode to SqlNode
>  - validate the result SqlNode
> test code is like this
> {code:java}
> // code placeholder
> @Test
> public void testSelectAll() throws Exception {
>   try (Statement s = parserContext.getStatement()) {
> s.execute("create table if not exists t (i int not null)");
> String sql = "select * from t";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> parserContext.getSqlValidator().validate(sqlNode);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> parserContext.getSqlValidator().validate(sqlNodeNew);
>   }
> }
> {code}
> Finally we will get an exception as follow:
> {code:java}
> // code placeholder
> org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectorg.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectjava.lang.NullPointerException
>  at org.apache.calcite.sql.validate.AggFinder.findAgg(AggFinder.java:58) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.getAgg(SqlValidatorImpl.java:2774)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.getAggregate(SqlValidatorImpl.java:2761)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.isAggregate(SqlValidatorImpl.java:2720)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2406)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2326)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:916)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
>  at org.apache.calcite.test.OptimizeTest.testSelectAll(OptimizeTest.java:206) 
> 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: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.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
>  at org.junit.rules.RunRules.evaluate(RunRules.java:20) 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){code}
>  
> After debugging, I found that the *main causes* of this exception are as 
> follows.
> First, while converting RelNode to SqlNode, in the method 
> {{~{color:#172b4d}^org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelect^{color}~}}
>  
> 

[jira] [Commented] (CALCITE-3300) In JDBC adapter, when generating SQL for count star, generates the star argument of the call

2019-10-23 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16957886#comment-16957886
 ] 

Wang Weidong commented on CALCITE-3300:
---

[~danny0405] OK.Asking by the way, have you remove the testing code of checking 
'star' parameter of 'count' ? 

> In JDBC adapter, when generating SQL for count star, generates the star 
> argument of the call
> 
>
> Key: CALCITE-3300
> URL: https://issues.apache.org/jira/browse/CALCITE-3300
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Danny Chen
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.22.0
>
>  Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> h4. Procedure to reproduce the problem:
>  - create table {{~^t^~}}
>  - parse query  select count(*) from t to SqlNode
>  - convert SqlNode to RelNode
>  - convert RelNode to SqlNode
>  - validate the result SqlNode
> test code is like this
> {code:java}
> // code placeholder
> @Test
> public void testSelectCountAll() throws Exception {
>   try (Statement s = parserContext.getStatement()) {
> s.execute("create table if not exists t (i int not null)");
> String sql = "select count(*) from t";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> parserContext.getSqlValidator().validate(sqlNode);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> parserContext.getSqlValidator().validate(sqlNodeNew);
>   }
> }
> {code}
> Finally we will get an exception as follow:
> {code:java}
> // code placeholder
> org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
> Invalid number of arguments to function 'COUNT'. Was expecting 1 
> argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, 
> column 0: Invalid number of arguments to function 'COUNT'. Was expecting 1 
> arguments at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> Method) at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>  at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>  at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) 
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
> org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
>  at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
> org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
> org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
>  at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
>  at 
> org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
>  at 
> org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:967)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:943)
>  at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:918)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
>  at 
> org.apache.calcite.test.OptimizeTest.testSelectCountAll(OptimizeTest.java:220)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
> at 
> 

[jira] [Commented] (CALCITE-3300) Add a star identifier as operand to "SqlCountAggFunction" if no operands given while in the method "createCall"

2019-10-17 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16953562#comment-16953562
 ] 

Wang Weidong commented on CALCITE-3300:
---

[~danny0405]  Thanks for you suggestions, I will fix my code later.

> Add a star identifier as operand to "SqlCountAggFunction" if no operands 
> given while in the method "createCall"
> ---
>
> Key: CALCITE-3300
> URL: https://issues.apache.org/jira/browse/CALCITE-3300
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> h4. Procedure to reproduce the problem:
>  - create table {{~^t^~}}
>  - parse query  select count(*) from t to SqlNode
>  - convert SqlNode to RelNode
>  - convert RelNode to SqlNode
>  - validate the result SqlNode
> test code is like this
> {code:java}
> // code placeholder
> @Test
> public void testSelectCountAll() throws Exception {
>   try (Statement s = parserContext.getStatement()) {
> s.execute("create table if not exists t (i int not null)");
> String sql = "select count(*) from t";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> parserContext.getSqlValidator().validate(sqlNode);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> parserContext.getSqlValidator().validate(sqlNodeNew);
>   }
> }
> {code}
> Finally we will get an exception as follow:
> {code:java}
> // code placeholder
> org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
> Invalid number of arguments to function 'COUNT'. Was expecting 1 
> argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, 
> column 0: Invalid number of arguments to function 'COUNT'. Was expecting 1 
> arguments at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> Method) at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>  at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>  at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) 
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
> org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
>  at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
> org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
> org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
>  at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
>  at 
> org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
>  at 
> org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:967)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:943)
>  at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:918)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
>  at 
> org.apache.calcite.test.OptimizeTest.testSelectCountAll(OptimizeTest.java:220)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
> at 
> 

[jira] [Comment Edited] (CALCITE-3300) Add a star identifier as operand to "SqlCountAggFunction" if no operands given while in the method "createCall"

2019-10-17 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16924714#comment-16924714
 ] 

Wang Weidong edited comment on CALCITE-3300 at 10/17/19 9:33 AM:
-

I support to standardize "assertThat".

If COUNT() is identical to COUNT(\*), can we solve this problem during 
validating? 

About test code.

“exec0” is a bad name which should be renamed.

Indentation change is because of format of IDE and no error is reported while 
style checking, so is it not correct to change it ?  




was (Author: wangweidong):
I support to standardize "assertThat".

If COUNT() is identical to COUNT(\*), can we solve this problem during 
validating? 

About test code.

“exec0” is a bad name which should be renamed.

Indentation change is because of format of IDE and no error is reported while 
style checking, so is it not correct to change it ?  

I thought you are a gentleman before but found "garbage"  about what you'd said.

> Add a star identifier as operand to "SqlCountAggFunction" if no operands 
> given while in the method "createCall"
> ---
>
> Key: CALCITE-3300
> URL: https://issues.apache.org/jira/browse/CALCITE-3300
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> h4. Procedure to reproduce the problem:
>  - create table {{~^t^~}}
>  - parse query  select count(*) from t to SqlNode
>  - convert SqlNode to RelNode
>  - convert RelNode to SqlNode
>  - validate the result SqlNode
> test code is like this
> {code:java}
> // code placeholder
> @Test
> public void testSelectCountAll() throws Exception {
>   try (Statement s = parserContext.getStatement()) {
> s.execute("create table if not exists t (i int not null)");
> String sql = "select count(*) from t";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> parserContext.getSqlValidator().validate(sqlNode);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> parserContext.getSqlValidator().validate(sqlNodeNew);
>   }
> }
> {code}
> Finally we will get an exception as follow:
> {code:java}
> // code placeholder
> org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
> Invalid number of arguments to function 'COUNT'. Was expecting 1 
> argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, 
> column 0: Invalid number of arguments to function 'COUNT'. Was expecting 1 
> arguments at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> Method) at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>  at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>  at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) 
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
> org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
>  at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
> org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
> org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
>  at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
>  at 
> org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
>  at 
> org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>  at 
> 

[jira] [Comment Edited] (CALCITE-3300) Add a star identifier as operand to "SqlCountAggFunction" if no operands given while in the method "createCall"

2019-10-09 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16948167#comment-16948167
 ] 

Wang Weidong edited comment on CALCITE-3300 at 10/10/19 3:31 AM:
-

[~julianhyde] Will you reply my discussion ? 


was (Author: wangweidong):
[~julianhyde] Will reply my discussion ? 

> Add a star identifier as operand to "SqlCountAggFunction" if no operands 
> given while in the method "createCall"
> ---
>
> Key: CALCITE-3300
> URL: https://issues.apache.org/jira/browse/CALCITE-3300
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> h4. Procedure to reproduce the problem:
>  - create table {{~^t^~}}
>  - parse query  select count(*) from t to SqlNode
>  - convert SqlNode to RelNode
>  - convert RelNode to SqlNode
>  - validate the result SqlNode
> test code is like this
> {code:java}
> // code placeholder
> @Test
> public void testSelectCountAll() throws Exception {
>   try (Statement s = parserContext.getStatement()) {
> s.execute("create table if not exists t (i int not null)");
> String sql = "select count(*) from t";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> parserContext.getSqlValidator().validate(sqlNode);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> parserContext.getSqlValidator().validate(sqlNodeNew);
>   }
> }
> {code}
> Finally we will get an exception as follow:
> {code:java}
> // code placeholder
> org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
> Invalid number of arguments to function 'COUNT'. Was expecting 1 
> argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, 
> column 0: Invalid number of arguments to function 'COUNT'. Was expecting 1 
> arguments at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> Method) at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>  at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>  at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) 
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
> org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
>  at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
> org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
> org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
>  at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
>  at 
> org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
>  at 
> org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:967)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:943)
>  at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:918)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
>  at 
> org.apache.calcite.test.OptimizeTest.testSelectCountAll(OptimizeTest.java:220)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at 
> 

[jira] [Commented] (CALCITE-3300) Add a star identifier as operand to "SqlCountAggFunction" if no operands given while in the method "createCall"

2019-10-09 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16948167#comment-16948167
 ] 

Wang Weidong commented on CALCITE-3300:
---

[~julianhyde] Will reply my discussion ? 

> Add a star identifier as operand to "SqlCountAggFunction" if no operands 
> given while in the method "createCall"
> ---
>
> Key: CALCITE-3300
> URL: https://issues.apache.org/jira/browse/CALCITE-3300
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> h4. Procedure to reproduce the problem:
>  - create table {{~^t^~}}
>  - parse query  select count(*) from t to SqlNode
>  - convert SqlNode to RelNode
>  - convert RelNode to SqlNode
>  - validate the result SqlNode
> test code is like this
> {code:java}
> // code placeholder
> @Test
> public void testSelectCountAll() throws Exception {
>   try (Statement s = parserContext.getStatement()) {
> s.execute("create table if not exists t (i int not null)");
> String sql = "select count(*) from t";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> parserContext.getSqlValidator().validate(sqlNode);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> parserContext.getSqlValidator().validate(sqlNodeNew);
>   }
> }
> {code}
> Finally we will get an exception as follow:
> {code:java}
> // code placeholder
> org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
> Invalid number of arguments to function 'COUNT'. Was expecting 1 
> argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, 
> column 0: Invalid number of arguments to function 'COUNT'. Was expecting 1 
> arguments at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> Method) at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>  at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>  at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) 
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
> org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
>  at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
> org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
> org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
>  at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
>  at 
> org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
>  at 
> org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:967)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:943)
>  at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:918)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
>  at 
> org.apache.calcite.test.OptimizeTest.testSelectCountAll(OptimizeTest.java:220)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
> at 
> 

[jira] [Comment Edited] (CALCITE-3300) Add a star identifier as operand to "SqlCountAggFunction" if no operands given while in the method "createCall"

2019-09-06 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16924714#comment-16924714
 ] 

Wang Weidong edited comment on CALCITE-3300 at 9/7/19 3:54 AM:
---

I support to standardize "assertThat".

If COUNT() is identical to COUNT(\*), can we solve this problem during 
validating? 

About test code.

“exec0” is a bad name which should be renamed.

Indentation change is because of format of IDE and no error is reported while 
style checking, so is it not correct to change it ?  

I thought you are a gentleman before but found "garbage"  about what you'd said.


was (Author: wangweidong):
I support to standardize "assertThat".

If COUNT() is identical to COUNT(*), can we solve this problem during 
validating? 

About test code.

“exec0” is a bad name which should be renamed.

Indentation change is because of format of IDE and no error is reported while 
style checking, so is it not correct to change it ?  

I thought you are a gentleman before but found "garbage"  about what you'd said.

> Add a star identifier as operand to "SqlCountAggFunction" if no operands 
> given while in the method "createCall"
> ---
>
> Key: CALCITE-3300
> URL: https://issues.apache.org/jira/browse/CALCITE-3300
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> h4. Procedure to reproduce the problem:
>  - create table {{~^t^~}}
>  - parse query  select count(*) from t to SqlNode
>  - convert SqlNode to RelNode
>  - convert RelNode to SqlNode
>  - validate the result SqlNode
> test code is like this
> {code:java}
> // code placeholder
> @Test
> public void testSelectCountAll() throws Exception {
>   try (Statement s = parserContext.getStatement()) {
> s.execute("create table if not exists t (i int not null)");
> String sql = "select count(*) from t";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> parserContext.getSqlValidator().validate(sqlNode);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> parserContext.getSqlValidator().validate(sqlNodeNew);
>   }
> }
> {code}
> Finally we will get an exception as follow:
> {code:java}
> // code placeholder
> org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
> Invalid number of arguments to function 'COUNT'. Was expecting 1 
> argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, 
> column 0: Invalid number of arguments to function 'COUNT'. Was expecting 1 
> arguments at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> Method) at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>  at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>  at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) 
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
> org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
>  at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
> org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
> org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
>  at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
>  at 
> org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
>  at 
> 

[jira] [Comment Edited] (CALCITE-3300) Add a star identifier as operand to "SqlCountAggFunction" if no operands given while in the method "createCall"

2019-09-06 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16924714#comment-16924714
 ] 

Wang Weidong edited comment on CALCITE-3300 at 9/7/19 3:54 AM:
---

I support to standardize "assertThat".

If COUNT() is identical to COUNT(*), can we solve this problem during 
validating? 

About test code.

“exec0” is a bad name which should be renamed.

Indentation change is because of format of IDE and no error is reported while 
style checking, so is it not correct to change it ?  

I thought you are a gentleman before but found "garbage"  about what you'd said.


was (Author: wangweidong):
I support to standardize "assertThat".

If COUNT() is identical to COUNT(*), can we solve this problem during 
validating? 

About test code.

“exec0” is a bad name which should be renamed.

Indentation change is because of format of IDE and no error is reported while 
style checking, so is it not correct to change it ?  

I thought you are a gentleman before but found "garbage"  about what you'd said.

> Add a star identifier as operand to "SqlCountAggFunction" if no operands 
> given while in the method "createCall"
> ---
>
> Key: CALCITE-3300
> URL: https://issues.apache.org/jira/browse/CALCITE-3300
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> h4. Procedure to reproduce the problem:
>  - create table {{~^t^~}}
>  - parse query  select count(*) from t to SqlNode
>  - convert SqlNode to RelNode
>  - convert RelNode to SqlNode
>  - validate the result SqlNode
> test code is like this
> {code:java}
> // code placeholder
> @Test
> public void testSelectCountAll() throws Exception {
>   try (Statement s = parserContext.getStatement()) {
> s.execute("create table if not exists t (i int not null)");
> String sql = "select count(*) from t";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> parserContext.getSqlValidator().validate(sqlNode);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> parserContext.getSqlValidator().validate(sqlNodeNew);
>   }
> }
> {code}
> Finally we will get an exception as follow:
> {code:java}
> // code placeholder
> org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
> Invalid number of arguments to function 'COUNT'. Was expecting 1 
> argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, 
> column 0: Invalid number of arguments to function 'COUNT'. Was expecting 1 
> arguments at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> Method) at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>  at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>  at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) 
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
> org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
>  at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
> org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
> org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
>  at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
>  at 
> org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
>  at 
> 

[jira] [Commented] (CALCITE-3300) Add a star identifier as operand to "SqlCountAggFunction" if no operands given while in the method "createCall"

2019-09-06 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16924714#comment-16924714
 ] 

Wang Weidong commented on CALCITE-3300:
---

I support to standardize "assertThat".

If COUNT() is identical to COUNT(*), can we solve this problem during 
validating? 

About test code.

“exec0” is a bad name which should be renamed.

Indentation change is because of format of IDE and no error is reported while 
style checking, so is it not correct to change it ?  

I thought you are a gentleman before but found "garbage"  about what you'd said.

> Add a star identifier as operand to "SqlCountAggFunction" if no operands 
> given while in the method "createCall"
> ---
>
> Key: CALCITE-3300
> URL: https://issues.apache.org/jira/browse/CALCITE-3300
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> h4. Procedure to reproduce the problem:
>  - create table {{~^t^~}}
>  - parse query  select count(*) from t to SqlNode
>  - convert SqlNode to RelNode
>  - convert RelNode to SqlNode
>  - validate the result SqlNode
> test code is like this
> {code:java}
> // code placeholder
> @Test
> public void testSelectCountAll() throws Exception {
>   try (Statement s = parserContext.getStatement()) {
> s.execute("create table if not exists t (i int not null)");
> String sql = "select count(*) from t";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> parserContext.getSqlValidator().validate(sqlNode);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> parserContext.getSqlValidator().validate(sqlNodeNew);
>   }
> }
> {code}
> Finally we will get an exception as follow:
> {code:java}
> // code placeholder
> org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
> Invalid number of arguments to function 'COUNT'. Was expecting 1 
> argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, 
> column 0: Invalid number of arguments to function 'COUNT'. Was expecting 1 
> arguments at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> Method) at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>  at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>  at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) 
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
> org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
>  at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
> org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
> org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
>  at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
>  at 
> org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
>  at 
> org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:967)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:943)
>  at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:918)
>  at 
> 

[jira] [Comment Edited] (CALCITE-3300) Add a star identifier as operand to "SqlCountAggFunction" if no operands given while in the method "createCall"

2019-09-03 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16921378#comment-16921378
 ] 

Wang Weidong edited comment on CALCITE-3300 at 9/3/19 12:11 PM:


[~julianhyde] 
 * "I don't think you should make {{SqlCountAggFunction}} "fix itself"; some 
caller might conceivably *really* want zero arguments; the bug is in 
{{RelToSqlConverter}} and that is the place I think you should fix."
 ** It may be better to fix this bug in {{RelToSqlConverter, but the problem is 
that we cannot distinguish whether "count" with no arguments means "count star" 
or not. With fixing in }}{{SqlCountAggFunction, }}{{"count" with no arguments 
only means "count star". How do you think about this? }}{{}}
 * Please use {{assertThat}} rather than {{assertEquals}} to {{assertTrue}}
 ** I've found that there is almost {{assertThat everywhere, but in some 
situations, it's obviously more convenient to use }}{{assertEquals or 
}}{{assertTrue, why is }}{{assertThat the only alternative? }}{{}}
 * Are the other changes to {{RelToSqlConverterTest}} necessary?
 ** That is because the I need to get SqlNode to check whether there is "count 
star" but I did not found any available methods or classes to use.


was (Author: wangweidong):
[~julianhyde] 
 * "I don't think you should make {{SqlCountAggFunction}} "fix itself"; some 
caller might conceivably *really* want zero arguments; the bug is in 
{{RelToSqlConverter}} and that is the place I think you should fix."
 ** It may be better to fix this bug in {{RelToSqlConverter, but the problem is 
that we cannot distinguish whether "count" with no arguments means "count star" 
or not. With fixing }}{{SqlCountAggFunction in, }}{{"count" with no arguments 
only means "count star". How do you think about this? }}{{}}
 * Please use {{assertThat}} rather than {{assertEquals}} to {{assertTrue}}
 ** I've found that there is almost {{assertThat everywhere, but in some 
situations, it's obviously more convenient to use }}{{assertEquals or 
}}{{assertTrue, why is }}{{assertThat the only alternative? }}{{}}
 * Are the other changes to {{RelToSqlConverterTest}} necessary?
 ** That is because the I need to get SqlNode to check whether there is "count 
star" but I did not found any available methods or classes to use.

> Add a star identifier as operand to "SqlCountAggFunction" if no operands 
> given while in the method "createCall"
> ---
>
> Key: CALCITE-3300
> URL: https://issues.apache.org/jira/browse/CALCITE-3300
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> h4. Procedure to reproduce the problem:
>  - create table {{~^t^~}}
>  - parse query  select count(*) from t to SqlNode
>  - convert SqlNode to RelNode
>  - convert RelNode to SqlNode
>  - validate the result SqlNode
> test code is like this
> {code:java}
> // code placeholder
> @Test
> public void testSelectCountAll() throws Exception {
>   try (Statement s = parserContext.getStatement()) {
> s.execute("create table if not exists t (i int not null)");
> String sql = "select count(*) from t";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> parserContext.getSqlValidator().validate(sqlNode);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> parserContext.getSqlValidator().validate(sqlNodeNew);
>   }
> }
> {code}
> Finally we will get an exception as follow:
> {code:java}
> // code placeholder
> org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
> Invalid number of arguments to function 'COUNT'. Was expecting 1 
> argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, 
> column 0: Invalid number of arguments to function 'COUNT'. Was expecting 1 
> arguments at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> Method) at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>  at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>  at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) 
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
> org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
>  at 
> 

[jira] [Commented] (CALCITE-3300) Add a star identifier as operand to "SqlCountAggFunction" if no operands given while in the method "createCall"

2019-09-03 Thread Wang Weidong (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-3300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16921378#comment-16921378
 ] 

Wang Weidong commented on CALCITE-3300:
---

[~julianhyde] 
 * "I don't think you should make {{SqlCountAggFunction}} "fix itself"; some 
caller might conceivably *really* want zero arguments; the bug is in 
{{RelToSqlConverter}} and that is the place I think you should fix."
 ** It may be better to fix this bug in {{RelToSqlConverter, but the problem is 
that we cannot distinguish whether "count" with no arguments means "count star" 
or not. With fixing }}{{SqlCountAggFunction in, }}{{"count" with no arguments 
only means "count star". How do you think about this? }}{{}}
 * Please use {{assertThat}} rather than {{assertEquals}} to {{assertTrue}}
 ** I've found that there is almost {{assertThat everywhere, but in some 
situations, it's obviously more convenient to use }}{{assertEquals or 
}}{{assertTrue, why is }}{{assertThat the only alternative? }}{{}}
 * Are the other changes to {{RelToSqlConverterTest}} necessary?
 ** That is because the I need to get SqlNode to check whether there is "count 
star" but I did not found any available methods or classes to use.

> Add a star identifier as operand to "SqlCountAggFunction" if no operands 
> given while in the method "createCall"
> ---
>
> Key: CALCITE-3300
> URL: https://issues.apache.org/jira/browse/CALCITE-3300
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> h4. Procedure to reproduce the problem:
>  - create table {{~^t^~}}
>  - parse query  select count(*) from t to SqlNode
>  - convert SqlNode to RelNode
>  - convert RelNode to SqlNode
>  - validate the result SqlNode
> test code is like this
> {code:java}
> // code placeholder
> @Test
> public void testSelectCountAll() throws Exception {
>   try (Statement s = parserContext.getStatement()) {
> s.execute("create table if not exists t (i int not null)");
> String sql = "select count(*) from t";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> parserContext.getSqlValidator().validate(sqlNode);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> parserContext.getSqlValidator().validate(sqlNodeNew);
>   }
> }
> {code}
> Finally we will get an exception as follow:
> {code:java}
> // code placeholder
> org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
> Invalid number of arguments to function 'COUNT'. Was expecting 1 
> argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, 
> column 0: Invalid number of arguments to function 'COUNT'. Was expecting 1 
> arguments at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> Method) at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>  at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>  at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) 
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
> org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
>  at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
> org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
> org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
>  at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
>  at 
> 

[jira] [Updated] (CALCITE-3299) Replace star identifier as select list of if no operands given while in the method "createCall"

2019-08-29 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3299:
--
Summary: Replace star identifier as select list of  if no operands given 
while in the method "createCall"  (was: Handle validating exception for SqlNode 
of select star converted by RelNode )

> Replace star identifier as select list of  if no operands given while in the 
> method "createCall"
> 
>
> Key: CALCITE-3299
> URL: https://issues.apache.org/jira/browse/CALCITE-3299
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>
> h4. Procedure to reproduce the problem:
>  - create table {{~^t^~}}
>  - parse query  ^{{~select * from t~}}^ to SqlNode
>  - convert SqlNode to RelNode
>  - convert RelNode to SqlNode
>  - validate the result SqlNode
> test code is like this
> {code:java}
> // code placeholder
> @Test
> public void testSelectAll() throws Exception {
>   try (Statement s = parserContext.getStatement()) {
> s.execute("create table if not exists t (i int not null)");
> String sql = "select * from t";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> parserContext.getSqlValidator().validate(sqlNode);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> parserContext.getSqlValidator().validate(sqlNodeNew);
>   }
> }
> {code}
> Finally we will get an exception as follow:
> {code:java}
> // code placeholder
> org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectorg.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectjava.lang.NullPointerException
>  at org.apache.calcite.sql.validate.AggFinder.findAgg(AggFinder.java:58) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.getAgg(SqlValidatorImpl.java:2774)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.getAggregate(SqlValidatorImpl.java:2761)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.isAggregate(SqlValidatorImpl.java:2720)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2406)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2326)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:916)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
>  at org.apache.calcite.test.OptimizeTest.testSelectAll(OptimizeTest.java:206) 
> 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: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.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
>  at org.junit.rules.RunRules.evaluate(RunRules.java:20) 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){code}
>  
> After debugging, I found that the *main causes* of this exception are as 
> follows.
> First, while converting RelNode to SqlNode, in the method 
> 

[jira] [Assigned] (CALCITE-3300) Add a star identifier as operand to "SqlCountAggFunction" if no operands given while in the method "createCall"

2019-08-29 Thread Wang Weidong (Jira)


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

Wang Weidong reassigned CALCITE-3300:
-

Assignee: Wang Weidong

> Add a star identifier as operand to "SqlCountAggFunction" if no operands 
> given while in the method "createCall"
> ---
>
> Key: CALCITE-3300
> URL: https://issues.apache.org/jira/browse/CALCITE-3300
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> h4. Procedure to reproduce the problem:
>  - create table {{~^t^~}}
>  - parse query  select count(*) from t to SqlNode
>  - convert SqlNode to RelNode
>  - convert RelNode to SqlNode
>  - validate the result SqlNode
> test code is like this
> {code:java}
> // code placeholder
> @Test
> public void testSelectCountAll() throws Exception {
>   try (Statement s = parserContext.getStatement()) {
> s.execute("create table if not exists t (i int not null)");
> String sql = "select count(*) from t";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> parserContext.getSqlValidator().validate(sqlNode);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> parserContext.getSqlValidator().validate(sqlNodeNew);
>   }
> }
> {code}
> Finally we will get an exception as follow:
> {code:java}
> // code placeholder
> org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
> Invalid number of arguments to function 'COUNT'. Was expecting 1 
> argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, 
> column 0: Invalid number of arguments to function 'COUNT'. Was expecting 1 
> arguments at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> Method) at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>  at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>  at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) 
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
> org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
>  at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
> org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
> org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
>  at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
>  at 
> org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
>  at 
> org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:967)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:943)
>  at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:918)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
>  at 
> org.apache.calcite.test.OptimizeTest.testSelectCountAll(OptimizeTest.java:220)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  at 

[jira] [Updated] (CALCITE-3300) Add a star identifier as operand to "SqlCountAggFunction" if no operands given while in the method "createCall"

2019-08-29 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3300:
--
Summary: Add a star identifier as operand to "SqlCountAggFunction" if no 
operands given while in the method "createCall"  (was: Handle validating 
exception for SqlNode of count star converted by RelNode)

> Add a star identifier as operand to "SqlCountAggFunction" if no operands 
> given while in the method "createCall"
> ---
>
> Key: CALCITE-3300
> URL: https://issues.apache.org/jira/browse/CALCITE-3300
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
>Reporter: Wang Weidong
>Priority: Major
>
> h4. Procedure to reproduce the problem:
>  - create table {{~^t^~}}
>  - parse query  select count(*) from t to SqlNode
>  - convert SqlNode to RelNode
>  - convert RelNode to SqlNode
>  - validate the result SqlNode
> test code is like this
> {code:java}
> // code placeholder
> @Test
> public void testSelectCountAll() throws Exception {
>   try (Statement s = parserContext.getStatement()) {
> s.execute("create table if not exists t (i int not null)");
> String sql = "select count(*) from t";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> parserContext.getSqlValidator().validate(sqlNode);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> parserContext.getSqlValidator().validate(sqlNodeNew);
>   }
> }
> {code}
> Finally we will get an exception as follow:
> {code:java}
> // code placeholder
> org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
> Invalid number of arguments to function 'COUNT'. Was expecting 1 
> argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, 
> column 0: Invalid number of arguments to function 'COUNT'. Was expecting 1 
> arguments at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> Method) at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>  at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>  at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) 
> at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
> org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
>  at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
> org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
> org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
>  at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
>  at 
> org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
>  at 
> org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:967)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:943)
>  at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225) at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:918)
>  at 
> org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
>  at 
> org.apache.calcite.test.OptimizeTest.testSelectCountAll(OptimizeTest.java:220)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 

[jira] [Updated] (CALCITE-3300) Handle validating exception for SqlNode of count star converted by RelNode

2019-08-28 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3300:
--
Description: 
h4. Procedure to reproduce the problem:
 - create table {{~^t^~}}
 - parse query  select count(*) from t to SqlNode
 - convert SqlNode to RelNode
 - convert RelNode to SqlNode
 - validate the result SqlNode

test code is like this
{code:java}
// code placeholder
@Test
public void testSelectCountAll() throws Exception {
  try (Statement s = parserContext.getStatement()) {
s.execute("create table if not exists t (i int not null)");

String sql = "select count(*) from t";
SqlNode sqlNode = parserContext.parseStmt(sql);
parserContext.getSqlValidator().validate(sqlNode);
RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
SqlNode sqlNodeNew = toSqlNode(relNode);
parserContext.getSqlValidator().validate(sqlNodeNew);
  }
}
{code}
Finally we will get an exception as follow:
{code:java}
// code placeholder
org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
Invalid number of arguments to function 'COUNT'. Was expecting 1 
argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, column 
0: Invalid number of arguments to function 'COUNT'. Was expecting 1 arguments 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) at 
org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
 at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
 at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
 at 
org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
 at 
org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:967)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:943)
 at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:918)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
 at 
org.apache.calcite.test.OptimizeTest.testSelectCountAll(OptimizeTest.java:220) 
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: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.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
 at org.junit.rules.RunRules.evaluate(RunRules.java:20) 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 

[jira] [Updated] (CALCITE-3300) Handle validating exception for SqlNode of count star converted by RelNode

2019-08-28 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3300:
--
Description: 
h4. Procedure to reproduce the problem:
 - create table {{~^t^~}}
 - parse "query  select count(*) from" to SqlNode
 - convert SqlNode to RelNode
 - convert RelNode to SqlNode
 - validate the result SqlNode

test code is like this
{code:java}
// code placeholder
@Test public void testSelectCountAll() throws Exception { try (Statement s = 
parserContext.getStatement()) { s.execute("create table if not exists t (i int 
not null)"); String sql = "select count(*) from t"; SqlNode sqlNode = 
parserContext.parseStmt(sql); 
parserContext.getSqlValidator().validate(sqlNode); RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel; 
SqlNode sqlNodeNew = toSqlNode(relNode); 
parserContext.getSqlValidator().validate(sqlNodeNew); } }
{code}
Finally we will get an exception as follow:
{code:java}
// code placeholder
org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
Invalid number of arguments to function 'COUNT'. Was expecting 1 
argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, column 
0: Invalid number of arguments to function 'COUNT'. Was expecting 1 arguments 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) at 
org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
 at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
 at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
 at 
org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
 at 
org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:967)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:943)
 at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:918)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
 at 
org.apache.calcite.test.OptimizeTest.testSelectCountAll(OptimizeTest.java:220) 
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: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.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
 at org.junit.rules.RunRules.evaluate(RunRules.java:20) 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 

[jira] [Updated] (CALCITE-3300) Handle validating exception for SqlNode of count star converted by RelNode

2019-08-28 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3300:
--
Description: 
h4. Procedure to reproduce the problem:
 - create table {{~^t^~}}
 - parse `query  select count(*) from t` to SqlNode
 - convert SqlNode to RelNode
 - convert RelNode to SqlNode
 - validate the result SqlNode

test code is like this
{code:java}
// code placeholder
@Test public void testSelectCountAll() throws Exception { try (Statement s = 
parserContext.getStatement()) { s.execute("create table if not exists t (i int 
not null)"); String sql = "select count(*) from t"; SqlNode sqlNode = 
parserContext.parseStmt(sql); 
parserContext.getSqlValidator().validate(sqlNode); RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel; 
SqlNode sqlNodeNew = toSqlNode(relNode); 
parserContext.getSqlValidator().validate(sqlNodeNew); } }
{code}
Finally we will get an exception as follow:
{code:java}
// code placeholder
org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
Invalid number of arguments to function 'COUNT'. Was expecting 1 
argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, column 
0: Invalid number of arguments to function 'COUNT'. Was expecting 1 arguments 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) at 
org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
 at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
 at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
 at 
org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
 at 
org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:967)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:943)
 at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:918)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
 at 
org.apache.calcite.test.OptimizeTest.testSelectCountAll(OptimizeTest.java:220) 
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: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.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
 at org.junit.rules.RunRules.evaluate(RunRules.java:20) 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 

[jira] [Updated] (CALCITE-3300) Handle validating exception for SqlNode of count star converted by RelNode

2019-08-28 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3300:
--
Description: 
h4. Procedure to reproduce the problem:
 - create table {{~^t^~}}
 - parse query  select count(*) from to SqlNode
 - convert SqlNode to RelNode
 - convert RelNode to SqlNode
 - validate the result SqlNode

test code is like this
{code:java}
// code placeholder
@Test public void testSelectCountAll() throws Exception { try (Statement s = 
parserContext.getStatement()) { s.execute("create table if not exists t (i int 
not null)"); String sql = "select count(*) from t"; SqlNode sqlNode = 
parserContext.parseStmt(sql); 
parserContext.getSqlValidator().validate(sqlNode); RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel; 
SqlNode sqlNodeNew = toSqlNode(relNode); 
parserContext.getSqlValidator().validate(sqlNodeNew); } }
{code}
Finally we will get an exception as follow:
{code:java}
// code placeholder
org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
Invalid number of arguments to function 'COUNT'. Was expecting 1 
argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, column 
0: Invalid number of arguments to function 'COUNT'. Was expecting 1 arguments 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) at 
org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
 at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
 at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
 at 
org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
 at 
org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:967)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:943)
 at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:918)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
 at 
org.apache.calcite.test.OptimizeTest.testSelectCountAll(OptimizeTest.java:220) 
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: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.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
 at org.junit.rules.RunRules.evaluate(RunRules.java:20) 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 

[jira] [Created] (CALCITE-3300) Handle validating exception for SqlNode of count star converted by RelNode

2019-08-28 Thread Wang Weidong (Jira)
Wang Weidong created CALCITE-3300:
-

 Summary: Handle validating exception for SqlNode of count star 
converted by RelNode
 Key: CALCITE-3300
 URL: https://issues.apache.org/jira/browse/CALCITE-3300
 Project: Calcite
  Issue Type: Bug
  Components: core
Affects Versions: 1.21.0
Reporter: Wang Weidong


h4. Procedure to reproduce the problem:
 - create table {{~^t^~}}
 - parse query  ^{{~select count(*) from t~}}^ to SqlNode
 - convert SqlNode to RelNode
 - convert RelNode to SqlNode
 - validate the result SqlNode

test code is like this
{code:java}
// code placeholder
@Test public void testSelectCountAll() throws Exception { try (Statement s = 
parserContext.getStatement()) { s.execute("create table if not exists t (i int 
not null)"); String sql = "select count(*) from t"; SqlNode sqlNode = 
parserContext.parseStmt(sql); 
parserContext.getSqlValidator().validate(sqlNode); RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel; 
SqlNode sqlNodeNew = toSqlNode(relNode); 
parserContext.getSqlValidator().validate(sqlNodeNew); } }
{code}
Finally we will get an exception as follow:
{code:java}
// code placeholder
org.apache.calcite.runtime.CalciteContextException: At line 0, column 0: 
Invalid number of arguments to function 'COUNT'. Was expecting 1 
argumentsorg.apache.calcite.runtime.CalciteContextException: At line 0, column 
0: Invalid number of arguments to function 'COUNT'. Was expecting 1 arguments 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at 
org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463) at 
org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:783) at 
org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:768) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4753)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1699)
 at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:270) at 
org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:215) at 
org.apache.calcite.sql.fun.SqlCountAggFunction.deriveType(SqlCountAggFunction.java:83)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5477)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:5464)
 at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:138) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1629)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1614)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:457)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4017)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3280)
 at 
org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
 at 
org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:967)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:943)
 at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:225) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:918)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
 at 
org.apache.calcite.test.OptimizeTest.testSelectCountAll(OptimizeTest.java:220) 
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: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.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
 at org.junit.rules.RunRules.evaluate(RunRules.java:20) at 
org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at 

[jira] [Updated] (CALCITE-3299) Handle validating exception for SqlNode of select star converted by RelNode

2019-08-28 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3299:
--
Description: 
h4. Procedure to reproduce the problem:
 - create table {{~^t^~}}
 - parse query  ^{{~select * from t~}}^ to SqlNode
 - convert SqlNode to RelNode
 - convert RelNode to SqlNode
 - validate the result SqlNode

test code is like this
{code:java}
// code placeholder
@Test
public void testSelectAll() throws Exception {
  try (Statement s = parserContext.getStatement()) {
s.execute("create table if not exists t (i int not null)");

String sql = "select * from t";
SqlNode sqlNode = parserContext.parseStmt(sql);
parserContext.getSqlValidator().validate(sqlNode);
RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
SqlNode sqlNodeNew = toSqlNode(relNode);
parserContext.getSqlValidator().validate(sqlNodeNew);
  }
}
{code}
Finally we will get an exception as follow:
{code:java}
// code placeholder
org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectorg.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectjava.lang.NullPointerException
 at org.apache.calcite.sql.validate.AggFinder.findAgg(AggFinder.java:58) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getAgg(SqlValidatorImpl.java:2774)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getAggregate(SqlValidatorImpl.java:2761)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.isAggregate(SqlValidatorImpl.java:2720)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2406)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2326)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:916)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
 at org.apache.calcite.test.OptimizeTest.testSelectAll(OptimizeTest.java:206) 
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: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.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
 at org.junit.rules.RunRules.evaluate(RunRules.java:20) 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){code}
 

After debugging, I found that the *main causes* of this exception are as 
follows.

First, while converting RelNode to SqlNode, in the method 
{{~{color:#172b4d}^org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelect^{color}~}}
 
[https://github.com/apache/calcite/blob/c3108bc1231b2aa4ba25227d225544fef4576508/core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java#L420],

the selectList of SqlSelect instance was set to null.

Second,  while validating  the result SqlNode, in the method  
{{org.apache.calcite.sql.validate.AggFinder#findAgg}}
 
[https://github.com/apache/calcite/blob/c3108bc1231b2aa4ba25227d225544fef4576508/core/src/main/java/org/apache/calcite/sql/validate/AggFinder.java#L59]
 ,

there is with no nullable checking.

 

*How to solve this problem?*  

I think we can solve it either in the first or second step, but solving it in 
the second step is more appropriate because SqlNode converted from RelNode 
should be same with the result parsed from sql string possibly.

 

  was:
h4. Procedure to reproduce the problem:
 - create 

[jira] [Updated] (CALCITE-3299) Handle validating exception for SqlNode of select star converted by RelNode

2019-08-28 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3299:
--
Description: 
h4. Procedure to reproduce the problem:
 - create table {{~^t^~}}
 - parse query  ^{{~select * from t~}}^ to SqlNode
 - convert SqlNode to RelNode
 - convert RelNode to SqlNode
 - validate the result SqlNode

test code is like this
{code:java}
// code placeholder
@Test
public void testSelectAll() throws Exception {
  try (Statement s = parserContext.getStatement()) {
s.execute("create table if not exists t (i int not null)");

String sql = "select * from t";
SqlNode sqlNode = parserContext.parseStmt(sql);
parserContext.getSqlValidator().validate(sqlNode);
RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
SqlNode sqlNodeNew = toSqlNode(relNode);
parserContext.getSqlValidator().validate(sqlNodeNew);
  }
}
{code}
Finally we will get an exception as follow:

 
{code:java}
// code placeholder
// code placeholder 
org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectorg.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectjava.lang.NullPointerException
 at org.apache.calcite.sql.validate.AggFinder.findAgg(AggFinder.java:58) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getAgg(SqlValidatorImpl.java:2774)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getAggregate(SqlValidatorImpl.java:2761)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.isAggregate(SqlValidatorImpl.java:2720)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2406)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2326)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:916)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
 at org.apache.calcite.test.OptimizeTest.testSelectAll(OptimizeTest.java:206) 
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: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.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
 at org.junit.rules.RunRules.evaluate(RunRules.java:20) 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){code}
 

After debugging, I found that the *main causes* of this exception are as 
follows.

First, while converting RelNode to SqlNode, in the method 
{{~{color:#172b4d}^org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelect^{color}~}}
[https://github.com/apache/calcite/blob/c3108bc1231b2aa4ba25227d225544fef4576508/core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java#L420],

the selectList of SqlSelect instance was set to null.

Second,  while validating  the result SqlNode, in the method  
{{org.apache.calcite.sql.validate.AggFinder#findAgg}}
[https://github.com/apache/calcite/blob/c3108bc1231b2aa4ba25227d225544fef4576508/core/src/main/java/org/apache/calcite/sql/validate/AggFinder.java#L59]
 ,

there is with no nullable checking.

 

*How to solve this problem?*  

I think we can solve it in either the first or second step, but I think solving 
it in the second step is more appropriate because SqlNode converting from 
RelNode should be same as parsing possibly.

 

  was:
h4. Procedure to reproduce the problem:
 - 

[jira] [Updated] (CALCITE-3299) Handle validating exception for SqlNode of select star converted by RelNode

2019-08-28 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3299:
--
Description: 
h4. Procedure to reproduce the problem:
 - create table {{~^t^~}}
 - parse query  ^{{~select * from t~}}^ to SqlNode
 - convert SqlNode to RelNode
 - convert RelNode to SqlNode
 - validate the result SqlNode

test code is like this
{code:java}
// code placeholder
@Test
public void testSelectAll() throws Exception {
  try (Statement s = parserContext.getStatement()) {
s.execute("create table if not exists t (i int not null)");

String sql = "select * from t";
SqlNode sqlNode = parserContext.parseStmt(sql);
parserContext.getSqlValidator().validate(sqlNode);
RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
SqlNode sqlNodeNew = toSqlNode(relNode);
parserContext.getSqlValidator().validate(sqlNodeNew);
  }
}
{code}
Finally we will get an exception as follow:

 
{code:java}
// code placeholder
// code placeholder 
org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectorg.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectjava.lang.NullPointerException
 at org.apache.calcite.sql.validate.AggFinder.findAgg(AggFinder.java:58) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getAgg(SqlValidatorImpl.java:2774)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getAggregate(SqlValidatorImpl.java:2761)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.isAggregate(SqlValidatorImpl.java:2720)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2406)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2326)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:916)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
 at org.apache.calcite.test.OptimizeTest.testSelectAll(OptimizeTest.java:206) 
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: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.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
 at org.junit.rules.RunRules.evaluate(RunRules.java:20) 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){code}
 

 

After debugging, I found that the *main causes* of this exception are as 
follows.

First, while converting RelNode to SqlNode, in the method [link 
title|'[https://github.com/apache/calcite/blob/c3108bc1231b2aa4ba25227d225544fef4576508/core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java#L420'|https://github.com/apache/calcite/blob/c3108bc1231b2aa4ba25227d225544fef4576508/core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java#L420]]
 [org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelect|#L420], the 
selectList of SqlSelect instance was set to null.

Second,  while validating  the result SqlNode, in the metho 
[org.apache.calcite.sql.validate.AggFinder#findAgg(org.apache.calcite.sql.SqlNode)|#L59]]
 , there is no nullable checking.

*How to solve this problem?*  

I think we can solve it in either the first or second step, but I think solving 
it in the second step is more appropriate because SqlNode converting from 
RelNode should be same as parsing possibly.

 

  was:
h4. Procedure to 

[jira] [Updated] (CALCITE-3299) Handle validating exception for SqlNode of select star converted by RelNode

2019-08-28 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3299:
--
Description: 
h4. Procedure to reproduce the problem:
 - create table {{~^t^~}}
 - parse query  ^{{~select * from t~}}^ to SqlNode
 - convert SqlNode to RelNode
 - convert RelNode to SqlNode
 - validate the result SqlNode

test code is like this
{code:java}
// code placeholder
@Test
public void testSelectAll() throws Exception {
  try (Statement s = parserContext.getStatement()) {
s.execute("create table if not exists t (i int not null)");

String sql = "select * from t";
SqlNode sqlNode = parserContext.parseStmt(sql);
parserContext.getSqlValidator().validate(sqlNode);
RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
SqlNode sqlNodeNew = toSqlNode(relNode);
parserContext.getSqlValidator().validate(sqlNodeNew);
  }
}
{code}
Finally we will get an exception as follow:

 
{code:java}
// code placeholder
// code placeholder 
org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectorg.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectjava.lang.NullPointerException
 at org.apache.calcite.sql.validate.AggFinder.findAgg(AggFinder.java:58) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getAgg(SqlValidatorImpl.java:2774)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getAggregate(SqlValidatorImpl.java:2761)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.isAggregate(SqlValidatorImpl.java:2720)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2406)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2326)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:916)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
 at org.apache.calcite.test.OptimizeTest.testSelectAll(OptimizeTest.java:206) 
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: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.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
 at org.junit.rules.RunRules.evaluate(RunRules.java:20) 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){code}
 

 

After debugging, I found that the *main causes* of this exception are as 
follows.

First, while converting RelNode to SqlNode, in the method  
[org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelect|#L420] [link 
title|[https://github.com/apache/calcite/blob/c3108bc1231b2aa4ba25227d225544fef4576508/core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java#L420]],
 the selectList of SqlSelect instance was set to null.

Second,  while validating  the result SqlNode, in the metho 
[org.apache.calcite.sql.validate.AggFinder#findAgg(org.apache.calcite.sql.SqlNode)|#L59]]
 , there is no nullable checking.

*How to solve this problem?*  

I think we can solve it in either the first or second step, but I think solving 
it in the second step is more appropriate because SqlNode converting from 
RelNode should be same as parsing possibly.

 

  was:
h4. Procedure to reproduce the problem:
 - create table {{~^t^~}}
 - parse query  ^{{~select * from t~}}^ to SqlNode
 - convert SqlNode to RelNode
 - convert RelNode to SqlNode
 - 

[jira] [Updated] (CALCITE-3299) Handle validating exception for SqlNode of select star converted by RelNode

2019-08-28 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3299:
--
Description: 
h4. Procedure to reproduce the problem:
 - create table {{~^t^~}}
 - parse query  ^{{~select * from t~}}^ to SqlNode
 - convert SqlNode to RelNode
 - convert RelNode to SqlNode
 - validate the result SqlNode

test code is like this
{code:java}
// code placeholder
@Test
public void testSelectAll() throws Exception {
  try (Statement s = parserContext.getStatement()) {
s.execute("create table if not exists t (i int not null)");

String sql = "select * from t";
SqlNode sqlNode = parserContext.parseStmt(sql);
parserContext.getSqlValidator().validate(sqlNode);
RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
SqlNode sqlNodeNew = toSqlNode(relNode);
parserContext.getSqlValidator().validate(sqlNodeNew);
  }
}
{code}
Finally we will get an exception as follow:

 
{code:java}
// code placeholder
// code placeholder 
org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectorg.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectjava.lang.NullPointerException
 at org.apache.calcite.sql.validate.AggFinder.findAgg(AggFinder.java:58) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getAgg(SqlValidatorImpl.java:2774)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getAggregate(SqlValidatorImpl.java:2761)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.isAggregate(SqlValidatorImpl.java:2720)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2406)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2326)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:916)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
 at org.apache.calcite.test.OptimizeTest.testSelectAll(OptimizeTest.java:206) 
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: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.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
 at org.junit.rules.RunRules.evaluate(RunRules.java:20) 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){code}
 

 

After debugging, I found that the *main causes* of this exception are as 
follows.

First, while converting RelNode to SqlNode, in the method  
[org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelect|#L420]] , the 
selectList of SqlSelect instance was set to null.

Second,  while validating  the result SqlNode, in the metho 
[org.apache.calcite.sql.validate.AggFinder#findAgg(org.apache.calcite.sql.SqlNode)|#L59]]
 , there is no nullable checking.

*How to solve this problem?*  

I think we can solve it in either the first or second step, but I think solving 
it in the second step is more appropriate because SqlNode converting from 
RelNode should be same as parsing possibly.

 

  was:
h4. Procedure to reproduce the problem:
 - create table {{~^t^~}}
 - parse query  ^{{~select * from t~}}^ to SqlNode
 - convert SqlNode to RelNode
 - convert RelNode to SqlNode
 - validate the result SqlNode

test code is like this
{code:java}
// code placeholder
@Test
public void testSelectAll() throws Exception {
  try (Statement s = 

[jira] [Updated] (CALCITE-3299) Handle validating exception for SqlNode of select star converted by RelNode

2019-08-28 Thread Wang Weidong (Jira)


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

Wang Weidong updated CALCITE-3299:
--
Description: 
h4. Procedure to reproduce the problem:
 - create table {{~^t^~}}
 - parse query  ^{{~select * from t~}}^ to SqlNode
 - convert SqlNode to RelNode
 - convert RelNode to SqlNode
 - validate the result SqlNode

test code is like this
{code:java}
// code placeholder
@Test
public void testSelectAll() throws Exception {
  try (Statement s = parserContext.getStatement()) {
s.execute("create table if not exists t (i int not null)");

String sql = "select * from t";
SqlNode sqlNode = parserContext.parseStmt(sql);
parserContext.getSqlValidator().validate(sqlNode);
RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
SqlNode sqlNodeNew = toSqlNode(relNode);
parserContext.getSqlValidator().validate(sqlNodeNew);
  }
}
{code}
Finally we will get an exception as follow:

 
{code:java}
// code placeholder
// code placeholder 
org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectorg.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectjava.lang.NullPointerException
 at org.apache.calcite.sql.validate.AggFinder.findAgg(AggFinder.java:58) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getAgg(SqlValidatorImpl.java:2774)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getAggregate(SqlValidatorImpl.java:2761)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.isAggregate(SqlValidatorImpl.java:2720)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2406)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2326)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:916)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
 at org.apache.calcite.test.OptimizeTest.testSelectAll(OptimizeTest.java:206) 
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: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.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
 at org.junit.rules.RunRules.evaluate(RunRules.java:20) 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){code}
 

 

After debugging, I found that the main causes of this exception are as follows.

First, while converting RelNode to SqlNode, in the method  
[org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelect|[https://github.com/apache/calcite/blob/c3108bc1231b2aa4ba25227d225544fef4576508/core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java#L420]]
 , the selectList of SqlSelect instance was set to null.

Second,  while validating  the result SqlNode, in the metho 
[org.apache.calcite.sql.validate.AggFinder#findAgg(org.apache.calcite.sql.SqlNode)|[https://github.com/apache/calcite/blob/c3108bc1231b2aa4ba25227d225544fef4576508/core/src/main/java/org/apache/calcite/sql/validate/AggFinder.java#L59]]
 , there is no nullable checking.

How to solve this problem?  

I think we can solve it in either the first or second step, but I think solving 
it in the second step is more appropriate because SqlNode converting from 
RelNode should be same as parsing possibly.

 

  was:
h4. Procedure to reproduce the problem:
 - create table 

[jira] [Created] (CALCITE-3299) Handle validating exception for SqlNode of select star converted by RelNode

2019-08-28 Thread Wang Weidong (Jira)
Wang Weidong created CALCITE-3299:
-

 Summary: Handle validating exception for SqlNode of select star 
converted by RelNode 
 Key: CALCITE-3299
 URL: https://issues.apache.org/jira/browse/CALCITE-3299
 Project: Calcite
  Issue Type: Bug
  Components: core
Affects Versions: 1.21.0
Reporter: Wang Weidong
Assignee: Wang Weidong


h4. Procedure to reproduce the problem:
 - create table {{~^t^~}}
 - parse query  ^{{~select * from t~}}^ to SqlNode
 - convert SqlNode to RelNode
 - convert RelNode to SqlNode
 - validate the result SqlNode

test code is like this
{code:java}
// code placeholder
@Test
public void testSelectAll() throws Exception {
  try (Statement s = parserContext.getStatement()) {
s.execute("create table if not exists t (i int not null)");

String sql = "select * from t";
SqlNode sqlNode = parserContext.parseStmt(sql);
parserContext.getSqlValidator().validate(sqlNode);
RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
SqlNode sqlNodeNew = toSqlNode(relNode);
parserContext.getSqlValidator().validate(sqlNodeNew);
  }
}
{code}
Finally we will get an exception as follow:
{code:java}
// code placeholder
org.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectorg.apache.calcite.rel.rel2sql.SqlImplementor#wrapSelectjava.lang.NullPointerException
 at org.apache.calcite.sql.validate.AggFinder.findAgg(AggFinder.java:58) at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getAgg(SqlValidatorImpl.java:2774)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.getAggregate(SqlValidatorImpl.java:2761)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.isAggregate(SqlValidatorImpl.java:2720)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2406)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.registerQuery(SqlValidatorImpl.java:2326)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:916)
 at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:628)
 at org.apache.calcite.test.OptimizeTest.testSelectAll(OptimizeTest.java:206) 
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: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.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
 at org.junit.rules.RunRules.evaluate(RunRules.java:20) 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)
{code}



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


[jira] [Assigned] (CALCITE-3210) RelToSqlConverter convert "cast(null as $type)" just as null

2019-07-24 Thread Wang Weidong (JIRA)


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

Wang Weidong reassigned CALCITE-3210:
-

Assignee: Wang Weidong

> RelToSqlConverter convert "cast(null as $type)" just as  null 
> --
>
> Key: CALCITE-3210
> URL: https://issues.apache.org/jira/browse/CALCITE-3210
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
> Environment: mac os
>Reporter: Wang Weidong
>Assignee: Wang Weidong
>Priority: Major
> Fix For: next
>
>
> I have as sql as follows: 
> {code:java}
> select cast(null as varchar) as a{code}
> The process step is : 
>  # parse sql to SqlNode;
>  # convert SqlNode to RelNode;
>  # convert RelNode to SqlNode;
>  # convert SqlNode to string.
> The result string is:
> {code:java}
> "SELECT NULL AS `A`\n"
> + "FROM (VALUES  (0)) AS `t` (`ZERO`)"{code}
> Finally, I found that the result string is absent of cast statement for  
> "null" which causes the result sql to be invalid.
> Actually, the result I expect is like:
> {code:java}
> "SELECT CAST(NULL AS VARCHAR) AS `A`\n"
> + "FROM (VALUES  (0)) AS `t` (`ZERO`)"{code}
>  
> Testing code is as follows
> {code:java}
> // code placeholder
> @Test
> public void testSeletNull() throws SqlParseException {
> String sql = "select cast(null as varchar) as a";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> Assert.assertEquals(sqlNodeNew.toString(), "SELECT NULL AS `A`\n"
> + "FROM (VALUES  (0)) AS `t` (`ZERO`)");
> }
> private static SqlNode toSqlNode(RelNode root) {
>   SqlDialect dialect = MysqlSqlDialect.DEFAULT;
>   RelToSqlConverter converter = new RelToSqlConverter(dialect == null ? 
> dialect : dialect);
>   return converter.visitChild(0, root).asStatement();
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)


[jira] [Commented] (CALCITE-3210) RelToSqlConverter convert "cast(null as $type)" just as null

2019-07-24 Thread Wang Weidong (JIRA)


[ 
https://issues.apache.org/jira/browse/CALCITE-3210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16892382#comment-16892382
 ] 

Wang Weidong commented on CALCITE-3210:
---

I mean that cast was abandoned while  RelToSqlConverter convert RelNode to 
SqlNode, is that appropriate ? 

> RelToSqlConverter convert "cast(null as $type)" just as  null 
> --
>
> Key: CALCITE-3210
> URL: https://issues.apache.org/jira/browse/CALCITE-3210
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
> Environment: mac os
>Reporter: Wang Weidong
>Priority: Major
> Fix For: next
>
>
> I have as sql as follows: 
> {code:java}
> select cast(null as varchar) as a{code}
> The process step is : 
>  # parse sql to SqlNode;
>  # convert SqlNode to RelNode;
>  # convert RelNode to SqlNode;
>  # convert SqlNode to string.
> The result string is:
> {code:java}
> "SELECT NULL AS `A`\n"
> + "FROM (VALUES  (0)) AS `t` (`ZERO`)"{code}
> Finally, I found that the result string is absent of cast statement for  
> "null" which causes the result sql to be invalid.
> Actually, the result I expect is like:
> {code:java}
> "SELECT CAST(NULL AS VARCHAR) AS `A`\n"
> + "FROM (VALUES  (0)) AS `t` (`ZERO`)"{code}
>  
> Testing code is as follows
> {code:java}
> // code placeholder
> @Test
> public void testSeletNull() throws SqlParseException {
> String sql = "select cast(null as varchar) as a";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> Assert.assertEquals(sqlNodeNew.toString(), "SELECT NULL AS `A`\n"
> + "FROM (VALUES  (0)) AS `t` (`ZERO`)");
> }
> private static SqlNode toSqlNode(RelNode root) {
>   SqlDialect dialect = MysqlSqlDialect.DEFAULT;
>   RelToSqlConverter converter = new RelToSqlConverter(dialect == null ? 
> dialect : dialect);
>   return converter.visitChild(0, root).asStatement();
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)


[jira] [Updated] (CALCITE-3210) RelToSqlConverter convert "cast(null as $type)" just as null

2019-07-24 Thread Wang Weidong (JIRA)


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

Wang Weidong updated CALCITE-3210:
--
Description: 
I have as sql as follows: 
{code:java}
select cast(null as varchar) as a{code}
The process step is : 
 # parse sql to SqlNode;
 # convert SqlNode to RelNode;
 # convert RelNode to SqlNode;
 # convert SqlNode to string.

The result string is:
{code:java}
"SELECT NULL AS `A`\n"
+ "FROM (VALUES  (0)) AS `t` (`ZERO`)"{code}
Finally, I found that the result string is absent of cast statement for  "null" 
which causes the result sql to be invalid.

Actually, the result I expect is like:
{code:java}
"SELECT CAST(NULL AS VARCHAR) AS `A`\n"
+ "FROM (VALUES  (0)) AS `t` (`ZERO`)"{code}
 

Testing code is as follows
{code:java}
// code placeholder
@Test
public void testSeletNull() throws SqlParseException {
String sql = "select cast(null as varchar) as a";
SqlNode sqlNode = parserContext.parseStmt(sql);
RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
SqlNode sqlNodeNew = toSqlNode(relNode);
Assert.assertEquals(sqlNodeNew.toString(), "SELECT NULL AS `A`\n"
+ "FROM (VALUES  (0)) AS `t` (`ZERO`)");
}

private static SqlNode toSqlNode(RelNode root) {
  SqlDialect dialect = MysqlSqlDialect.DEFAULT;
  RelToSqlConverter converter = new RelToSqlConverter(dialect == null ? dialect 
: dialect);
  return converter.visitChild(0, root).asStatement();
}
{code}

  was:
I have as sql as follows: 
{code:java}
select cast(null as varchar) as a{code}
The process step is : 
 # parse sql to SqlNode;
 # convert SqlNode to RelNode;
 # convert RelNode to SqlNode;
 # convert SqlNode to string.

The result string is:
{code:java}
"SELECT NULL AS `A`\n"
+ "FROM (VALUES  (0)) AS `t` (`ZERO`)"{code}
Finally, I found that the result string is absent of cast statement for  "null" 
which causes the result sql to be invalid.

Actually, the result I expect is like:
{code:java}
SELECT CAST(NULL AS VARCHAR) AS `A`\n"
+ "FROM (VALUES  (0)) AS `t` (`ZERO`){code}
 

Testing code is as follows
{code:java}
// code placeholder
@Test
public void testSeletNull() throws SqlParseException {
String sql = "select cast(null as varchar) as a";
SqlNode sqlNode = parserContext.parseStmt(sql);
RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
SqlNode sqlNodeNew = toSqlNode(relNode);
Assert.assertEquals(sqlNodeNew.toString(), "SELECT NULL AS `A`\n"
+ "FROM (VALUES  (0)) AS `t` (`ZERO`)");
}

private static SqlNode toSqlNode(RelNode root) {
  SqlDialect dialect = MysqlSqlDialect.DEFAULT;
  RelToSqlConverter converter = new RelToSqlConverter(dialect == null ? dialect 
: dialect);
  return converter.visitChild(0, root).asStatement();
}
{code}


> RelToSqlConverter convert "cast(null as $type)" just as  null 
> --
>
> Key: CALCITE-3210
> URL: https://issues.apache.org/jira/browse/CALCITE-3210
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.21.0
> Environment: mac os
>Reporter: Wang Weidong
>Priority: Major
> Fix For: next
>
>
> I have as sql as follows: 
> {code:java}
> select cast(null as varchar) as a{code}
> The process step is : 
>  # parse sql to SqlNode;
>  # convert SqlNode to RelNode;
>  # convert RelNode to SqlNode;
>  # convert SqlNode to string.
> The result string is:
> {code:java}
> "SELECT NULL AS `A`\n"
> + "FROM (VALUES  (0)) AS `t` (`ZERO`)"{code}
> Finally, I found that the result string is absent of cast statement for  
> "null" which causes the result sql to be invalid.
> Actually, the result I expect is like:
> {code:java}
> "SELECT CAST(NULL AS VARCHAR) AS `A`\n"
> + "FROM (VALUES  (0)) AS `t` (`ZERO`)"{code}
>  
> Testing code is as follows
> {code:java}
> // code placeholder
> @Test
> public void testSeletNull() throws SqlParseException {
> String sql = "select cast(null as varchar) as a";
> SqlNode sqlNode = parserContext.parseStmt(sql);
> RelNode relNode = 
> parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
> SqlNode sqlNodeNew = toSqlNode(relNode);
> Assert.assertEquals(sqlNodeNew.toString(), "SELECT NULL AS `A`\n"
> + "FROM (VALUES  (0)) AS `t` (`ZERO`)");
> }
> private static SqlNode toSqlNode(RelNode root) {
>   SqlDialect dialect = MysqlSqlDialect.DEFAULT;
>   RelToSqlConverter converter = new RelToSqlConverter(dialect == null ? 
> dialect : dialect);
>   return converter.visitChild(0, root).asStatement();
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)


[jira] [Created] (CALCITE-3210) RelToSqlConverter convert "cast(null as $type)" just as null

2019-07-24 Thread Wang Weidong (JIRA)
Wang Weidong created CALCITE-3210:
-

 Summary: RelToSqlConverter convert "cast(null as $type)" just as  
null 
 Key: CALCITE-3210
 URL: https://issues.apache.org/jira/browse/CALCITE-3210
 Project: Calcite
  Issue Type: Bug
  Components: core
Affects Versions: 1.21.0
 Environment: mac os
Reporter: Wang Weidong
 Fix For: next


I have as sql as follows: 
{code:java}
select cast(null as varchar) as a{code}
The process step is : 
 # parse sql to SqlNode;
 # convert SqlNode to RelNode;
 # convert RelNode to SqlNode;
 # convert SqlNode to string.

The result string is:
{code:java}
"SELECT NULL AS `A`\n"
+ "FROM (VALUES  (0)) AS `t` (`ZERO`)"{code}
Finally, I found that the result string is absent of cast statement for  "null" 
which causes the result sql to be invalid.

Actually, the result I expect is like:
{code:java}
SELECT CAST(NULL AS VARCHAR) AS `A`\n"
+ "FROM (VALUES  (0)) AS `t` (`ZERO`){code}
 

Testing code is as follows
{code:java}
// code placeholder
@Test
public void testSeletNull() throws SqlParseException {
String sql = "select cast(null as varchar) as a";
SqlNode sqlNode = parserContext.parseStmt(sql);
RelNode relNode = 
parserContext.getSqlToRelConverter().convertQuery(sqlNode, true, true).rel;
SqlNode sqlNodeNew = toSqlNode(relNode);
Assert.assertEquals(sqlNodeNew.toString(), "SELECT NULL AS `A`\n"
+ "FROM (VALUES  (0)) AS `t` (`ZERO`)");
}

private static SqlNode toSqlNode(RelNode root) {
  SqlDialect dialect = MysqlSqlDialect.DEFAULT;
  RelToSqlConverter converter = new RelToSqlConverter(dialect == null ? dialect 
: dialect);
  return converter.visitChild(0, root).asStatement();
}
{code}



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)