Skip to content
Permalink
Browse files
feat: add additional time partitioning intervals (#737)
* feat: add additional time partitioning intervals

* docstring updates based on comments
  • Loading branch information
stephaniewang526 committed Sep 17, 2020
1 parent 4e0d5a9 commit a57dbdf96440bc7e51443efb99b007ac42cd481b
@@ -37,16 +37,20 @@ public abstract class TimePartitioning implements Serializable {
private static final long serialVersionUID = -8565064035346940951L;

/**
* The supported types are DAY, which will generate one partition per day, and HOUR, which will
* generate one partition per hour. (Providing an empty string used to cause an error, but in
* OnePlatform the field will be treated as unset.)
* [Optional] The supported types are DAY, HOUR, MONTH, and YEAR, which will generate one
* partition per day, hour, month, and year, respectively. When the interval is not specified, the
* default behavior is DAY.
*/
public enum Type {

/** Table is partitioned per day, based on data loading time. */
/** Table is partitioned per day. */
DAY,
/** Table is partitioned per hour, based on data loading time. */
HOUR
/** Table is partitioned per hour. */
HOUR,
/** Table is partitioned per month. */
MONTH,
/** Table is partitioned per year. */
YEAR
}

TimePartitioning() {
@@ -29,6 +29,8 @@ public class TimePartitioningTest {

private static final Type TYPE_DAY = Type.DAY;
private static final Type TYPE_HOUR = Type.HOUR;
private static final Type TYPE_MONTH = Type.MONTH;
private static final Type TYPE_YEAR = Type.YEAR;
private static final long EXPIRATION_MS = 42;
private static final boolean REQUIRE_PARTITION_FILTER = false;
private static final String FIELD = "field";
@@ -44,11 +46,25 @@ public class TimePartitioningTest {
.setRequirePartitionFilter(REQUIRE_PARTITION_FILTER)
.setField(FIELD)
.build();
private static final TimePartitioning TIME_PARTITIONING_MONTH =
TimePartitioning.newBuilder(TYPE_MONTH)
.setExpirationMs(EXPIRATION_MS)
.setRequirePartitionFilter(REQUIRE_PARTITION_FILTER)
.setField(FIELD)
.build();
private static final TimePartitioning TIME_PARTITIONING_YEAR =
TimePartitioning.newBuilder(TYPE_YEAR)
.setExpirationMs(EXPIRATION_MS)
.setRequirePartitionFilter(REQUIRE_PARTITION_FILTER)
.setField(FIELD)
.build();

@Test
public void testOf() {
assertEquals(TYPE_DAY, TIME_PARTITIONING_DAY.getType());
assertEquals(TYPE_HOUR, TIME_PARTITIONING_HOUR.getType());
assertEquals(TYPE_MONTH, TIME_PARTITIONING_MONTH.getType());
assertEquals(TYPE_YEAR, TIME_PARTITIONING_YEAR.getType());
assertEquals(EXPIRATION_MS, TIME_PARTITIONING_DAY.getExpirationMs().longValue());
assertEquals(REQUIRE_PARTITION_FILTER, TIME_PARTITIONING_DAY.getRequirePartitionFilter());
assertEquals(FIELD, TIME_PARTITIONING_DAY.getField());

0 comments on commit a57dbdf

Please sign in to comment.