calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "pengzhiwei (JIRA)" <>
Subject [jira] [Created] (CALCITE-2382) Column not found when subquery join lateral table function
Date Tue, 26 Jun 2018 11:09:00 GMT
pengzhiwei created CALCITE-2382:

             Summary: Column not found when subquery join lateral table function
                 Key: CALCITE-2382
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.16.0
            Reporter: pengzhiwei
            Assignee: Julian Hyde

When use subquery join lateral table function as followed:

 select * from ( select 5 as f0 from s.t ) a,lateral table(s.GenerateStrings(f0)) as t(n,
c)  where char_length(c) > 3
'SqlValidatorException: Column 'F0' not found in any table'  has thrown out.

I find the reason is that  SqlValidatorImpl add the Identifier 's.t' namespace to the children
of tableScope,but not the subquey's namespace,just as the code show bellow in  SqlValidatorImpl#registerFrom:

  if (tableScope == null) {
  tableScope = new TableScope(parentScope, node);
 tableScope.addChild(newNs, alias, forceNullable);{code}


I think the namespace of  JoinScope's left child should be right for the child of tableScope
which was referenced by the table function,just as the code show bellow in  SqlValidatorImpl#registerFrom:
  TableScope tableScope = null;

  if(parentScope instanceof JoinScope) {

  tableScope = new TableScope(new EmptyScope(this),operand);
  JoinScope scope = (JoinScope) parentScope;

  SqlValidatorNamespace leftNs = scope.getChildren().get(0);

After this modification,the case upon runs well.

Is there any problem for this modification? Any suggestions is welcomed.Thanks a lot.





This message was sent by Atlassian JIRA

View raw message