Skip to content

Commit 745a42b

Browse files
Completing testcase for nested data (Addressbook(
1 parent 6125c75 commit 745a42b

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

sql/core/src/test/scala/org/apache/spark/sql/parquet/ParquetQuerySuite.scala

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@ import parquet.schema.MessageTypeParser
2828

2929
import org.apache.spark.sql._
3030
import org.apache.spark.sql.catalyst.util.getTempFilePath
31-
import org.apache.spark.sql.catalyst.expressions._
3231
import org.apache.spark.sql.test.TestSQLContext
3332
import org.apache.spark.sql.TestData
3433
import org.apache.spark.sql.SchemaRDD
35-
import org.apache.spark.sql.catalyst.expressions.Row
36-
import org.apache.spark.sql.catalyst.expressions.Equals
34+
import org.apache.spark.sql.catalyst.expressions._
3735
import org.apache.spark.sql.catalyst.types.IntegerType
3836
import org.apache.spark.util.Utils
3937

@@ -366,20 +364,26 @@ class ParquetQuerySuite extends QueryTest with FunSuiteLike with BeforeAndAfterA
366364
assert(query.collect().size === 10)
367365
}
368366

369-
test("Importing nested File") {
367+
test("Importing nested Parquet file (Addressbook)") {
370368
ParquetTestData.readNestedFile()
371369
val result = getRDD(ParquetTestData.testNestedData1).collect()
372370
assert(result != null)
373371
assert(result.size === 2)
374-
assert(result(0).size === 3)
375-
assert(result(1).apply(1) === null)
376-
assert(result(1).apply(2) === null)
377-
assert(result(1).apply(0) === "A. Nonymous")
378-
assert(result(0).apply(0).isInstanceOf[java.lang.String])
379-
assert(result(0).apply(0) === "Julien Le Dem")
380-
assert(result(0).apply(1).asInstanceOf[Row].apply(0) === "555 123 4567")
381-
assert(result(0).apply(1).asInstanceOf[Row].apply(2) === "XXX XXX XXXX")
382-
assert(result(0).apply(1).asInstanceOf[Row].apply(3) === null) // this should not even be there!
372+
val first_record = result(0)
373+
val second_record = result(1)
374+
val first_owner_numbers = result(0).apply(1).asInstanceOf[ArrayBuffer[Any]]
375+
val first_contacts = result(0).apply(2).asInstanceOf[ArrayBuffer[ArrayBuffer[Any]]]
376+
assert(first_record.size === 3)
377+
assert(second_record.apply(1) === null)
378+
assert(second_record.apply(2) === null)
379+
assert(second_record.apply(0) === "A. Nonymous")
380+
assert(first_record.apply(0) === "Julien Le Dem")
381+
assert(first_owner_numbers.apply(0) === "555 123 4567")
382+
assert(first_owner_numbers.apply(2) === "XXX XXX XXXX")
383+
assert(first_contacts.apply(0).size === 2)
384+
assert(first_contacts.apply(0).apply(0) === "Dmitriy Ryaboy")
385+
assert(first_contacts.apply(0).apply(1) === "555 987 6543")
386+
assert(first_contacts.apply(1).apply(0) === "Chris Aniszczyk")
383387
}
384388

385389
/**

0 commit comments

Comments
 (0)