zhengruifeng commented on code in PR #58124: URL: https://github.com/apache/spark/pull/58124#discussion_r3829617192
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/WrapUDT.scala: ########## @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.catalyst.expressions + +import org.apache.spark.sql.AnalysisException +import org.apache.spark.sql.catalyst.analysis.TypeCheckResult +import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.DataTypeMismatch +import org.apache.spark.sql.catalyst.expressions.Cast._ +import org.apache.spark.sql.catalyst.expressions.codegen.{CodegenContext, ExprCode} +import org.apache.spark.sql.catalyst.types.DataTypeUtils +import org.apache.spark.sql.catalyst.util.TypeUtils.ordinalNumber +import org.apache.spark.sql.types.{DataType, UserDefinedType} + +/** + * Wrap a column with a UDT whose underlying SQL type matches the column data type. + * + * @see [[UnwrapUDT]] for converting a UDT column to its underlying SQL type. + */ +case class WrapUDT(child: Expression, udt: UserDefinedType[_]) + extends UnaryExpression with NonSQLExpression { + + def this(expressions: Seq[Expression]) = { Review Comment: Thanks, fixed in the latest push. `WrapUDT` now uses a fixed `(Expression, Expression)` auxiliary constructor, so `FunctionRegistry` enforces the two-argument contract instead of selecting a variadic `Seq[Expression]` constructor. I also added arity coverage through `FunctionRegistry.internal` for too few and too many args. I added an ML e2e nullable-vector case in `FunctionsSuite` as well, and verified it locally with: `build/sbt 'mllib/testOnly org.apache.spark.ml.FunctionsSuite -- -z "wrap and unwrap nullable vector UDT columns"'` Could you please take another look? -- 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]
