From 91d6740a63392d310cb0550ab6456aa2871e7980 Mon Sep 17 00:00:00 2001 From: Bing Li Date: Fri, 7 Jun 2024 10:20:56 -0700 Subject: [PATCH] reformat --- .../snowpark_java/types/SnowflakeFile.java | 4 +-- .../snowflake/snowpark/types/Variant.scala | 30 ++++++++++--------- .../snowpark_test/DataTypeSuite.scala | 17 +++-------- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/snowflake/snowpark_java/types/SnowflakeFile.java b/src/main/java/com/snowflake/snowpark_java/types/SnowflakeFile.java index 1f7cca4e..477a8370 100644 --- a/src/main/java/com/snowflake/snowpark_java/types/SnowflakeFile.java +++ b/src/main/java/com/snowflake/snowpark_java/types/SnowflakeFile.java @@ -12,8 +12,8 @@ public class SnowflakeFile { /** * Create a new instance of SnowflakeFile. Calls into our C++ layer to construct it. * - * @param scopedUrl can be scoped URL. Stage file references should use - * the second override to set requireScopedUrl to false. + * @param scopedUrl can be scoped URL. Stage file references should use the second override to set + * requireScopedUrl to false. * @return A new instance of SnowflakeFile for the given URL. * @since 1.3.0 */ diff --git a/src/main/scala/com/snowflake/snowpark/types/Variant.scala b/src/main/scala/com/snowflake/snowpark/types/Variant.scala index 28ce5b67..5ff86f9c 100644 --- a/src/main/scala/com/snowflake/snowpark/types/Variant.scala +++ b/src/main/scala/com/snowflake/snowpark/types/Variant.scala @@ -162,21 +162,23 @@ class Variant private[snowpark] ( * @since 0.2.0 */ def this(str: String) = - this({ - try { - // `ObjectMapper` only reads the first token from - // the input string but not the whole string. - // For example, It can successfully - // convert "null dummy" to `null` value without reporting error. - if (str.toLowerCase().startsWith("null") && str != "null") { - JsonNodeFactory.instance.textNode(str) - } else { - MAPPER.readTree(str) + this( + { + try { + // `ObjectMapper` only reads the first token from + // the input string but not the whole string. + // For example, It can successfully + // convert "null dummy" to `null` value without reporting error. + if (str.toLowerCase().startsWith("null") && str != "null") { + JsonNodeFactory.instance.textNode(str) + } else { + MAPPER.readTree(str) + } + } catch { + case _: Exception => JsonNodeFactory.instance.textNode(str) } - } catch { - case _: Exception => JsonNodeFactory.instance.textNode(str) - } - }, VariantTypes.String) + }, + VariantTypes.String) /** * Creates a Variant from binary value diff --git a/src/test/scala/com/snowflake/snowpark_test/DataTypeSuite.scala b/src/test/scala/com/snowflake/snowpark_test/DataTypeSuite.scala index 0d19d5e8..8e7e2b06 100644 --- a/src/test/scala/com/snowflake/snowpark_test/DataTypeSuite.scala +++ b/src/test/scala/com/snowflake/snowpark_test/DataTypeSuite.scala @@ -590,27 +590,18 @@ class DataTypeSuite extends SNTestBase { // scalastyle:on } - test("Variant containing word null in the text") { + test("Variant containing word null in the text") { import session.implicits._ var variant = new Variant("null string starts with null") var df = Seq(variant).toDF("a") - checkAnswer( - df, - Row("\"null string starts with null\"") - ) + checkAnswer(df, Row("\"null string starts with null\"")) variant = new Variant("string with null in the middle") df = Seq(variant).toDF("a") - checkAnswer( - df, - Row("\"string with null in the middle\"") - ) + checkAnswer(df, Row("\"string with null in the middle\"")) variant = new Variant("string with null in the end null") df = Seq(variant).toDF("a") - checkAnswer( - df, - Row("\"string with null in the end null\"") - ) + checkAnswer(df, Row("\"string with null in the end null\"")) } }