class CaseExpr extends Column

Represents a CASE expression.

To construct this object for a CASE expression, call the functions.when . specifying a condition and the corresponding result for that condition. Then, call the when and otherwise methods to specify additional conditions and results.

For example:

import com.snowflake.snowpark.functions._
df.select(
  when(col("col").is_null, lit(1))
    .when(col("col") === 1, lit(2))
    .otherwise(lit(3))
)
Since

0.2.0

Linear Supertypes
Column , Serializable , Serializable , Product , Equals , Logging , AnyRef , Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. CaseExpr
  2. Column
  3. Serializable
  4. Serializable
  5. Product
  6. Equals
  7. Logging
  8. AnyRef
  9. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def != ( arg0: Any ) : Boolean
    Definition Classes
    AnyRef → Any
  2. final def ## () : Int
    Definition Classes
    AnyRef → Any
  3. def % ( other: Any ) : Column

    Remainder.

    Remainder. Alias for mod .

    Definition Classes
    Column
    Since

    0.1.0

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

    And.

    And. Alias for and .

    Definition Classes
    Column
    Since

    0.1.0

  5. def * ( other: Any ) : Column

    Multiply.

    Multiply. Alias for multiply .

    Definition Classes
    Column
    Since

    0.1.0

  6. def + ( other: Any ) : Column

    Plus.

    Plus. Alias for plus .

    Definition Classes
    Column
    Since

    0.1.0

  7. def - ( other: Any ) : Column

    Minus.

    Minus. Alias for minus .

    Definition Classes
    Column
    Since

    0.1.0

  8. def / ( other: Any ) : Column

    Divide.

    Divide. Alias for divide .

    Definition Classes
    Column
    Since

    0.1.0

  9. def < ( other: Any ) : Column

    Less than.

    Less than. Alias for lt .

    Definition Classes
    Column
    Since

    0.1.0

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

    Less than or equal to.

    Less than or equal to. Alias for leq .

    Definition Classes
    Column
    Since

    0.1.0

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

    Equal to.

    Equal to. You can use this for comparisons against a null value. Alias for equal_null .

    Definition Classes
    Column
    Since

    0.1.0

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

    Not equal to.

    Not equal to. Alias for not_equal .

    Definition Classes
    Column
    Since

    0.1.0

  13. final def == ( arg0: Any ) : Boolean
    Definition Classes
    AnyRef → Any
  14. def === ( other: Any ) : Column

    Equal to.

    Equal to. Alias for equal_to . Use this instead of == to perform an equality check in an expression. For example:

    lhs.filter(col("a") === 10).join(rhs, rhs("id") === lhs("id"))
    Definition Classes
    Column
    Since

    0.1.0

  15. def > ( other: Any ) : Column

    Greater than.

    Greater than. Alias for gt .

    Definition Classes
    Column
    Since

    0.1.0

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

    Greater than or equal to.

    Greater than or equal to. Alias for geq .

    Definition Classes
    Column
    Since

    0.1.0

  17. def alias ( alias: String ) : Column

    Returns a new renamed Column.

    Returns a new renamed Column. Alias for name .

    Definition Classes
    Column
    Since

    0.1.0

  18. def and ( other: Column ) : Column

    And.

    And.

    Definition Classes
    Column
    Since

    0.1.0

  19. def apply ( idx: Int ) : Column

    Returns the element (field) at the specified index in a column that contains semi-structured data .

    Returns the element (field) at the specified index in a column that contains semi-structured data .

    The method applies case-sensitive matching to the names of the specified elements.

    This is equivalent to using bracket notation in SQL ( column[index] ).

    • If the column is an ARRAY value, this function extracts the VARIANT value of the array element at the specified index.
      • If the index points outside of the array boundaries or if an element does not exist at the specified index (e.g. if the array is sparsely populated), the method returns NULL.
    • If the column is a VARIANT value, this function first checks if the VARIANT value contains an ARRAY value.
      • If the VARIANT value does not contain an ARRAY value, the method returns NULL.
      • Otherwise, the method works as described above.

    For example:

    import com.snowflake.snowpark.functions.col
    df.select(col("src")(1)(0)("name")(0))
    idx

    index of the subfield to be extracted

    Definition Classes
    Column
    Since

    0.2.0

  20. def apply ( field: String ) : Column

    Returns the specified element (field) in a column that contains semi-structured data .

    Returns the specified element (field) in a column that contains semi-structured data .

    The method applies case-sensitive matching to the names of the specified elements.

    This is equivalent to using bracket notation in SQL ( column['element'] ).

    • If the column is an OBJECT value, this function extracts the VARIANT value of the element with the specified name from the OBJECT value.
      • If the element is not found, the method returns NULL.
      • You must not specify an empty string for the element name.
    • If the column is a VARIANT value, this function first checks if the VARIANT value contains an OBJECT value.
      • If the VARIANT value does not contain an OBJECT value, the method returns NULL.
      • Otherwise, the method works as described above.

    For example:

    import com.snowflake.snowpark.functions.col
    df.select(col("src")("salesperson")("emails")(0))
    field

    field name of the subfield to be extracted. You cannot specify a path.

    Definition Classes
    Column
    Since

    0.2.0

  21. def as ( alias: String ) : Column

    Returns a new renamed Column.

    Returns a new renamed Column. Alias for name .

    Definition Classes
    Column
    Since

    0.1.0

  22. final def asInstanceOf [ T0 ] : T0
    Definition Classes
    Any
  23. def asc : Column

    Returns a Column expression with values sorted in ascending order.

    Returns a Column expression with values sorted in ascending order.

    Definition Classes
    Column
    Since

    0.1.0

  24. def asc_nulls_first : Column

    Returns a Column expression with values sorted in ascending order (null values sorted before non-null values).

    Returns a Column expression with values sorted in ascending order (null values sorted before non-null values).

    Definition Classes
    Column
    Since

    0.1.0

  25. def asc_nulls_last : Column

    Returns a Column expression with values sorted in ascending order (null values sorted after non-null values).

    Returns a Column expression with values sorted in ascending order (null values sorted after non-null values).

    Definition Classes
    Column
    Since

    0.1.0

  26. def between ( lowerBound: Column , upperBound: Column ) : Column

    Between lower bound and upper bound.

    Between lower bound and upper bound.

    Definition Classes
    Column
    Since

    0.1.0

  27. def bitand ( other: Column ) : Column

    Bitwise and.

    Bitwise and.

    Definition Classes
    Column
    Since

    0.1.0

  28. def bitor ( other: Column ) : Column

    Bitwise or.

    Bitwise or.

    Definition Classes
    Column
    Since

    0.1.0

  29. def bitxor ( other: Column ) : Column

    Bitwise xor.

    Bitwise xor.

    Definition Classes
    Column
    Since

    0.1.0

  30. def cast ( to: DataType ) : Column

    Casts the values in the Column to the specified data type.

    Casts the values in the Column to the specified data type.

    Definition Classes
    Column
    Since

    0.1.0

  31. def clone () : AnyRef
    Attributes
    protected[ lang ]
    Definition Classes
    AnyRef
    Annotations
    @throws ( ... ) @native () @HotSpotIntrinsicCandidate ()
  32. def collate ( collateSpec: String ) : Column

    Returns a copy of the original Column with the specified collationSpec property, rather than the original collation specification property.

    Returns a copy of the original Column with the specified collationSpec property, rather than the original collation specification property.

    For details, see the Snowflake documentation on collation specifications .

    Definition Classes
    Column
    Since

    0.1.0

  33. def desc : Column

    Returns a Column expression with values sorted in descending order.

    Returns a Column expression with values sorted in descending order.

    Definition Classes
    Column
    Since

    0.1.0

  34. def desc_nulls_first : Column

    Returns a Column expression with values sorted in descending order (null values sorted before non-null values).

    Returns a Column expression with values sorted in descending order (null values sorted before non-null values).

    Definition Classes
    Column
    Since

    0.1.0

  35. def desc_nulls_last : Column

    Returns a Column expression with values sorted in descending order (null values sorted after non-null values).

    Returns a Column expression with values sorted in descending order (null values sorted after non-null values).

    Definition Classes
    Column
    Since

    0.1.0

  36. def divide ( other: Column ) : Column

    Divide.

    Divide.

    Definition Classes
    Column
    Since

    0.1.0

  37. def else ( value: Column ) : Column

    Sets the default result for this CASE expression.

    Sets the default result for this CASE expression. Alias for otherwise .

    Since

    0.2.0

  38. final def eq ( arg0: AnyRef ) : Boolean
    Definition Classes
    AnyRef
  39. def equal_nan : Column

    Is NaN.

    Is NaN.

    Definition Classes
    Column
    Since

    0.1.0

  40. def equal_null ( other: Column ) : Column

    Equal to.

    Equal to. You can use this for comparisons against a null value.

    Definition Classes
    Column
    Since

    0.1.0

  41. def equal_to ( other: Column ) : Column

    Equal to.

    Equal to. Same as === .

    Definition Classes
    Column
    Since

    0.1.0

  42. def geq ( other: Column ) : Column

    Greater than or equal to.

    Greater than or equal to.

    Definition Classes
    Column
    Since

    0.1.0

  43. final def getClass () : Class [_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native () @HotSpotIntrinsicCandidate ()
  44. def getName : Option [ String ]

    Returns the column name (if the column has a name).

    Returns the column name (if the column has a name).

    Definition Classes
    Column
    Since

    0.2.0

  45. def gt ( other: Column ) : Column

    Greater than.

    Greater than.

    Definition Classes
    Column
    Since

    0.1.0

  46. def in ( df: DataFrame ) : Column

    Returns a conditional expression that you can pass to the filter or where method to perform a WHERE ...

    Returns a conditional expression that you can pass to the filter or where method to perform a WHERE ... IN query with a specified subquery.

    The expression evaluates to true if the value in the column is one of the values in the column of the same name in a specified DataFrame.

    For example, the following code returns a DataFrame that contains the rows where the column "a" of df2 contains one of the values from column "a" in df1 . This is equivalent to SELECT * FROM table2 WHERE a IN (SELECT a FROM table1).

    val df1 = session.table(table1)
    val df2 = session.table(table2)
    df2.filter(col("a").in(df1))
    Definition Classes
    Column
    Since

    0.10.0

  47. def in ( values: Seq [ Any ] ) : Column

    Returns a conditional expression that you can pass to the filter or where method to perform the equivalent of a WHERE ...

    Returns a conditional expression that you can pass to the filter or where method to perform the equivalent of a WHERE ... IN query with a specified list of values.

    The expression evaluates to true if the value in the column is one of the values in a specified sequence.

    For example, the following code returns a DataFrame that contains the rows where the column "a" contains the value 1, 2, or 3. This is equivalent to SELECT * FROM table WHERE a IN (1, 2, 3).

    df.filter(df("a").in(Seq(1, 2, 3)))
    Definition Classes
    Column
    Since

    0.10.0

  48. final def isInstanceOf [ T0 ] : Boolean
    Definition Classes
    Any
  49. def isNull : Column

    Wrapper for is_null function.

    Wrapper for is_null function.

    Definition Classes
    Column
    Since

    1.10.0

  50. def is_not_null : Column

    Is not null.

    Is not null.

    Definition Classes
    Column
    Since

    0.1.0

  51. def is_null : Column

    Is null.

    Is null.

    Definition Classes
    Column
    Since

    0.1.0

  52. def leq ( other: Column ) : Column

    Less than or equal to.

    Less than or equal to.

    Definition Classes
    Column
    Since

    0.1.0

  53. def like ( pattern: Column ) : Column

    Allows case-sensitive matching of strings based on comparison with a pattern.

    Allows case-sensitive matching of strings based on comparison with a pattern.

    For details, see the Snowflake documentation on LIKE .

    Definition Classes
    Column
    Since

    0.1.0

  54. def log () : Logger
    Attributes
    protected[ internal ]
    Definition Classes
    Logging
  55. def logDebug ( msg: String , throwable: Throwable ) : Unit
    Attributes
    protected[ internal ]
    Definition Classes
    Logging
  56. def logDebug ( msg: String ) : Unit
    Attributes
    protected[ internal ]
    Definition Classes
    Logging
  57. def logError ( msg: String , throwable: Throwable ) : Unit
    Attributes
    protected[ internal ]
    Definition Classes
    Logging
  58. def logError ( msg: String ) : Unit
    Attributes
    protected[ internal ]
    Definition Classes
    Logging
  59. def logInfo ( msg: String , throwable: Throwable ) : Unit
    Attributes
    protected[ internal ]
    Definition Classes
    Logging
  60. def logInfo ( msg: String ) : Unit
    Attributes
    protected[ internal ]
    Definition Classes
    Logging
  61. def logTrace ( msg: String , throwable: Throwable ) : Unit
    Attributes
    protected[ internal ]
    Definition Classes
    Logging
  62. def logTrace ( msg: String ) : Unit
    Attributes
    protected[ internal ]
    Definition Classes
    Logging
  63. def logWarning ( msg: String , throwable: Throwable ) : Unit
    Attributes
    protected[ internal ]
    Definition Classes
    Logging
  64. def logWarning ( msg: String ) : Unit
    Attributes
    protected[ internal ]
    Definition Classes
    Logging
  65. def lt ( other: Column ) : Column

    Less than.

    Less than.

    Definition Classes
    Column
    Since

    0.1.0

  66. def minus ( other: Column ) : Column

    Minus.

    Minus.

    Definition Classes
    Column
    Since

    0.1.0

  67. def mod ( other: Column ) : Column

    Remainder.

    Remainder.

    Definition Classes
    Column
    Since

    0.1.0

  68. def multiply ( other: Column ) : Column

    Multiply.

    Multiply.

    Definition Classes
    Column
    Since

    0.1.0

  69. def name ( alias: String ) : Column

    Returns a new renamed Column.

    Returns a new renamed Column.

    Definition Classes
    Column
    Since

    0.1.0

  70. final def ne ( arg0: AnyRef ) : Boolean
    Definition Classes
    AnyRef
  71. def not_equal ( other: Column ) : Column

    Not equal to.

    Not equal to.

    Definition Classes
    Column
    Since

    0.1.0

  72. final def notify () : Unit
    Definition Classes
    AnyRef
    Annotations
    @native () @HotSpotIntrinsicCandidate ()
  73. final def notifyAll () : Unit
    Definition Classes
    AnyRef
    Annotations
    @native () @HotSpotIntrinsicCandidate ()
  74. def or ( other: Column ) : Column

    Or.

    Or.

    Definition Classes
    Column
    Since

    0.1.0

  75. def otherwise ( value: Column ) : Column

    Sets the default result for this CASE expression.

    Sets the default result for this CASE expression.

    Since

    0.2.0

  76. def over () : Column

    Returns a windows frame, based on an empty WindowSpec expression.

    Returns a windows frame, based on an empty WindowSpec expression.

    Definition Classes
    Column
    Since

    0.1.0

  77. def over ( window: WindowSpec ) : Column

    Returns a windows frame, based on the specified WindowSpec .

    Returns a windows frame, based on the specified WindowSpec .

    Definition Classes
    Column
    Since

    0.1.0

  78. def plus ( other: Column ) : Column

    Plus.

    Plus.

    Definition Classes
    Column
    Since

    0.1.0

  79. def regexp ( pattern: Column ) : Column

    Returns true if this Column matches the specified regular expression.

    Returns true if this Column matches the specified regular expression.

    For details, see the Snowflake documentation on regular expressions .

    Definition Classes
    Column
    Since

    0.1.0

  80. final def synchronized [ T0 ] ( arg0: ⇒ T0 ) : T0
    Definition Classes
    AnyRef
  81. def toString () : String

    Returns a string representation of the expression corresponding to this Column instance.

    Returns a string representation of the expression corresponding to this Column instance.

    Definition Classes
    Column → AnyRef → Any
    Since

    0.1.0

  82. def unary_! : Column

    Unary not.

    Unary not.

    Definition Classes
    Column
    Since

    0.1.0

  83. def unary_- : Column

    Unary minus.

    Unary minus.

    Definition Classes
    Column
    Since

    0.1.0

  84. final def wait ( arg0: Long , arg1: Int ) : Unit
    Definition Classes
    AnyRef
    Annotations
    @throws ( ... )
  85. final def wait ( arg0: Long ) : Unit
    Definition Classes
    AnyRef
    Annotations
    @throws ( ... ) @native ()
  86. final def wait () : Unit
    Definition Classes
    AnyRef
    Annotations
    @throws ( ... )
  87. def when ( condition: Column , value: Column ) : CaseExpr

    Appends one more WHEN condition to the CASE expression.

    Appends one more WHEN condition to the CASE expression.

    Since

    0.2.0

  88. def withExpr ( newExpr: Expression ) : Column
    Attributes
    protected
    Definition Classes
    Column
  89. def withinGroup ( cols: Seq [ Column ] ) : Column

    Returns a Column expression that adds a WITHIN GROUP clause to sort the rows by the specified sequence of columns.

    Returns a Column expression that adds a WITHIN GROUP clause to sort the rows by the specified sequence of columns.

    This method is supported on Column expressions returned by some of the aggregate functions, including functions.array_agg , LISTAGG(), PERCENTILE_CONT(), and PERCENTILE_DISC().

    For example:

    import com.snowflake.snowpark.functions._
    import session.implicits._
    // Create a DataFrame from a sequence.
    val df = Seq((3, "v1"), (1, "v3"), (2, "v2")).toDF("a", "b")
    // Create a DataFrame containing the values in "a" sorted by "b".
    df.select(array_agg(col("a")).withinGroup(Seq(col("b"))))
    // Create a DataFrame containing the values in "a" grouped by "b"
    // and sorted by "a" in descending order.
    df.select(
      array_agg(Seq(col("a")))
      .withinGroup(col("a").desc)
      .over(Window.partitionBy(col("b")))
    )

    For details, see the Snowflake documentation for the aggregate function that you are using (e.g. ARRAY_AGG ).

    Definition Classes
    Column
    Since

    0.6.0

  90. def withinGroup ( first: Column , remaining: Column * ) : Column

    Returns a Column expression that adds a WITHIN GROUP clause to sort the rows by the specified columns.

    Returns a Column expression that adds a WITHIN GROUP clause to sort the rows by the specified columns.

    This method is supported on Column expressions returned by some of the aggregate functions, including functions.array_agg , LISTAGG(), PERCENTILE_CONT(), and PERCENTILE_DISC().

    For example:

    import com.snowflake.snowpark.functions._
    import session.implicits._
    // Create a DataFrame from a sequence.
    val df = Seq((3, "v1"), (1, "v3"), (2, "v2")).toDF("a", "b")
    // Create a DataFrame containing the values in "a" sorted by "b".
    val dfArrayAgg = df.select(array_agg(col("a")).withinGroup(col("b")))
    // Create a DataFrame containing the values in "a" grouped by "b"
    // and sorted by "a" in descending order.
    var dfArrayAggWindow = df.select(
      array_agg(col("a"))
      .withinGroup(col("a").desc)
      .over(Window.partitionBy(col("b")))
    )

    For details, see the Snowflake documentation for the aggregate function that you are using (e.g. ARRAY_AGG ).

    Definition Classes
    Column
    Since

    0.6.0

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

    Or.

    Or. Alias for or .

    Definition Classes
    Column
    Since

    0.1.0

Deprecated Value Members

  1. def finalize () : Unit
    Attributes
    protected[ lang ]
    Definition Classes
    AnyRef
    Annotations
    @throws ( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from Column

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from Logging

Inherited from AnyRef

Inherited from Any

Expression Operation Functions

Utility Functions

Ungrouped