Github user dilipbiswal commented on the pull request:
https://github.com/apache/spark/pull/11563#issuecomment-193542558
@rxin. Hi Reynold,
We have two cases to handle.
```SQL
SELECT explode(array(1,2,3)) FROM src
SELECT gentab2.* FROM t1 LATERAL VIEW explode(array(array(1,2,3))) gentab1
AS gencol1 LATERAL VIEW explode(gentab1.gencol1) gentab2 AS gencol2
```
Currently, I handle the first case in `projToSql` and the 2nd case in
`generateToSql`,
as we wanted to generate SQLs which is closer to the original SQL.
Lateral view also can refer to columns from tables before itself. So i felt
it is safer to
generate the SQL very close to the source SQL to reduce any risk. I also
thought
about treating the first case as a special case of LATERAL view. In this
case we
had to handle the generation of a table alias which is missing in case-1
and fixing up
the projection list above to refer to it.
However, I went with the approach in this PR as it didn't seem too complex
and also retained the layout of the original SQL. I could be easily overlooking
something here and would appreciate your guidance. Please let me know.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]