alpass163 commented on code in PR #19227:
URL: https://github.com/apache/iotdb/pull/19227#discussion_r4546229067
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/ExpressionAnalyzer.java:
##########
@@ -1174,6 +1178,51 @@ public Type visitFunctionCall(FunctionCall node,
StackableAstVisitorContext<Cont
functionName));
}
}
+ break;
+ case INTEGRAL:
+ // Syntactic sugar: integral(c1) => integral(c1, '1s', time)
+ // integral(c1, time_unit) => integral(c1,
time_unit, time)
+ if (argumentsNum == 1) {
+ node.getArguments().add(new
StringLiteral(DEFAULT_INTEGRAL_TIME_UNIT));
+ addTimeArgument(node.getArguments(),
getActualTimeFieldName(relationType));
+ } else if (argumentsNum == 2) {
+ addTimeArgument(node.getArguments(),
getActualTimeFieldName(relationType));
+ } else if (argumentsNum == 3) {
+ if (!checkArgumentIsTimestamp(
+ node.getArguments().get(2), (List<Field>)
relationType.getVisibleFields())) {
+ throw new SemanticException(
+ String.format(
+ DataNodeQueryMessages
+
.THE_THIRD_ARGUMENT_OF_S_FUNCTION_MUST_BE_ACTUAL_TIME_NAME,
+ functionName));
+ }
+ } else {
+ throw new SemanticException(
+ String.format(
+ DataNodeQueryMessages
+
.AGGREGATE_FUNCTIONS_S_SHOULD_ONLY_HAVE_ONE_TWO_OR_THREE_ARGUMENTS_C1ADA261,
+ functionName));
+ }
+ // Normalize time_unit to ticks of the current timestamp precision
once, so that the
+ // accumulator does not have to parse the duration string at
execution time
+ Expression timeUnitArgument = node.getArguments().get(1);
+ if (!(timeUnitArgument instanceof LongLiteral)) {
Review Comment:
change the same syntaxes, and integral(COLUMNS(*), '1s') cannot work is
acceptable
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]