Created
February 27, 2015 04:26
-
-
Save liancheng/df2cd35b819a7dcb7ac0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test("save - append - ArrayType.containsNull") { | |
withTempPath { file => | |
val df = Seq.empty[Tuple1[Seq[Int]]].toDF("arrayVal") | |
val nonNullSchema = StructType(df.schema.map { | |
case f @ StructField(_, a: ArrayType, _, _) => | |
f.copy(dataType = a.copy(containsNull = false)) | |
case f => f | |
}) | |
sqlContext.createDataFrame(df.rdd, nonNullSchema).save(file.getCanonicalPath) | |
(Tuple1(Seq(1, 2)) :: Tuple1(null.asInstanceOf[Seq[Int]]) :: Nil) | |
.toDF("arrayVal") | |
.save(file.getCanonicalPath, SaveMode.Append) | |
checkAnswer( | |
parquetFile(file.getCanonicalPath), | |
Row(ArrayBuffer(1, 2)) :: Row(null) :: Nil) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment