Skip to content

Commit

Permalink
Add check to query generator ensuring that BETWEEN on numerical liter…
Browse files Browse the repository at this point in the history
…als has correct ordering since returned result table will be empty otherwise
  • Loading branch information
yashmayya committed Oct 4, 2024
1 parent 4825c2c commit 0975b60
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,16 @@ public QueryFragment generatePredicate(String columnName, boolean useMultistageE
List<String> 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));
Expand Down

0 comments on commit 0975b60

Please sign in to comment.