AMashenkov commented on a change in pull request #9226:
URL: https://github.com/apache/ignite/pull/9226#discussion_r687636789
##########
File path:
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/IgniteSqlValidator.java
##########
@@ -312,14 +315,49 @@ private void validateAggregateFunction(SqlCall call,
SqlAggFunction aggFunction)
case AVG:
case MIN:
case MAX:
-
+ return;
+ case STRING_AGG:
+ case GROUP_CONCAT:
+ validateStringAggFunction(call, aggFunction);
return;
default:
throw newValidationError(call,
IgniteResource.INSTANCE.unsupportedAggregationFunction(aggFunction.getName()));
}
}
+ /** */
+ private void validateStringAggFunction(SqlCall call, SqlAggFunction
function) {
+ if (call.getFunctionQuantifier() == null)
+ return;
+
+ SqlLiteral quantifier = call.getFunctionQuantifier();
+
+ if (!(quantifier.getValue() instanceof SqlSelectKeyword))
+ return;
+
+ SqlSelectKeyword keyword = (SqlSelectKeyword)quantifier.getValue();
+
+ if (SqlSelectKeyword.DISTINCT != keyword)
+ return;
+
+ List<SqlNode> operands = call.getOperandList();
+
+ Optional<SqlNode> nodeList = operands.stream().filter(operand ->
operand instanceof SqlNodeList).findFirst();
+
+ if (!nodeList.isPresent())
+ return;
+
+ Optional<SqlNode> illegalArguments =
((SqlNodeList)nodeList.get()).stream()
+ .filter(
+ node -> operands.stream().noneMatch(operand ->
operand.equalsDeep(node, Litmus.IGNORE))
+ ).findAny();
Review comment:
I can't figure out what happens here, and how this match to the next
tests?
And why 2-nd test - OK, and 1-st NOT-OK.
```
statement error
SELECT STRING_AGG(s,',' ORDER BY s::VARCHAR ASC), STRING_AGG(DISTINCT s, ','
ORDER BY s::VARCHAR ASC) FROM integers
query TT
SELECT STRING_AGG(s,',' ORDER BY s::VARCHAR ASC), STRING_AGG(DISTINCT
s::VARCHAR, ',' ORDER BY s::VARCHAR ASC) FROM integers
----
```
--
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]