From 0975b60daba6116eea4144e3ef1109f96c7b465e Mon Sep 17 00:00:00 2001 From: Yash Mayya Date: Fri, 4 Oct 2024 17:31:57 +0530 Subject: [PATCH] Add check to query generator ensuring that BETWEEN on numerical literals has correct ordering since returned result table will be empty otherwise --- .../apache/pinot/integration/tests/QueryGenerator.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pinot-integration-test-base/src/test/java/org/apache/pinot/integration/tests/QueryGenerator.java b/pinot-integration-test-base/src/test/java/org/apache/pinot/integration/tests/QueryGenerator.java index 37cbdc8ad9cb..baf02481ada7 100644 --- a/pinot-integration-test-base/src/test/java/org/apache/pinot/integration/tests/QueryGenerator.java +++ b/pinot-integration-test-base/src/test/java/org/apache/pinot/integration/tests/QueryGenerator.java @@ -1005,6 +1005,16 @@ public QueryFragment generatePredicate(String columnName, boolean useMultistageE List columnValues = _columnToValueList.get(columnName); String leftValue = pickRandom(columnValues); String rightValue = pickRandom(columnValues); + + if (_singleValueNumericalColumnNames.contains(columnName)) { + // For numerical columns, make sure leftValue < rightValue. + if (Double.parseDouble(leftValue) > Double.parseDouble(rightValue)) { + String temp = leftValue; + leftValue = rightValue; + rightValue = temp; + } + } + return new StringQueryFragment( String.format("%s BETWEEN %s AND %s", columnName, leftValue, rightValue), String.format("`%s` BETWEEN %s AND %s", columnName, leftValue, rightValue));