uros-b commented on code in PR #56409:
URL: https://github.com/apache/spark/pull/56409#discussion_r3394229795
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/resolver/TimezoneAwareExpressionResolver.scala:
##########
@@ -64,8 +67,11 @@ class TimezoneAwareExpressionResolver(expressionResolver:
ExpressionResolver)
)
coercedTimezoneAwareExpression match {
- case cast: Cast if traversals.current.defaultCollation.isDefined =>
- tryCollapseCast(cast, traversals.current.defaultCollation.get)
+ case cast: Cast =>
+ val collapsedCast = traversals.current.defaultCollation
Review Comment:
In the fixed-point path, transformDownWithPruning carries tags over to the
rewritten node (TreeNode.scala:509, afterRule.copyTagsFrom(this)), so the outer
cast keeps USER_SPECIFIED_CAST (set by the parser for every explicit cast,
AstBuilder.scala:3598). In the single-pass path it does not.
rewriteDateNanosCast below returns a brand-new outer Cast and nothing copies
tags from collapsedCast, so USER_SPECIFIED_CAST is dropped in single-pass but
preserved in fixed-point.
Consumers that check it after resolution include usePrettyExpression
(auto-generated alias names, catalyst/util/package.scala:129) and
ApplyDefaultCollation/DefaultCollationTypeCoercion. Note the dual-run suite
passing doesn't disprove this: tags don't participate in plan equality, so
HybridAnalyzer only catches downstream effects (e.g. divergent alias text), not
the tag loss itself. The class doc of this very resolver emphasizes that tags
like USER_SPECIFIED_CAST must be preserved.
Suggested fix — copy tags onto the rewritten cast in the single-pass branch
(or inside rewriteDateNanosCast, which is harmlessly redundant in fixed-point).
--
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]