srielau commented on code in PR #40474: URL: https://github.com/apache/spark/pull/40474#discussion_r1286473766
########## 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: OK, I have changed it to ALWAYS use store assign and ANIS mode. Given that it's new that's defensible. -- 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