Class ExpressionUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic booleanequivalent(Expression left, Expression right, Types.StructType struct, boolean caseSensitive) Returns whether two unbound expressions will accept the same inputs.static ExpressionextractByIdInclusive(Expression expression, Schema schema, boolean caseSensitive, int... ids) Returns an expression that retains only predicates which reference one of the given field IDs.static Expressionsanitize(Expression expr) Produces an unboundExpressionwith the same structure, but with data values replaced by descriptions.static Expressionsanitize(Types.StructType struct, Expression expr, boolean caseSensitive) Produces an unboundExpressionwith the same structure, but with data values replaced by descriptions.static booleanselectsPartitions(Expression expr, PartitionSpec spec, boolean caseSensitive) Returns whether an expression selects whole partitions for a partition spec.static booleanselectsPartitions(Expression expr, Table table, boolean caseSensitive) Returns whether an expression selects whole partitions for all partition specs in a table.static StringtoSanitizedString(Expression expr) Produces a sanitized expression string with the same structure, but with data values replaced by descriptions.static StringtoSanitizedString(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> static <T> UnboundTerm<T>
-
Method Details
-
sanitize
Produces an unboundExpressionwith 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.
- Parameters:
expr- an Expression to sanitize- Returns:
- a sanitized Expression
-
sanitize
Produces an unboundExpressionwith 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.
- Parameters:
struct- a StructType to bind the expressionexpr- an Expression to sanitizecaseSensitive- whether to bind case sensitively- Returns:
- a sanitized Expression
-
toSanitizedString
Produces a sanitized expression string 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.
- Parameters:
expr- an Expression to sanitize- Returns:
- a sanitized expression string
-
toSanitizedString
public static 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.Numbers are replaced with magnitude and type, string-like values are replaced by hashes, and date/time values are replaced by the type.
- Parameters:
struct- a StructType to bind the expressionexpr- an Expression to sanitizecaseSensitive- whether to bind case sensitively- Returns:
- a sanitized expression string
-
extractByIdInclusive
public static Expression extractByIdInclusive(Expression expression, Schema schema, boolean caseSensitive, int... ids) Returns an expression that retains only predicates which reference one of the given field IDs.- Parameters:
expression- a filter expressionschema- schema for binding referencescaseSensitive- whether binding is case sensitiveids- field IDs to retain predicates for- Returns:
- expression containing only predicates that reference the given IDs
-
equivalent
public static boolean equivalent(Expression left, Expression right, Types.StructType struct, boolean caseSensitive) Returns whether two unbound expressions will accept the same inputs.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.
- Parameters:
left- an unbound expressionright- an unbound expressionstruct- a struct type for bindingcaseSensitive- whether to bind expressions using case-sensitive matching- Returns:
- true if the expressions are equivalent
-
selectsPartitions
Returns whether an expression selects whole partitions for all partition specs in a table.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)].
- Parameters:
expr- an unbound expressiontable- a tablecaseSensitive- whether expression binding should be case sensitive- Returns:
- true if the expression will select whole partitions in all table specs
-
selectsPartitions
Returns whether an expression selects whole partitions for a partition spec.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)].
- Parameters:
expr- an unbound expressionspec- a partition spec- Returns:
- true if the expression will select whole partitions in the given spec
-
describe
-
unbind
-
unbind
-