diff --git a/sql/core/src/main/scala/org/apache/spark/sql/Column.scala b/sql/core/src/main/scala/org/apache/spark/sql/Column.scala index b3cd9e1eff142..4b0f46c01b9b4 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/Column.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/Column.scala @@ -466,29 +466,56 @@ class Column(protected[sql] val expr: Expression) extends Logging { (this >= lowerBound) && (this <= upperBound) } + /** + * @group expr_ops + * @deprecated As of 1.6.0, replaced by `isnan`. This will be removed in Spark 2.0. + */ + @deprecated("Use isnan. This will be removed in Spark 2.0.", "1.6.0") + def isNaN: Column = isnan + /** * True if the current expression is NaN. * * @group expr_ops - * @since 1.5.0 + * @since 1.6.0 */ - def isNaN: Column = withExpr { IsNaN(expr) } + def isnan: Column = withExpr { IsNaN(expr) } + + /** + * @group expr_ops + * @deprecated As of 1.6.0, replaced by `isnull`. This will be removed in Spark 2.0. + */ + def isNull: Column = isnull /** * True if the current expression is null. * * @group expr_ops - * @since 1.3.0 + * @since 1.6.0 */ - def isNull: Column = withExpr { IsNull(expr) } + def isnull: Column = withExpr { IsNull(expr) } + + /** + * @group expr_ops + * @deprecated As of 1.6.0, replaced by `isnotnull`. This will be removed in Spark 2.0. + */ + def isNotNull: Column = isnotnull /** * True if the current expression is NOT null. * * @group expr_ops - * @since 1.3.0 + * @since 1.6.0 + */ + def isnotnull: Column = withExpr { IsNotNull(expr) } + + /** + * True if the current expression is NOT null. + * + * @group expr_ops + * @since 1.6.0 */ - def isNotNull: Column = withExpr { IsNotNull(expr) } + def notnull: Column = isnotnull /** * Boolean OR. diff --git a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala index e79defbbbdeea..15e29fd537809 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala @@ -865,6 +865,22 @@ object functions extends LegacyFunctions { */ def isnull(e: Column): Column = withExpr { IsNull(e.expr) } + /** + * Return true iff the column is NOT null. + * + * @group normal_funcs + * @since 1.6.0 + */ + def isnotnull(e: Column): Column = withExpr { IsNotNull(e.expr) } + + /** + * Return true iff the column is NOT null. + * + * @group normal_funcs + * @since 1.6.0 + */ + def notnull(e: Column): Column = isnotnull(e) + /** * A column expression that generates monotonically increasing 64-bit integers. * diff --git a/sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala index 38c0eb589f965..1ae511e8914e0 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/ColumnExpressionSuite.scala @@ -265,9 +265,9 @@ class ColumnExpressionSuite extends QueryTest with SharedSQLContext { complexData.collect().toSeq.map(r => Row(!r.getBoolean(3)))) } - test("isNull") { + test("isnull") { checkAnswer( - nullStrings.toDF.where($"s".isNull), + nullStrings.toDF.where($"s".isnull), nullStrings.collect().toSeq.filter(r => r.getString(1) eq null)) checkAnswer( @@ -275,9 +275,9 @@ class ColumnExpressionSuite extends QueryTest with SharedSQLContext { Row(true, false)) } - test("isNotNull") { + test("isnotnull") { checkAnswer( - nullStrings.toDF.where($"s".isNotNull), + nullStrings.toDF.where($"s".isnotnull), nullStrings.collect().toSeq.filter(r => r.getString(1) ne null)) checkAnswer( @@ -285,7 +285,7 @@ class ColumnExpressionSuite extends QueryTest with SharedSQLContext { Row(false, true)) } - test("isNaN") { + test("isnan") { val testData = sqlContext.createDataFrame(sparkContext.parallelize( Row(Double.NaN, Float.NaN) :: Row(math.log(-1), math.log(-3).toFloat) :: @@ -294,11 +294,11 @@ class ColumnExpressionSuite extends QueryTest with SharedSQLContext { StructType(Seq(StructField("a", DoubleType), StructField("b", FloatType)))) checkAnswer( - testData.select($"a".isNaN, $"b".isNaN), + testData.select($"a".isnan, $"b".isnan), Row(true, true) :: Row(true, true) :: Row(false, false) :: Row(false, false) :: Nil) checkAnswer( - testData.select(isNaN($"a"), isNaN($"b")), + testData.select(isnan($"a"), isnan($"b")), Row(true, true) :: Row(true, true) :: Row(false, false) :: Row(false, false) :: Nil) checkAnswer(