From 0f7d24e3610cac094d949c9e2a6f3c7000381e08 Mon Sep 17 00:00:00 2001 From: Bing Li Date: Wed, 29 Nov 2023 15:52:53 -0800 Subject: [PATCH] add java doc --- .../snowpark_java/TableFunctions.java | 18 +++++++++++++----- .../snowflake/snowpark/tableFunctions.scala | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/snowflake/snowpark_java/TableFunctions.java b/src/main/java/com/snowflake/snowpark_java/TableFunctions.java index b2ed8e6f..524c89c0 100644 --- a/src/main/java/com/snowflake/snowpark_java/TableFunctions.java +++ b/src/main/java/com/snowflake/snowpark_java/TableFunctions.java @@ -1,6 +1,5 @@ package com.snowflake.snowpark_java; - /** * Provides utility functions that generate table function expressions that can be passed to * DataFrame join method and Session tableFunction method. @@ -159,13 +158,22 @@ public static Column flatten(Column input) { *

Example * *

{@code
-   * df.join(TableFunctions.flatten(
-   *   Functions.parse_json(df.col("col"))));
+   * DataFrame df =
+   *   getSession()
+   *     .createDataFrame(
+   *       new Row[] {Row.create("{\"a\":1, \"b\":2}")},
+   *       StructType.create(new StructField("col", DataTypes.StringType)));
+   * DataFrame df1 =
+   *   df.select(
+   *     Functions.parse_json(df.col("col"))
+   *       .cast(DataTypes.createMapType(DataTypes.StringType, DataTypes.IntegerType))
+   *       .as("col"));
+   * df1.select(TableFunctions.explode(df1.col("col"))).show()
    * }
* * @since 1.10.0 - * @param input The expression that will be unseated into rows. The expression must be MapType or - * ArrayType data. + * @param input The expression that will be unseated into rows. The expression must be either + * MapType or ArrayType data. * @return The result Column reference */ public static Column explode(Column input) { diff --git a/src/main/scala/com/snowflake/snowpark/tableFunctions.scala b/src/main/scala/com/snowflake/snowpark/tableFunctions.scala index f5d611b4..91f40c13 100644 --- a/src/main/scala/com/snowflake/snowpark/tableFunctions.scala +++ b/src/main/scala/com/snowflake/snowpark/tableFunctions.scala @@ -217,7 +217,7 @@ object tableFunctions { * * @since 1.10.0 * @param input The expression that will be unseated into rows. - * The expression must be MapType or ArrayType data. + * The expression must be either MapType or ArrayType data. * @return The result Column reference */ def explode(input: Column): Column = TableFunction("explode").apply(input)