-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add lambda support and array_transform udf #18921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 26 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
dbf2aa5
add lambda support
gstvg fa4a8fb
add lambdas: None to existing ScalarFunctionArgs in tests/benches
gstvg b18d214
simplify lambda support
gstvg d844b2d
rename LambdaColumn to LambdaVariable
gstvg e1921eb
feat: add LambdaUDF
gstvg 1f19c64
feat: remove lambda support for ScalarUDF
gstvg 570cc53
temporarily add pr description as DOC.md
gstvg 83dfbdd
add lambda note in substrait consumer
gstvg 34137e1
add LambdaSignature
gstvg 3ded115
improve lambda type coercion
gstvg 82930ec
lambda function type coercion: stop using unstable Iterator::eq_by
gstvg 86d5999
remove signature section from DOC.md
gstvg 60cabc0
polish lambda impl
gstvg 41152c3
minor improvoments
gstvg 2be9e54
Merge branch 'main' into lambda4
gstvg 90eb08f
improve lambdas
gstvg d874db7
cargo fmt
gstvg a59ffe8
simplify LambdaUDF coerce_value_types
gstvg cd22c04
remove DOC.md
gstvg 0188d40
add physical lambda function comments
gstvg 6f2c92b
remove secondary lambda features to be added later
gstvg b3bdc48
fix removal of lambda features
gstvg 9728a2e
fix typo
gstvg 811aa0a
Merge branch 'main' of https://github.com/apache/datafusion into lambda4
gstvg f724ef5
remove paste! from lambda macros
gstvg 5380884
fix lambda sqllogictests
gstvg d75dfe3
improve Expr::Lambda docs
gstvg a241a51
add clarifying comment on lambda type coercion
gstvg 547c148
simplify lambda type coercion
gstvg 6ae73cb
handle null values in array_transform
gstvg 39db62b
simplify LambdaUDF::lambdas_parameters
gstvg 7a7d371
cargo fmt
gstvg 83fb18d
add tip on LambdaUDF::lambdas_parameters docs to LambdaFunction helper
gstvg e76ff25
minor fixes
gstvg 51dfa81
Merge branch 'main' of https://github.com/apache/datafusion into lambda4
gstvg 6c32ef8
minor fixes
gstvg 27a3e24
simplify array_transform tests
gstvg 93e66f7
evaluate LambdaVariable by index instead of name
gstvg a9d0e6c
add LambdaUDF::clean_null_values
gstvg 69c44fc
rename LambdaUDF::lambdas_parameters to lambda_parameters
gstvg 66839d3
rename LambdaFunction to HigherOrderFunction, LambdaUDF to HigherOrde…
gstvg f0cf8d7
fix typo
gstvg 1b7f4bf
handle CaseWhen optimization
gstvg 6d7c52a
remove HigherOrderUDF::as_any
gstvg 7255820
add TaskContext::higher_order_functions
gstvg 96d8ad2
return DataType::Null for Expr::Lambda ExprSchemable::get_type
gstvg 474b22e
add higher order function type coercion tests
gstvg 954a360
avoid clone at HigherOrderFunctionExpr::with_nullable
gstvg 5c2c72a
include index in physical LambdaVariable formatting
gstvg 2259f70
improve physical LambdaVariable
gstvg 8571853
fix typo udf to udhof at HigherOrderFunctionExpr
gstvg 3c9fe39
include higher order functions in scalar function sql user guide docs
gstvg 3486e53
Merge branch 'main' of https://github.com/apache/datafusion into lambda4
gstvg 5c0b41d
Merge branch 'main' into lambda4
gstvg ca260a7
handle wrapped lambdas
gstvg 5a6f470
Merge branch 'main' of https://github.com/apache/datafusion into lambda4
gstvg 98d365a
Merge branch 'main' of https://github.com/apache/datafusion into lambda4
gstvg 9ad1d6f
remove PhysicalExpr::as_any from lambda impl
gstvg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ pub mod proxy; | |
| pub mod string_utils; | ||
|
|
||
| use crate::assert_or_internal_err; | ||
| use crate::error::{_exec_datafusion_err, _internal_datafusion_err}; | ||
| use crate::error::{_exec_datafusion_err, _exec_err, _internal_datafusion_err}; | ||
| use crate::{Result, ScalarValue}; | ||
| use arrow::array::{ | ||
| Array, ArrayRef, FixedSizeListArray, LargeListArray, ListArray, OffsetSizeTrait, | ||
|
|
@@ -971,11 +971,27 @@ pub fn take_function_args<const N: usize, T>( | |
| }) | ||
| } | ||
|
|
||
| /// Returns the inner values of a list, or an error otherwise | ||
| /// For [`ListArray`] and [`LargeListArray`], if it's sliced, it returns a | ||
| /// sliced array too. Therefore, too reconstruct a list using it, | ||
| /// you must adjust the offsets using [`adjust_offsets_for_slice`] | ||
|
Comment on lines
+986
to
+989
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are not returning the sliced values
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| pub fn list_values(array: &dyn Array) -> Result<ArrayRef> { | ||
| match array.data_type() { | ||
| DataType::List(_) => Ok(Arc::clone(array.as_list::<i32>().values())), | ||
| DataType::LargeList(_) => Ok(Arc::clone(array.as_list::<i64>().values())), | ||
| DataType::FixedSizeList(_, _) => { | ||
| Ok(Arc::clone(array.as_fixed_size_list().values())) | ||
| } | ||
| other => _exec_err!("expected list, got {other}"), | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
| use crate::ScalarValue::Null; | ||
| use arrow::array::Float64Array; | ||
| use sqlparser::ast::Ident; | ||
|
|
||
| #[test] | ||
| fn test_bisect_linear_left_and_right() -> Result<()> { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to create PR to arrow with my utils to handle nulls and list sliced but don't wait for me