spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiszk <...@git.apache.org>
Subject [GitHub] spark pull request #18327: [SPARK-21047] Add test suites for complicated cas...
Date Thu, 22 Jun 2017 12:27:29 GMT
Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18327#discussion_r123495879
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/execution/vectorized/ColumnarBatchSuite.scala
---
    @@ -739,6 +739,157 @@ class ColumnarBatchSuite extends SparkFunSuite {
         }}
       }
     
    +  test("Nest Array(not containing null) in Array.") {
    +    (MemoryMode.ON_HEAP :: MemoryMode.OFF_HEAP :: Nil).foreach { memMode =>
    +      val column = ColumnVector.allocate(10, new ArrayType(new ArrayType(IntegerType,
false), true),
    +        memMode)
    +      val childColumn = column.arrayData()
    +      val data = column.arrayData().arrayData()
    +      (0 until 6).foreach { i =>
    +        data.putInt(i, i)
    +      }
    +      // Arrays in child column: [0], [1, 2], [], [3, 4, 5]
    +      childColumn.putArray(0, 0, 1)
    +      childColumn.putArray(1, 1, 2)
    +      childColumn.putArray(2, 2, 0)
    +      childColumn.putArray(3, 3, 3)
    +      // Arrays in column: [[0]], [[1, 2], []], [[], [3, 4, 5]], null
    +      column.putArray(0, 0, 1)
    +      column.putArray(1, 1, 2)
    +      column.putArray(2, 2, 2)
    +      column.putNull(3)
    +
    +      assert(column.getArray(0).getArray(0).toIntArray() === Array(0))
    +      assert(column.getArray(1).getArray(0).toIntArray() === Array(1, 2))
    +      assert(column.getArray(1).getArray(1).toIntArray() === Array())
    +      assert(column.getArray(2).getArray(0).toIntArray() === Array())
    +      assert(column.getArray(2).getArray(1).toIntArray() === Array(3, 4, 5))
    +      assert(column.isNullAt(3))
    +    }
    +  }
    +
    +  test("Nest Array(containing null) in Array.") {
    +    (MemoryMode.ON_HEAP :: MemoryMode.OFF_HEAP :: Nil).foreach { memMode =>
    +      val column = ColumnVector.allocate(10, new ArrayType(new ArrayType(IntegerType,
true), true),
    +        memMode)
    +      val childColumn = column.arrayData()
    +      val data = column.arrayData().arrayData()
    +      (0 until 6).foreach {
    +        case 3 => data.putNull(3)
    +        case i => data.putInt(i, i)
    +      }
    +      // Arrays in child column: [0], [1, 2], [], [null, 4, 5]
    +      childColumn.putArray(0, 0, 1)
    +      childColumn.putArray(1, 1, 2)
    +      childColumn.putArray(2, 2, 0)
    +      childColumn.putArray(3, 3, 3)
    +      // Arrays in column: [[0]], [[1, 2], []], [[], [null, 4, 5]], null
    +      column.putArray(0, 0, 1)
    +      column.putArray(1, 1, 2)
    +      column.putArray(2, 2, 2)
    +      column.putNull(3)
    +
    +      assert(column.getArray(0).getArray(0).toIntArray() === Array(0))
    +      assert(column.getArray(1).getArray(0).toIntArray() === Array(1, 2))
    +      assert(column.getArray(1).getArray(1).toIntArray() === Array())
    +      assert(column.getArray(2).getArray(0).toIntArray() === Array())
    +      assert(column.getArray(2).getArray(1)isNullAt(0))
    --- End diff --
    
    Should it be `getArray(1).isNullAt(0)`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message