zhengruifeng commented on code in PR #45741: URL: https://github.com/apache/spark/pull/45741#discussion_r1542253499
########## python/pyspark/sql/functions/builtin.py: ########## @@ -15098,6 +15098,38 @@ def from_json( return _invoke_function("from_json", _to_java_column(col), schema, _options_to_str(options)) +@_try_remote_functions +def parse_json( + col: "ColumnOrName", +) -> Column: + """ + Parses a column containing a JSON string into a :class:`VariantType`. + + .. versionadded:: 4.0.0 + + Parameters + ---------- + col : :class:`~pyspark.sql.Column` or str + a column or column name JSON formatted strings + + .. # noqa + + Returns + ------- + :class:`~pyspark.sql.Column` + a new column of VariantType. + + Examples + -------- + >>> from pyspark.sql.types import * + >>> df = spark.createDataFrame([ {'json': '''{ "a" : 1 }'''} ]) + >>> df.select(to_json(parse_json(df.json)).alias("v")).collect() Review Comment: let's do not use alias to also verify the default column name -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org