mcdull-zhang opened a new pull request, #38877:
URL: https://github.com/apache/spark/pull/38877

   ### What changes were proposed in this pull request?
   The problem can be reproduced in the following way:
   ```shell
   spark-sql> CREATE OR REPLACE TEMPORARY VIEW t1 AS VALUES (1, 'a'), (2, 'b') 
tbl(c1, c2);
   
   spark-sql> CREATE OR REPLACE TEMPORARY VIEW t2 AS VALUES (1.0, 1), (2.0, 4) 
tbl(c1, c2); 
   
   spark-sql> SELECT
            > TRANSFORM(*) USING 'cat' AS (a)
            > FROM
            > (
            > SELECT c2 AS c from t2
            > UNION
            > SELECT c2 AS c from t1);
   Invalid call to toAttribute on unresolved object
   ```
   The reason is that when WidenSetOperationTypes rewrites the reference of the 
parent plan (possibly Unresolved), it will call the references of the parent 
plan to obtain all Attributes.
   
   ScriptTransformation overrides references, and it takes `child.output` as 
references.
   
   This problem may occur if the child of ScriptTransformation is Unresolved.
   
   ### Why are the changes needed?
   fix the problem
   
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   ### How was this patch tested?
   added Test
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to