From 30adfb6c6c913e57d2d52968e9c7b81c65eb4099 Mon Sep 17 00:00:00 2001 From: ricky Date: Wed, 29 May 2024 10:32:38 +0800 Subject: [PATCH] json_column: check types Signed-off-by: ricky --- be/src/formats/json/map_column.cpp | 5 +++++ be/src/formats/json/struct_column.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/be/src/formats/json/map_column.cpp b/be/src/formats/json/map_column.cpp index 08f6d4ab10745..9ce94306dfb56 100644 --- a/be/src/formats/json/map_column.cpp +++ b/be/src/formats/json/map_column.cpp @@ -26,6 +26,11 @@ Status add_map_column(Column* column, const TypeDescriptor& type_desc, const std auto map_column = down_cast(column); try { + if (value->type() != simdjson::ondemand::json_type::object) { + std::ostringstream ss; + ss << "Expected value type [object], got [" << value->type() << "]"; + return Status::DataQualityError(ss.str()); + } simdjson::ondemand::object obj = value->get_object(); simdjson::ondemand::parser parser; size_t field_count = 0; diff --git a/be/src/formats/json/struct_column.cpp b/be/src/formats/json/struct_column.cpp index 4503afa76a5d5..34bd3bcbc6925 100644 --- a/be/src/formats/json/struct_column.cpp +++ b/be/src/formats/json/struct_column.cpp @@ -25,6 +25,11 @@ Status add_struct_column(Column* column, const TypeDescriptor& type_desc, const auto struct_column = down_cast(column); try { + if (value->type() != simdjson::ondemand::json_type::object) { + std::ostringstream ss; + ss << "Expected value type [object], got [" << value->type() << "]"; + return Status::DataQualityError(ss.str()); + } simdjson::ondemand::object obj = value->get_object(); for (size_t i = 0; i < type_desc.children.size(); i++) {