zhengruifeng commented on code in PR #58124:
URL: https://github.com/apache/spark/pull/58124#discussion_r3821430135
##########
sql/api/src/main/scala/org/apache/spark/sql/functions.scala:
##########
@@ -17723,6 +17723,32 @@ object functions {
*/
def unwrap_udt(column: Column): Column = Column.internalFn("unwrap_udt",
column)
+ /**
+ * Wrap a column as a user-defined type.
+ * @param column
+ * the column to wrap. The column data type must match the UDT's
underlying SQL type.
+ * @param udt
+ * the target user-defined type.
+ * @group udf_funcs
+ * @since 4.4.0
+ */
+ def wrap_udt(column: Column, udt: UserDefinedType[_]): Column = {
+ wrap_udt(column, lit(udt.json))
+ }
+
+ /**
+ * Wrap a column as a user-defined type.
+ * @param column
+ * the column to wrap. The column data type must match the UDT's
underlying SQL type.
+ * @param udt
+ * the target user-defined type as a constant JSON string column.
+ * @group udf_funcs
+ * @since 4.4.0
+ */
+ def wrap_udt(column: Column, udt: Column): Column = {
Review Comment:
Thanks for the suggestion. I agree `udtJsonColumn` is more explicit, but it
seems conventional in this file to keep the semantic argument name stable
across overloads when only the accepted representation changes.
For example, `from_json` keeps the parameter name as `schema` across
`StructType`, `DataType`, `String`, and `Column` overloads, and `from_csv` does
the same for `StructType` and `Column` schema overloads. Following that
convention, I would prefer to keep this overload as `udt` and clarify in the
Scaladoc that the `Column` must be a constant UDT JSON string.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]