public class Column
extends Object
DataFrame
.
Constructor and Description |
---|
Column(org.apache.spark.sql.catalyst.expressions.Expression expr) |
Column(String name) |
Modifier and Type | Method and Description |
---|---|
Column |
and(Column other)
Boolean AND.
|
static Column |
apply(org.apache.spark.sql.catalyst.expressions.Expression expr) |
static Column |
apply(String colName) |
Column |
as(String alias)
Gives the column an alias.
|
Column |
as(scala.Symbol alias)
Gives the column an alias.
|
Column |
asc()
Returns an ordering used in sorting.
|
Column |
cast(org.apache.spark.sql.types.DataType to)
Casts the column to a different data type.
|
Column |
cast(String to)
Casts the column to a different data type, using the canonical string representation
of the type.
|
Column |
contains(Object other)
Contains the other element.
|
Column |
desc()
Returns an ordering used in sorting.
|
Column |
divide(Object other)
Division this expression by another expression.
|
Column |
endsWith(Column other)
String ends with.
|
Column |
endsWith(String literal)
String ends with another string literal.
|
Column |
eqNullSafe(Object other)
Equality test that is safe for null values.
|
boolean |
equals(Object that) |
Column |
equalTo(Object other)
Equality test.
|
void |
explain(boolean extended)
Prints the expression to the console for debugging purpose.
|
Column |
geq(Object other)
Greater than or equal to an expression.
|
Column |
getField(String fieldName)
An expression that gets a field by name in a
StructField . |
Column |
getItem(int ordinal)
An expression that gets an item at position
ordinal out of an array. |
Column |
gt(Object other)
Greater than.
|
int |
hashCode() |
Column |
in(Column... list)
A boolean expression that is evaluated to true if the value of this expression is contained
by the evaluated values of the arguments.
|
Column |
in(scala.collection.Seq<Column> list)
A boolean expression that is evaluated to true if the value of this expression is contained
by the evaluated values of the arguments.
|
Column |
isNotNull()
True if the current expression is NOT null.
|
Column |
isNull()
True if the current expression is null.
|
Column |
leq(Object other)
Less than or equal to.
|
Column |
like(String literal)
SQL like expression.
|
Column |
lt(Object other)
Less than.
|
Column |
minus(Object other)
Subtraction.
|
Column |
mod(Object other)
Modulo (a.k.a.
|
Column |
multiply(Object other)
Multiplication of this expression and another expression.
|
Column |
notEqual(Object other)
Inequality test.
|
Column |
or(Column other)
Boolean OR.
|
Column |
plus(Object other)
Sum of this expression and another expression.
|
Column |
rlike(String literal)
SQL RLIKE expression (LIKE with Regex).
|
Column |
startsWith(Column other)
String starts with.
|
Column |
startsWith(String literal)
String starts with another string literal.
|
Column |
substr(Column startPos,
Column len)
An expression that returns a substring.
|
Column |
substr(int startPos,
int len)
An expression that returns a substring.
|
String |
toString() |
static scala.Option<org.apache.spark.sql.catalyst.expressions.Expression> |
unapply(Column col) |
public Column(org.apache.spark.sql.catalyst.expressions.Expression expr)
public Column(String name)
public static Column apply(String colName)
public static Column apply(org.apache.spark.sql.catalyst.expressions.Expression expr)
public static scala.Option<org.apache.spark.sql.catalyst.expressions.Expression> unapply(Column col)
public Column in(Column... list)
public String toString()
toString
in class Object
public boolean equals(Object that)
equals
in class Object
public int hashCode()
hashCode
in class Object
public Column equalTo(Object other)
// Scala:
df.filter( df("colA") === df("colB") )
// Java
import static org.apache.spark.sql.functions.*;
df.filter( col("colA").equalTo(col("colB")) );
public Column notEqual(Object other)
// Scala:
df.select( df("colA") !== df("colB") )
df.select( !(df("colA") === df("colB")) )
// Java:
import static org.apache.spark.sql.functions.*;
df.filter( col("colA").notEqual(col("colB")) );
public Column gt(Object other)
// Scala: The following selects people older than 21.
people.select( people("age") > lit(21) )
// Java:
import static org.apache.spark.sql.functions.*;
people.select( people("age").gt(21) );
public Column lt(Object other)
// Scala: The following selects people younger than 21.
people.select( people("age") < 21 )
// Java:
people.select( people("age").lt(21) );
public Column leq(Object other)
// Scala: The following selects people age 21 or younger than 21.
people.select( people("age") <= 21 )
// Java:
people.select( people("age").leq(21) );
public Column geq(Object other)
// Scala: The following selects people age 21 or older than 21.
people.select( people("age") >= 21 )
// Java:
people.select( people("age").geq(21) )
public Column eqNullSafe(Object other)
public Column isNull()
public Column isNotNull()
public Column or(Column other)
// Scala: The following selects people that are in school or employed.
people.filter( people("inSchool") || people("isEmployed") )
// Java:
people.filter( people("inSchool").or(people("isEmployed")) );
public Column and(Column other)
// Scala: The following selects people that are in school and employed at the same time.
people.select( people("inSchool") && people("isEmployed") )
// Java:
people.select( people("inSchool").and(people("isEmployed")) );
public Column plus(Object other)
// Scala: The following selects the sum of a person's height and weight.
people.select( people("height") + people("weight") )
// Java:
people.select( people("height").plus(people("weight")) );
public Column minus(Object other)
// Scala: The following selects the difference between people's height and their weight.
people.select( people("height") - people("weight") )
// Java:
people.select( people("height").minus(people("weight")) );
public Column multiply(Object other)
// Scala: The following multiplies a person's height by their weight.
people.select( people("height") * people("weight") )
// Java:
people.select( people("height").multiply(people("weight")) );
public Column divide(Object other)
// Scala: The following divides a person's height by their weight.
people.select( people("height") / people("weight") )
// Java:
people.select( people("height").divide(people("weight")) );
public Column mod(Object other)
public Column in(scala.collection.Seq<Column> list)
public Column like(String literal)
public Column rlike(String literal)
public Column getItem(int ordinal)
ordinal
out of an array.
public Column getField(String fieldName)
StructField
.
public Column substr(Column startPos, Column len)
startPos
- expression for the starting position.len
- expression for the length of the substring.
public Column substr(int startPos, int len)
startPos
- starting position.len
- length of the substring.
public Column contains(Object other)
public Column startsWith(String literal)
public Column endsWith(String literal)
public Column as(String alias)
// Renames colA to colB in select output.
df.select($"colA".as("colB"))
public Column as(scala.Symbol alias)
// Renames colA to colB in select output.
df.select($"colA".as('colB))
public Column cast(org.apache.spark.sql.types.DataType to)
// Casts colA to IntegerType.
import org.apache.spark.sql.types.IntegerType
df.select(df("colA").cast(IntegerType))
// equivalent to
df.select(df("colA").cast("int"))
public Column cast(String to)
string
, boolean
, byte
, short
, int
, long
,
float
, double
, decimal
, date
, timestamp
.
// Casts colA to integer.
df.select(df("colA").cast("int"))
public Column desc()
// Scala: sort a DataFrame by age column in descending order.
df.sort(df("age").desc)
// Java
df.sort(df.col("age").desc());
public Column asc()
// Scala: sort a DataFrame by age column in ascending order.
df.sort(df("age").asc)
// Java
df.sort(df.col("age").asc());
public void explain(boolean extended)