mirror of https://github.com/apache/druid.git
Add EIGHT_HOUR into possible list of Granularities. (#12717)
* Add EIGHT_HOUR into possible list of Granularities. * Add the missing definition. * fix test. * Fix another test. * Stylecheck finally passed. Co-authored-by: Didip Kerabat <didip@apple.com>
This commit is contained in:
parent
2b330186e2
commit
06251c5d2a
|
@ -33,6 +33,7 @@ public class Granularities
|
|||
public static final Granularity THIRTY_MINUTE = GranularityType.THIRTY_MINUTE.getDefaultGranularity();
|
||||
public static final Granularity HOUR = GranularityType.HOUR.getDefaultGranularity();
|
||||
public static final Granularity SIX_HOUR = GranularityType.SIX_HOUR.getDefaultGranularity();
|
||||
public static final Granularity EIGHT_HOUR = GranularityType.EIGHT_HOUR.getDefaultGranularity();
|
||||
public static final Granularity DAY = GranularityType.DAY.getDefaultGranularity();
|
||||
public static final Granularity WEEK = GranularityType.WEEK.getDefaultGranularity();
|
||||
public static final Granularity MONTH = GranularityType.MONTH.getDefaultGranularity();
|
||||
|
|
|
@ -57,6 +57,7 @@ public enum GranularityType
|
|||
"PT1H"
|
||||
),
|
||||
SIX_HOUR(HOUR, "PT6H"),
|
||||
EIGHT_HOUR(HOUR, "PT8H"),
|
||||
DAY(
|
||||
"'dt'=yyyy-MM-dd",
|
||||
"'y'=yyyy/'m'=MM/'d'=dd",
|
||||
|
@ -214,7 +215,9 @@ public enum GranularityType
|
|||
case 3:
|
||||
return GranularityType.DAY;
|
||||
case 4:
|
||||
if (vals[index] == 6) {
|
||||
if (vals[index] == 8) {
|
||||
return GranularityType.EIGHT_HOUR;
|
||||
} else if (vals[index] == 6) {
|
||||
return GranularityType.SIX_HOUR;
|
||||
} else if (vals[index] == 1) {
|
||||
return GranularityType.HOUR;
|
||||
|
|
|
@ -46,6 +46,7 @@ public class GranularityTest
|
|||
final Granularity MINUTE = Granularities.MINUTE;
|
||||
final Granularity HOUR = Granularities.HOUR;
|
||||
final Granularity SIX_HOUR = Granularities.SIX_HOUR;
|
||||
final Granularity EIGHT_HOUR = Granularities.EIGHT_HOUR;
|
||||
final Granularity FIFTEEN_MINUTE = Granularities.FIFTEEN_MINUTE;
|
||||
final Granularity DAY = Granularities.DAY;
|
||||
final Granularity WEEK = Granularities.WEEK;
|
||||
|
@ -399,6 +400,90 @@ public class GranularityTest
|
|||
checkToDate(SIX_HOUR, Granularity.Formatter.DEFAULT, hourChecks);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEightHourToDate()
|
||||
{
|
||||
PathDate[] hourChecks = {
|
||||
new PathDate(
|
||||
new DateTime(2011, 3, 15, 16, 0, 0, 0, ISOChronology.getInstanceUTC()),
|
||||
null,
|
||||
"y=2011/m=03/d=15/H=20/M=50/S=43/Test0"
|
||||
),
|
||||
new PathDate(
|
||||
new DateTime(2011, 3, 15, 16, 0, 0, 0, ISOChronology.getInstanceUTC()),
|
||||
null,
|
||||
"/y=2011/m=03/d=15/H=20/M=50/S=43/Test0"
|
||||
),
|
||||
new PathDate(
|
||||
new DateTime(2011, 3, 15, 16, 0, 0, 0, ISOChronology.getInstanceUTC()),
|
||||
null,
|
||||
"valid/y=2011/m=03/d=15/H=20/M=50/S=43/Test1"
|
||||
),
|
||||
new PathDate(
|
||||
new DateTime(2011, 3, 15, 16, 0, 0, 0, ISOChronology.getInstanceUTC()),
|
||||
null,
|
||||
"valid/y=2011/m=03/d=15/H=20/M=50/Test2"
|
||||
),
|
||||
new PathDate(
|
||||
new DateTime(2011, 3, 15, 16, 0, 0, 0, ISOChronology.getInstanceUTC()),
|
||||
null,
|
||||
"valid/y=2011/m=03/d=15/H=20/Test3"
|
||||
),
|
||||
new PathDate(null, null, "valid/y=2011/m=03/d=15/Test4"),
|
||||
new PathDate(null, null, "valid/y=2011/m=03/Test5"),
|
||||
new PathDate(null, null, "valid/y=2011/Test6"),
|
||||
new PathDate(null, null, "null/y=/m=/d=/Test7"),
|
||||
new PathDate(null, null, "null/m=10/y=2011/d=23/Test8"),
|
||||
new PathDate(null, null, "null/Test9"),
|
||||
new PathDate(null, null, ""), //Test10 Intentionally empty.
|
||||
new PathDate(
|
||||
new DateTime(2011, 10, 20, 16, 0, 0, 0, ISOChronology.getInstanceUTC()),
|
||||
null,
|
||||
"error/y=2011/m=10/d=20/H=20/M=42/S=72/Test11"
|
||||
),
|
||||
new PathDate(
|
||||
new DateTime(2011, 10, 20, 16, 0, 0, 0, ISOChronology.getInstanceUTC()),
|
||||
null,
|
||||
"error/y=2011/m=10/d=20/H=20/M=90/S=24/Test12"
|
||||
),
|
||||
new PathDate(
|
||||
new DateTime(2011, 10, 20, 0, 0, 0, 0, ISOChronology.getInstanceUTC()),
|
||||
null,
|
||||
"error/y=2011/m=10/d=20/H=00/M=90/S=24/Test12"
|
||||
),
|
||||
new PathDate(
|
||||
new DateTime(2011, 10, 20, 0, 0, 0, 0, ISOChronology.getInstanceUTC()),
|
||||
null,
|
||||
"error/y=2011/m=10/d=20/H=02/M=90/S=24/Test12"
|
||||
),
|
||||
new PathDate(
|
||||
new DateTime(2011, 10, 20, 0, 0, 0, 0, ISOChronology.getInstanceUTC()),
|
||||
null,
|
||||
"error/y=2011/m=10/d=20/H=06/M=90/S=24/Test12"
|
||||
),
|
||||
new PathDate(
|
||||
new DateTime(2011, 10, 20, 8, 0, 0, 0, ISOChronology.getInstanceUTC()),
|
||||
null,
|
||||
"error/y=2011/m=10/d=20/H=11/M=90/S=24/Test12"
|
||||
),
|
||||
new PathDate(
|
||||
new DateTime(2011, 10, 20, 8, 0, 0, 0, ISOChronology.getInstanceUTC()),
|
||||
null,
|
||||
"error/y=2011/m=10/d=20/H=12/M=90/S=24/Test12"
|
||||
),
|
||||
new PathDate(
|
||||
new DateTime(2011, 10, 20, 8, 0, 0, 0, ISOChronology.getInstanceUTC()),
|
||||
null,
|
||||
"error/y=2011/m=10/d=20/H=13/M=90/S=24/Test12"
|
||||
),
|
||||
new PathDate(null, IllegalFieldValueException.class, "error/y=2011/m=10/d=20/H=42/M=42/S=24/Test13"),
|
||||
new PathDate(null, IllegalFieldValueException.class, "error/y=2011/m=10/d=33/H=20/M=42/S=24/Test14"),
|
||||
new PathDate(null, IllegalFieldValueException.class, "error/y=2011/m=13/d=20/H=20/M=42/S=24/Test15")
|
||||
};
|
||||
|
||||
checkToDate(EIGHT_HOUR, Granularity.Formatter.DEFAULT, hourChecks);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDayToDate()
|
||||
{
|
||||
|
@ -886,6 +971,7 @@ public class GranularityTest
|
|||
Assert.assertEquals(
|
||||
ImmutableList.of(
|
||||
Granularities.DAY,
|
||||
Granularities.EIGHT_HOUR,
|
||||
Granularities.SIX_HOUR,
|
||||
Granularities.HOUR,
|
||||
Granularities.THIRTY_MINUTE,
|
||||
|
@ -927,6 +1013,7 @@ public class GranularityTest
|
|||
Granularities.MONTH,
|
||||
Granularities.WEEK,
|
||||
Granularities.DAY,
|
||||
Granularities.EIGHT_HOUR,
|
||||
Granularities.SIX_HOUR,
|
||||
Granularities.HOUR,
|
||||
Granularities.THIRTY_MINUTE,
|
||||
|
|
|
@ -1632,6 +1632,7 @@ public class CompactionTaskTest
|
|||
Granularities.SECOND,
|
||||
Granularities.MINUTE,
|
||||
Granularities.SIX_HOUR,
|
||||
Granularities.EIGHT_HOUR,
|
||||
Granularities.DAY,
|
||||
null,
|
||||
Granularities.ALL,
|
||||
|
@ -1648,6 +1649,7 @@ public class CompactionTaskTest
|
|||
Granularities.SECOND,
|
||||
Granularities.MINUTE,
|
||||
Granularities.SIX_HOUR,
|
||||
Granularities.EIGHT_HOUR,
|
||||
Granularities.NONE,
|
||||
Granularities.DAY,
|
||||
Granularities.NONE,
|
||||
|
|
|
@ -750,7 +750,7 @@ public class CalciteInsertDmlTest extends CalciteIngestionDmlTest
|
|||
ThrowableMessageMatcher.hasMessage(CoreMatchers.containsString(
|
||||
"The granularity specified in PARTITIONED BY is not supported. "
|
||||
+ "Please use an equivalent of these granularities: second, minute, five_minute, ten_minute, "
|
||||
+ "fifteen_minute, thirty_minute, hour, six_hour, day, week, month, quarter, year, all."))
|
||||
+ "fifteen_minute, thirty_minute, hour, six_hour, eight_hour, day, week, month, quarter, year, all."))
|
||||
)
|
||||
)
|
||||
.verify();
|
||||
|
|
Loading…
Reference in New Issue