-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-27370: support 4 bytes characters #5624
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?
Conversation
|
@difin, please take a look when you have time |
@deniskuzZ Sorry, I also overlooked this comments. I fixed it. |
Sure. I was not confident that I should review coworker's patch to avoid bias. I will check this anyway. |
substr('あa🤎いiうu', 1, 3) as b1, | ||
substr('あa🤎いiうu', 3) as b2, | ||
substr('あa🤎いiうu', -5) as b3 | ||
FROM src tablesample (1 rows); |
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.
I verified the master branch can't pass this test case
+POSTHOOK: query: SELECT
+ substr('あa🤎いiうu', 1, 3) as b1,
+ substr('あa🤎いiうu', 3) as b2,
+ substr('あa🤎いiうu', -5) as b3
+FROM src tablesample (1 rows)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+あa? 🤎いiうu ?いiうu
String s = t.toString(); | ||
int[] index = makeIndex(pos, len, s.length()); | ||
if (index == null) { | ||
byte[] utf8String = t.toString().getBytes(); |
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.
Why not use Text#getBytes
or Text#copyBytes
? Probably, getBytes
is preferable because we don't mutate it. Note that we have to use Text#getLength
instead of the size of the byte array.
https://github.com/apache/hadoop/blob/rel/release-3.4.1/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/Text.java#L116-L132
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.
Ah, OK. I will fix it.
Co-authored-by: Shohei Okumiya <[email protected]>
Looks good to me, but we're running additional in-house integration tests just in case. |
|
What changes were proposed in this pull request?
If a
SUBSTR
UDF has a 4-byte characters in its parameter, the behavior is different between vectorized and non-vectorized. The vectorized version handles 4-byte characters properly, but the non-vectorized version does not, so similar logic is needed.And these fixes use vectorized logic:
https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStartLen.java#L89-L130
https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/exec/vector/expressions/StringSubstrColStart.java#L78-L109
Why are the changes needed?
Vectorized and non-vectorized have different results.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added pattern tests to itest for these to work correctly.