Skip to main content

unnest_to_explode_select

Function unnest_to_explode_select 

Source
pub fn unnest_to_explode_select(expr: Expression) -> Result<Expression>
Expand description

Convert CROSS JOIN UNNEST to LATERAL VIEW EXPLODE/INLINE for Spark/Hive/Databricks.

This is a SELECT-level structural transformation that:

  1. Converts UNNEST in FROM clause to INLINE/EXPLODE
  2. Converts CROSS JOIN (LATERAL) UNNEST to LATERAL VIEW entries
  3. For single-arg UNNEST: uses EXPLODE
  4. For multi-arg UNNEST: uses INLINE(ARRAYS_ZIP(…))

Based on Python sqlglot’s unnest_to_explode transform in transforms.py (lines 290-391).