github-actions[bot] commented on code in PR #67737:
URL: https://github.com/apache/doris/pull/67737#discussion_r4079180539


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Cast.java:
##########
@@ -316,26 +319,46 @@ public static boolean mayFailOnNonNullInput(DataType 
sourceType, DataType target
             return false;
         }
 
-        // BE casts to a character type through to_string_batch for these 
source types.
-        // JSON and VARIANT take separate paths and are intentionally left 
conservative.
-        boolean concreteNumber = (sourceType.isIntegralType() && 
sourceType.width() > 0)
-                || sourceType.isFloatLikeType() || 
sourceType.isDecimalLikeType();
+        // Every valid typed value has a string representation. The generic 
serde path and the
+        // dedicated JSON/VARIANT paths do not report data-dependent 
conversion failures.
         if (targetType.isStringLikeType()) {
-            return !(sourceType.isStringLikeType() || 
sourceType.isBooleanType() || concreteNumber
-                    || sourceType.isDateLikeType() || sourceType.isTimeType()
-                    || sourceType.isArrayType() || sourceType.isMapType() || 
sourceType.isStructType());
+            return false;

Review Comment:
   **[P1] Keep JSON-to-string out of the failure-free COUNT path**
   
   This makes the following plan eligible:
   
   ```text
   LogicalAggregate(count(CAST(j AS STRING)))
     PhysicalStorageLayerAggregate(COUNT)
       PhysicalOlapScan(j JSON NOT NULL)
   ```
   
   For a real row containing a valid JSON object, the cast is non-NULL and the 
unpushed count is 1. The pushed OLAP path instead has `VStatisticsIterator` 
insert a source-typed default; JSON uses `ColumnString`, whose default is zero 
bytes, and both JSON-to-string implementations turn that invalid empty JSONB 
payload into SQL NULL. The retained upper count can therefore return 0 for a 
non-empty segment. Keep JSON conservative here:
   
   ```suggestion
               return sourceType.isJsonType();
   ```
   
   Please also update the JSON classifier assertion and add an OLAP runtime 
case with a valid `JSON NOT NULL` object so this storage-default boundary is 
exercised.



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