Is your feature request related to a problem or challenge?
UNNEST is implemented in two ways, SELECT UNNEST(...) is handled with other functions
|
// Build Unnest expression |
|
if name.eq("unnest") { |
|
let mut exprs = self.function_args_to_expr(args, schema, planner_context)?; |
|
if exprs.len() != 1 { |
|
return plan_err!("unnest() requires exactly one argument"); |
|
} |
|
let expr = exprs.swap_remove(0); |
|
Self::check_unnest_arg(&expr, schema)?; |
|
return Ok(Expr::Unnest(Unnest::new(expr))); |
|
} |
And SELECT ... FROM UNNEST(...) is provided as TableFactory
|
TableFactor::UNNEST { |
|
alias, |
|
array_exprs, |
|
with_offset: false, |
|
with_offset_alias: None, |
|
with_ordinality, |
|
} => { |
But those two ways are both non-generic, cases like substrait can't handle it properly, as the decoder will try to look for table function:
async fn roundtrip_unnest() -> Result<()> {
roundtrip("SELECT * FROM unnest([1, 2, 3])").await
}
Describe the solution you'd like
Implement UNNEST as a table function, making it more general and reduce the complexity (and branches) of implementation
Describe alternatives you've considered
No response
Additional context
No response
Is your feature request related to a problem or challenge?
UNNESTis implemented in two ways,SELECT UNNEST(...)is handled with other functionsdatafusion/datafusion/sql/src/expr/function.rs
Lines 246 to 255 in 84232d8
And
SELECT ... FROM UNNEST(...)is provided asTableFactorydatafusion/datafusion/sql/src/relation/mod.rs
Lines 117 to 123 in 84232d8
But those two ways are both non-generic, cases like substrait can't handle it properly, as the decoder will try to look for table function:
Describe the solution you'd like
Implement
UNNESTas a table function, making it more general and reduce the complexity (and branches) of implementationDescribe alternatives you've considered
No response
Additional context
No response