Skip to content
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

feat: add additional time partitioning intervals #737

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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.)
* The supported types are DAY, HOUR, MONTH, and YEAR which will generate one partition per time
* unit type. (Providing an empty string used to cause an error, but in OnePlatform the field will
stephaniewang526 marked this conversation as resolved.
Show resolved Hide resolved
* be treated as unset.)
*/
public enum Type {

/** Table is partitioned per day, based on data loading time. */
stephaniewang526 marked this conversation as resolved.
Show resolved Hide resolved
DAY,
/** Table is partitioned per hour, based on data loading time. */
HOUR
HOUR,
/** Table is partitioned per month, based on data loading time. */
MONTH,
/** Table is partitioned per year, based on data loading time. */
YEAR
}

TimePartitioning() {
Expand Down
Expand Up @@ -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";
Expand All @@ -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());
Expand Down