Skip to content

Commit

Permalink
remove previous change
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-yuwang committed Aug 20, 2024
1 parent c34aea0 commit 924d48f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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),
Expand All @@ -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.
Expand Down
21 changes: 15 additions & 6 deletions src/main/scala/com/snowflake/snowpark/internal/Utils.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
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
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
Expand Down Expand Up @@ -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()
Expand Down
14 changes: 2 additions & 12 deletions src/test/scala/com/snowflake/snowpark/UtilsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down

0 comments on commit 924d48f

Please sign in to comment.