Skip to content

Commit 16d6d0b

Browse files
committed
feat(partition-ttl): Introduce KeepByEventTimeStrategy to expire partitions by event time
1 parent 3504bdd commit 16d6d0b

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/ttl/strategy/KeepByEventTimeStrategy.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@
3939
* (last commit time) and {@link KeepByCreationTimeStrategy} (creation commit time).
4040
*
4141
* <h3>Supported path shapes</h3>
42-
* The first-class, tested shapes are day and hour granularity, configured via
43-
* {@link org.apache.hudi.config.HoodieTTLConfig#EVENT_TIME_FORMAT}. Each example shows the
44-
* partition path on the left and the required {@code startIndex} on the right (see
42+
* The first-class, tested shapes are day and hour granularity. Each example shows the partition
43+
* path on the left and the required {@code startIndex} on the right (see
4544
* <i>Locating the time block</i> below); non-time segments may appear before and/or after the
4645
* time block.
4746
* <ul>
@@ -90,16 +89,31 @@
9089
*
9190
* <h3>Locating the time block</h3>
9291
* The time block must occupy a <i>contiguous</i> segment range of the partition path. Only the
93-
* segments before it count toward
94-
* {@link org.apache.hudi.config.HoodieTTLConfig#EVENT_TIME_PARTITION_START_INDEX}; segments after
95-
* are ignored. Interleaved layouts such as {@code dt=20260627/source=app/hh=12} are not
96-
* supported -- the time block must be in one piece.
92+
* segments before it count toward {@code startIndex}; segments after are ignored. Interleaved
93+
* layouts such as {@code dt=20260627/source=app/hh=12} are not supported -- the time block must
94+
* be in one piece.
9795
*
9896
* <h3>Time zone</h3>
9997
* Both the partition's event time and the cutoff derived from {@code instantTime} are interpreted
10098
* in UTC. Set {@code hoodie.table.timeline.timezone=UTC} so the timeline writes instants under the
10199
* same convention; otherwise the cutoff drifts by the JVM's UTC offset -- a boundary effect at
102100
* day granularity, a full-offset shift at hour granularity.
101+
*
102+
* <h3>Configuration</h3>
103+
* All three knobs come with defaults, so a table whose partition path is purely a date in
104+
* {@code yyyy-MM-dd} form works out of the box.
105+
* <ul>
106+
* <li>{@link org.apache.hudi.config.HoodieTTLConfig#EVENT_TIME_FORMAT} — date-time pattern of
107+
* the time block in the partition path. Default {@code yyyy-MM-dd}. A {@code /} in the
108+
* pattern means the time block spans that many consecutive segments.</li>
109+
* <li>{@link org.apache.hudi.config.HoodieTTLConfig#EVENT_TIME_PARTITION_START_INDEX} —
110+
* 0-based index of the first segment that carries the time block. Default {@code 0}.
111+
* Raise it when non-time segments come before the time block (see examples above).</li>
112+
* <li>{@link org.apache.hudi.config.HoodieTTLConfig#EVENT_TIME_DELETE_HIVE_DEFAULT_PARTITION} —
113+
* whether to treat partitions containing {@code __HIVE_DEFAULT_PARTITION__} (i.e. data
114+
* whose event-time column was {@code NULL}) as expired. Default {@code false}, i.e. such
115+
* partitions are skipped with a WARN and the user keeps explicit control over them.</li>
116+
* </ul>
103117
*/
104118
@Slf4j
105119
public class KeepByEventTimeStrategy extends KeepByTimeStrategy {

0 commit comments

Comments
 (0)