From 924d48f442b2e84145c9e1562971d34322472826 Mon Sep 17 00:00:00 2001 From: Yuyang Wang Date: Tue, 20 Aug 2024 09:43:19 -0700 Subject: [PATCH] remove previous change --- .../snowpark/internal/UDFClassPath.scala | 9 +------- .../snowflake/snowpark/internal/Utils.scala | 21 +++++++++++++------ .../com/snowflake/snowpark/UtilsSuite.scala | 14 ++----------- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/main/scala/com/snowflake/snowpark/internal/UDFClassPath.scala b/src/main/scala/com/snowflake/snowpark/internal/UDFClassPath.scala index 31c8200f..aedbc8a6 100644 --- a/src/main/scala/com/snowflake/snowpark/internal/UDFClassPath.scala +++ b/src/main/scala/com/snowflake/snowpark/internal/UDFClassPath.scala @@ -3,7 +3,6 @@ package com.snowflake.snowpark.internal import com.fasterxml.jackson.annotation.JsonView import com.fasterxml.jackson.core.TreeNode import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.module.scala.DefaultScalaModule import java.io.File import java.net.{URI, URLClassLoader} @@ -25,8 +24,6 @@ object UDFClassPath extends Logging { val jacksonDatabindClass: Class[JsonNode] = classOf[com.fasterxml.jackson.databind.JsonNode] val jacksonCoreClass: Class[TreeNode] = classOf[com.fasterxml.jackson.core.TreeNode] val jacksonAnnotationClass: Class[JsonView] = classOf[com.fasterxml.jackson.annotation.JsonView] - val jacksonModuleScalaClass: Class[DefaultScalaModule] = - classOf[com.fasterxml.jackson.module.scala.DefaultScalaModule] val jacksonJarSeq = Seq( RequiredLibrary( getPathForClass(jacksonDatabindClass), @@ -36,11 +33,7 @@ object UDFClassPath extends Logging { RequiredLibrary( getPathForClass(jacksonAnnotationClass), "jackson-annotation", - jacksonAnnotationClass), - RequiredLibrary( - getPathForClass(jacksonModuleScalaClass), - "jackson-module-scala", - jacksonModuleScalaClass)) + jacksonAnnotationClass)) /* * Libraries required to compile java code generated by snowpark for user's lambda. diff --git a/src/main/scala/com/snowflake/snowpark/internal/Utils.scala b/src/main/scala/com/snowflake/snowpark/internal/Utils.scala index f84459ee..67943432 100644 --- a/src/main/scala/com/snowflake/snowpark/internal/Utils.scala +++ b/src/main/scala/com/snowflake/snowpark/internal/Utils.scala @@ -1,7 +1,14 @@ package com.snowflake.snowpark.internal +import com.fasterxml.jackson.databind.{JsonNode, ObjectMapper} +import com.fasterxml.jackson.databind.node.JsonNodeType import com.snowflake.snowpark.Column -import com.snowflake.snowpark.internal.analyzer.{Attribute, LogicalPlan, TableFunctionExpression, singleQuote} +import com.snowflake.snowpark.internal.analyzer.{ + Attribute, + LogicalPlan, + TableFunctionExpression, + singleQuote +} import java.io.{File, FileInputStream} import java.lang.invoke.SerializedLambda @@ -9,8 +16,6 @@ import java.security.{DigestInputStream, MessageDigest} import java.util.Locale import com.snowflake.snowpark.udtf.UDTF import net.snowflake.client.jdbc.SnowflakeSQLException -import net.snowflake.client.jdbc.internal.fasterxml.jackson.databind.{JsonNode, ObjectMapper} -import net.snowflake.client.jdbc.internal.fasterxml.jackson.databind.node.JsonNodeType import scala.collection.JavaConverters.asScalaIteratorConverter import scala.collection.mutable @@ -465,9 +470,13 @@ object Utils extends Logging { case JsonNodeType.STRING => node.asText() case JsonNodeType.NULL => null case JsonNodeType.OBJECT => - node.fields().asScala.map(entry => { - entry.getKey -> jsonToScala(entry.getValue) - }).toMap + node + .fields() + .asScala + .map(entry => { + entry.getKey -> jsonToScala(entry.getValue) + }) + .toMap case JsonNodeType.ARRAY => node.elements().asScala.map(entry => jsonToScala(entry)).toList case JsonNodeType.BOOLEAN => node.asBoolean() diff --git a/src/test/scala/com/snowflake/snowpark/UtilsSuite.scala b/src/test/scala/com/snowflake/snowpark/UtilsSuite.scala index d02984da..963e2ba6 100644 --- a/src/test/scala/com/snowflake/snowpark/UtilsSuite.scala +++ b/src/test/scala/com/snowflake/snowpark/UtilsSuite.scala @@ -677,18 +677,8 @@ class UtilsSuite extends SNTestBase { val map = Map( "integerKey" -> 1.1, "stringKey" -> "stringValue", - "nestedMap" -> Map( - "insideKey" -> "stringValue", - "insideList" -> Seq(1, 2, 3) - ), - "nestedList" -> Seq( - 1, - Map( - "nestedKey" -> "nestedValue" - ), - List(1, 2, 3) - ) - ) + "nestedMap" -> Map("insideKey" -> "stringValue", "insideList" -> Seq(1, 2, 3)), + "nestedList" -> Seq(1, Map("nestedKey" -> "nestedValue"), List(1, 2, 3))) val jsonString = Utils.mapToJson(map) val readMap = Utils.jsonToMap(jsonString.getOrElse("")) val transformedString = Utils.mapToJson(readMap.getOrElse(Map()))