LeiRui commented on a change in pull request #462: [IOTDB-253]time expression
URL: https://github.com/apache/incubator-iotdb/pull/462#discussion_r336825512
##########
File path:
server/src/main/java/org/apache/iotdb/db/qp/constant/DatetimeUtils.java
##########
@@ -475,6 +475,66 @@ public static long convertDatetimeStrToLong(String str,
ZoneOffset offset, int d
return getInstantWithPrecision(str, timestampPrecision);
}
+ /**
+ * convert duration string to millisecond, microsecond or nanosecond.
+ */
+ public static long convertDurationStrToLong(long value, String unit, String
timestampPrecision) {
+
+ long res = value;
+ switch (unit) {
+ case "y":
+ res *= 365 * 86400_000;
+ break;
+ case "mo":
+ res *= 30 * 86400_000;
+ break;
+ case "w":
+ res *= 7 * 86400_000;
+ break;
+ case "d":
+ res *= 86400_000;
+ break;
+ case "h":
+ res *= 3600_000;
+ break;
+ case "m":
+ res *= 60_000;
+ break;
+ case "s":
+ res *= 1_000;
+ break;
+ default:
Review comment:
Plus Plus Plus, if this miss of "ns" is a bug, better add tests to cover
this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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