Copilot commented on code in PR #63003:
URL: https://github.com/apache/doris/pull/63003#discussion_r3206190694
##########
be/src/exprs/function/function_date_or_datetime_to_something.h:
##########
@@ -37,13 +37,17 @@ struct Transformer {
vec_to.resize(size);
for (size_t i = 0; i < size; ++i) {
- //FIXME: seems external table still generates invalid
date/datetime. but where?
+ // Only check in debug mode. for external table there's risk to
write an invalid datetime. use this to find it.
+ // Not checked in RELEASE mode for performance considerations
Review Comment:
The new debug-only comment is hard to read due to sentence casing/wording
(e.g., "Only check in debug mode. for external table... use this...") and
refers to "RELEASE mode" even though the guard is `NDEBUG` (which can differ
from a true Release build). Please rephrase to clear, grammatically correct
sentences and align the wording with the actual compile-time condition.
##########
be/src/exprs/function/function_date_or_datetime_to_something.h:
##########
@@ -37,13 +37,17 @@ struct Transformer {
vec_to.resize(size);
for (size_t i = 0; i < size; ++i) {
- //FIXME: seems external table still generates invalid
date/datetime. but where?
+ // Only check in debug mode. for external table there's risk to
write an invalid datetime. use this to find it.
+ // Not checked in RELEASE mode for performance considerations
+#ifndef NDEBUG
if (!vec_from[i].is_valid_date()) [[unlikely]] {
char buf[64];
vec_from[i].to_string(buf);
throw Exception(ErrorCode::INVALID_ARGUMENT, "Operation {}
meets invalid data: {}",
Transform::name, buf);
}
+#endif
Review Comment:
Wrapping the invalid date/datetime validation in `#ifndef NDEBUG` changes
runtime behavior: in Release builds invalid values will now flow into
`Transform::execute()`. Many `date_time_transforms` call methods (e.g.,
month/day name, formatting) that assume a valid date/time; skipping validation
risks incorrect results or even UB/crashes when external sources produce
invalid values. Consider keeping the validity check in Release (or ensuring all
downstream transforms are robust to invalid inputs and return a defined result,
e.g., NULL/error) rather than compiling it out.
--
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]