-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
HIVE-27522: Iceberg: Bucket partition transformation date type support #4507
Conversation
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.
+1
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.
LGTM. 1 minor comment.
Transform<Integer, Integer> dateTransform = Transforms.bucket(Types.DateType.get(), numBuckets); | ||
evaluator = arg -> { | ||
DateWritableV2 val = (DateWritableV2) converter.convert(arg.get()); | ||
result.set(dateTransform.apply(val.get().toEpochDay())); |
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.
How about val.getDays()
instead of val.get().toEpochDay()
?
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.
👍, fixed
result.set(dateTransform.apply(val.getDays())); | ||
}; | ||
break; | ||
|
||
default: | ||
throw new UDFArgumentException( | ||
" ICEBERG_BUCKET() only takes STRING/CHAR/VARCHAR/BINARY/INT/LONG/DECIMAL/FLOAT/DOUBLE" + |
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.
Shoud we add DATE
type in the UDFArgumentException message?
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.
nice catch, thanks!
case DATE: | ||
converter = new PrimitiveObjectInspectorConverter.DateConverter(argumentOI, | ||
PrimitiveObjectInspectorFactory.writableDateObjectInspector); | ||
Transform<Integer, Integer> dateTransform = Transforms.bucket(Types.DateType.get(), numBuckets); |
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.
Nit: Transform<T, Integer> bucket(Type type, int numBuckets)
will be removed in the future.
https://github.com/apache/iceberg/blob/e7d21a948865dc182a718f779757cb5f181856cb/api/src/main/java/org/apache/iceberg/transforms/Transforms.java#L196-L208
Maybe we can use this instread:
Function<Object, Integer> dateTransform = Transforms.bucket(numBuckets).bind(Types.DateType.get());
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.
changed
0facce7
to
ec2b33a
Compare
Kudos, SonarCloud Quality Gate passed! |
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.
+1. Change looks good to me.
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.
LGTM
…t (Denys Kuzmenko, reviewed by Attila Turoczy, Ayush Saxena, Butao Zhang, Sourabh Badhya) Closes apache#4507
What changes were proposed in this pull request?
Bucket partition transformation date type support
Why are the changes needed?
UDFArgumentException: ICEBERG_BUCKET() only takes STRING/CHAR/VARCHAR/BINARY/INT/LONG/DECIMAL/FLOAT/DOUBLE types as first argument, got DATE
Does this PR introduce any user-facing change?
No
Is the change a dependency upgrade?
No
How was this patch tested?
qtest