Skip to content

Commit

Permalink
Fix ExactMatch Filter for Non-Convertible Types; Use RangeFilter on Q…
Browse files Browse the repository at this point in the history
…ueryScope Vars (#5587)

Co-authored-by: Ryan Caudy <[email protected]>
  • Loading branch information
nbauernfeind and rcaudy authored Jun 25, 2024
1 parent f98c78d commit f647f1a
Show file tree
Hide file tree
Showing 21 changed files with 1,283 additions and 384 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,14 @@ public OUTPUT_TYPE get() {
}
return cachedResult;
}

public OUTPUT_TYPE getIfCached() {
if (hasCachedResult) { // force a volatile read
if (errorResult != null) {
throw errorResult;
}
return cachedResult;
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,7 @@ private PreAndPostFilters applyFilterRenamings(WhereFilter[] filters) {
} else if (filter instanceof MatchFilter) {
final MatchFilter matchFilter = (MatchFilter) filter;
Assert.assertion(myRenames.size() == 1, "Match Filters should only use one column!");
String newName = myRenames.get(matchFilter.getColumnName());
Assert.neqNull(newName, "newName");
final MatchFilter newFilter = matchFilter.renameFilter(newName);
final WhereFilter newFilter = matchFilter.renameFilter(myRenames);
newFilter.init(tableReference.getDefinition(), compilationProcessor);
preViewFilters.add(newFilter);
} else if (filter instanceof ConditionFilter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ public ByteRangeFilter(String columnName, byte val1, byte val2, boolean lowerInc
}
}

static WhereFilter makeByteRangeFilter(String columnName, Condition condition, String value) {
static WhereFilter makeByteRangeFilter(String columnName, Condition condition, byte value) {
switch (condition) {
case LESS_THAN:
return lt(columnName, RangeConditionFilter.parseByteFilter(value));
return lt(columnName, value);
case LESS_THAN_OR_EQUAL:
return leq(columnName, RangeConditionFilter.parseByteFilter(value));
return leq(columnName, value);
case GREATER_THAN:
return gt(columnName, RangeConditionFilter.parseByteFilter(value));
return gt(columnName, value);
case GREATER_THAN_OR_EQUAL:
return geq(columnName, RangeConditionFilter.parseByteFilter(value));
return geq(columnName, value);
default:
throw new IllegalArgumentException("RangeConditionFilter does not support condition " + condition);
throw new IllegalArgumentException("RangeFilter does not support condition " + condition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ public CharRangeFilter(String columnName, char val1, char val2, boolean lowerInc
}
}

static WhereFilter makeCharRangeFilter(String columnName, Condition condition, String value) {
static WhereFilter makeCharRangeFilter(String columnName, Condition condition, char value) {
switch (condition) {
case LESS_THAN:
return lt(columnName, RangeConditionFilter.parseCharFilter(value));
return lt(columnName, value);
case LESS_THAN_OR_EQUAL:
return leq(columnName, RangeConditionFilter.parseCharFilter(value));
return leq(columnName, value);
case GREATER_THAN:
return gt(columnName, RangeConditionFilter.parseCharFilter(value));
return gt(columnName, value);
case GREATER_THAN_OR_EQUAL:
return geq(columnName, RangeConditionFilter.parseCharFilter(value));
return geq(columnName, value);
default:
throw new IllegalArgumentException("RangeConditionFilter does not support condition " + condition);
throw new IllegalArgumentException("RangeFilter does not support condition " + condition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ public static WhereFilter makeRange(String columnName, String val) {
(double) (positiveOrZero ? parsed + offset : parsed - offset), positiveOrZero, !positiveOrZero);
}

static WhereFilter makeDoubleRangeFilter(String columnName, Condition condition, String value) {
static WhereFilter makeDoubleRangeFilter(String columnName, Condition condition, double value) {
switch (condition) {
case LESS_THAN:
return lt(columnName, Double.parseDouble(value));
return lt(columnName, value);
case LESS_THAN_OR_EQUAL:
return leq(columnName, Double.parseDouble(value));
return leq(columnName, value);
case GREATER_THAN:
return gt(columnName, Double.parseDouble(value));
return gt(columnName, value);
case GREATER_THAN_OR_EQUAL:
return geq(columnName, Double.parseDouble(value));
return geq(columnName, value);
default:
throw new IllegalArgumentException("RangeConditionFilter does not support condition " + condition);
throw new IllegalArgumentException("RangeFilter does not support condition " + condition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ public static WhereFilter makeRange(String columnName, String val) {
(float) (positiveOrZero ? parsed + offset : parsed - offset), positiveOrZero, !positiveOrZero);
}

static WhereFilter makeFloatRangeFilter(String columnName, Condition condition, String value) {
static WhereFilter makeFloatRangeFilter(String columnName, Condition condition, float value) {
switch (condition) {
case LESS_THAN:
return lt(columnName, Float.parseFloat(value));
return lt(columnName, value);
case LESS_THAN_OR_EQUAL:
return leq(columnName, Float.parseFloat(value));
return leq(columnName, value);
case GREATER_THAN:
return gt(columnName, Float.parseFloat(value));
return gt(columnName, value);
case GREATER_THAN_OR_EQUAL:
return geq(columnName, Float.parseFloat(value));
return geq(columnName, value);
default:
throw new IllegalArgumentException("RangeConditionFilter does not support condition " + condition);
throw new IllegalArgumentException("RangeFilter does not support condition " + condition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ public IntRangeFilter(String columnName, int val1, int val2, boolean lowerInclus
}
}

static WhereFilter makeIntRangeFilter(String columnName, Condition condition, String value) {
static WhereFilter makeIntRangeFilter(String columnName, Condition condition, int value) {
switch (condition) {
case LESS_THAN:
return lt(columnName, RangeConditionFilter.parseIntFilter(value));
return lt(columnName, value);
case LESS_THAN_OR_EQUAL:
return leq(columnName, RangeConditionFilter.parseIntFilter(value));
return leq(columnName, value);
case GREATER_THAN:
return gt(columnName, RangeConditionFilter.parseIntFilter(value));
return gt(columnName, value);
case GREATER_THAN_OR_EQUAL:
return geq(columnName, RangeConditionFilter.parseIntFilter(value));
return geq(columnName, value);
default:
throw new IllegalArgumentException("RangeConditionFilter does not support condition " + condition);
throw new IllegalArgumentException("RangeFilter does not support condition " + condition);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ public LongRangeFilter(String columnName, long val1, long val2, boolean lowerInc
}
}

static WhereFilter makeLongRangeFilter(String columnName, Condition condition, String value) {
static WhereFilter makeLongRangeFilter(String columnName, Condition condition, long value) {
switch (condition) {
case LESS_THAN:
return lt(columnName, RangeConditionFilter.parseLongFilter(value));
return lt(columnName, value);
case LESS_THAN_OR_EQUAL:
return leq(columnName, RangeConditionFilter.parseLongFilter(value));
return leq(columnName, value);
case GREATER_THAN:
return gt(columnName, RangeConditionFilter.parseLongFilter(value));
return gt(columnName, value);
case GREATER_THAN_OR_EQUAL:
return geq(columnName, RangeConditionFilter.parseLongFilter(value));
return geq(columnName, value);
default:
throw new IllegalArgumentException("RangeConditionFilter does not support condition " + condition);
throw new IllegalArgumentException("RangeFilter does not support condition " + condition);
}
}

Expand Down
Loading

0 comments on commit f647f1a

Please sign in to comment.