xzh_dz created CALCITE-3971:
-------------------------------

             Summary: Support Calc in RelMdColumnOrigins
                 Key: CALCITE-3971
                 URL: https://issues.apache.org/jira/browse/CALCITE-3971
             Project: Calcite
          Issue Type: Wish
            Reporter: xzh_dz


In my project, we often use `RelColumnOrigin` to find metadata information for 
columns.
When i try to get origin column , and i got exception as below, the exception 
can be reproduced. 
{code:java}
final String sql = "select name,deptno from dept";
    final RelNode relNode = convertSql(sql);
    final HepProgram program = new HepProgramBuilder().
        addRuleInstance(ProjectToCalcRule.INSTANCE).build();
    final HepPlanner planner = new HepPlanner(program);
    planner.setRoot(relNode);
    final RelNode calc = planner.findBestExp();
    final RelMetadataQuery mq = calc.getCluster().getMetadataQuery();
    final RelColumnOrigin nameColumn = mq.getColumnOrigin(calc, 0);
    assertThat(nameColumn.getOriginColumnOrdinal(), is(1));
{code}
java.lang.NullPointerException
        at 
org.apache.calcite.test.RelMetadataTest.testCalcColumnOriginsTable(RelMetadataTest.java:391)
        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.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675)
        at 
org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)



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

Reply via email to