public class TableFunctions extends Object
This object also provides functions that correspond to Snowflake system-defined table functions
| Modifier and Type | Method and Description |
|---|---|
static TableFunction |
flatten()
Flattens (explodes) compound values into multiple rows.
|
static TableFunction |
split_to_table()
This table function splits a string (based on a specified delimiter) and flattens the results
into rows.
|
public static TableFunction split_to_table()
Argument List:
First argument (no name): Required. Text to be split.
Second argument (no name): Required. Text to split string by.
Example
session.tableFunction(TableFunctions.split_to_table(),
Functions.lit("split by space"), Functions.lit(" "));
public static TableFunction flatten()
Argument List:
input: Required. The expression that will be unseated into rows. The expression must be of data type VariantType, MapType or ArrayType.
path: Optional. The path to the element within a VariantType data structure which needs to be flattened. Can be a zero-length string (i.e. empty path) if the outermost element is to be flattened. Default: Zero-length string (i.e. empty path)
outer: Optional boolean value. If FALSE, any input rows that cannot be expanded, either because they cannot be accessed in the path or because they have zero fields or entries, are completely omitted from the output. If TRUE, exactly one row is generated for zero-row expansions (with NULL in the KEY, INDEX, and VALUE columns). Default: FALSE
recursive: Optional boolean value If FALSE, only the element referenced by PATH is expanded. If TRUE, the expansion is performed for all sub-elements recursively. Default: FALSE
mode: Optional String ("object", "array", or "both") Specifies whether only objects, arrays, or both should be flattened. Default: both
Example
Map<String, Column> args = new HashMap<>();
args.put("input", Functions.parse_json(Functions.lit("[1,2]")));
session.tableFunction(TableFunctions.flatten(), args);
© 2023 Snowflake Inc. All Rights Reserved