diff --git a/src/main/java/com/snowflake/snowpark_java/Functions.java b/src/main/java/com/snowflake/snowpark_java/Functions.java index 65f50020..ae2a10eb 100644 --- a/src/main/java/com/snowflake/snowpark_java/Functions.java +++ b/src/main/java/com/snowflake/snowpark_java/Functions.java @@ -4053,6 +4053,90 @@ public static Column last(Column col) { return new Column(functions.last(col.toScalaColumn())); } + /** + * Computes the logarithm of the given value in base 10. + * + *
{@code
+   * DataFrame df = getSession().sql("select * from values (100) as T(a)");
+   * df.select(Functions.log10(df.col("a")).as("log10")).show();
+   * -----------
+   * |"LOG10"  |
+   * -----------
+   * |2.0      |
+   * -----------
+   * }
+ * + * @since 1.14.0 + * @param col The input column to get last value + * @return column object from last function. + */ + public static Column log10(Column col) { + return new Column(functions.log10(col.toScalaColumn())); + } + + /** + * Computes the logarithm of the given value in base 10. + * + *
{@code
+   * DataFrame df = getSession().sql("select * from values (100) as T(a)");
+   * df.select(Functions.log10("a").as("log10")).show();
+   * -----------
+   * |"LOG10"  |
+   * -----------
+   * |2.0      |
+   * -----------
+   * }
+ * + * @since 1.14.0 + * @param s The input column to get last value + * @return column object from last function. + */ + public static Column log10(String s) { + return new Column(functions.log10(s)); + } + + /** + * Computes the logarithm of the given value in base 10. + * + *
{@code
+   * DataFrame df = getSession().sql("select * from values (0.1) as T(a)");
+   * df.select(Functions.log1p(df.col("a")).as("log1p")).show();
+   * -----------------------
+   * |"LOG1P"              |
+   * -----------------------
+   * |0.09531017980432493  |
+   * -----------------------
+   * }
+ * + * @since 1.14.0 + * @param col The input column to get last value + * @return column object from last function. + */ + public static Column log1p(Column col) { + return new Column(functions.log1p(col.toScalaColumn())); + } + + /** + * Computes the logarithm of the given value in base 10. + * + *
{@code
+   * DataFrame df = getSession().sql("select * from values (0.1) as T(a)");
+   * df.select(Functions.log1p("a").as("log1p")).show();
+   * -----------------------
+   * |"LOG1P"              |
+   * -----------------------
+   * |0.09531017980432493  |
+   * -----------------------
+   * }
+ * + * @since 1.14.0 + * @param s The input column to get last value + * @return column object from last function. + */ + public static Column log1p(String s) { + return new Column(functions.log1p(s)); + } + /** * Calls a user-defined function (UDF) by name. * diff --git a/src/main/scala/com/snowflake/snowpark/functions.scala b/src/main/scala/com/snowflake/snowpark/functions.scala index 47eb9cd9..93f4eaf3 100644 --- a/src/main/scala/com/snowflake/snowpark/functions.scala +++ b/src/main/scala/com/snowflake/snowpark/functions.scala @@ -3357,7 +3357,7 @@ object functions { *Example * {{{ * val df = session.createDataFrame(Seq(0.1)).toDF("a") - * df.select(log1p(col("a"))).show() + * df.select(log1p(col("a")).as("log1p")).show() * ----------------------- * |"LOG1P" | * ----------------------- diff --git a/src/test/java/com/snowflake/snowpark_test/JavaFunctionSuite.java b/src/test/java/com/snowflake/snowpark_test/JavaFunctionSuite.java index 624ea481..126ee302 100644 --- a/src/test/java/com/snowflake/snowpark_test/JavaFunctionSuite.java +++ b/src/test/java/com/snowflake/snowpark_test/JavaFunctionSuite.java @@ -2828,4 +2828,36 @@ public void last() { expected, false); } + + @Test + public void log10_col() { + DataFrame df = getSession().sql("select * from values (100) as T(a)"); + Row[] expected = {Row.create(2.0)}; + + checkAnswer(df.select(Functions.log10(df.col("a"))), expected, false); + } + + @Test + public void log10_str() { + DataFrame df = getSession().sql("select * from values (100) as T(a)"); + Row[] expected = {Row.create(2.0)}; + + checkAnswer(df.select(Functions.log10("a")), expected, false); + } + + @Test + public void log1p_col() { + DataFrame df = getSession().sql("select * from values (0.1) as T(a)"); + Row[] expected = {Row.create(0.09531017980432493)}; + + checkAnswer(df.select(Functions.log1p(df.col("a"))), expected, false); + } + + @Test + public void log1p_str() { + DataFrame df = getSession().sql("select * from values (0.1) as T(a)"); + Row[] expected = {Row.create(0.09531017980432493)}; + + checkAnswer(df.select(Functions.log1p("a")), expected, false); + } }