Copilot commented on code in PR #63718:
URL: https://github.com/apache/doris/pull/63718#discussion_r3308606287
##########
be/src/core/data_type_serde/data_type_variant_serde.cpp:
##########
@@ -37,6 +39,32 @@
#include "util/jsonb_writer.h"
namespace doris {
+namespace {
+
+template <typename BuilderType>
+Status write_variant_column_to_arrow_impl(const IColumn& column, const
ColumnVariant& var,
+ const NullMap* null_map,
BuilderType& builder,
+ int64_t start, int64_t end, const
cctz::time_zone& ctz) {
+ DataTypeSerDe::FormatOptions options;
+ options.timezone = &ctz;
+ for (int64_t i = start; i < end; ++i) {
+ if (null_map && (*null_map)[cast_set<size_t>(i)]) {
+ RETURN_IF_ERROR(checkArrowStatus(builder.AppendNull(),
column.get_name(),
+ builder.type()->name()));
+ continue;
+ }
+
+ std::string serialized_value;
+ var.serialize_one_row_to_string(i, &serialized_value, options);
+ const auto serialized_size =
+ cast_set<typename
BuilderType::offset_type>(serialized_value.size());
+
RETURN_IF_ERROR(checkArrowStatus(builder.Append(serialized_value.data(),
serialized_size),
+ column.get_name(),
builder.type()->name()));
Review Comment:
`cast_set<BuilderType::offset_type>(serialized_value.size())` will throw a
Doris Exception on overflow (e.g., when writing a very large VARIANT value to a
utf8/StringBuilder). Since this function returns `Status` and may be called
from other SerDe implementations without a try/catch, this can turn an
oversized value into an uncaught exception/crash. Prefer an explicit size check
that returns `Status::InvalidArgument` (or use an unchecked cast consistent
with other Arrow string serdes and rely on Arrow to return an error) to avoid
throwing here.
--
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]