xuzifu666 commented on code in PR #4933:
URL: https://github.com/apache/calcite/pull/4933#discussion_r3437423453
##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -3261,8 +3069,10 @@ private void registerQuery(
if (orderList != null) {
// If the query is 'SELECT DISTINCT', restrict the columns
// available to the ORDER BY clause.
+ // DISTINCT ON is an exception: ORDER BY may reference columns
+ // not in the SELECT list.
final SqlValidatorScope selectScope3 =
- select.isDistinct()
+ (select.isDistinct() && !select.isDistinctOn())
Review Comment:
> And then you won't need an aggregate because the result has only 1 row?
Yes, that’s the reason. I also added tests for `DISTINCT` and `DISTINCT ON`;
in fact, this syntax isn't supported and results in an immediate error.
##########
core/src/main/java/org/apache/calcite/sql/SqlSelectOperator.java:
##########
@@ -37,14 +37,19 @@
* <p>Operands are:
*
* <ul>
- * <li>0: distinct ({@link SqlLiteral})</li>
+ * <li>0: keywordList ({@link SqlNodeList})</li>
Review Comment:
Yes, there is no need. I changed it.
--
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]