Skip to content

Commit

Permalink
json_column: check types
Browse files Browse the repository at this point in the history
Signed-off-by: ricky <rickif@qq.com>
  • Loading branch information
rickif committed May 29, 2024
1 parent ff0cd06 commit 30adfb6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions be/src/formats/json/map_column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ Status add_map_column(Column* column, const TypeDescriptor& type_desc, const std
auto map_column = down_cast<MapColumn*>(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;
Expand Down
5 changes: 5 additions & 0 deletions be/src/formats/json/struct_column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ Status add_struct_column(Column* column, const TypeDescriptor& type_desc, const
auto struct_column = down_cast<StructColumn*>(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++) {
Expand Down

0 comments on commit 30adfb6

Please sign in to comment.