rangadi commented on code in PR #38286:
URL: https://github.com/apache/spark/pull/38286#discussion_r997526883
##########
connector/protobuf/src/test/scala/org/apache/spark/sql/protobuf/ProtobufCatalystDataConversionSuite.scala:
##########
@@ -99,26 +115,32 @@ class ProtobufCatalystDataConversionSuite
StructType(StructField("bytes_type", BinaryType, nullable = true) :: Nil),
StructType(StructField("string_type", StringType, nullable = true) :: Nil))
- private val catalystTypesToProtoMessages: Map[DataType, String] = Map(
- IntegerType -> "IntegerMsg",
- DoubleType -> "DoubleMsg",
- FloatType -> "FloatMsg",
- BinaryType -> "BytesMsg",
- StringType -> "StringMsg")
+ private val catalystTypesToProtoMessages: Map[DataType, (String, Any)] = Map(
+ IntegerType -> ("IntegerMsg", 0),
+ DoubleType -> ("DoubleMsg", 0.0d),
+ FloatType -> ("FloatMsg", 0.0f),
+ BinaryType -> ("BytesMsg", ByteString.empty().toByteArray),
+ StringType -> ("StringMsg", ""))
testingTypes.foreach { dt =>
val seed = 1 + scala.util.Random.nextInt((1024 - 1) + 1)
- val filePath = testFile("protobuf/catalyst_types.desc").replace("file:/",
"/")
test(s"single $dt with seed $seed") {
+
+ val (messageName, defaultValue) =
catalystTypesToProtoMessages(dt.fields(0).dataType)
+
val rand = new scala.util.Random(seed)
- val data = RandomDataGenerator.forType(dt, rand = rand).get.apply()
+ val generator = RandomDataGenerator.forType(dt, rand = rand).get
+ var data = generator()
+ while (data.asInstanceOf[Row].get(0) == defaultValue) // Do not use
default values, since
Review Comment:
Or just rerunning handful of times triggers this. `RandomDataGenerator`
intentionally returns edge values like '0' often (50% of the time by default).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]