public final class FilterApi extends Object
Example usage:
IntColumn foo = intColumn("foo");
DoubleColumn bar = doubleColumn("x.y.bar");
// foo == 10 || bar <= 17.0
FilterPredicate pred = or(eq(foo, 10), ltEq(bar, 17.0));
| Modifier and Type | Method and Description |
|---|---|
static FilterPredicate |
and(FilterPredicate left,
FilterPredicate right)
Constructs the logical and of two predicates.
|
static Operators.BinaryColumn |
binaryColumn(String columnPath) |
static Operators.BooleanColumn |
booleanColumn(String columnPath) |
static <T extends Comparable<T>,P extends org.apache.parquet.filter2.predicate.Operators.SingleColumnFilterPredicate<T>> |
contains(P pred) |
static Operators.DoubleColumn |
doubleColumn(String columnPath) |
static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq> |
eq(C column,
T value)
Keeps records if their value is equal to the provided value.
|
static Operators.FloatColumn |
floatColumn(String columnPath) |
static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt> |
gt(C column,
T value)
Keeps records if their value is greater than (but not equal to) the provided value.
|
static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt> |
gtEq(C column,
T value)
Keeps records if their value is greater than or equal to the provided value.
|
static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq> |
in(C column,
Set<T> values)
Keeps records if their value is in the provided values.
|
static Operators.IntColumn |
intColumn(String columnPath) |
static Operators.LongColumn |
longColumn(String columnPath) |
static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt> |
lt(C column,
T value)
Keeps records if their value is less than (but not equal to) the provided value.
|
static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt> |
ltEq(C column,
T value)
Keeps records if their value is less than or equal to the provided value.
|
static FilterPredicate |
not(FilterPredicate predicate)
Constructs the logical not (or inverse) of a predicate.
|
static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq> |
notEq(C column,
T value)
Keeps records if their value is not equal to the provided value.
|
static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq> |
notIn(C column,
Set<T> values)
Keeps records if their value is not in the provided values.
|
static FilterPredicate |
or(FilterPredicate left,
FilterPredicate right)
Constructs the logical or of two predicates.
|
static <T extends Comparable<T>,U extends UserDefinedPredicate<T>> |
userDefined(Operators.Column<T> column,
Class<U> clazz)
Keeps records that pass the provided
UserDefinedPredicate |
static <T extends Comparable<T>,U extends UserDefinedPredicate<T> & Serializable> |
userDefined(Operators.Column<T> column,
U udp)
Keeps records that pass the provided
UserDefinedPredicate |
public static Operators.IntColumn intColumn(String columnPath)
public static Operators.LongColumn longColumn(String columnPath)
public static Operators.FloatColumn floatColumn(String columnPath)
public static Operators.DoubleColumn doubleColumn(String columnPath)
public static Operators.BooleanColumn booleanColumn(String columnPath)
public static Operators.BinaryColumn binaryColumn(String columnPath)
public static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq> Operators.Eq<T> eq(C column, T value)
For example: eq(column, null) will keep all records whose value is null. eq(column, 7) will keep all records whose value is 7, and will drop records whose value is null
T - the Java type of values in the columnC - the column type that corresponds to values of type Tcolumn - a column reference created by FilterApivalue - a value that matches the column's typepublic static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq> Operators.NotEq<T> notEq(C column, T value)
For example: notEq(column, null) will keep all records whose value is not null. notEq(column, 7) will keep all records whose value is not 7, including records whose value is null.
NOTE: this is different from how some query languages handle null. For example, SQL and pig will drop nulls when you filter by not equal to 7. To achieve similar behavior in this api, do: and(notEq(column, 7), notEq(column, null))
NOTE: be sure to read the lt(C, T), ltEq(C, T), gt(C, T), gtEq(C, T) operator's docs
for how they handle nulls
T - the Java type of values in the columnC - the column type that corresponds to values of type Tcolumn - a column reference created by FilterApivalue - a value that matches the column's typepublic static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt> Operators.Lt<T> lt(C column, T value)
For example: lt(column, 7) will keep all records whose value is less than (but not equal to) 7, and not null.
T - the Java type of values in the columnC - the column type that corresponds to values of type Tcolumn - a column reference created by FilterApivalue - a value that matches the column's typepublic static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt> Operators.LtEq<T> ltEq(C column, T value)
For example: ltEq(column, 7) will keep all records whose value is less than or equal to 7, and not null.
T - the Java type of values in the columnC - the column type that corresponds to values of type Tcolumn - a column reference created by FilterApivalue - a value that matches the column's typepublic static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt> Operators.Gt<T> gt(C column, T value)
For example: gt(column, 7) will keep all records whose value is greater than (but not equal to) 7, and not null.
T - the Java type of values in the columnC - the column type that corresponds to values of type Tcolumn - a column reference created by FilterApivalue - a value that matches the column's typepublic static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsLtGt> Operators.GtEq<T> gtEq(C column, T value)
For example: gtEq(column, 7) will keep all records whose value is greater than or equal to 7, and not null.
T - the Java type of values in the columnC - the column type that corresponds to values of type Tcolumn - a column reference created by FilterApivalue - a value that matches the column's typepublic static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq> Operators.In<T> in(C column, Set<T> values)
For example:
Set<Integer> set = new HashSet<>();
set.add(9);
set.add(null);
set.add(50);
in(column, set);
will keep all records whose values are 9, null, or 50.T - the Java type of values in the columnC - the column type that corresponds to values of type Tcolumn - a column reference created by FilterApivalues - a set of values that match the column's typepublic static <T extends Comparable<T>,C extends Operators.Column<T> & Operators.SupportsEqNotEq> Operators.NotIn<T> notIn(C column, Set<T> values)
For example:
Set<Integer> set = new HashSet<>();
set.add(9);
set.add(null);
set.add(50);
notIn(column, set);
will keep all records whose values are not 9, null, and 50.T - the Java type of values in the columnC - the column type that corresponds to values of type Tcolumn - a column reference created by FilterApivalues - a set of values that match the column's typepublic static <T extends Comparable<T>,P extends org.apache.parquet.filter2.predicate.Operators.SingleColumnFilterPredicate<T>> Operators.Contains<T> contains(P pred)
public static <T extends Comparable<T>,U extends UserDefinedPredicate<T>> Operators.UserDefined<T,U> userDefined(Operators.Column<T> column, Class<U> clazz)
UserDefinedPredicate
The provided class must have a default constructor. To use an instance of a UserDefinedPredicate instead, see userDefined below.
T - the Java type of values in the columnU - a user-defined predicate for values of type Tcolumn - a column reference created by FilterApiclazz - a user-defined predicate classpublic static <T extends Comparable<T>,U extends UserDefinedPredicate<T> & Serializable> Operators.UserDefined<T,U> userDefined(Operators.Column<T> column, U udp)
UserDefinedPredicate
The provided instance of UserDefinedPredicate must be serializable.
T - the Java type of values in the columnU - a user-defined predicate for values of type Tcolumn - a column reference created by FilterApiudp - a user-defined predicate instancepublic static FilterPredicate and(FilterPredicate left, FilterPredicate right)
left - a predicateright - a predicatepublic static FilterPredicate or(FilterPredicate left, FilterPredicate right)
left - a predicateright - a predicatepublic static FilterPredicate not(FilterPredicate predicate)
predicate - a predicateCopyright © 2024 The Apache Software Foundation. All rights reserved.