This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new d736307f8e Refine isNullsLast and isAsc functions. (#11199)
d736307f8e is described below
commit d736307f8ebad9e80de98affad5fe1c46f3607a0
Author: Shen Yu <[email protected]>
AuthorDate: Fri Jul 28 00:32:54 2023 -0700
Refine isNullsLast and isAsc functions. (#11199)
---
.../context/utils/QueryContextConverterUtils.java | 31 +++++++++-------------
1 file changed, 13 insertions(+), 18 deletions(-)
diff --git
a/pinot-core/src/main/java/org/apache/pinot/core/query/request/context/utils/QueryContextConverterUtils.java
b/pinot-core/src/main/java/org/apache/pinot/core/query/request/context/utils/QueryContextConverterUtils.java
index 7d16ed1cc4..0395330850 100644
---
a/pinot-core/src/main/java/org/apache/pinot/core/query/request/context/utils/QueryContextConverterUtils.java
+++
b/pinot-core/src/main/java/org/apache/pinot/core/query/request/context/utils/QueryContextConverterUtils.java
@@ -116,8 +116,8 @@ public class QueryContextConverterUtils {
orderByExpressions = new ArrayList<>(orderByList.size());
Set<Expression> seen = new HashSet<>();
for (Expression orderBy : orderByList) {
- boolean isAsc = isAsc(orderBy);
Boolean isNullsLast = isNullsLast(orderBy);
+ boolean isAsc = isAsc(orderBy, isNullsLast);
Expression orderByFunctionsRemoved =
CalciteSqlParser.removeOrderByFunctions(orderBy);
// Deduplicate the order-by expressions
if (seen.add(orderByFunctionsRemoved)) {
@@ -156,27 +156,22 @@ public class QueryContextConverterUtils {
.setExplain(pinotQuery.isExplain()).build();
}
- private static boolean isAsc(Expression expression) {
- while (expression != null && expression.isSetFunctionCall()) {
- if
(expression.getFunctionCall().getOperator().equals(CalciteSqlParser.ASC)) {
- return true;
- }
- expression = expression.getFunctionCall().getOperands().get(0);
+ @Nullable
+ private static Boolean isNullsLast(Expression expression) {
+ String operator = expression.getFunctionCall().getOperator();
+ if (operator.equals(CalciteSqlParser.NULLS_LAST)) {
+ return true;
+ } else if (operator.equals(CalciteSqlParser.NULLS_FIRST)) {
+ return false;
+ } else {
+ return null;
}
- return false;
}
- @Nullable
- private static Boolean isNullsLast(Expression expression) {
- while (expression != null && expression.isSetFunctionCall()) {
- String operator = expression.getFunctionCall().getOperator();
- if (operator.equals(CalciteSqlParser.NULLS_LAST)) {
- return true;
- } else if (operator.equals(CalciteSqlParser.NULLS_FIRST)) {
- return false;
- }
+ private static boolean isAsc(Expression expression, Boolean isNullsLast) {
+ if (isNullsLast != null) {
expression = expression.getFunctionCall().getOperands().get(0);
}
- return null;
+ return
expression.getFunctionCall().getOperator().equals(CalciteSqlParser.ASC);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]