-
Notifications
You must be signed in to change notification settings - Fork 13.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
[FLINK-26474][hive] Fold exprNode to fix the issue of failing to call some hive udf required constant parameters with implicit constant passed #18975
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- SORT_QUERY_RESULTS | ||
|
||
select bround(55.0, -1); | ||
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. Is there any test which the second parameter is positive? 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. I add a query |
||
|
||
[+I[60]] | ||
|
||
select bround(55.0, +1); | ||
|
||
[+I[55]] | ||
|
||
select round(123.45, -2); | ||
|
||
[+I[100]] | ||
|
||
select sha2('ABC', cast(null as int)); | ||
|
||
[+I[null]] |
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.
Is there any reason for this change? IIUC, the
toFormatString(8)
is on purpose because it is cast todecimal(30,8)
.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.
Yes, it's. But there's a special case when comes to cast constant and constant fold is enabled. Actually, the current behavior is same to Hive.
I try with the following sql in Hive:
The plan for the sql in hive
select cast(cast('2012-12-19 11:12:19.1234567' as timestamp) as decimal(30,8))
is:The plan for
select cast(c1 as decimal(30, 8)) from t1
is :The reason I found is the
HiveDecimalConverter
used to convert data in Hive'sGenericUDFToDecimal
function actually won't padding zero for2012-12-19 11:12:19.1234567
, althogh the type isdecimal(30,8)
.Then, the first sql will select a constant
1355915539.1234567
.But for the second sql, a further padding will be done which will result
1355915539.12345670
.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.
Thank you for the explanation.