Doris-Breakwater commented on issue #68725:
URL: https://github.com/apache/doris/issues/68725#issuecomment-5978378300

   Breakwater-GitHub-Analysis-Slot: slot_13c59cc27c4f
   
   **Assessment: confirmed FE constant-folding correctness bug (source-level 
confirmation).** The supplied SQL demonstrates a real distinction between the 
string `'-null'` and SQL `NULL`. I inspected the reported build commit 
`ad35a140c7f`; I have not independently run a Doris cluster. The issue 
currently has no labels, and the reproduction provides enough detail for 
triage. No logs or profile are needed to identify this deterministic path.
   
   **Mechanism:** For a TIME literal, 
[`DateTimeFormatterUtils.formatTemporalLiteral`](https://github.com/apache/doris/blob/ad35a140c7fd0b842f18c23300bac581f7d04326/fe/fe-core/src/main/java/org/apache/doris/nereids/util/DateTimeFormatterUtils.java#L294-L344)
 receives zero date fields and returns Java `null` for `%a` (likewise for the 
listed date-dependent specifiers). Its [TIME 
overload](https://github.com/apache/doris/blob/ad35a140c7fd0b842f18c23300bac581f7d04326/fe/fe-core/src/main/java/org/apache/doris/nereids/util/DateTimeFormatterUtils.java#L177-L185)
 concatenates `"-" + res` for negative values, converting that Java `null` to 
the non-null string `"-null"`. The [FE executable 
function](https://github.com/apache/doris/blob/ad35a140c7fd0b842f18c23300bac581f7d04326/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java#L295-L305)
 wraps it in `VarcharLiteral`, so the planner can substitute a string literal. 
On the BE
  path, the [TIME formatter rejects date-only 
fields](https://github.com/apache/doris/blob/ad35a140c7fd0b842f18c23300bac581f7d04326/be/src/core/value/vdatetime_value.cpp#L3189-L3202),
 and [`FunctionTimeFormat` marks a failed format as SQL 
`NULL`](https://github.com/apache/doris/blob/ad35a140c7fd0b842f18c23300bac581f7d04326/be/src/exprs/function/date_time_transforms.h#L566-L583).
   
   **Suggested next step:** Fix the FE fold so a missing-date result cannot 
pass through sign concatenation as text. Ensure the folding caller produces a 
typed SQL `NULL` or defers evaluation to BE; simply returning Java `null` to 
the current `new VarcharLiteral(...)` caller is insufficient because that 
constructor accesses `value.length()`. Add a regression case comparing folded 
literals with a TIME column (and with folding skipped) for negative and 
positive TIME values, all affected date specifiers, and a valid time-only 
format such as `%H`. The supplied `debug_skip_fold_constant = true` setting is 
a temporary workaround for queries affected by this discrepancy.
   


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