-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Iceberg]Support bucket transform for TimeType #24829
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
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,7 @@ | |
| import static com.facebook.presto.common.type.Decimals.isShortDecimal; | ||
| import static com.facebook.presto.common.type.Decimals.readBigDecimal; | ||
| import static com.facebook.presto.common.type.IntegerType.INTEGER; | ||
| import static com.facebook.presto.common.type.TimeType.TIME; | ||
| import static com.facebook.presto.common.type.TimestampType.TIMESTAMP; | ||
| import static com.facebook.presto.common.type.TypeUtils.readNativeValue; | ||
| import static com.facebook.presto.common.type.VarbinaryType.VARBINARY; | ||
|
|
@@ -51,6 +52,7 @@ | |
| import static java.lang.Math.floorDiv; | ||
| import static java.util.Objects.requireNonNull; | ||
| import static java.util.concurrent.TimeUnit.DAYS; | ||
| import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
| import static org.joda.time.chrono.ISOChronology.getInstanceUTC; | ||
|
|
||
| public final class PartitionTransforms | ||
|
|
@@ -157,6 +159,11 @@ public static ColumnTransform getColumnTransform(PartitionField field, Type type | |
| block -> bucketDate(block, count), | ||
| (block, position) -> bucketValueDate(block, position, count)); | ||
| } | ||
| if (type.equals(TIME)) { | ||
| return new ColumnTransform(transform, INTEGER, | ||
| block -> bucketTime(block, count), | ||
| (block, position) -> bucketValueTime(block, position, count)); | ||
| } | ||
| if (type instanceof VarcharType) { | ||
| return new ColumnTransform(transform, INTEGER, | ||
| block -> bucketVarchar(block, count), | ||
|
|
@@ -309,6 +316,16 @@ private static int bucketValueDate(Block block, int position, int count) | |
| return bucketValue(block, position, count, pos -> bucketHash(DATE.getLong(block, pos))); | ||
| } | ||
|
|
||
| private static Block bucketTime(Block block, int count) | ||
| { | ||
| return bucketBlock(block, count, position -> bucketHash(MILLISECONDS.toMicros(TIME.getLong(block, position)))); | ||
|
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. Just to confirm my understanding, we need to do this
Member
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. To be compatible with the bucketing of other systems is one of the reason, but the more important reason is to be compatible with Iceberg's file planning with filter. When we query the partitioned table with a filter on column of type TimeType as follows: We will actually first use the predicate So if we doing bucketHash directly on the
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. This was roughly my thinking. Thanks for confirming |
||
| } | ||
|
|
||
| private static int bucketValueTime(Block block, int position, int count) | ||
| { | ||
| return bucketValue(block, position, count, pos -> bucketHash(MILLISECONDS.toMicros(TIME.getLong(block, pos)))); | ||
| } | ||
|
|
||
| private static Block bucketVarchar(Block block, int count) | ||
| { | ||
| return bucketBlock(block, count, position -> bucketHash(VARCHAR.getSlice(block, position))); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.