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
- Grouped
- Alphabetic
- By Inheritance
- CaseExpr
- Column
- Serializable
- Serializable
- Product
- Equals
- Logging
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=
(
arg0:
Any
)
:
Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##
()
:
Int
- Definition Classes
- AnyRef → Any
-
def
%
(
other:
Any
)
:
Column
Remainder.
-
def
&&
(
other:
Any
)
:
Column
And.
-
def
*
(
other:
Any
)
:
Column
Multiply.
-
def
+
(
other:
Any
)
:
Column
Plus.
-
def
-
(
other:
Any
)
:
Column
Minus.
-
def
/
(
other:
Any
)
:
Column
Divide.
-
def
<
(
other:
Any
)
:
Column
Less than.
-
def
<=
(
other:
Any
)
:
Column
Less than or equal to.
-
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
-
def
=!=
(
other:
Any
)
:
Column
Not equal to.
-
final
def
==
(
arg0:
Any
)
:
Boolean
- Definition Classes
- AnyRef → Any
-
def
===
(
other:
Any
)
:
Column
Equal to.
-
def
>
(
other:
Any
)
:
Column
Greater than.
-
def
>=
(
other:
Any
)
:
Column
Greater than or equal to.
-
def
alias
(
alias:
String
)
:
Column
Returns a new renamed Column.
-
def
and
(
other:
Column
)
:
Column
And.
And.
- Definition Classes
- Column
- Since
-
0.1.0
-
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
-
If the column is an ARRAY value, this function extracts the VARIANT value of the array
element at the specified index.
-
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
-
If the column is an OBJECT value, this function extracts the VARIANT value of the element
with the specified name from the OBJECT value.
-
def
as
(
alias:
String
)
:
Column
Returns a new renamed Column.
-
final
def
asInstanceOf
[
T0
]
:
T0
- Definition Classes
- Any
-
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
-
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
-
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
-
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
-
def
bitand
(
other:
Column
)
:
Column
Bitwise and.
Bitwise and.
- Definition Classes
- Column
- Since
-
0.1.0
-
def
bitor
(
other:
Column
)
:
Column
Bitwise or.
Bitwise or.
- Definition Classes
- Column
- Since
-
0.1.0
-
def
bitxor
(
other:
Column
)
:
Column
Bitwise xor.
Bitwise xor.
- Definition Classes
- Column
- Since
-
0.1.0
-
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
-
def
clone
()
:
AnyRef
- Attributes
- protected[ lang ]
- Definition Classes
- AnyRef
- Annotations
- @throws ( ... ) @native () @HotSpotIntrinsicCandidate ()
-
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
-
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
-
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
-
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
-
def
divide
(
other:
Column
)
:
Column
Divide.
Divide.
- Definition Classes
- Column
- Since
-
0.1.0
-
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
-
final
def
eq
(
arg0:
AnyRef
)
:
Boolean
- Definition Classes
- AnyRef
-
def
equal_nan
:
Column
Is NaN.
Is NaN.
- Definition Classes
- Column
- Since
-
0.1.0
-
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
-
def
equal_to
(
other:
Column
)
:
Column
Equal to.
Equal to. Same as
===
.- Definition Classes
- Column
- Since
-
0.1.0
-
def
geq
(
other:
Column
)
:
Column
Greater than or equal to.
Greater than or equal to.
- Definition Classes
- Column
- Since
-
0.1.0
-
final
def
getClass
()
:
Class
[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native () @HotSpotIntrinsicCandidate ()
-
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
-
def
gt
(
other:
Column
)
:
Column
Greater than.
Greater than.
- Definition Classes
- Column
- Since
-
0.1.0
-
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" indf1
. 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
-
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
-
final
def
isInstanceOf
[
T0
]
:
Boolean
- Definition Classes
- Any
-
def
isNull
:
Column
Wrapper for is_null function.
Wrapper for is_null function.
- Definition Classes
- Column
- Since
-
1.10.0
-
def
is_not_null
:
Column
Is not null.
Is not null.
- Definition Classes
- Column
- Since
-
0.1.0
-
def
is_null
:
Column
Is null.
Is null.
- Definition Classes
- Column
- Since
-
0.1.0
-
def
leq
(
other:
Column
)
:
Column
Less than or equal to.
Less than or equal to.
- Definition Classes
- Column
- Since
-
0.1.0
-
def
like
(
pattern:
Column
)
:
Column
Allows case-sensitive matching of strings based on comparison with a pattern.
-
def
log
()
:
Logger
- Attributes
- protected[ internal ]
- Definition Classes
- Logging
-
def
logDebug
(
msg:
String
,
throwable:
Throwable
)
:
Unit
- Attributes
- protected[ internal ]
- Definition Classes
- Logging
-
def
logDebug
(
msg:
String
)
:
Unit
- Attributes
- protected[ internal ]
- Definition Classes
- Logging
-
def
logError
(
msg:
String
,
throwable:
Throwable
)
:
Unit
- Attributes
- protected[ internal ]
- Definition Classes
- Logging
-
def
logError
(
msg:
String
)
:
Unit
- Attributes
- protected[ internal ]
- Definition Classes
- Logging
-
def
logInfo
(
msg:
String
,
throwable:
Throwable
)
:
Unit
- Attributes
- protected[ internal ]
- Definition Classes
- Logging
-
def
logInfo
(
msg:
String
)
:
Unit
- Attributes
- protected[ internal ]
- Definition Classes
- Logging
-
def
logTrace
(
msg:
String
,
throwable:
Throwable
)
:
Unit
- Attributes
- protected[ internal ]
- Definition Classes
- Logging
-
def
logTrace
(
msg:
String
)
:
Unit
- Attributes
- protected[ internal ]
- Definition Classes
- Logging
-
def
logWarning
(
msg:
String
,
throwable:
Throwable
)
:
Unit
- Attributes
- protected[ internal ]
- Definition Classes
- Logging
-
def
logWarning
(
msg:
String
)
:
Unit
- Attributes
- protected[ internal ]
- Definition Classes
- Logging
-
def
lt
(
other:
Column
)
:
Column
Less than.
Less than.
- Definition Classes
- Column
- Since
-
0.1.0
-
def
minus
(
other:
Column
)
:
Column
Minus.
Minus.
- Definition Classes
- Column
- Since
-
0.1.0
-
def
mod
(
other:
Column
)
:
Column
Remainder.
Remainder.
- Definition Classes
- Column
- Since
-
0.1.0
-
def
multiply
(
other:
Column
)
:
Column
Multiply.
Multiply.
- Definition Classes
- Column
- Since
-
0.1.0
-
def
name
(
alias:
String
)
:
Column
Returns a new renamed Column.
Returns a new renamed Column.
- Definition Classes
- Column
- Since
-
0.1.0
-
final
def
ne
(
arg0:
AnyRef
)
:
Boolean
- Definition Classes
- AnyRef
-
def
not_equal
(
other:
Column
)
:
Column
Not equal to.
Not equal to.
- Definition Classes
- Column
- Since
-
0.1.0
-
final
def
notify
()
:
Unit
- Definition Classes
- AnyRef
- Annotations
- @native () @HotSpotIntrinsicCandidate ()
-
final
def
notifyAll
()
:
Unit
- Definition Classes
- AnyRef
- Annotations
- @native () @HotSpotIntrinsicCandidate ()
-
def
or
(
other:
Column
)
:
Column
Or.
Or.
- Definition Classes
- Column
- Since
-
0.1.0
-
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
-
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
-
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
-
def
plus
(
other:
Column
)
:
Column
Plus.
Plus.
- Definition Classes
- Column
- Since
-
0.1.0
-
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
-
final
def
synchronized
[
T0
]
(
arg0: ⇒
T0
)
:
T0
- Definition Classes
- AnyRef
-
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
-
def
unary_!
:
Column
Unary not.
Unary not.
- Definition Classes
- Column
- Since
-
0.1.0
-
def
unary_-
:
Column
Unary minus.
Unary minus.
- Definition Classes
- Column
- Since
-
0.1.0
-
final
def
wait
(
arg0:
Long
,
arg1:
Int
)
:
Unit
- Definition Classes
- AnyRef
- Annotations
- @throws ( ... )
-
final
def
wait
(
arg0:
Long
)
:
Unit
- Definition Classes
- AnyRef
- Annotations
- @throws ( ... ) @native ()
-
final
def
wait
()
:
Unit
- Definition Classes
- AnyRef
- Annotations
- @throws ( ... )
-
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
-
def
withExpr
(
newExpr:
Expression
)
:
Column
- Attributes
- protected
- Definition Classes
- Column
-
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
-
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
-
def
||
(
other:
Any
)
:
Column
Or.
Deprecated Value Members
-
def
finalize
()
:
Unit
- Attributes
- protected[ lang ]
- Definition Classes
- AnyRef
- Annotations
- @throws ( classOf[java.lang.Throwable] ) @Deprecated
- Deprecated