Skip to content

Commit

Permalink
Create a wrapper for the is_null function.
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dchaconbarrantes committed Nov 30, 2023
1 parent 8a8406c commit 0e506cc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/com/snowflake/snowpark_java/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,16 @@ public Column is_null() {
return new Column(this.scalaColumn.is_null());
}

/**
* Wrapper for is_null function.
*
* @return The result column object
* @since 1.10.0
*/
public Column isNull() {
return is_null();
}

/**
* Is not null.
*
Expand Down
8 changes: 8 additions & 0 deletions src/main/scala/com/snowflake/snowpark/Column.scala
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ case class Column private[snowpark] (private[snowpark] val expr: Expression) ext
*/
def is_null: Column = withExpr(IsNull(expr))

/**
* Wrapper for is_null function.
*
* @group op
* @since 1.10.0
*/
def isNull: Column = is_null

/**
* Is not null.
* @group op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void isNull() {
DataFrame data = getSession().sql("select * from values(1),(null) as T(a)");
Row[] expected = {Row.create(false, true), Row.create(true, false)};
checkAnswer(data.select(data.col("a").is_null(), data.col("a").is_not_null()), expected, false);
checkAnswer(data.select(data.col("a").isNull(), data.col("a").is_not_null()), expected, false);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class ColumnSuite extends TestData {

assert(df.where(df("A").equal_nan).collect() sameElements Array[Row](Row(Double.NaN, 3)))
assert(df.where(df("A").is_null).collect() sameElements Array[Row](Row(null, 2)))
assert(df.where(df("A").isNull).collect() sameElements Array[Row](Row(null, 2)))
assert(
df.where(df("A").is_not_null).collect() sameElements Array[Row](
Row(1.1, 1),
Expand Down

0 comments on commit 0e506cc

Please sign in to comment.