diff --git a/src/main/java/com/snowflake/snowpark_java/Functions.java b/src/main/java/com/snowflake/snowpark_java/Functions.java index 8daaf9fc..65f50020 100644 --- a/src/main/java/com/snowflake/snowpark_java/Functions.java +++ b/src/main/java/com/snowflake/snowpark_java/Functions.java @@ -3986,7 +3986,7 @@ public static Column expr(String s) { *
{@code * DataFrame df = getSession().sql("select * from values(1,2,3) as T(a,b,c)"); * df.select(Functions.array(df.col("a"), df.col("b"), df.col("c")).as("array")).show(); - *----------- + * ----------- * |"ARRAY" | * ----------- * |[ | @@ -4001,10 +4001,11 @@ public static Column expr(String s) { * @param cols The input column names * @return Column object as array. */ - public static Column array(Column... cols) { return array_construct(cols); } + public static Column array(Column... cols) { + return array_construct(cols); + } /** - * * Converts an input expression into the corresponding date in the specified date format. * *{@code diff --git a/src/main/scala/com/snowflake/snowpark/functions.scala b/src/main/scala/com/snowflake/snowpark/functions.scala index 662a00c4..5c6f599f 100644 --- a/src/main/scala/com/snowflake/snowpark/functions.scala +++ b/src/main/scala/com/snowflake/snowpark/functions.scala @@ -2,7 +2,12 @@ package com.snowflake.snowpark import com.snowflake.snowpark.internal.analyzer._ import com.snowflake.snowpark.internal.ScalaFunctions._ -import com.snowflake.snowpark.internal.{ErrorMessage, OpenTelemetry, UDXRegistrationHandler, Utils} +import com.snowflake.snowpark.internal.{ + ErrorMessage, + OpenTelemetry, + UDXRegistrationHandler, + Utils +} import com.snowflake.snowpark.types.TimestampType import scala.reflect.runtime.universe.TypeTag @@ -3151,7 +3156,7 @@ object functions { * |1 | * -------- * }}} - * + * * @since 1.14.0 * @param colName Column name. * @return Column object ordered in a descending manner. @@ -3299,7 +3304,7 @@ object functions { * |d | * --------------------- * }}} - * + * * @since 1.14.0 * @param c Column to obtain last value. * @return Column object. diff --git a/src/test/java/com/snowflake/snowpark_test/JavaFunctionSuite.java b/src/test/java/com/snowflake/snowpark_test/JavaFunctionSuite.java index edddec2e..624ea481 100644 --- a/src/test/java/com/snowflake/snowpark_test/JavaFunctionSuite.java +++ b/src/test/java/com/snowflake/snowpark_test/JavaFunctionSuite.java @@ -2783,9 +2783,8 @@ public void test_desc() { @Test public void test_size() { - DataFrame df = getSession() - .sql( - "select array_construct(a,b,c) as arr from values(1,2,3) as T(a,b,c)"); + DataFrame df = + getSession().sql("select array_construct(a,b,c) as arr from values(1,2,3) as T(a,b,c)"); Row[] expected = {Row.create(3)}; checkAnswer(df.select(Functions.size(Functions.col("arr"))), expected, false); @@ -2815,10 +2814,18 @@ public void date_format() { @Test public void last() { - DataFrame df = getSession().sql("select * from values (5, 'a', 10), (5, 'b', 20),\n" + - " (3, 'd', 15), (3, 'e', 40) as T(grade,name,score)"); + DataFrame df = + getSession() + .sql( + "select * from values (5, 'a', 10), (5, 'b', 20),\n" + + " (3, 'd', 15), (3, 'e', 40) as T(grade,name,score)"); Row[] expected = {Row.create("a"), Row.create("a"), Row.create("d"), Row.create("d")}; - checkAnswer(df.select(Functions.last(df.col("name")).over(Window.partitionBy(df.col("grade")).orderBy(df.col("score").desc()))), expected, false); + checkAnswer( + df.select( + Functions.last(df.col("name")) + .over(Window.partitionBy(df.col("grade")).orderBy(df.col("score").desc()))), + expected, + false); } } diff --git a/src/test/scala/com/snowflake/snowpark_test/FunctionSuite.scala b/src/test/scala/com/snowflake/snowpark_test/FunctionSuite.scala index 806a6ff8..8a89d87b 100644 --- a/src/test/scala/com/snowflake/snowpark_test/FunctionSuite.scala +++ b/src/test/scala/com/snowflake/snowpark_test/FunctionSuite.scala @@ -2206,7 +2206,7 @@ trait FunctionSuite extends TestData { val expected = Seq((3)).toDF("size") checkAnswer(input.select(size(col("size"))), expected, sort = false) } - + test("expr function") { val input = Seq(1, 2, 3).toDF("id") @@ -2226,19 +2226,23 @@ trait FunctionSuite extends TestData { val input = Seq("2023-10-10", "2022-05-15").toDF("date") val expected = Seq("2023/10/10", "2022/05/15").toDF("formatted_date") - checkAnswer(input.select(date_format(col("date"), "YYYY/MM/DD").as("formatted_date")), - expected, sort = false) + checkAnswer( + input.select(date_format(col("date"), "YYYY/MM/DD").as("formatted_date")), + expected, + sort = false) } test("last function") { - val input = Seq((5, "a", 10), (5, "b", 20), - (3, "d", 15), (3, "e", 40)).toDF("grade", "name", "score") + val input = + Seq((5, "a", 10), (5, "b", 20), (3, "d", 15), (3, "e", 40)).toDF("grade", "name", "score") val window = Window.partitionBy(col("grade")).orderBy(col("score").desc) val expected = Seq("a", "a", "d", "d").toDF("last_score_name") - checkAnswer(input.select(last(col("name")).over(window).as("last_score_name")), - expected, sort = false) + checkAnswer( + input.select(last(col("name")).over(window).as("last_score_name")), + expected, + sort = false) } }