cloud-fan commented on code in PR #40474:
URL: https://github.com/apache/spark/pull/40474#discussion_r1285370162


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TableOutputResolver.scala:
##########
@@ -34,6 +35,36 @@ import 
org.apache.spark.sql.internal.SQLConf.StoreAssignmentPolicy
 import org.apache.spark.sql.types.{ArrayType, DataType, DecimalType, 
IntegralType, MapType, StructType}
 
 object TableOutputResolver {
+
+  def resolveVariableOutputColumns(
+      expected: Seq[Expression],
+      query: LogicalPlan,
+      conf: SQLConf): LogicalPlan = {
+
+    if (expected.size != query.output.size) {
+      throw new AnalysisException(errorClass = "ASSIGNMENT_ARITY_MISMATCH",
+        messageParameters = Map("numTarget" -> expected.size.toString,
+          "numExpr" -> query.output.size.toString))
+    }
+
+    val resolved: Seq[NamedExpression] = {
+      query.output.zip(expected.asInstanceOf[Seq[VariableReference]]).map {
+        case (inputCol, expected) =>
+        if (DataTypeUtils.sameType(inputCol.dataType, expected.dataType)) {
+          inputCol
+        } else {
+          Alias(cast(inputCol, expected.dataType, conf, expected.varName), 
expected.varName)()

Review Comment:
   shall we respect the store assignment policy, like INSERT does?



-- 
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]

Reply via email to