[native] Add longVariableConstraints to function metadata#24759
[native] Add longVariableConstraints to function metadata#24759pdabre12 merged 1 commit intoprestodb:masterfrom
Conversation
64bd2eb to
f8aad49
Compare
...common/src/main/java/com/facebook/presto/functionNamespace/JsonBasedUdfFunctionMetadata.java
Show resolved
Hide resolved
f8aad49 to
ee2e5a7
Compare
|
@ScrapCodes Addressed your comments, PTAL. |
ee2e5a7 to
de146c6
Compare
aditi-pandit
left a comment
There was a problem hiding this comment.
@pdabre12 : Have an overall design question.
presto-native-execution/presto_cpp/main/types/FunctionMetadata.cpp
Outdated
Show resolved
Hide resolved
|
Hi @aditi-pandit and @pdabre12 , I have a basic question - how are these long variable constraint expressed by an end user/ developer? |
|
@ScrapCodes : The Velox developers add these constraints in function registration. Most of the current usage is for computing precision, scale of the result of arithmetic calculations of decimals |
1d4f27f to
5747600
Compare
aditi-pandit
left a comment
There was a problem hiding this comment.
@pdabre12 :This looks good overall. Just wanted you to confirm about the protocol generation.
There was a problem hiding this comment.
Please can you confirm that you built this with the make presto_protocol command, and these are not manual changes.
There was a problem hiding this comment.
Can confirm that this is built with the make presto_protocol command.
5747600 to
2b893ae
Compare
2b893ae to
3f46353
Compare
|
@jaystarshot : PTAL. |
jaystarshot
left a comment
There was a problem hiding this comment.
I may not have the right context but can you help me understand what the behavior change is (i.e what was happening before and what this fixes) and check which test case to look at to understand that?
| "date_trunc('month', from_unixtime(orderkey, '+03:00')), date_trunc('day', from_unixtime(orderkey, '-07:00')), " + | ||
| "date_trunc('hour', from_unixtime(orderkey, '-09:30')), date_trunc('minute', from_unixtime(orderkey, '+05:30')), " + | ||
| "date_trunc('second', from_unixtime(orderkey, '+00:00')) FROM orders"); | ||
| assertQuery("SELECT mod(orderkey, linenumber) FROM lineitem"); |
There was a problem hiding this comment.
What is this testing? Was the query failing before?
There was a problem hiding this comment.
I was testing function e2e test cases when sidecar is enabled, I ran into this issue there. Draft PR
Before this change, this query was failing
"SELECT mod(orderkey, linenumber) FROM lineitem"); with the error: Variable is not bound: i3.
When identifying the applicable functions from all the available mod functions , because of the lack of the longVariableConstraints, the coordinator did not know how to bind these variables.
This PR adds the necessary longVariableConstraints metadata to functions so coordinator knows how to bind these variables using the formulae defined in longVariableConstraints.
There was a problem hiding this comment.
I don't see a @constraint annotation for any mod function? (java implementation)
There was a problem hiding this comment.
These are functions that are pulled in from the C++ worker.
The constraints are already defined in the C++ function signatures, just adding them to the metadata returned via the \v1\functions endpoint here.
There was a problem hiding this comment.
But then why are constraints added in c++ function signature for mod when there is no corresponding definition in java?
There was a problem hiding this comment.
For java, they are defined here:
https://github.com/prestodb/presto/blob/master/presto-main-base/src/main/java/com/facebook/presto/type/DecimalOperators.java decimalAddOperator() when defining the signatures.
There was a problem hiding this comment.
I see so this just passes those constraints to the v1/functions? so this query should still succeed in native coordinator-worker setup but i guess its failing in the sidecar only?
Unrelated but still I am a bit confused by why mod has those constraints in c++ but not java.
There was a problem hiding this comment.
Yes, it's failing for native execution with sidecar enabled only.
For native execution without sidecar enabled, we still depend on the Java built-in functions for resolution and java Mod function signatures already have the constraints defined, hence we do not run into this issue.
There was a problem hiding this comment.
Even java mod functions have these constraints , they are added here
jaystarshot
left a comment
There was a problem hiding this comment.
Please add a release note (functions with long constraints) fail in sidecar
|
The failing |
Description
Add
longVariableConstraintsto function metadata.longVariableConstraintsare optional constraints present in the signature which are used to identify the applicable functions in the coordinator.For eg:
Consider a query like
SELECT mod(orderkey, linenumber) FROM lineitem.While identifying the applicable functions for
mod, there is a function signature with decimal args and a decimal return type.Motivation and Context
When sidecar is enabled, this query fails
"SELECT mod(orderkey, linenumber) FROM lineitem"); with the error: Variable is not bound: i3The issue arose when identifying applicable functions for the mod operation, as the lack of
longVariableConstraintsprevented the coordinator from binding variables properly. Without this metadata, the coordinator could not determine how to bind variables to the functions.This change addresses the issue by adding the necessary
longVariableConstraintsmetadata to the functions, enabling the coordinator to bind the variables correctly using the formulae defined inlongVariableConstraints.Contributor checklist