提交 d858442f authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Result of EXTRACT with MCS and NS arguments fits into int

上级 2f63fe27
...@@ -1501,17 +1501,9 @@ public class Function extends Expression implements FunctionCall { ...@@ -1501,17 +1501,9 @@ public class Function extends Expression implements FunctionCall {
break; break;
case EXTRACT: { case EXTRACT: {
int field = getDatePart(v0.getString()); int field = getDatePart(v0.getString());
switch (field) { if (field != EPOCH) {
default:
result = ValueInt.get(getIntDatePart(v1, field)); result = ValueInt.get(getIntDatePart(v1, field));
break; } else {
case Function.MICROSECOND:
result = ValueLong.get(DateTimeUtils.dateAndTimeFromValue(v1)[1] / 1_000 % 1_000_000);
break;
case Function.NANOSECOND:
result = ValueLong.get(DateTimeUtils.dateAndTimeFromValue(v1)[1] % 1_000_000_000);
break;
case EPOCH: {
// Case where we retrieve the EPOCH time. // Case where we retrieve the EPOCH time.
// First we retrieve the dateValue and his time in nanoseconds. // First we retrieve the dateValue and his time in nanoseconds.
...@@ -1556,7 +1548,6 @@ public class Function extends Expression implements FunctionCall { ...@@ -1556,7 +1548,6 @@ public class Function extends Expression implements FunctionCall {
result = ValueDecimal.get(timeNanosBigDecimal.divide(nanosSeconds).add(numberOfDays.multiply(secondsPerDay))); result = ValueDecimal.get(timeNanosBigDecimal.divide(nanosSeconds).add(numberOfDays.multiply(secondsPerDay)));
} }
} }
}
break; break;
} }
case FORMATDATETIME: { case FORMATDATETIME: {
...@@ -2897,6 +2888,10 @@ public class Function extends Expression implements FunctionCall { ...@@ -2897,6 +2888,10 @@ public class Function extends Expression implements FunctionCall {
return (int) (timeNanos / 1_000_000_000 % 60); return (int) (timeNanos / 1_000_000_000 % 60);
case Function.MILLISECOND: case Function.MILLISECOND:
return (int) (timeNanos / 1_000_000 % 1_000); return (int) (timeNanos / 1_000_000 % 1_000);
case Function.MICROSECOND:
return (int) (timeNanos / 1_000 % 1_000_000);
case Function.NANOSECOND:
return (int) (timeNanos % 1_000_000_000);
case Function.DAY_OF_YEAR: case Function.DAY_OF_YEAR:
return DateTimeUtils.getDayOfYear(dateValue); return DateTimeUtils.getDayOfYear(dateValue);
case Function.DAY_OF_WEEK: case Function.DAY_OF_WEEK:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论