morrySnow commented on code in PR #67718:
URL: https://github.com/apache/doris/pull/67718#discussion_r3987959139


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AccessPathExpressionCollector.java:
##########
@@ -321,7 +322,17 @@ public Void visitAlias(Alias alias, CollectorContext 
context) {
 
     @Override
     public Void visitCast(Cast cast, CollectorContext context) {
+        // TRY_CAST semantics cover the WHOLE value: for a composite type any 
element
+        // conversion failure makes the entire cast NULL (or, for a plain cast 
under
+        // strict mode, raises an error). Narrowing the read/type to only the 
fields an
+        // outer expression accesses would drop the conversion attempts of the 
other
+        // fields and silently change the result (e.g. element_at(try_cast(s as
+        // struct<a:int,b:int>), 'a') must still fail when only field b is 
unparsable).
+        // Plain Cast over nested types is pruned field-by-field on purpose; 
TryCast is
+        // not, so do not translate a narrowed access path through a TryCast. 
Falling
+        // through to the fresh context below reads the whole child value.
         if (!context.accessPathBuilder.isEmpty()
+                && !(cast instanceof TryCast)

Review Comment:
   加一个visitTryCast,而不是在visitCast里面处理TryCast



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