-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[fix](fe) Prevent cast project pushdown through union distinct #64080
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
base: master
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -42,6 +42,11 @@ public int getLen() { | |
| return len; | ||
| } | ||
|
|
||
| @Override | ||
|
Contributor
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. char[100] cast 成 char[10] 应该不能提升到 distinct 之上
Contributor
Author
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. be现在不处理这个,所以如果还有这种cast,他是安全的。cast之后也是100个字符 |
||
| public boolean canSafetyCastTo(DataType target) { | ||
|
Contributor
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. canSafetyCastTo 的目的是: 把 cast 看成函数,要求这个是单射,对吗
Contributor
Author
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. 好的 |
||
| return target instanceof CharacterType; | ||
| } | ||
|
|
||
| @Override | ||
| public Type toCatalogDataType() { | ||
| throw new RuntimeException("CharacterType is only used for implicit cast."); | ||
|
|
||
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.
canSafetyCastTois now used to decide whetherUNION DISTINCTduplicate elimination may be moved after the cast, sotruehere must mean the cast is injective. Complex-to-character casts are not always injective: for arrays/maps/structs containingFLOATorDOUBLE, direct float/double-to-string is intentionally not marked safe, but complex stringification delegates to the nested serde (for arrays,DataTypeArraySerDe::to_stringcallsnested_serde->to_string) and BE formats float/double with onlydigits10 + 1significant digits incast_to_string.h. Two distinct arrays whose float elements differ only beyond that formatted precision can therefore stringify to the same value; after this rewrite the pushed cast would makeUNION DISTINCTcollapse a row that the original plan kept. The same unconditionaltarget instanceof CharacterTypepattern inMapTypeandStructTypehas the same issue. Please either leave complex-to-character casts unsafe or require the nested types themselves to be injective when cast to the character target.