srielau commented on code in PR #58130:
URL: https://github.com/apache/spark/pull/58130#discussion_r3836591212


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercionHelper.scala:
##########
@@ -649,16 +715,31 @@ abstract class TypeCoercionHelper {
         }
         e.withNewChildren(children)
 
+      case j: JsonTuple =>
+        val expected = StringTypeWithCollation(supportsTrimCollation = true)
+        val children = j.children.map { child =>
+          charVarcharToPlainString(child.dataType, expected)
+            .map(dt => if (dt == child.dataType) child else Cast(child, dt))
+            .getOrElse(child)
+        }
+        j.withNewChildren(children)

Review Comment:
   Added. The comment on the arm now spells out the failure mode rather than 
just the rule, so the cost of folding it in is visible at the point of 
temptation:
   
   ```scala
   // JsonTuple validates its own input types and rejects non-string children 
with
   // NON_STRING_TYPE, so it only takes the CHAR/VARCHAR promotion here. Do not 
fold this into
   // the ExpectsInputTypes arm below: that would also apply the NullType 
rewrite and turn
   // json_tuple(json, null) from an analysis error into a typed STRING null.
   ```



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