@Evolving
public class Expressions
extends Object
Modifier and Type | Method and Description |
---|---|
static Transform |
apply(String name,
Expression... args)
Create a logical transform for applying a named transform.
|
static Transform |
bucket(int numBuckets,
String... columns)
Create a bucket transform for one or more columns.
|
static NamedReference |
column(String name)
Create a named reference expression for a (nested) column.
|
static Transform |
days(String column)
Create a daily transform for a timestamp or date column.
|
static Transform |
hours(String column)
Create an hourly transform for a timestamp column.
|
static Transform |
identity(String column)
Create an identity transform for a column.
|
static <T> Literal<T> |
literal(T value)
Create a literal from a value.
|
static Transform |
months(String column)
Create a monthly transform for a timestamp or date column.
|
static SortOrder |
sort(Expression expr,
SortDirection direction)
Create a sort expression.
|
static SortOrder |
sort(Expression expr,
SortDirection direction,
NullOrdering nullOrder)
Create a sort expression.
|
static Transform |
years(String column)
Create a yearly transform for a timestamp or date column.
|
public static Transform apply(String name, Expression... args)
This transform can represent applying any named transform.
name
- the transform nameargs
- expression arguments to the transformpublic static NamedReference column(String name)
name
- The column name. It refers to nested column if name contains dot.public static <T> Literal<T> literal(T value)
The JVM type of the value held by a literal must be the type used by Spark's InternalRow API
for the literal's SQL data type
.
T
- the JVM type of the valuevalue
- a valuepublic static Transform bucket(int numBuckets, String... columns)
This transform represents a logical mapping from a value to a bucket id in [0, numBuckets) based on a hash of the value.
The name reported by transforms created with this method is "bucket".
numBuckets
- the number of output bucketscolumns
- input columns for the bucket transformpublic static Transform identity(String column)
This transform represents a logical mapping from a value to itself.
The name reported by transforms created with this method is "identity".
column
- an input columnpublic static Transform years(String column)
This transform represents a logical mapping from a timestamp or date to a year, such as 2018.
The name reported by transforms created with this method is "years".
column
- an input timestamp or date columnpublic static Transform months(String column)
This transform represents a logical mapping from a timestamp or date to a month, such as 2018-05.
The name reported by transforms created with this method is "months".
column
- an input timestamp or date columnpublic static Transform days(String column)
This transform represents a logical mapping from a timestamp or date to a date, such as 2018-05-13.
The name reported by transforms created with this method is "days".
column
- an input timestamp or date columnpublic static Transform hours(String column)
This transform represents a logical mapping from a timestamp to a date and hour, such as 2018-05-13, hour 19.
The name reported by transforms created with this method is "hours".
column
- an input timestamp columnpublic static SortOrder sort(Expression expr, SortDirection direction, NullOrdering nullOrder)
expr
- an expression to produce values to sortdirection
- direction of the sortnullOrder
- null order of the sortpublic static SortOrder sort(Expression expr, SortDirection direction)
expr
- an expression to produce values to sortdirection
- direction of the sort