-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-15582: [C++] Add support for registering tricky functions with the Substrait consumer (or add a bunch of substrait meta functions) #13285
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 all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7830d16
feat: compute functions mapping for substrait
sanjibansg 91740f8
feat: using function mappings in extension set
sanjibansg 5cbdcf5
feat: variadic boolean function mapping
sanjibansg ffc77d9
remove: enum for all function mappings
sanjibansg 754b3a3
feat: Get functions to return status invalid if function not found
sanjibansg 23f37f5
feat: registration api to return invalid status if function already r…
sanjibansg b28e5b1
feat: helpers for conversion functions
sanjibansg 3b939c1
feat: support for subtract and multiply functions
sanjibansg 76891e6
feat: mapped modulus function
sanjibansg 99cab94
feat: remaining comparison function mapping
sanjibansg a27e03f
feat: mappings for string functions
sanjibansg 93c16b5
feat: mapping for cast function
sanjibansg 7e27a7f
feat: mapping for datetime function
sanjibansg d0f8ff3
feat: mappings for divide functions
sanjibansg a716c30
feat: mappings for sum & avg aggregate functions
sanjibansg 56cbfff
feat: register functions to use function mappings
sanjibansg 3f39eae
review changes
sanjibansg 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |
| #include "arrow/util/make_unique.h" | ||
| #include "arrow/visit_scalar_inline.h" | ||
|
|
||
|
|
||
| namespace arrow { | ||
|
|
||
| using internal::checked_cast; | ||
|
|
@@ -159,21 +160,17 @@ Result<compute::Expression> FromProto(const substrait::Expression& expr, | |
|
|
||
| ARROW_ASSIGN_OR_RAISE(auto decoded_function, | ||
| ext_set.DecodeFunction(scalar_fn.function_reference())); | ||
| ARROW_ASSIGN_OR_RAISE(auto arrow_function, ext_set.GetFunctionMap().GetArrowFromSubstrait(decoded_function.name.to_string())); | ||
| return arrow_function(scalar_fn); | ||
| } | ||
|
|
||
| std::vector<compute::Expression> arguments(scalar_fn.args_size()); | ||
| for (int i = 0; i < scalar_fn.args_size(); ++i) { | ||
| ARROW_ASSIGN_OR_RAISE(arguments[i], FromProto(scalar_fn.args(i), ext_set)); | ||
| } | ||
|
|
||
| auto func_name = decoded_function.name.to_string(); | ||
| if (func_name != "cast") { | ||
| return compute::call(func_name, std::move(arguments)); | ||
| } else { | ||
| ARROW_ASSIGN_OR_RAISE(auto output_type_desc, | ||
| FromProto(scalar_fn.output_type(), ext_set)); | ||
| auto cast_options = compute::CastOptions::Safe(std::move(output_type_desc.first)); | ||
| return compute::call(func_name, std::move(arguments), std::move(cast_options)); | ||
| } | ||
| case substrait::Expression::kEnum: { | ||
| auto enum_expr = expr.enum_(); | ||
|
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. Does this convert to the string value of the enum? Can you add a small comment here explaining that. |
||
| if(enum_expr.has_specified()){ | ||
| return compute::literal(std::move(enum_expr.specified())); | ||
| } else { | ||
| return Status::Invalid("Substrait Enum value not specified"); | ||
| } | ||
| } | ||
|
|
||
| default: | ||
|
|
||
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.