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

Viktor Batytskyi edited comment on CALCITE-1388 at 10/7/16 12:44 PM:
---------------------------------------------------------------------

Consequent issues while transforming RelNode to SQL have arisen. Reopening the 
issue, as it will take too much time to resolve.


was (Author: victor.ba...@gmail.com):
Consequent issues while transforming RelNode to SQL has arisen. Re-opening 
issue, as for now it will take too much time to resolve.

> Error during RelNode to sql string conversion
> ---------------------------------------------
>
>                 Key: CALCITE-1388
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1388
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>         Environment: Oracle JDK 1.8
>            Reporter: Viktor Batytskyi
>            Assignee: Julian Hyde
>
> The following query contains ROLLUP operator in GROUP BY clause. 
> {code:sql}
> SELECT player_id, video_id, SUM(clicks)
> FROM Table
> GROUP BY ROLLUP((player_id, video_id))
> {code}
> After the sql string is parsed and validated by executing: 
> {code}
>       val planner = Frameworks.getPlanner(config)
>       val sqlNode = planner.parse(mockedSql)
>       val validatedSql = planner.validate(sqlNode)
>       val relExpression = planner.rel(validatedSql).project()
> {code}
> The resulting relExpression can't be transformed back to a query:
> {code}
> private val VERTICA = SqlDialect.DatabaseProduct.VERTICA.getDialect
> .....................
> val sql = new RelToSqlConverter(VERTICA).visitChild(0, 
> relExpression).asQuery.toSqlString(VERTICA).getSql
> {code}
> The exception is thrown:
> {code}
> Caused by: java.lang.reflect.InvocationTargetException: null
>       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.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:531)
>       ... 29 common frames omitted
> Caused by: java.lang.AssertionError: Internal error: While invoking method 
> 'public org.apache.calcite.rel.rel2sql.SqlImplementor$Result 
> org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(org.apache.calcite.rel.core.Project)'
>       at org.apache.calcite.util.Util.newInternal(Util.java:792)
>       at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:534)
>       at 
> org.apache.calcite.rel.rel2sql.RelToSqlConverter.dispatch(RelToSqlConverter.java:80)
>       at 
> org.apache.calcite.rel.rel2sql.RelToSqlConverter.visitChild(RelToSqlConverter.java:84)
>       at 
> org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(RelToSqlConverter.java:125)
>       ... 34 common frames omitted
> Caused by: java.lang.reflect.InvocationTargetException: null
>       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.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:531)
>       ... 37 common frames omitted
> Caused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
>       at java.util.ArrayList.rangeCheck(ArrayList.java:653)
>       at java.util.ArrayList.get(ArrayList.java:429)
>       at org.apache.calcite.sql.SqlNodeList.get(SqlNodeList.java:93)
>       at 
> org.apache.calcite.rel.rel2sql.SqlImplementor$Result$1.field(SqlImplementor.java:781)
>       at 
> org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:450)
>       at 
> org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(RelToSqlConverter.java:133)
>       ... 42 common frames omitted
> {code}
> The failure can be tested by (RelToSqlConverterTest of Calcite Core project):
> {code:java}
>   @Test public void testSimpleRollup() {
>     String query = "select \"product_id\"\n" +
>             "from \"product\"\n" +
>             "group by rollup((\"product_id\"))";
>     String expected = "select \"product_id\"\n" +
>             "from \"product\"\n" +
>             "group by rollup((\"product_id\"))";
>     sql(query).ok(expected);
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to