fx19880617 commented on a change in pull request #6152:
URL: https://github.com/apache/incubator-pinot/pull/6152#discussion_r507007311
##########
File path:
pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
##########
@@ -364,6 +367,42 @@ private static void queryRewrite(PinotQuery pinotQuery) {
validate(aliasMap, pinotQuery);
}
+ private static void applyOrdinals(PinotQuery pinotQuery) {
+ // handle GROUP BY clause
+ for (int i = 0; i < pinotQuery.getGroupByListSize(); i++) {
+ final Expression groupByExpr = pinotQuery.getGroupByList().get(i);
+ if (groupByExpr.isSetLiteral() &&
groupByExpr.getLiteral().isSetLongValue()) {
+ final int ordinal = (int) groupByExpr.getLiteral().getLongValue();
+ pinotQuery.getGroupByList().set(i,
getExpressionFromOrdinal(pinotQuery.getSelectList(), ordinal));
+ }
+ }
+
+ // handle ORDER BY clause
+ for (int i = 0; i < pinotQuery.getOrderByListSize(); i++) {
+ final Expression orderByExpr =
pinotQuery.getOrderByList().get(i).getFunctionCall().getOperands().get(0);
+ if (orderByExpr.isSetLiteral() &&
orderByExpr.getLiteral().isSetLongValue()) {
+ final int ordinal = (int) orderByExpr.getLiteral().getLongValue();
+ pinotQuery.getOrderByList().get(i).getFunctionCall()
+
.setOperands(Arrays.asList(getExpressionFromOrdinal(pinotQuery.getSelectList(),
ordinal)));
+ }
+ }
Review comment:
Below is an example of query and results from mysql:

----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]