Class

org.apache.spark.sql

TypedColumn

Related Doc: package sql

Permalink

class TypedColumn[-T, U] extends Column

A Column where an Encoder has been given for the expected input and return type. To create a TypedColumn, use the as function on a Column.

T

The input type expected for this expression. Can be Any if the expression is type checked by the analyzer instead of the compiler (i.e. expr("sum(...)")).

U

The output type of this column.

Annotations
@Stable()
Source
Column.scala
Since

1.6.0

Linear Supertypes
Column, Logging, AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. TypedColumn
  2. Column
  3. Logging
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new TypedColumn(expr: Expression, encoder: ExpressionEncoder[U])

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def %(other: Any): Column

    Permalink

    Modulo (a.k.a.

    Modulo (a.k.a. remainder) expression.

    Definition Classes
    Column
    Since

    1.3.0

  4. def &&(other: Any): Column

    Permalink

    Boolean 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

  5. def *(other: Any): Column

    Permalink

    Multiplication 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

  6. def +(other: Any): Column

    Permalink

    Sum 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

  7. def -(other: Any): Column

    Permalink

    Subtraction.

    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

  8. def /(other: Any): Column

    Permalink

    Division 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

  9. def <(other: Any): Column

    Permalink

    Less 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

  10. def <=(other: Any): Column

    Permalink

    Less 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

  11. def <=>(other: Any): Column

    Permalink

    Equality test that is safe for null values.

    Equality test that is safe for null values.

    Definition Classes
    Column
    Since

    1.3.0

  12. def =!=(other: Any): Column

    Permalink

    Inequality 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

  13. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  14. def ===(other: Any): Column

    Permalink

    Equality 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

  15. def >(other: Any): Column

    Permalink

    Greater 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

  16. def >=(other: Any): Column

    Permalink

    Greater 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

  17. def alias(alias: String): Column

    Permalink

    Gives 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

  18. def and(other: Column): Column

    Permalink

    Boolean 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

  19. def apply(extraction: Any): Column

    Permalink

    Extracts 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

  20. def as(alias: String, metadata: Metadata): Column

    Permalink

    Gives 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

  21. def as(alias: Symbol): Column

    Permalink

    Gives 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 as with explicitly empty metadata.

    Definition Classes
    Column
    Since

    1.3.0

  22. def as(aliases: Array[String]): Column

    Permalink

    Assigns 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

  23. def as(aliases: Seq[String]): Column

    Permalink

    (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

  24. def as(alias: String): Column

    Permalink

    Gives 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 as with explicitly empty metadata.

    Definition Classes
    Column
    Since

    1.3.0

  25. def as[U](implicit arg0: Encoder[U]): TypedColumn[Any, U]

    Permalink

    Provides a type hint about the expected return value of this column.

    Provides a type hint about the expected return value of this column. This information can be used by operations such as select on a Dataset to automatically convert the results into the correct JVM types.

    Definition Classes
    Column
    Since

    1.6.0

  26. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  27. def asc: Column

    Permalink

    Returns 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

  28. def asc_nulls_first: Column

    Permalink

    Returns 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

  29. def asc_nulls_last: Column

    Permalink

    Returns 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

  30. def between(lowerBound: Any, upperBound: Any): Column

    Permalink

    True 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

  31. def bitwiseAND(other: Any): Column

    Permalink

    Compute 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

  32. def bitwiseOR(other: Any): Column

    Permalink

    Compute 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

  33. def bitwiseXOR(other: Any): Column

    Permalink

    Compute 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

  34. def cast(to: String): Column

    Permalink

    Casts 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

  35. def cast(to: DataType): Column

    Permalink

    Casts 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

  36. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  37. def contains(other: Any): Column

    Permalink

    Contains the other element.

    Contains the other element. Returns a boolean column based on a string match.

    Definition Classes
    Column
    Since

    1.3.0

  38. def desc: Column

    Permalink

    Returns 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

  39. def desc_nulls_first: Column

    Permalink

    Returns 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

  40. def desc_nulls_last: Column

    Permalink

    Returns 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

  41. def divide(other: Any): Column

    Permalink

    Division 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

  42. def endsWith(literal: String): Column

    Permalink

    String 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

  43. def endsWith(other: Column): Column

    Permalink

    String ends with.

    String ends with. Returns a boolean column based on a string match.

    Definition Classes
    Column
    Since

    1.3.0

  44. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  45. def eqNullSafe(other: Any): Column

    Permalink

    Equality test that is safe for null values.

    Equality test that is safe for null values.

    Definition Classes
    Column
    Since

    1.3.0

  46. def equalTo(other: Any): Column

    Permalink

    Equality 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

  47. def equals(that: Any): Boolean

    Permalink
    Definition Classes
    Column → AnyRef → Any
  48. def explain(extended: Boolean): Unit

    Permalink

    Prints the expression to the console for debugging purposes.

    Prints the expression to the console for debugging purposes.

    Definition Classes
    Column
    Since

    1.3.0

  49. val expr: Expression

    Permalink
    Definition Classes
    Column
  50. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  51. def geq(other: Any): Column

    Permalink

    Greater 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

  52. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  53. def getField(fieldName: String): Column

    Permalink

    An 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

  54. def getItem(key: Any): Column

    Permalink

    An expression that gets an item at position ordinal out of an array, or gets a value by key key in a MapType.

    An expression that gets an item at position ordinal out of an array, or gets a value by key key in a MapType.

    Definition Classes
    Column
    Since

    1.3.0

  55. def gt(other: Any): Column

    Permalink

    Greater 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

  56. def hashCode(): Int

    Permalink
    Definition Classes
    Column → AnyRef → Any
  57. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean = false): Boolean

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  58. def initializeLogIfNecessary(isInterpreter: Boolean): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  59. def isInCollection(values: Iterable[_]): Column

    Permalink

    A 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

  60. def isInCollection(values: Iterable[_]): Column

    Permalink

    A 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

  61. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  62. def isNaN: Column

    Permalink

    True if the current expression is NaN.

    True if the current expression is NaN.

    Definition Classes
    Column
    Since

    1.5.0

  63. def isNotNull: Column

    Permalink

    True if the current expression is NOT null.

    True if the current expression is NOT null.

    Definition Classes
    Column
    Since

    1.3.0

  64. def isNull: Column

    Permalink

    True if the current expression is null.

    True if the current expression is null.

    Definition Classes
    Column
    Since

    1.3.0

  65. def isTraceEnabled(): Boolean

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  66. def isin(list: Any*): Column

    Permalink

    A 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

  67. def leq(other: Any): Column

    Permalink

    Less 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

  68. def like(literal: String): Column

    Permalink

    SQL like expression.

    SQL like expression. Returns a boolean column based on a SQL LIKE match.

    Definition Classes
    Column
    Since

    1.3.0

  69. def log: Logger

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  70. def logDebug(msg: ⇒ String, throwable: Throwable): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  71. def logDebug(msg: ⇒ String): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  72. def logError(msg: ⇒ String, throwable: Throwable): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  73. def logError(msg: ⇒ String): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  74. def logInfo(msg: ⇒ String, throwable: Throwable): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  75. def logInfo(msg: ⇒ String): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  76. def logName: String

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  77. def logTrace(msg: ⇒ String, throwable: Throwable): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  78. def logTrace(msg: ⇒ String): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  79. def logWarning(msg: ⇒ String, throwable: Throwable): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  80. def logWarning(msg: ⇒ String): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  81. def lt(other: Any): Column

    Permalink

    Less 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

  82. def minus(other: Any): Column

    Permalink

    Subtraction.

    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

  83. def mod(other: Any): Column

    Permalink

    Modulo (a.k.a.

    Modulo (a.k.a. remainder) expression.

    Definition Classes
    Column
    Since

    1.3.0

  84. def multiply(other: Any): Column

    Permalink

    Multiplication 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

  85. def name(alias: String): TypedColumn[T, U]

    Permalink

    Gives the TypedColumn a name (alias).

    Gives the TypedColumn a name (alias). If the current TypedColumn has metadata associated with it, this metadata will be propagated to the new column.

    Definition Classes
    TypedColumnColumn
    Since

    2.0.0

  86. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  87. def notEqual(other: Any): Column

    Permalink

    Inequality 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

  88. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  89. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  90. def or(other: Column): Column

    Permalink

    Boolean 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

  91. def otherwise(value: Any): Column

    Permalink

    Evaluates 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

  92. def over(): Column

    Permalink

    Defines 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

  93. def over(window: WindowSpec): Column

    Permalink

    Defines 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

  94. def plus(other: Any): Column

    Permalink

    Sum 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

  95. def rlike(literal: String): Column

    Permalink

    SQL 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

  96. def startsWith(literal: String): Column

    Permalink

    String 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

  97. def startsWith(other: Column): Column

    Permalink

    String starts with.

    String starts with. Returns a boolean column based on a string match.

    Definition Classes
    Column
    Since

    1.3.0

  98. def substr(startPos: Int, len: Int): Column

    Permalink

    An 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

  99. def substr(startPos: Column, len: Column): Column

    Permalink

    An 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

  100. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  101. def toString(): String

    Permalink
    Definition Classes
    Column → AnyRef → Any
  102. def unary_!: Column

    Permalink

    Inversion 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

  103. def unary_-: Column

    Permalink

    Unary 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

  104. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  105. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  106. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  107. def when(condition: Column, value: Any): Column

    Permalink

    Evaluates 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

  108. def ||(other: Any): Column

    Permalink

    Boolean 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

  1. def !==(other: Any): Column

    Permalink

    Inequality 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

Inherited from Column

Inherited from Logging

Inherited from AnyRef

Inherited from Any

DataFrame functions

Expression operators

Java-specific expression operators

Support functions for DataFrames