Skip to content

Commit

Permalink
Devin's feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nbauernfeind committed Jun 26, 2024
1 parent bb200f8 commit 9ece811
Showing 1 changed file with 4 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ public WhereFilter onComparison(CompareCondition.CompareOperation operation, Cas
private WhereFilter generateNumericConditionFilter(CompareCondition.CompareOperation operation, Value lhs,
Value rhs) {
boolean invert;
String columName;
Literal value;
final String columName;
final Literal value;
if (lhs.getDataCase() == Value.DataCase.LITERAL && rhs.getDataCase() == Value.DataCase.REFERENCE) {
invert = true;
value = lhs.getLiteral();
Expand All @@ -119,31 +119,7 @@ private WhereFilter generateNumericConditionFilter(CompareCondition.CompareOpera
.setRhs(rhs)
.build()).build());
}
String valueString;
switch (value.getValueCase()) {
case STRING_VALUE:
valueString = value.getStringValue();
break;
case DOUBLE_VALUE:
// doubles can hold up to 16 decimal places of precision
DecimalFormat format = new DecimalFormat("##0.################");
format.setDecimalSeparatorAlwaysShown(false);
format.setGroupingUsed(false);
valueString = format.format(value.getDoubleValue());
break;
case BOOL_VALUE:
valueString = Boolean.toString(value.getBoolValue());
break;
case LONG_VALUE:
valueString = Long.toString(value.getLongValue());
break;
case NANO_TIME_VALUE:
valueString = String.format("'%d'", value.getNanoTimeValue());
break;
case VALUE_NOT_SET:
default:
throw new IllegalStateException("Range filter can't handle literal type " + value.getValueCase());
}
final String valueString = FilterPrinter.printNoEscape(value);
return new RangeFilter(columName, rangeCondition(operation, invert), valueString, null,
FormulaParserConfiguration.parser);
}
Expand Down Expand Up @@ -180,13 +156,7 @@ public WhereFilter onIn(Value target, List<Value> candidatesList, CaseSensitivit
for (int i = 0; i < candidatesList.size(); i++) {
Value d = candidatesList.get(i);
assert d.getDataCase() == Value.DataCase.LITERAL;
Literal literal = d.getLiteral();
// all other literals get created from a toString except DateTime
if (literal.getValueCase() == Literal.ValueCase.NANO_TIME_VALUE) {
values[i] = String.format("'%d'", literal.getNanoTimeValue());
} else {
values[i] = FilterPrinter.printNoEscape(literal);
}
values[i] = FilterPrinter.printNoEscape(d.getLiteral());
}
return new MatchFilter(caseSensitivity(caseSensitivity), matchType(matchType), reference.getColumnName(),
values);
Expand Down

0 comments on commit 9ece811

Please sign in to comment.