You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (JIRA)" <ji...@apache.org> on 2016/10/07 16:33:20 UTC

[jira] [Updated] (CALCITE-1388) JDBC adapter throws while converting ROLLUP operator to SQL

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

Julian Hyde updated CALCITE-1388:
---------------------------------
    Summary: JDBC adapter throws while converting ROLLUP operator to SQL  (was: Error during RelNode to sql string conversion)

> JDBC adapter throws while converting ROLLUP operator to SQL
> -----------------------------------------------------------
>
>                 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)