find_unnest_column_alias

Function find_unnest_column_alias 

Source
pub(super) fn find_unnest_column_alias(
    plan: &LogicalPlan,
) -> (&LogicalPlan, Option<String>)
Expand description

Try to find the column alias for UNNEST in the inner projection. For example:

    SELECT * FROM t1 CROSS JOIN UNNEST(t1.c1) AS u(c1)

The above query will be parsed into the following plan:

Projection: *
  Cross Join:
    SubqueryAlias: t1
      TableScan: t
    SubqueryAlias: u
      Subquery:
        Projection: UNNEST(outer_ref(t1.c1)) AS c1
          Projection: __unnest_placeholder(outer_ref(t1.c1),depth=1) AS UNNEST(outer_ref(t1.c1))
            Unnest: lists[__unnest_placeholder(outer_ref(t1.c1))|depth=1] structs[]
              Projection: outer_ref(t1.c1) AS __unnest_placeholder(outer_ref(t1.c1))
                EmptyRelation

The function will return the inner projection and the column alias c1 if the column name starts with UNNEST( (the Display result of Expr::Unnest) in the inner projection.