feat(core): evaluate return-type programs and inline arithmetic - #1288
Open
alexandrefimov wants to merge 1 commit into
Open
feat(core): evaluate return-type programs and inline arithmetic#1288alexandrefimov wants to merge 1 commit into
alexandrefimov wants to merge 1 commit into
Conversation
Decimal arithmetic functions declare their return type as assignments followed by a final type expression. The evaluator currently rejects these programs, so their precision and scale cannot be derived from the function declaration. Evaluate sequential assignments and arithmetic inside type parameters using the existing argument bindings. Support integer arithmetic, min/max, comparisons, boolean operations and conditionals from [spec v0.102.0](https://github.com/substrait-io/substrait/blob/v0.102.0/site/docs/expressions/scalar_functions.md#return-type-expressions). Use signed 64-bit intermediate values and reject arithmetic overflow or narrowing outside the type parameter's 32-bit range. Integer division truncates toward zero. AND/OR evaluate both operands, while conditionals evaluate only the selected branch, matching [substrait-go's evaluator](https://github.com/substrait-io/substrait-go/blob/cb2d6e648bc0ee1549e354dbfe705d9f8a1ce2b1/types/type_derivation.go). This enables 11 of the 15 catalog return programs: eight decimal arithmetic and three rounding variants. Four temporal variants still reference integer_parameter(precision) without binding precision from an argument type and remain unsupported. Refs substrait-io#1242
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Decimal arithmetic functions declare their return type as assignments followed by a final type expression. The evaluator currently rejects these programs, so their precision and scale cannot be derived from the function declaration.
Evaluate sequential assignments and arithmetic inside type parameters using the existing argument bindings. Support integer arithmetic, min/max, comparisons, boolean operations and conditionals from spec v0.102.0. Use signed 64-bit intermediate values and reject arithmetic overflow or narrowing outside the type parameter's 32-bit range.
Integer division truncates toward zero. AND/OR evaluate both operands, while conditionals evaluate only the selected branch, matching substrait-go's evaluator.
This enables 11 of the 15 catalog return programs: eight decimal arithmetic and three rounding variants. Four temporal variants still reference integer_parameter(precision) without binding precision from an argument type and remain unsupported.
Unary abs in return expressions also remains unsupported.
Refs #1242