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


##########
docs/sql-migration-guide.md:
##########
@@ -29,6 +29,7 @@ license: |
 ## Upgrading from Spark SQL 4.3 to 4.4
 
 - Since Spark 4.4, when `spark.sql.preserveCharVarcharTypeInfo` is true and 
`spark.sql.charVarchar.standardSemantics.enabled` is false, ORC reads that 
apply a CHAR/VARCHAR schema over STRING storage return the stored values 
without ORC truncation, matching Parquet. Previously the ORC reader requested 
`char(n)`/`varchar(n)` and truncated STRING-stored values to `n`. Read-side 
length checks (`EXCEED_LIMIT_LENGTH`) apply only when 
`spark.sql.charVarchar.standardSemantics.enabled` is true.
+- Since Spark 4.4, when `spark.sql.charVarchar.standardSemantics.enabled` is 
true, XML names used as `MAP<CHAR(n), _>` or `MAP<VARCHAR(n), _>` keys in 
`from_xml` and the XML datasource are length-checked without padding or 
trimming. The checked names are element names, `attributePrefix` plus attribute 
names (default prefix `_`), and the `valueTag` (default `_VALUE`) when mixed 
text is present. A `CHAR(n)` key must already be exactly `n` characters, and a 
`VARCHAR(n)` key must already be at most `n` characters. Mismatched keys fail 
with `UNSUPPORTED_XML_CHAR_VARCHAR_MAP_KEY` (SQLSTATE `0A000`) and follow the 
XML parse mode (`PERMISSIVE` or `FAILFAST`). Exact repeated names last-win; 
`spark.sql.mapKeyDedupPolicy` is not applied. XML CHAR/VARCHAR values use the 
same pad and `EXCEED_LIMIT_LENGTH` checks as other parsed text. Empty, 
attribute-only, and text-only map elements stay SQL NULL or a malformed record, 
matching 4.3; they do not become an empty map or a `valueTag` entry. In Spark
  4.3, `MAP<CHAR(n), _>` and `MAP<VARCHAR(n), _>` XML maps were malformed 
records because only unbounded STRING keys were accepted. Padding of CHAR keys 
and VARCHAR `EXCEED_LIMIT_LENGTH` apply when the standard-semantics flag is 
false and `spark.sql.preserveCharVarcharTypeInfo` is true, so first-class 
CHAR/VARCHAR types still reach the parser.

Review Comment:
   Fixed. The 4.3 sentence now describes `failIfHasCharVarchar`: 
`UNSUPPORTED_CHAR_OR_VARCHAR_AS_STRING`, or STRING under 
`spark.sql.legacy.charVarcharAsString`. Flag-off over-length CHAR or VARCHAR 
keys raise `EXCEED_LIMIT_LENGTH` in both the bullet and the `convertMap` 
scaladoc. There is a flag-off `CHAR(3)` / `<abcd>` test next to the existing 
VARCHAR overflow check.
   
   `38a81e3` also deletes `DuplicateMapKeyUtils` and the five `StaxXmlParser` 
arms plus the unused test helpers. `PartialResultException` always becomes 
`BadRecordException`.



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