You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "amaliujia (via GitHub)" <gi...@apache.org> on 2023/05/23 01:53:00 UTC

[GitHub] [spark] amaliujia commented on a diff in pull request #41264: [SPARK-43717][Connect] Scala client reduce agg cannot handle null partitions for scala primitive inputs

amaliujia commented on code in PR #41264:
URL: https://github.com/apache/spark/pull/41264#discussion_r1201405460


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala:
##########
@@ -154,6 +154,17 @@ object ScalaReflection extends ScalaReflection {
     case _ => "array"
   }
 
+  private[sql] def defaultValueFor(enc: AgnosticEncoder[_]): Any = enc match {
+      case PrimitiveBooleanEncoder => null.asInstanceOf[Boolean]
+      case PrimitiveByteEncoder => null.asInstanceOf[Byte]
+      case PrimitiveShortEncoder => null.asInstanceOf[Short]
+      case PrimitiveIntEncoder => null.asInstanceOf[Int]
+      case PrimitiveLongEncoder => null.asInstanceOf[Long]
+      case PrimitiveFloatEncoder => null.asInstanceOf[Float]
+      case PrimitiveDoubleEncoder => null.asInstanceOf[Double]
+      case _ => null

Review Comment:
   It's a bit confusing to call it as `defaultValue`?  Usually for Boolean, default value is `false`, etc.
   
   This is more like `nullValueFor`?



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org