nikolamand-db commented on PR #46580:
URL: https://github.com/apache/spark/pull/46580#issuecomment-2129615940

   > I think this fixes https://issues.apache.org/jira/browse/SPARK-46625 as 
well. Can we add a test to verify?
   
   Checked locally, seems like these changes don't resolve the issue:
   ```
   spark-sql (default)> explain extended WITH S(c1, c2) AS (VALUES(1, 2), (2, 
3)), T(c1, c2) AS (VALUES ('a', 'b'), ('c', 'd')) SELECT 
IDENTIFIER('max')(IDENTIFIER('c1')) FROM IDENTIFIER('T');
   
   == Parsed Logical Plan ==
   CTE [S, T]
   :  :- 'SubqueryAlias S
   :  :  +- 'UnresolvedSubqueryColumnAliases [c1, c2]
   :  :     +- 'UnresolvedInlineTable [col1, col2], [[1, 2], [2, 3]]
   :  +- 'SubqueryAlias T
   :     +- 'UnresolvedSubqueryColumnAliases [c1, c2]
   :        +- 'UnresolvedInlineTable [col1, col2], [[a, b], [c, d]]
   +- 'Project [unresolvedalias(expressionwithunresolvedidentifier(max, 
expressionwithunresolvedidentifier(c1, <function2>), 
org.apache.spark.sql.catalyst.parser.AstBuilder$$Lambda$1453/0x0000000401c95138@312ddc51))]
      +- 'PlanWithUnresolvedIdentifier T, 
org.apache.spark.sql.catalyst.parser.AstBuilder$$Lambda$1420/0x0000000401c5e688@330f3046
   
   == Analyzed Logical Plan ==
   org.apache.spark.sql.AnalysisException: [UNRESOLVED_COLUMN.WITH_SUGGESTION] 
A column, variable, or function parameter with name `c1` cannot be resolved. 
Did you mean one of the following? [`Z`, `s`]. SQLSTATE: 42703; line 1 pos 129;
   'WithCTE
   :- CTERelationDef 0, false
   :  +- SubqueryAlias S
   :     +- Project [col1#5 AS c1#9, col2#6 AS c2#10]
   :        +- LocalRelation [col1#5, col2#6]
   :- CTERelationDef 1, false
   :  +- SubqueryAlias T
   :     +- Project [col1#7 AS c1#11, col2#8 AS c2#12]
   :        +- LocalRelation [col1#7, col2#8]
   +- 'Project [unresolvedalias('max('c1))]
      +- SubqueryAlias spark_catalog.default.t
         +- Relation spark_catalog.default.t[Z#13,s#14] parquet
   ```
   `PlanWithUnresolvedIdentifier` gets resolved but it tries to use table `t` 
from catalog instead of CTE definition.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to