Convert an `Unnest` logical plan node to a `LATERAL FLATTEN(INPUT => expr, ...)` table factor for Snowflake-style SQL output.
(
&self,
unnest: &Unnest,
)
| 1615 | /// Convert an `Unnest` logical plan node to a `LATERAL FLATTEN(INPUT => expr, ...)` |
| 1616 | /// table factor for Snowflake-style SQL output. |
| 1617 | fn try_unnest_to_lateral_flatten_sql( |
| 1618 | &self, |
| 1619 | unnest: &Unnest, |
| 1620 | ) -> Result<Option<FlattenRelationBuilder>> { |
| 1621 | let Some(projection) = Self::peel_to_inner_projection(unnest.input.as_ref()) |
| 1622 | else { |
| 1623 | return Ok(None); |
| 1624 | }; |
| 1625 | |
| 1626 | // For now, handle the simple case of a single expression to flatten. |
| 1627 | // Multi-expression would require multiple LATERAL FLATTEN calls chained together. |
| 1628 | let Some(first_expr) = projection.expr.first() else { |
| 1629 | return Ok(None); |
| 1630 | }; |
| 1631 | |
| 1632 | let input_expr = self.expr_to_sql(first_expr)?; |
| 1633 | |
| 1634 | let mut flatten = FlattenRelationBuilder::default(); |
| 1635 | flatten.input_expr(input_expr); |
| 1636 | flatten.outer(unnest.options.preserve_nulls); |
| 1637 | |
| 1638 | Ok(Some(flatten)) |
| 1639 | } |
| 1640 | |
| 1641 | fn is_scan_with_pushdown(scan: &TableScan) -> bool { |
| 1642 | scan.projection.is_some() || !scan.filters.is_empty() || scan.fetch.is_some() |
no test coverage detected