pnowojski commented on a change in pull request #6614: [FLINK-9432] [table]
Support extract timeunit: DECADE, EPOCH, ISODOW, ISOYEAR…
URL: https://github.com/apache/flink/pull/6614#discussion_r220160479
##########
File path:
flink-libraries/flink-table/src/main/java/org/apache/calcite/avatica/util/DateTimeUtils.java
##########
@@ -751,15 +770,15 @@ private static int julianExtract(TimeUnitRange range,
int julian) {
return day;
case DOW:
return (int) floorMod(julian + 1, 7) + 1; //
sun=1, sat=7
+ case ISODOW:
+ return (int) floorMod(julian, 7) + 1; // mon=1,
sun=7
case WEEK:
- long fmofw = firstMondayOfFirstWeek(year);
- if (julian < fmofw) {
- fmofw = firstMondayOfFirstWeek(year -
1);
- }
- return (int) (julian - fmofw) / 7 + 1;
+ return getIso8601WeekNumber(julian, year,
month, day);
case DOY:
final long janFirst = ymdToJulian(year, 1, 1);
return (int) (julian - janFirst) + 1;
+ case DECADE:
+ return year / 10;
case CENTURY:
return year > 0
? (year + 99) / 100
Review comment:
Why `default` throws `AssertionError`? Shouldn't it be `ValidationException`
or `UnsupportedOperationException`? If it should never happen then it should be
`IllegalStateException`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services