HyukjinKwon commented on code in PR #59270:
URL: https://github.com/apache/spark/pull/59270#discussion_r4226361151


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CollationTypeCoercion.scala:
##########
@@ -113,8 +113,10 @@ object CollationTypeCoercion extends SQLConfHelper {
    *
    * Literal and Cast: wrap in a new Cast when the CHAR/VARCHAR constraint
    * changes so truncation, overflow, and padding stay on the original node.
-   * Collation-only changes retarget with `copy(dataType)`, which keeps a
-   * non-string Cast child non-string and therefore Default strength.
+   * Collation-only changes retarget with `copy(dataType)` and copy
+   * `USER_SPECIFIED_CAST` (truncation). Do not copy all tags: a stale
+   * `COLLATION_CONTEXT_TAG` would reuse the pre-LCT collation. That keeps

Review Comment:
   **Nit (P3):** With the new sentences inserted, `That keeps a non-string Cast 
child non-string and therefore Default strength.` now follows the 
`COLLATION_CONTEXT_TAG` sentence, so it reads as if not copying the tags is 
what keeps Default strength. The strength actually comes from retargeting with 
`copy(dataType)` instead of wrapping in a new Cast: `findCollationContext` 
derives a Cast's strength from whether its child is a string type, and tags 
play no part. Maybe something like:
   
   ```
      * Collation-only changes retarget with `copy(dataType)`, which keeps a
      * non-string Cast child non-string and therefore Default strength. The 
copy
      * keeps only `USER_SPECIFIED_CAST` (truncation); copying all tags would 
reuse
      * a stale `COLLATION_CONTEXT_TAG` with the pre-LCT collation.
   ```
   
   **Verification:**
   - **Inspection:** The rewritten scaladoc ties the Default-strength statement 
to the copy(dataType) retarget, keeps the tag-copy rationale, contains only 
ASCII, and keeps every line within 100 characters.



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