@@ -28,12 +28,10 @@ import parquet.schema.MessageTypeParser
28
28
29
29
import org .apache .spark .sql ._
30
30
import org .apache .spark .sql .catalyst .util .getTempFilePath
31
- import org .apache .spark .sql .catalyst .expressions ._
32
31
import org .apache .spark .sql .test .TestSQLContext
33
32
import org .apache .spark .sql .TestData
34
33
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 ._
37
35
import org .apache .spark .sql .catalyst .types .IntegerType
38
36
import org .apache .spark .util .Utils
39
37
@@ -366,20 +364,26 @@ class ParquetQuerySuite extends QueryTest with FunSuiteLike with BeforeAndAfterA
366
364
assert(query.collect().size === 10 )
367
365
}
368
366
369
- test(" Importing nested File " ) {
367
+ test(" Importing nested Parquet file (Addressbook) " ) {
370
368
ParquetTestData .readNestedFile()
371
369
val result = getRDD(ParquetTestData .testNestedData1).collect()
372
370
assert(result != null )
373
371
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" )
383
387
}
384
388
385
389
/**
0 commit comments