You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "TANG Wen-hui (Jira)" <ji...@apache.org> on 2020/03/24 02:27:00 UTC

[jira] [Assigned] (CALCITE-3354) RelToSqlConverter does not support LogicalTableFunctionScan

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

TANG Wen-hui reassigned CALCITE-3354:
-------------------------------------

    Assignee: TANG Wen-hui

> RelToSqlConverter does not support LogicalTableFunctionScan
> -----------------------------------------------------------
>
>                 Key: CALCITE-3354
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3354
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.21.0
>            Reporter: Anton Haidai
>            Assignee: TANG Wen-hui
>            Priority: Minor
>
> Here is the test in *RelBuilderTest* to reproduce the issue using *RelBuilder* (the right place for this test is RelToSqlConverterTest, but it does not have table functions configured):
> {code}
>   @Test
>   public void testFailToConvertLogicalTableFunctionScanToSql() {
>     final RelBuilder builder = RelBuilder.create(config().build());
>     final SqlOperator rampFunction = new MockSqlOperatorTable.RampFunction();
>     RelNode root = builder.functionScan(rampFunction, 0, builder.literal(3))
>         .build();
>     toSql(root, CalciteSqlDialect.DEFAULT);
>   }
>   private static String toSql(RelNode root, SqlDialect dialect) {
>     final RelToSqlConverter converter = new RelToSqlConverter(dialect);
>     final SqlNode sqlNode = converter.visitChild(0, root).asStatement();
>     return sqlNode.toSqlString(dialect).getSql();
>   }
> {code}
> Here is the same issue reproduced using *SQL* (placed in *SqlToRelConverterTest*: once again, the test file was selected because of table functions infrastructure availability):
> {code}
>   @Test
>   public void testFailToConvertLogicalTableFunctionScanToSql() {
>     String sql = "select * from table(ramp(3))";
>     final RelNode rel = tester.convertSqlToRel(sql).rel;
>     toSql(rel, CalciteSqlDialect.DEFAULT);
>   }
>   private static String toSql(RelNode root, SqlDialect dialect) {
>     final RelToSqlConverter converter = new RelToSqlConverter(dialect);
>     final SqlNode sqlNode = converter.visitChild(0, root).asStatement();
>     return sqlNode.toSqlString(dialect).getSql();
>   }
> {code}
> Result: 
> {code}
> java.lang.RuntimeException: While invoking method 'public org.apache.calcite.rel.rel2sql.SqlImplementor$Result org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(org.apache.calcite.rel.RelNode)'
> 	at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:527)
> 	at org.apache.calcite.rel.rel2sql.RelToSqlConverter.dispatch(RelToSqlConverter.java:122)
> 	at org.apache.calcite.rel.rel2sql.RelToSqlConverter.visitChild(RelToSqlConverter.java:128)
> 	at org.apache.calcite.test.RelBuilderTest.toSql(RelBuilderTest.java:331)
> 	at org.apache.calcite.test.RelBuilderTest.testFailToConvertLogicalTableFunctionScanToSql(RelBuilderTest.java:326)
> 	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 com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
> 	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
> 	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
> 	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
> Caused by: java.lang.reflect.InvocationTargetException
> 	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:524)
> 	... 26 more
> Caused by: java.lang.AssertionError: Need to implement org.apache.calcite.rel.logical.LogicalTableFunctionScan
> 	at org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(RelToSqlConverter.java:136)
> 	... 31 more
> {code}



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