(
&self,
unnest: &Unnest,
)
| 1564 | } |
| 1565 | |
| 1566 | fn try_unnest_to_table_factor_sql( |
| 1567 | &self, |
| 1568 | unnest: &Unnest, |
| 1569 | ) -> Result<Option<UnnestRelationBuilder>> { |
| 1570 | let mut unnest_relation = UnnestRelationBuilder::default(); |
| 1571 | let LogicalPlan::Projection(projection) = unnest.input.as_ref() else { |
| 1572 | return Ok(None); |
| 1573 | }; |
| 1574 | |
| 1575 | if !matches!(projection.input.as_ref(), LogicalPlan::EmptyRelation(_)) { |
| 1576 | // It may be possible that UNNEST is used as a source for the query. |
| 1577 | // However, at this point, we don't yet know if it is just a single expression |
| 1578 | // from another source or if it's from UNNEST. |
| 1579 | // |
| 1580 | // Unnest(Projection(EmptyRelation)) denotes a case with `UNNEST([...])`, |
| 1581 | // which is normally safe to unnest as a table factor. |
| 1582 | // However, in the future, more comprehensive checks can be added here. |
| 1583 | return Ok(None); |
| 1584 | }; |
| 1585 | |
| 1586 | let exprs = projection |
| 1587 | .expr |
| 1588 | .iter() |
| 1589 | .map(|e| self.expr_to_sql(e)) |
| 1590 | .collect::<Result<Vec<_>>>()?; |
| 1591 | unnest_relation.array_exprs(exprs); |
| 1592 | |
| 1593 | Ok(Some(unnest_relation)) |
| 1594 | } |
| 1595 | |
| 1596 | /// Build a `SELECT alias."VALUE"` item for Snowflake FLATTEN output. |
| 1597 | fn build_flatten_value_select_item( |
no test coverage detected