-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Window UDF signature check #12045
Window UDF signature check #12045
Conversation
Signed-off-by: jayzhan211 <[email protected]>
1 1 | ||
|
||
# RowNumber expect 0 args. | ||
query error |
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.
not an error on main
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.
Wild -- I double checked and you are right
DataFusion CLI v41.0.0
> create table t(a int, b int) as values (1, 2);
0 row(s) fetched.
Elapsed 0.015 seconds.
> select a, row_number() over (order by b) as rn from t;
+---+----+
| a | rn |
+---+----+
| 1 | 1 |
+---+----+
1 row(s) fetched.
Elapsed 0.006 seconds.
> select a, row_number(a) over (order by b) as rn from t;
+---+----+
| a | rn |
+---+----+
| 1 | 1 |
+---+----+
1 row(s) fetched.
Elapsed 0.002 seconds.
Signed-off-by: jayzhan211 <[email protected]>
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.
Thanks @jayzhan211 Overall LGTM but one typo comment.
datafusion/expr/src/udwf.rs
Outdated
/// Coerce arguments of a function call to types that the function can evaluate. | ||
/// | ||
/// This function is only called if [`WindowUDFImpl::signature`] returns [`crate::TypeSignature::UserDefined`]. Most | ||
/// UDAFs should return one of the other variants of `TypeSignature` which handle common |
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.
/// UDAFs should return one of the other variants of `TypeSignature` which handle common | |
/// UDWFs should return one of the other variants of `TypeSignature` which handle common |
It looks like a typo (?
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.
Thanks @jayzhan211 and @goldmedal for the review
I didn't realize there was no signature checking 🤯
@@ -95,6 +94,32 @@ pub fn data_types_with_aggregate_udf( | |||
try_coerce_types(valid_types, current_types, &signature.type_signature) | |||
} | |||
|
|||
pub fn data_types_with_window_udf( |
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.
Can you please add documentation for this (pub
) function? I think we could basically follow the pattern of the docs on data_types_with_scalar_udf
above
1 1 | ||
|
||
# RowNumber expect 0 args. | ||
query error |
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.
Wild -- I double checked and you are right
DataFusion CLI v41.0.0
> create table t(a int, b int) as values (1, 2);
0 row(s) fetched.
Elapsed 0.015 seconds.
> select a, row_number() over (order by b) as rn from t;
+---+----+
| a | rn |
+---+----+
| 1 | 1 |
+---+----+
1 row(s) fetched.
Elapsed 0.006 seconds.
> select a, row_number(a) over (order by b) as rn from t;
+---+----+
| a | rn |
+---+----+
| 1 | 1 |
+---+----+
1 row(s) fetched.
Elapsed 0.002 seconds.
Signed-off-by: jayzhan211 <[email protected]>
Thanks @goldmedal @alamb |
Which issue does this PR close?
Closes #.
Rationale for this change
We haven't add signature check for window udf, so we didn't get the expected error if the arguments failed to match the signature
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?