From a56c2b16648db5238182afd8ee1bd3941800c2ad Mon Sep 17 00:00:00 2001 From: Kaijie Chen Date: Wed, 13 Mar 2024 16:10:38 +0800 Subject: [PATCH] strict string parse --- be/src/vec/functions/function_cast.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/be/src/vec/functions/function_cast.h b/be/src/vec/functions/function_cast.h index 7b28d883307cdd..7ef3957de24cd1 100644 --- a/be/src/vec/functions/function_cast.h +++ b/be/src/vec/functions/function_cast.h @@ -1560,6 +1560,11 @@ struct ConvertThroughParsing { parsed = try_parse_impl( vec_to[i], read_buffer, context->state()->timezone_obj()); } + bool parse_success = parsed && is_all_read(read_buffer); + if (string_size > 0 && !parse_success) { + std::string_view raw{reinterpret_cast(&(*chars)[current_offset]), string_size}; + return Status::RuntimeError("failed to parse '{}' as {}", raw, col_to->get_name()); + } (*vec_null_map_to)[i] = !parsed || !is_all_read(read_buffer); current_offset = next_offset; }