class ColumnName extends Column
A convenient class used for constructing schema.
- Annotations
- @Stable()
- Source
- Column.scala
- Since
- 1.3.0 
- Grouped
- Alphabetic
- By Inheritance
- ColumnName
- Column
- TableValuedFunctionArgument
- Logging
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
-  new ColumnName(name: String)
Type Members
-   implicit  class LogStringContext extends AnyRef- Definition Classes
- Logging
 
Value Members
-   final  def !=(arg0: Any): Boolean- Definition Classes
- AnyRef → Any
 
-   final  def ##: Int- Definition Classes
- AnyRef → Any
 
-    def %(other: Any): ColumnModulo (a.k.a. Modulo (a.k.a. remainder) expression. - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def &&(other: Any): ColumnBoolean AND. Boolean AND. // 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.col("inSchool").and(people.col("isEmployed")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def *(other: Any): ColumnMultiplication of this expression and another expression. Multiplication of this expression and another expression. // Scala: The following multiplies a person's height by their weight. people.select( people("height") * people("weight") ) // Java: people.select( people.col("height").multiply(people.col("weight")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def +(other: Any): ColumnSum of this expression and another expression. Sum of this expression and another expression. // Scala: The following selects the sum of a person's height and weight. people.select( people("height") + people("weight") ) // Java: people.select( people.col("height").plus(people.col("weight")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def -(other: Any): ColumnSubtraction. Subtraction. Subtract the other expression from this expression. // Scala: The following selects the difference between people's height and their weight. people.select( people("height") - people("weight") ) // Java: people.select( people.col("height").minus(people.col("weight")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def /(other: Any): ColumnDivision this expression by another expression. Division this expression by another expression. // Scala: The following divides a person's height by their weight. people.select( people("height") / people("weight") ) // Java: people.select( people.col("height").divide(people.col("weight")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def <(other: Any): ColumnLess than. Less than. // Scala: The following selects people younger than 21. people.select( people("age") < 21 ) // Java: people.select( people.col("age").lt(21) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def <=(other: Any): ColumnLess than or equal to. Less than or equal to. // Scala: The following selects people age 21 or younger than 21. people.select( people("age") <= 21 ) // Java: people.select( people.col("age").leq(21) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def <=>(other: Any): ColumnEquality test that is safe for null values. Equality test that is safe for null values. - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def =!=(other: Any): ColumnInequality test. Inequality test. // 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")) ); - Definition Classes
- Column
- Since
- 2.0.0 
 
-   final  def ==(arg0: Any): Boolean- Definition Classes
- AnyRef → Any
 
-    def ===(other: Any): ColumnEquality test. Equality test. // Scala: df.filter( df("colA") === df("colB") ) // Java import static org.apache.spark.sql.functions.*; df.filter( col("colA").equalTo(col("colB")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def >(other: Any): ColumnGreater than. Greater than. // Scala: The following selects people older than 21. people.select( people("age") > 21 ) // Java: import static org.apache.spark.sql.functions.*; people.select( people.col("age").gt(21) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def >=(other: Any): ColumnGreater than or equal to an expression. Greater than or equal to an expression. // Scala: The following selects people age 21 or older than 21. people.select( people("age") >= 21 ) // Java: people.select( people.col("age").geq(21) ) - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def MDC(key: LogKey, value: Any): MDC- Attributes
- protected
- Definition Classes
- Logging
 
-    def alias(alias: String): ColumnGives the column an alias. Gives the column an alias. Same as as.// Renames colA to colB in select output. df.select($"colA".alias("colB")) - Definition Classes
- Column
- Since
- 1.4.0 
 
-    def and(other: Column): ColumnBoolean AND. Boolean AND. // 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.col("inSchool").and(people.col("isEmployed")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def apply(extraction: Any): ColumnExtracts a value or values from a complex type. Extracts a value or values from a complex type. The following types of extraction are supported: - Given an Array, an integer ordinal can be used to retrieve a single value.
- Given a Map, a key of the correct type can be used to retrieve an individual value.
- Given a Struct, a string fieldName can be used to extract that field.
- Given an Array of Structs, a string fieldName can be used to extract filed of every struct in that array, and return an Array of fields.
 - Definition Classes
- Column
- Since
- 1.4.0 
 
-    def array(dataType: DataType): StructFieldCreates a new StructFieldof type array.Creates a new StructFieldof type array.- Since
- 1.3.0 
 
-    def as(alias: String, metadata: Metadata): ColumnGives the column an alias with metadata. Gives the column an alias with metadata. val metadata: Metadata = ... df.select($"colA".as("colB", metadata)) - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def as(alias: Symbol): ColumnGives the column an alias. Gives the column an alias. // Renames colA to colB in select output. df.select($"colA".as("colB")) If the current column has metadata associated with it, this metadata will be propagated to the new column. If this not desired, use the API as(alias: String, metadata: Metadata)with explicit metadata.- Definition Classes
- Column
- Since
- 1.3.0 
 
-    def as(aliases: Array[String]): ColumnAssigns the given aliases to the results of a table generating function. Assigns the given aliases to the results of a table generating function. // Renames colA to colB in select output. df.select(explode($"myMap").as("key" :: "value" :: Nil)) - Definition Classes
- Column
- Since
- 1.4.0 
 
-    def as(aliases: Seq[String]): Column(Scala-specific) Assigns the given aliases to the results of a table generating function. (Scala-specific) Assigns the given aliases to the results of a table generating function. // Renames colA to colB in select output. df.select(explode($"myMap").as("key" :: "value" :: Nil)) - Definition Classes
- Column
- Since
- 1.4.0 
 
-    def as(alias: String): ColumnGives the column an alias. Gives the column an alias. // Renames colA to colB in select output. df.select($"colA".as("colB")) If the current column has metadata associated with it, this metadata will be propagated to the new column. If this not desired, use the API as(alias: String, metadata: Metadata)with explicit metadata.- Definition Classes
- Column
- Since
- 1.3.0 
 
-    def as[U](implicit arg0: Encoder[U]): TypedColumn[Any, U]Provides a type hint about the expected return value of this column. 
-   final  def asInstanceOf[T0]: T0- Definition Classes
- Any
 
-    def asc: ColumnReturns a sort expression based on ascending order of the column. Returns a sort expression based on ascending order of the column. // Scala: sort a DataFrame by age column in ascending order. df.sort(df("age").asc) // Java df.sort(df.col("age").asc()); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def asc_nulls_first: ColumnReturns a sort expression based on ascending order of the column, and null values return before non-null values. Returns a sort expression based on ascending order of the column, and null values return before non-null values. // Scala: sort a DataFrame by age column in ascending order and null values appearing first. df.sort(df("age").asc_nulls_first) // Java df.sort(df.col("age").asc_nulls_first()); - Definition Classes
- Column
- Since
- 2.1.0 
 
-    def asc_nulls_last: ColumnReturns a sort expression based on ascending order of the column, and null values appear after non-null values. Returns a sort expression based on ascending order of the column, and null values appear after non-null values. // Scala: sort a DataFrame by age column in ascending order and null values appearing last. df.sort(df("age").asc_nulls_last) // Java df.sort(df.col("age").asc_nulls_last()); - Definition Classes
- Column
- Since
- 2.1.0 
 
-    def between(lowerBound: Any, upperBound: Any): ColumnTrue if the current column is between the lower bound and upper bound, inclusive. True if the current column is between the lower bound and upper bound, inclusive. - Definition Classes
- Column
- Since
- 1.4.0 
 
-    def binary: StructFieldCreates a new StructFieldof type binary.Creates a new StructFieldof type binary.- Since
- 1.3.0 
 
-    def bitwiseAND(other: Any): ColumnCompute bitwise AND of this expression with another expression. Compute bitwise AND of this expression with another expression. df.select($"colA".bitwiseAND($"colB")) - Definition Classes
- Column
- Since
- 1.4.0 
 
-    def bitwiseOR(other: Any): ColumnCompute bitwise OR of this expression with another expression. Compute bitwise OR of this expression with another expression. df.select($"colA".bitwiseOR($"colB")) - Definition Classes
- Column
- Since
- 1.4.0 
 
-    def bitwiseXOR(other: Any): ColumnCompute bitwise XOR of this expression with another expression. Compute bitwise XOR of this expression with another expression. df.select($"colA".bitwiseXOR($"colB")) - Definition Classes
- Column
- Since
- 1.4.0 
 
-    def boolean: StructFieldCreates a new StructFieldof type boolean.Creates a new StructFieldof type boolean.- Since
- 1.3.0 
 
-    def byte: StructFieldCreates a new StructFieldof type byte.Creates a new StructFieldof type byte.- Since
- 1.3.0 
 
-    def cast(to: String): ColumnCasts the column to a different data type, using the canonical string representation of the type. Casts the column to a different data type, using the canonical string representation of the type. The supported types are: string,boolean,byte,short,int,long,float,double,decimal,date,timestamp.// Casts colA to integer. df.select(df("colA").cast("int")) - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def cast(to: DataType): ColumnCasts the column to a different data type. Casts the column to a different data type. // 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")) - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def clone(): AnyRef- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
 
-    def contains(other: Any): ColumnContains the other element. Contains the other element. Returns a boolean column based on a string match. - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def date: StructFieldCreates a new StructFieldof type date.Creates a new StructFieldof type date.- Since
- 1.3.0 
 
-    def decimal(precision: Int, scale: Int): StructFieldCreates a new StructFieldof type decimal.Creates a new StructFieldof type decimal.- Since
- 1.3.0 
 
-    def decimal: StructFieldCreates a new StructFieldof type decimal.Creates a new StructFieldof type decimal.- Since
- 1.3.0 
 
-    def desc: ColumnReturns a sort expression based on the descending order of the column. Returns a sort expression based on the descending order of the column. // Scala df.sort(df("age").desc) // Java df.sort(df.col("age").desc()); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def desc_nulls_first: ColumnReturns a sort expression based on the descending order of the column, and null values appear before non-null values. Returns a sort expression based on the descending order of the column, and null values appear before non-null values. // Scala: sort a DataFrame by age column in descending order and null values appearing first. df.sort(df("age").desc_nulls_first) // Java df.sort(df.col("age").desc_nulls_first()); - Definition Classes
- Column
- Since
- 2.1.0 
 
-    def desc_nulls_last: ColumnReturns a sort expression based on the descending order of the column, and null values appear after non-null values. Returns a sort expression based on the descending order of the column, and null values appear after non-null values. // Scala: sort a DataFrame by age column in descending order and null values appearing last. df.sort(df("age").desc_nulls_last) // Java df.sort(df.col("age").desc_nulls_last()); - Definition Classes
- Column
- Since
- 2.1.0 
 
-    def divide(other: Any): ColumnDivision this expression by another expression. Division this expression by another expression. // Scala: The following divides a person's height by their weight. people.select( people("height") / people("weight") ) // Java: people.select( people.col("height").divide(people.col("weight")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def double: StructFieldCreates a new StructFieldof type double.Creates a new StructFieldof type double.- Since
- 1.3.0 
 
-    def dropFields(fieldNames: String*): ColumnAn expression that drops fields in StructTypeby name.An expression that drops fields in StructTypeby name. This is a no-op if schema doesn't contain field name(s).val df = sql("SELECT named_struct('a', 1, 'b', 2) struct_col") df.select($"struct_col".dropFields("b")) // result: {"a":1} val df = sql("SELECT named_struct('a', 1, 'b', 2) struct_col") df.select($"struct_col".dropFields("c")) // result: {"a":1,"b":2} val df = sql("SELECT named_struct('a', 1, 'b', 2, 'c', 3) struct_col") df.select($"struct_col".dropFields("b", "c")) // result: {"a":1} val df = sql("SELECT named_struct('a', 1, 'b', 2) struct_col") df.select($"struct_col".dropFields("a", "b")) // result: org.apache.spark.sql.AnalysisException: [DATATYPE_MISMATCH.CANNOT_DROP_ALL_FIELDS] Cannot resolve "update_fields(struct_col, dropfield(), dropfield())" due to data type mismatch: Cannot drop all fields in struct.; val df = sql("SELECT CAST(NULL AS struct<a:int,b:int>) struct_col") df.select($"struct_col".dropFields("b")) // result: null of type struct<a:int> val df = sql("SELECT named_struct('a', 1, 'b', 2, 'b', 3) struct_col") df.select($"struct_col".dropFields("b")) // result: {"a":1} val df = sql("SELECT named_struct('a', named_struct('a', 1, 'b', 2)) struct_col") df.select($"struct_col".dropFields("a.b")) // result: {"a":{"a":1}} val df = sql("SELECT named_struct('a', named_struct('b', 1), 'a', named_struct('c', 2)) struct_col") df.select($"struct_col".dropFields("a.c")) // result: org.apache.spark.sql.AnalysisException: Ambiguous reference to fields This method supports dropping multiple nested fields directly e.g. val df = sql("SELECT named_struct('a', named_struct('a', 1, 'b', 2)) struct_col") df.select($"struct_col".dropFields("a.b", "a.c")) // result: {"a":{"a":1}} However, if you are going to drop multiple nested fields, it is more optimal to extract out the nested struct before dropping multiple fields from it e.g. val df = sql("SELECT named_struct('a', named_struct('a', 1, 'b', 2)) struct_col") df.select($"struct_col".withField("a", $"struct_col.a".dropFields("b", "c"))) // result: {"a":{"a":1}} - Definition Classes
- Column
- Since
- 3.1.0 
 
-    def endsWith(literal: String): ColumnString ends with another string literal. String ends with another string literal. Returns a boolean column based on a string match. - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def endsWith(other: Column): ColumnString ends with. String ends with. Returns a boolean column based on a string match. - Definition Classes
- Column
- Since
- 1.3.0 
 
-   final  def eq(arg0: AnyRef): Boolean- Definition Classes
- AnyRef
 
-    def eqNullSafe(other: Any): ColumnEquality test that is safe for null values. Equality test that is safe for null values. - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def equalTo(other: Any): ColumnEquality test. Equality test. // Scala: df.filter( df("colA") === df("colB") ) // Java import static org.apache.spark.sql.functions.*; df.filter( col("colA").equalTo(col("colB")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def equals(that: Any): Boolean- Definition Classes
- Column → AnyRef → Any
 
-    def explain(extended: Boolean): UnitPrints the expression to the console for debugging purposes. Prints the expression to the console for debugging purposes. - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def float: StructFieldCreates a new StructFieldof type float.Creates a new StructFieldof type float.- Since
- 1.3.0 
 
-    def geq(other: Any): ColumnGreater than or equal to an expression. Greater than or equal to an expression. // Scala: The following selects people age 21 or older than 21. people.select( people("age") >= 21 ) // Java: people.select( people.col("age").geq(21) ) - Definition Classes
- Column
- Since
- 1.3.0 
 
-   final  def getClass(): Class[_ <: AnyRef]- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
 
-    def getField(fieldName: String): ColumnAn expression that gets a field by name in a StructType.An expression that gets a field by name in a StructType.- Definition Classes
- Column
- Since
- 1.3.0 
 
-    def getItem(key: Any): ColumnAn expression that gets an item at position ordinalout of an array, or gets a value by keykeyin aMapType.An expression that gets an item at position ordinalout of an array, or gets a value by keykeyin aMapType.- Definition Classes
- Column
- Since
- 1.3.0 
 
-    def gt(other: Any): ColumnGreater than. Greater than. // 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.col("age").gt(21) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def hashCode(): Int- Definition Classes
- Column → AnyRef → Any
 
-    def ilike(literal: String): ColumnSQL ILIKE expression (case insensitive LIKE). SQL ILIKE expression (case insensitive LIKE). - Definition Classes
- Column
- Since
- 3.3.0 
 
-    def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean- Attributes
- protected
- Definition Classes
- Logging
 
-    def initializeLogIfNecessary(isInterpreter: Boolean): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def int: StructFieldCreates a new StructFieldof type int.Creates a new StructFieldof type int.- Since
- 1.3.0 
 
-    def isInCollection(values: Iterable[_]): ColumnA boolean expression that is evaluated to true if the value of this expression is contained by the provided collection. A boolean expression that is evaluated to true if the value of this expression is contained by the provided collection. Note: Since the type of the elements in the collection are inferred only during the run time, the elements will be "up-casted" to the most common type for comparison. For eg: 1) In the case of "Int vs String", the "Int" will be up-casted to "String" and the comparison will look like "String vs String". 2) In the case of "Float vs Double", the "Float" will be up-casted to "Double" and the comparison will look like "Double vs Double" - Definition Classes
- Column
- Since
- 2.4.0 
 
-    def isInCollection(values: Iterable[_]): ColumnA boolean expression that is evaluated to true if the value of this expression is contained by the provided collection. A boolean expression that is evaluated to true if the value of this expression is contained by the provided collection. Note: Since the type of the elements in the collection are inferred only during the run time, the elements will be "up-casted" to the most common type for comparison. For eg: 1) In the case of "Int vs String", the "Int" will be up-casted to "String" and the comparison will look like "String vs String". 2) In the case of "Float vs Double", the "Float" will be up-casted to "Double" and the comparison will look like "Double vs Double" - Definition Classes
- Column
- Since
- 2.4.0 
 
-   final  def isInstanceOf[T0]: Boolean- Definition Classes
- Any
 
-    def isNaN: ColumnTrue if the current expression is NaN. True if the current expression is NaN. - Definition Classes
- Column
- Since
- 1.5.0 
 
-    def isNotNull: ColumnTrue if the current expression is NOT null. True if the current expression is NOT null. - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def isNull: ColumnTrue if the current expression is null. True if the current expression is null. - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def isTraceEnabled(): Boolean- Attributes
- protected
- Definition Classes
- Logging
 
-    def isin(ds: Dataset[_]): ColumnA boolean expression that is evaluated to true if the value of this expression is contained by the provided Dataset/DataFrame. A boolean expression that is evaluated to true if the value of this expression is contained by the provided Dataset/DataFrame. - Definition Classes
- Column
- Since
- 4.1.0 
 
-    def isin(list: Any*): ColumnA boolean expression that is evaluated to true if the value of this expression is contained by the evaluated values of the arguments. A boolean expression that is evaluated to true if the value of this expression is contained by the evaluated values of the arguments. Note: Since the type of the elements in the list are inferred only during the run time, the elements will be "up-casted" to the most common type for comparison. For eg: 1) In the case of "Int vs String", the "Int" will be up-casted to "String" and the comparison will look like "String vs String". 2) In the case of "Float vs Double", the "Float" will be up-casted to "Double" and the comparison will look like "Double vs Double" - Definition Classes
- Column
- Annotations
- @varargs()
- Since
- 1.5.0 
 
-    def leq(other: Any): ColumnLess than or equal to. Less than or equal to. // Scala: The following selects people age 21 or younger than 21. people.select( people("age") <= 21 ) // Java: people.select( people.col("age").leq(21) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def like(literal: String): ColumnSQL like expression. SQL like expression. Returns a boolean column based on a SQL LIKE match. - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def log: Logger- Attributes
- protected
- Definition Classes
- Logging
 
-    def logBasedOnLevel(level: Level)(f: => MessageWithContext): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logDebug(msg: => String, throwable: Throwable): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logDebug(entry: LogEntry, throwable: Throwable): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logDebug(entry: LogEntry): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logDebug(msg: => String): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logError(msg: => String, throwable: Throwable): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logError(entry: LogEntry, throwable: Throwable): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logError(entry: LogEntry): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logError(msg: => String): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logInfo(msg: => String, throwable: Throwable): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logInfo(entry: LogEntry, throwable: Throwable): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logInfo(entry: LogEntry): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logInfo(msg: => String): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logName: String- Attributes
- protected
- Definition Classes
- Logging
 
-    def logTrace(msg: => String, throwable: Throwable): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logTrace(entry: LogEntry, throwable: Throwable): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logTrace(entry: LogEntry): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logTrace(msg: => String): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logWarning(msg: => String, throwable: Throwable): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logWarning(entry: LogEntry, throwable: Throwable): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logWarning(entry: LogEntry): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def logWarning(msg: => String): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def long: StructFieldCreates a new StructFieldof type long.Creates a new StructFieldof type long.- Since
- 1.3.0 
 
-    def lt(other: Any): ColumnLess than. Less than. // Scala: The following selects people younger than 21. people.select( people("age") < 21 ) // Java: people.select( people.col("age").lt(21) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-  def map(mapType: MapType): StructField
-    def map(keyType: DataType, valueType: DataType): StructFieldCreates a new StructFieldof type map.Creates a new StructFieldof type map.- Since
- 1.3.0 
 
-    def minus(other: Any): ColumnSubtraction. Subtraction. Subtract the other expression from this expression. // Scala: The following selects the difference between people's height and their weight. people.select( people("height") - people("weight") ) // Java: people.select( people.col("height").minus(people.col("weight")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def mod(other: Any): ColumnModulo (a.k.a. Modulo (a.k.a. remainder) expression. - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def multiply(other: Any): ColumnMultiplication of this expression and another expression. Multiplication of this expression and another expression. // Scala: The following multiplies a person's height by their weight. people.select( people("height") * people("weight") ) // Java: people.select( people.col("height").multiply(people.col("weight")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def name(alias: String): ColumnGives the column a name (alias). Gives the column a name (alias). // Renames colA to colB in select output. df.select($"colA".name("colB")) If the current column has metadata associated with it, this metadata will be propagated to the new column. If this not desired, use the API as(alias: String, metadata: Metadata)with explicit metadata.- Definition Classes
- Column
- Since
- 2.0.0 
 
-   final  def ne(arg0: AnyRef): Boolean- Definition Classes
- AnyRef
 
-    val node: ColumnNode- Definition Classes
- Column
 
-    def notEqual(other: Any): ColumnInequality test. Inequality test. // 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")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-   final  def notify(): Unit- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
 
-   final  def notifyAll(): Unit- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
 
-    def or(other: Column): ColumnBoolean OR. Boolean OR. // Scala: The following selects people that are in school or employed. people.filter( people("inSchool") || people("isEmployed") ) // Java: people.filter( people.col("inSchool").or(people.col("isEmployed")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def otherwise(value: Any): ColumnEvaluates a list of conditions and returns one of multiple possible result expressions. Evaluates a list of conditions and returns one of multiple possible result expressions. If otherwise is not defined at the end, null is returned for unmatched conditions. // Example: encoding gender string column into integer. // Scala: people.select(when(people("gender") === "male", 0) .when(people("gender") === "female", 1) .otherwise(2)) // Java: people.select(when(col("gender").equalTo("male"), 0) .when(col("gender").equalTo("female"), 1) .otherwise(2)) - Definition Classes
- Column
- Since
- 1.4.0 
 
-    def outer(): ColumnMark this column as an outer column if its expression refers to columns from an outer query. Mark this column as an outer column if its expression refers to columns from an outer query. This is used to trigger lazy analysis of Spark Classic DataFrame, so that we can use it to build subquery expressions. Spark Connect DataFrame is always lazily analyzed and does not need to use this function. // Spark can't analyze this `df` now as it doesn't know how to resolve `t1.col`. val df = spark.table("t2").where($"t2.col" === $"t1.col".outer()) // Since this `df` is lazily analyzed, you won't see any error until you try to execute it. df.collect() // Fails with UNRESOLVED_COLUMN error. // Now Spark can resolve `t1.col` with the outer plan `spark.table("t1")`. spark.table("t1").where(df.exists()) - Definition Classes
- Column
- Since
- 4.0.0 
 
-    def over(): ColumnDefines an empty analytic clause. Defines an empty analytic clause. In this case the analytic function is applied and presented for all rows in the result set. df.select( sum("price").over(), avg("price").over() ) - Definition Classes
- Column
- Since
- 2.0.0 
 
-    def over(window: WindowSpec): ColumnDefines a windowing column. Defines a windowing column. val w = Window.partitionBy("name").orderBy("id") df.select( sum("price").over(w.rangeBetween(Window.unboundedPreceding, 2)), avg("price").over(w.rowsBetween(Window.currentRow, 4)) ) - Definition Classes
- Column
- Since
- 1.4.0 
 
-    def plus(other: Any): ColumnSum of this expression and another expression. Sum of this expression and another expression. // Scala: The following selects the sum of a person's height and weight. people.select( people("height") + people("weight") ) // Java: people.select( people.col("height").plus(people.col("weight")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def rlike(literal: String): ColumnSQL RLIKE expression (LIKE with Regex). SQL RLIKE expression (LIKE with Regex). Returns a boolean column based on a regex match. - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def short: StructFieldCreates a new StructFieldof type short.Creates a new StructFieldof type short.- Since
- 1.3.0 
 
-    def startsWith(literal: String): ColumnString starts with another string literal. String starts with another string literal. Returns a boolean column based on a string match. - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def startsWith(other: Column): ColumnString starts with. String starts with. Returns a boolean column based on a string match. - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def string: StructFieldCreates a new StructFieldof type string.Creates a new StructFieldof type string.- Since
- 1.3.0 
 
-    def struct(structType: StructType): StructFieldCreates a new StructFieldof type struct.Creates a new StructFieldof type struct.- Since
- 1.3.0 
 
-    def struct(fields: StructField*): StructFieldCreates a new StructFieldof type struct.Creates a new StructFieldof type struct.- Since
- 1.3.0 
 
-    def substr(startPos: Int, len: Int): ColumnAn expression that returns a substring. An expression that returns a substring. - startPos
- starting position. 
- len
- length of the substring. 
 - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def substr(startPos: Column, len: Column): ColumnAn expression that returns a substring. An expression that returns a substring. - startPos
- expression for the starting position. 
- len
- expression for the length of the substring. 
 - Definition Classes
- Column
- Since
- 1.3.0 
 
-   final  def synchronized[T0](arg0: => T0): T0- Definition Classes
- AnyRef
 
-    def timestamp: StructFieldCreates a new StructFieldof type timestamp.Creates a new StructFieldof type timestamp.- Since
- 1.3.0 
 
-    def toString(): String- Definition Classes
- Column → AnyRef → Any
 
-    def transform(f: (Column) => Column): ColumnConcise syntax for chaining custom transformations. Concise syntax for chaining custom transformations. def addPrefix(c: Column): Column = concat(lit("prefix_"), c) df.select($"name".transform(addPrefix)) // Chaining multiple transformations df.select($"name".transform(addPrefix).transform(upper)) - Definition Classes
- Column
- Since
- 4.1.0 
 
-    def try_cast(to: String): ColumnCasts the column to a different data type and the result is null on failure. Casts the column to a different data type and the result is null on failure. // Casts colA to integer. df.select(df("colA").try_cast("int")) - Definition Classes
- Column
- Since
- 4.0.0 
 
-    def try_cast(to: DataType): ColumnCasts the column to a different data type and the result is null on failure. Casts the column to a different data type and the result is null on failure. // Casts colA to IntegerType. import org.apache.spark.sql.types.IntegerType df.select(df("colA").try_cast(IntegerType)) // equivalent to df.select(df("colA").try_cast("int")) - Definition Classes
- Column
- Since
- 4.0.0 
 
-    def unary_!: ColumnInversion of boolean expression, i.e. Inversion of boolean expression, i.e. NOT. // Scala: select rows that are not active (isActive === false) df.filter( !df("isActive") ) // Java: import static org.apache.spark.sql.functions.*; df.filter( not(df.col("isActive")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-    def unary_-: ColumnUnary minus, i.e. Unary minus, i.e. negate the expression. // Scala: select the amount column and negates all values. df.select( -df("amount") ) // Java: import static org.apache.spark.sql.functions.*; df.select( negate(col("amount") ); - Definition Classes
- Column
- Since
- 1.3.0 
 
-   final  def wait(arg0: Long, arg1: Int): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
 
-   final  def wait(arg0: Long): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
 
-   final  def wait(): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
 
-    def when(condition: Column, value: Any): ColumnEvaluates a list of conditions and returns one of multiple possible result expressions. Evaluates a list of conditions and returns one of multiple possible result expressions. If otherwise is not defined at the end, null is returned for unmatched conditions. // Example: encoding gender string column into integer. // Scala: people.select(when(people("gender") === "male", 0) .when(people("gender") === "female", 1) .otherwise(2)) // Java: people.select(when(col("gender").equalTo("male"), 0) .when(col("gender").equalTo("female"), 1) .otherwise(2)) - Definition Classes
- Column
- Since
- 1.4.0 
 
-    def withField(fieldName: String, col: Column): ColumnAn expression that adds/replaces field in StructTypeby name.An expression that adds/replaces field in StructTypeby name.val df = sql("SELECT named_struct('a', 1, 'b', 2) struct_col") df.select($"struct_col".withField("c", lit(3))) // result: {"a":1,"b":2,"c":3} val df = sql("SELECT named_struct('a', 1, 'b', 2) struct_col") df.select($"struct_col".withField("b", lit(3))) // result: {"a":1,"b":3} val df = sql("SELECT CAST(NULL AS struct<a:int,b:int>) struct_col") df.select($"struct_col".withField("c", lit(3))) // result: null of type struct<a:int,b:int,c:int> val df = sql("SELECT named_struct('a', 1, 'b', 2, 'b', 3) struct_col") df.select($"struct_col".withField("b", lit(100))) // result: {"a":1,"b":100,"b":100} val df = sql("SELECT named_struct('a', named_struct('a', 1, 'b', 2)) struct_col") df.select($"struct_col".withField("a.c", lit(3))) // result: {"a":{"a":1,"b":2,"c":3}} val df = sql("SELECT named_struct('a', named_struct('b', 1), 'a', named_struct('c', 2)) struct_col") df.select($"struct_col".withField("a.c", lit(3))) // result: org.apache.spark.sql.AnalysisException: Ambiguous reference to fields This method supports adding/replacing nested fields directly e.g. val df = sql("SELECT named_struct('a', named_struct('a', 1, 'b', 2)) struct_col") df.select($"struct_col".withField("a.c", lit(3)).withField("a.d", lit(4))) // result: {"a":{"a":1,"b":2,"c":3,"d":4}} However, if you are going to add/replace multiple nested fields, it is more optimal to extract out the nested struct before adding/replacing multiple fields e.g. val df = sql("SELECT named_struct('a', named_struct('a', 1, 'b', 2)) struct_col") df.select($"struct_col".withField("a", $"struct_col.a".withField("c", lit(3)).withField("d", lit(4)))) // result: {"a":{"a":1,"b":2,"c":3,"d":4}} - Definition Classes
- Column
- Since
- 3.1.0 
 
-    def withLogContext(context: Map[String, String])(body: => Unit): Unit- Attributes
- protected
- Definition Classes
- Logging
 
-    def ||(other: Any): ColumnBoolean OR. Boolean OR. // Scala: The following selects people that are in school or employed. people.filter( people("inSchool") || people("isEmployed") ) // Java: people.filter( people.col("inSchool").or(people.col("isEmployed")) ); - Definition Classes
- Column
- Since
- 1.3.0 
 
Deprecated Value Members
-    def !==(other: Any): ColumnInequality test. Inequality test. // 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")) ); - Definition Classes
- Column
- Annotations
- @deprecated
- Deprecated
- (Since version 2.0.0) !== does not have the same precedence as ===, use =!= instead 
- Since
- 1.3.0 
 
-    def finalize(): Unit- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
- (Since version 9)