cloud-fan commented on code in PR #52016:
URL: https://github.com/apache/spark/pull/52016#discussion_r2416927216
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TableOutputResolver.scala:
##########
@@ -471,29 +403,20 @@ object TableOutputResolver extends SQLConfHelper with
Logging {
expectedType: ArrayType,
byName: Boolean,
conf: SQLConf,
- addError: String => Unit,
- colPath: Seq[String]): Option[NamedExpression] = {
- val nullCheckedInput = checkNullability(input, expected, conf, colPath)
+ colPath: Seq[String]): Expression = {
+ val nullCheckedInput = withNullabilityChecked(input, expected, conf,
colPath)
val param = NamedLambdaVariable("element", inputType.elementType,
inputType.containsNull)
val fakeAttr =
AttributeReference("element", expectedType.elementType,
expectedType.containsNull)()
- val res = if (byName) {
- reorderColumnsByName(tableName, Seq(param), Seq(fakeAttr), conf,
addError, colPath)
+ val res = resolveColumns(tableName, Seq(param), Seq(fakeAttr),
+ conf, byName, fillDefaultValue = false, colPath)
+ if (res.head == param) {
+ // If the element type is the same, we can reuse the input array
directly.
+ nullCheckedInput
} else {
- resolveColumnsByPosition(tableName, Seq(param), Seq(fakeAttr), conf,
addError, colPath)
- }
- if (res.length == 1) {
- val castedArray =
- if (res.head == param) {
- // If the element type is the same, we can reuse the input array
directly.
- nullCheckedInput
- } else {
- val func = LambdaFunction(res.head, Seq(param))
- ArrayTransform(nullCheckedInput, func)
- }
- Some(applyColumnMetadata(castedArray, expected))
- } else {
- None
+ // todo: can't we just use a cast here?
Review Comment:
array cast does the same thing essentially: traverse each element and do the
cast.
--
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]