Skip to content

Support unparsing implicit lateral UNNEST plan to SQL text #13793

Description

@goldmedal

Is your feature request related to a problem or challenge?

After #13695, we can plan the implicit lateral unnest plan now. However, the generated logical plan can't be unparsed back to the SQL text.

If we tried to unparse the plan:

#[tokio::main]
pub async fn main() -> Result<()> {
    let ctx = SessionContext::new();
    ctx.sql("CREATE TABLE t (c1 array<int>)").await?.show().await?;
    ctx.sql("INSERT INTO t VALUES (ARRAY[1, 2, 3])").await?.show().await?;
    let sql = r#"select * from t, unnest(t.c1)"#;
    println!("SQL: {}", sql);
    let df = ctx.sql(sql).await?;
    let planned = df.into_optimized_plan()?;
    println!("Plan: {}", planned);
    let sql = plan_to_sql(&planned)?;
    println!("Plan to SQL: {}", sql);
    Ok(())
}

We will get the unsupported error

Error: This feature is not implemented: Unsupported operator: Subquery(<subquery>)

Describe the solution you'd like

Implement the unparsing behavior in Unparser::select_to_sql_recursively

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions