You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by da...@apache.org on 2015/11/17 08:16:22 UTC
spark git commit: [MINOR] [SQL] Fix randomly generated ArrayData in
RowEncoderSuite
Repository: spark
Updated Branches:
refs/heads/master e01865af0 -> d79d8b08f
[MINOR] [SQL] Fix randomly generated ArrayData in RowEncoderSuite
The randomly generated ArrayData used for the UDT `ExamplePoint` in `RowEncoderSuite` sometimes doesn't have enough elements. In this case, this test will fail. This patch is to fix it.
Author: Liang-Chi Hsieh <vi...@appier.com>
Closes #9757 from viirya/fix-randomgenerated-udt.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/d79d8b08
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/d79d8b08
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/d79d8b08
Branch: refs/heads/master
Commit: d79d8b08ff69b30b02fe87839e695e29bfea5ace
Parents: e01865a
Author: Liang-Chi Hsieh <vi...@appier.com>
Authored: Mon Nov 16 23:16:17 2015 -0800
Committer: Davies Liu <da...@gmail.com>
Committed: Mon Nov 16 23:16:17 2015 -0800
----------------------------------------------------------------------
.../spark/sql/catalyst/encoders/RowEncoderSuite.scala | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/d79d8b08/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/encoders/RowEncoderSuite.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/encoders/RowEncoderSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/encoders/RowEncoderSuite.scala
index c868dde..46c6e0d 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/encoders/RowEncoderSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/encoders/RowEncoderSuite.scala
@@ -17,6 +17,8 @@
package org.apache.spark.sql.catalyst.encoders
+import scala.util.Random
+
import org.apache.spark.SparkFunSuite
import org.apache.spark.sql.{RandomDataGenerator, Row}
import org.apache.spark.sql.catalyst.util.{GenericArrayData, ArrayData}
@@ -59,7 +61,12 @@ class ExamplePointUDT extends UserDefinedType[ExamplePoint] {
override def deserialize(datum: Any): ExamplePoint = {
datum match {
case values: ArrayData =>
- new ExamplePoint(values.getDouble(0), values.getDouble(1))
+ if (values.numElements() > 1) {
+ new ExamplePoint(values.getDouble(0), values.getDouble(1))
+ } else {
+ val random = new Random()
+ new ExamplePoint(random.nextDouble(), random.nextDouble())
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org