Skip to content
Snippets Groups Projects
Commit 13eb37c8 authored by hyukjinkwon's avatar hyukjinkwon Committed by Reynold Xin
Browse files

[MINOR][SQL] Fix the test title from =!= to <=>, remove a duplicated test and add a test for =!=

## What changes were proposed in this pull request?

This PR proposes three things as below:

- This test looks not testing `<=>` and identical with the test above, `===`. So, it removes the test.

  ```diff
  -   test("<=>") {
  -     checkAnswer(
  -      testData2.filter($"a" === 1),
  -      testData2.collect().toSeq.filter(r => r.getInt(0) == 1))
  -
  -    checkAnswer(
  -      testData2.filter($"a" === $"b"),
  -      testData2.collect().toSeq.filter(r => r.getInt(0) == r.getInt(1)))
  -   }
  ```

- Replace the test title from `=!=` to `<=>`. It looks the test actually testing `<=>`.

  ```diff
  +  private lazy val nullData = Seq(
  +    (Some(1), Some(1)), (Some(1), Some(2)), (Some(1), None), (None, None)).toDF("a", "b")
  +
    ...
  -  test("=!=") {
  +  test("<=>") {
  -    val nullData = spark.createDataFrame(sparkContext.parallelize(
  -      Row(1, 1) ::
  -      Row(1, 2) ::
  -      Row(1, null) ::
  -      Row(null, null) :: Nil),
  -      StructType(Seq(StructField("a", IntegerType), StructField("b", IntegerType))))
  -
         checkAnswer(
           nullData.filter($"b" <=> 1),
    ...
  ```

- Add the tests for `=!=` which looks not existing.

  ```diff
  +  test("=!=") {
  +    checkAnswer(
  +      nullData.filter($"b" =!= 1),
  +      Row(1, 2) :: Nil)
  +
  +    checkAnswer(nullData.filter($"b" =!= null), Nil)
  +
  +    checkAnswer(
  +      nullData.filter($"a" =!= $"b"),
  +      Row(1, 2) :: Nil)
  +  }
  ```

## How was this patch tested?

Manually running the tests.

Author: hyukjinkwon <gurwls223@gmail.com>

Closes #17842 from HyukjinKwon/minor-test-fix.
parent 6b9e49d1
No related branches found
No related tags found
No related merge requests found
...@@ -39,6 +39,9 @@ class ColumnExpressionSuite extends QueryTest with SharedSQLContext { ...@@ -39,6 +39,9 @@ class ColumnExpressionSuite extends QueryTest with SharedSQLContext {
StructType(Seq(StructField("a", BooleanType), StructField("b", BooleanType)))) StructType(Seq(StructField("a", BooleanType), StructField("b", BooleanType))))
} }
private lazy val nullData = Seq(
(Some(1), Some(1)), (Some(1), Some(2)), (Some(1), None), (None, None)).toDF("a", "b")
test("column names with space") { test("column names with space") {
val df = Seq((1, "a")).toDF("name with space", "name.with.dot") val df = Seq((1, "a")).toDF("name with space", "name.with.dot")
...@@ -283,23 +286,6 @@ class ColumnExpressionSuite extends QueryTest with SharedSQLContext { ...@@ -283,23 +286,6 @@ class ColumnExpressionSuite extends QueryTest with SharedSQLContext {
} }
test("<=>") { test("<=>") {
checkAnswer(
testData2.filter($"a" === 1),
testData2.collect().toSeq.filter(r => r.getInt(0) == 1))
checkAnswer(
testData2.filter($"a" === $"b"),
testData2.collect().toSeq.filter(r => r.getInt(0) == r.getInt(1)))
}
test("=!=") {
val nullData = spark.createDataFrame(sparkContext.parallelize(
Row(1, 1) ::
Row(1, 2) ::
Row(1, null) ::
Row(null, null) :: Nil),
StructType(Seq(StructField("a", IntegerType), StructField("b", IntegerType))))
checkAnswer( checkAnswer(
nullData.filter($"b" <=> 1), nullData.filter($"b" <=> 1),
Row(1, 1) :: Nil) Row(1, 1) :: Nil)
...@@ -321,7 +307,18 @@ class ColumnExpressionSuite extends QueryTest with SharedSQLContext { ...@@ -321,7 +307,18 @@ class ColumnExpressionSuite extends QueryTest with SharedSQLContext {
checkAnswer( checkAnswer(
nullData2.filter($"a" <=> null), nullData2.filter($"a" <=> null),
Row(null) :: Nil) Row(null) :: Nil)
}
test("=!=") {
checkAnswer(
nullData.filter($"b" =!= 1),
Row(1, 2) :: Nil)
checkAnswer(nullData.filter($"b" =!= null), Nil)
checkAnswer(
nullData.filter($"a" =!= $"b"),
Row(1, 2) :: Nil)
} }
test(">") { test(">") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment