You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/05/24 20:15:51 UTC

[GitHub] [spark] planga82 commented on a change in pull request #32599: [SPARK-35320][SQL] Support other data types as key types when parsing map in from_json

planga82 commented on a change in pull request #32599:
URL: https://github.com/apache/spark/pull/32599#discussion_r638245343



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/json/JacksonParser.scala
##########
@@ -325,6 +328,36 @@ class JacksonParser(
         parseJsonToken[AnyRef](parser, dataType)(PartialFunction.empty[JsonToken, AnyRef])
   }
 
+  def makeKeyConverter(dataType: DataType): KeyConverter = dataType match {
+    case BooleanType => (key: String) => key.toBoolean
+    case ByteType => (key: String) => key.toByte
+    case ShortType => (key: String) => key.toShort
+    case IntegerType => (key: String) => key.toInt
+    case LongType => (key: String) => key.toLong
+    case FloatType => (key: String) => key match {
+      case "NaN" => Float.NaN
+      case "Infinity" => Float.PositiveInfinity
+      case "-Infinity" => Float.NegativeInfinity

Review comment:
       Good point. I got it from makeConverter, but in  Cast.processFloatingPointSpecialLiterals I think we have a more complete use case. I'm going to change it in makeConverter in other PR to avoid mix things.




-- 
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.

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