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 434d9733c3 Add a comment to and a unit test for the group by expressions deduplication logic (#10803) 434d9733c3 is described below commit 434d9733c3f7d6fdbae256895d8322bd4266b964 Author: Shen Yu <s...@startree.ai> AuthorDate: Thu May 25 13:28:57 2023 -0700 Add a comment to and a unit test for the group by expressions deduplication logic (#10803) --- .../request/context/utils/QueryContextConverterUtils.java | 1 + .../utils/BrokerRequestToQueryContextConverterTest.java | 10 ++++++++++ 2 files changed, 11 insertions(+) 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 c04e0f7b42..eccc584bbb 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 @@ public class QueryContextConverterUtils { // 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 018bb275f4..ca67b1fbc4 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 @@ public class BrokerRequestToQueryContextConverterTest { } } } + + @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); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org