jamie12221 created CALCITE-4093:
-----------------------------------

             Summary: Unable to translate correlate to SQL
                 Key: CALCITE-4093
                 URL: https://issues.apache.org/jira/browse/CALCITE-4093
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.23.0
            Reporter: jamie12221


Exception:
{code:java}
Caused by: java.lang.reflect.InvocationTargetExceptionCaused 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) ... 13 
moreCaused by: 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.core.Project)'
 at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:527) at 
org.apache.calcite.rel.rel2sql.RelToSqlConverter.dispatch(RelToSqlConverter.java:129)
 at io.mycat.optimizer.Main$1RelToSqlConverter2.dispatch(Main.java:153) at 
org.apache.calcite.rel.rel2sql.RelToSqlConverter.visitChild(RelToSqlConverter.java:135)
 at 
org.apache.calcite.rel.rel2sql.SqlImplementor.visitChild(SqlImplementor.java:129)
 at 
org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(RelToSqlConverter.java:284)
 ... 18 moreCaused 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) ... 23 
moreCaused by: java.lang.UnsupportedOperationException at 
org.apache.calcite.rel.rel2sql.SqlImplementor$Context.getAliasContext(SqlImplementor.java:898)
 at 
org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:623)
 at 
org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(RelToSqlConverter.java:336)
 ... 
{code}
The Test Case:
{code:java}
private static void test(RelBuilder relBuilder) {
    RelNode left = relBuilder
            .values(new String[]{"f", "f2"}, "1", "2").build();

    CorrelationId correlationId = new CorrelationId(0);
    RexNode rexCorrel =
            relBuilder.getRexBuilder().makeCorrel(
                    left.getRowType(),
                    correlationId);

    RelNode right = relBuilder
            .values(new String[]{"f3", "f4"}, "1", "2")
            .project(relBuilder.field(0),
                    relBuilder.getRexBuilder()
                            .makeFieldAccess(rexCorrel, 0))
            .build();
    RelNode correlate = new LogicalCorrelate(left.getCluster(),
            left.getTraitSet(), left, right, correlationId,
            ImmutableBitSet.of(0), JoinRelType.SEMI);

    class RelToSqlConverter2 extends RelToSqlConverter {
        public RelToSqlConverter2() {
            super(MysqlSqlDialect.DEFAULT);
        }

        @Override
        public Result dispatch(RelNode e) {
            return super.dispatch(e);
        }
    }
    ;
    correlate = RelDecorrelator.decorrelateQuery(correlate, relBuilder);
    RelToSqlConverter2 relToSqlConverter2 = new RelToSqlConverter2();
    SqlString sqlString = 
relToSqlConverter2.dispatch(correlate).asStatement().toSqlString(MysqlSqlDialect.DEFAULT);
}
{code}



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

Reply via email to