allisonwang-db commented on pull request #32303:
URL: https://github.com/apache/spark/pull/32303#issuecomment-827100090
> ```
> scala> sql("SELECT * FROM (VALUES (1), (2)) tx(a), LATERAL (SELECT a FROM
tx) ty(a)").show()
> org.apache.spark.sql.AnalysisException: Table or view not found: tx; line
1 pos 62;
> 'Project [*]
> +- 'Join LateralJoin(Inner)
> :- SubqueryAlias tx
> : +- Project [col1#345 AS a#346]
> : +- LocalRelation [col1#345]
> +- 'SubqueryAlias ty
> +- 'UnresolvedSubqueryColumnAliases [a]
> +- 'Project ['a]
> +- 'UnresolvedRelation [tx], [], false
> ```
>
> How bout the case above? The table resolution couldn't work well.
In this case `tx` in `LATERAL (SELECT a FROM tx)` will be resolved as a
relation instead of a lateral reference. Postgres also raises an error in this
case:
```
SELECT * FROM (VALUES (1), (2)) tx(a), LATERAL (SELECT a FROM tx) ty(a)
relation "tx" does not exist
```
Both of the following queries will work:
```sql
SELECT * FROM (VALUES (1), (2)) tx(a), LATERAL (SELECT a) ty(a)
SELECT * FROM (VALUES (1), (2)) tx(a), LATERAL (SELECT tx.a) ty(a)
```
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]