Vladimir Sitnikov created CALCITE-7948:
------------------------------------------

             Summary: Piglet: a statement that refers to an undefined relation 
throws NullPointerException or is ignored
                 Key: CALCITE-7948
                 URL: https://issues.apache.org/jira/browse/CALCITE-7948
             Project: Calcite
          Issue Type: Bug
          Components: piglet
    Affects Versions: 1.42.0
            Reporter: Vladimir Sitnikov


When a Pig Latin script refers to a relation that no earlier statement defined, 
Piglet throws a NullPointerException for FILTER and silently ignores DUMP.

{code}
A = LOAD 'DEPT';
B = FILTER X BY DEPTNO;
{code}

fails with:

{noformat}
java.lang.NullPointerException: Cannot invoke 
"org.apache.calcite.rel.RelNode.getRowType()" because "rel" is null
  at org.apache.calcite.tools.RelBuilder$Frame.<init>(RelBuilder.java:5390)
  at org.apache.calcite.tools.RelBuilder$Frame.<init>(RelBuilder.java:5372)
  at org.apache.calcite.tools.RelBuilder.push(RelBuilder.java:378)
  at org.apache.calcite.piglet.Handler.handle(Handler.java:109)
{noformat}

{code}
A = LOAD 'DEPT';
DUMP X;
{code}

prints nothing and reports no error.

Expected: both scripts fail with an error that names the undefined relation, 
such as {{unknown relation 'X'}}.

Reproduced on main at 9801f30e72 with OpenJDK 21.0.9. The other statements that 
look up a relation by name in Handler (FOREACH, ORDER, LIMIT, DISTINCT, GROUP, 
DESCRIBE) do the same lookup.

Found while reviewing CALCITE-7736, which changed these lookups; the fix there 
keeps the old behavior, so this issue tracks it separately.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to