public class ExpressionUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
describe(Term term) |
static boolean |
equivalent(Expression left,
Expression right,
Types.StructType struct,
boolean caseSensitive)
Returns whether two unbound expressions will accept the same inputs.
|
static Expression |
extractByIdInclusive(Expression expression,
Schema schema,
boolean caseSensitive,
int... ids)
Extracts an expression that references only the given column IDs from the given expression.
|
static Expression |
sanitize(Expression expr)
Produces an unbound
Expression with the same structure, but with data values replaced
by descriptions. |
static Expression |
sanitize(Types.StructType struct,
Expression expr,
boolean caseSensitive)
Produces an unbound
Expression with the same structure, but with data values replaced
by descriptions. |
static boolean |
selectsPartitions(Expression expr,
PartitionSpec spec,
boolean caseSensitive)
Returns whether an expression selects whole partitions for a partition spec.
|
static boolean |
selectsPartitions(Expression expr,
Table table,
boolean caseSensitive)
Returns whether an expression selects whole partitions for all partition specs in a table.
|
static java.lang.String |
toSanitizedString(Expression expr)
Produces a sanitized expression string with the same structure, but with data values replaced
by descriptions.
|
static java.lang.String |
toSanitizedString(Types.StructType struct,
Expression expr,
boolean caseSensitive)
Produces a sanitized expression string with the same structure, but with data values replaced
by descriptions.
|
static <T> UnboundTerm<T> |
unbind(BoundTerm<T> term) |
static <T> UnboundTerm<T> |
unbind(Term term) |
public static Expression sanitize(Expression expr)
Expression
with the same structure, but with data values replaced
by descriptions.
Numbers are replaced with magnitude and type, string-like values are replaced by hashes, and date/time values are replaced by the type.
expr
- an Expression to sanitizepublic static Expression sanitize(Types.StructType struct, Expression expr, boolean caseSensitive)
Expression
with the same structure, but with data values replaced
by descriptions.
Numbers are replaced with magnitude and type, string-like values are replaced by hashes, and date/time values are replaced by the type.
struct
- a StructType to bind the expressionexpr
- an Expression to sanitizecaseSensitive
- whether to bind case sensitivelypublic static java.lang.String toSanitizedString(Expression expr)
Numbers are replaced with magnitude and type, string-like values are replaced by hashes, and date/time values are replaced by the type.
expr
- an Expression to sanitizepublic static java.lang.String toSanitizedString(Types.StructType struct, Expression expr, boolean caseSensitive)
Numbers are replaced with magnitude and type, string-like values are replaced by hashes, and date/time values are replaced by the type.
struct
- a StructType to bind the expressionexpr
- an Expression to sanitizecaseSensitive
- whether to bind case sensitivelypublic static Expression extractByIdInclusive(Expression expression, Schema schema, boolean caseSensitive, int... ids)
The result is inclusive. If a row would match the original filter, it must match the result filter.
expression
- a filter Expressionschema
- a SchemacaseSensitive
- whether binding is case sensitiveids
- field IDs used to match predicates to extract from the expressionpublic static boolean equivalent(Expression left, Expression right, Types.StructType struct, boolean caseSensitive)
If this returns true, the expressions are guaranteed to return the same evaluation for the same input. However, if this returns false the expressions may return the same evaluation for the same input. That is, expressions may be equivalent even if this returns false.
left
- an unbound expressionright
- an unbound expressionstruct
- a struct type for bindingcaseSensitive
- whether to bind expressions using case-sensitive matchingpublic static boolean selectsPartitions(Expression expr, Table table, boolean caseSensitive)
For example, ts < '2021-03-09T10:00:00.000' selects whole partitions in an hourly spec, [hours(ts)], but does not select whole partitions in a daily spec, [days(ts)].
expr
- an unbound expressiontable
- a tablecaseSensitive
- whether expression binding should be case sensitivepublic static boolean selectsPartitions(Expression expr, PartitionSpec spec, boolean caseSensitive)
For example, ts < '2021-03-09T10:00:00.000' selects whole partitions in an hourly spec, [hours(ts)], but does not select whole partitions in a daily spec, [days(ts)].
expr
- an unbound expressionspec
- a partition specpublic static java.lang.String describe(Term term)
public static <T> UnboundTerm<T> unbind(BoundTerm<T> term)
public static <T> UnboundTerm<T> unbind(Term term)