commit | 434d9733c3f7d6fdbae256895d8322bd4266b964 | [log] [tgz] |
---|---|---|
author | Shen Yu <shen@startree.ai> | Thu May 25 13:28:57 2023 -0700 |
committer | GitHub <noreply@github.com> | Thu May 25 13:28:57 2023 -0700 |
tree | 35aa8b38aedd507c01a0748c9375fe6b8f4e2fe9 | |
parent | ded7e8f5ed63dbf41fb1cdff2e6bc86672e496aa [diff] |
Add a comment to and a unit test for the group by expressions deduplication logic (#10803)
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 c04e0f7..eccc584 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
@@ -131,6 +131,7 @@ // NOTE: Order-by is always a Function with the ordering of the Expression Function thriftFunction = orderBy.getFunctionCall(); ExpressionContext expression = RequestContextUtils.getExpression(thriftFunction.getOperands().get(0)); + // Skip duplicate order by expressions, e.g.: SELECT name FROM employees ORDER BY name, name if (expressionSet.add(expression)) { boolean isAsc = thriftFunction.getOperator().equalsIgnoreCase("ASC"); orderByExpressions.add(new OrderByExpressionContext(expression, isAsc));
diff --git a/pinot-core/src/test/java/org/apache/pinot/core/query/request/context/utils/BrokerRequestToQueryContextConverterTest.java b/pinot-core/src/test/java/org/apache/pinot/core/query/request/context/utils/BrokerRequestToQueryContextConverterTest.java index 018bb275..ca67b1f 100644 --- a/pinot-core/src/test/java/org/apache/pinot/core/query/request/context/utils/BrokerRequestToQueryContextConverterTest.java +++ b/pinot-core/src/test/java/org/apache/pinot/core/query/request/context/utils/BrokerRequestToQueryContextConverterTest.java
@@ -649,4 +649,14 @@ } } } + + @Test + void testSkipDuplicateOrderByExpressions() { + String query = "SELECT name FROM employees ORDER BY name, name"; + + QueryContext queryContext = QueryContextConverterUtils.getQueryContext(query); + + assertNotNull(queryContext.getOrderByExpressions()); + assertEquals(queryContext.getOrderByExpressions().size(), 1); + } }