srielau commented on code in PR #59302:
URL: https://github.com/apache/spark/pull/59302#discussion_r4234762148
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala:
##########
@@ -1856,6 +1857,21 @@ class AstBuilder extends DataTypeAstBuilder
schemaLess
)
)
+ // Under standard semantics, assign declared CHAR/VARCHAR (pad / length
check) in a
+ // Project so the query result type matches AS (...). Flag off and
preserve-only keep
+ // the historical STRING result with no pad and no EXCEED_LIMIT_LENGTH.
+ if (conf.charVarcharStandardSemantics &&
+ attributes.exists(a =>
CharVarcharUtils.getRawType(a.metadata).isDefined)) {
+ Project(
+ attributes.map { a =>
+ Alias(
+ CharVarcharUtils.stringLengthCheck(a, a),
Review Comment:
Agreed. `If` goes through `CollationTypeCoercion.collateToSingleType` and
was widening `VARCHAR(n) COLLATE UNICODE_CI` inside the rebuilt struct.
`stringLengthCheck` now uses `CaseWhen` for the null guard
(`nullSafeRebuiltStruct`), which has the same-type skip. Restored `COLLATE
UNICODE_CI` on the Hive nested struct and added a no-SerDe variant in
`SparkScriptTransformationSuite`.
--
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]