You are viewing documentation about an older version (1.4.0). View latest version

snowflake.snowpark.functions.json_extract_path_text

snowflake.snowpark.functions.json_extract_path_text(col: ColumnOrName, path: ColumnOrName) Column[source]

Parses a JSON string and returns the value of an element at a specified path in the resulting JSON document.

Example:

>>> from snowflake.snowpark.functions import json_extract_path_text, to_variant
>>> df = session.create_dataframe([[{"a": "foo"}, "a"], [{"a": None}, "a"], [{"a": "foo"}, "b"], [None, "a"]], schema=["k", "v"])
>>> df.select(json_extract_path_text(to_variant("k"), "v").as_("res")).collect()
[Row(RES='foo'), Row(RES=None), Row(RES=None), Row(RES=None)]
Copy