This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 9349746987 [Fix](stream-load-json) fix
VJsonReader::_write_data_to_column invalid column type cast when meet null
(#11564)
9349746987 is described below
commit 9349746987f2dfa10275605a9bb68f09e44bd43d
Author: lihangyu <[email protected]>
AuthorDate: Mon Aug 8 15:57:39 2022 +0800
[Fix](stream-load-json) fix VJsonReader::_write_data_to_column invalid
column type cast when meet null (#11564)
column_ptr will be a none nullable column pointer after `column_ptr =
&nullable_column->get_nested_column()`
so we should not cast column_ptr to ColumnNullable any more
---
be/src/vec/exec/vjson_scanner.cpp | 8 +++++---
regression-test/data/load/stream_load/simple_object_json.json | 4 +++-
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/be/src/vec/exec/vjson_scanner.cpp
b/be/src/vec/exec/vjson_scanner.cpp
index d176f7ccdb..5a407adb48 100644
--- a/be/src/vec/exec/vjson_scanner.cpp
+++ b/be/src/vec/exec/vjson_scanner.cpp
@@ -286,8 +286,9 @@ Status
VJsonReader::_write_data_to_column(rapidjson::Value::ConstValueIterator v
int32_t wbytes = 0;
std::string json_str;
+ vectorized::ColumnNullable* nullable_column = nullptr;
if (slot_desc->is_nullable()) {
- auto* nullable_column =
reinterpret_cast<vectorized::ColumnNullable*>(column_ptr);
+ nullable_column =
reinterpret_cast<vectorized::ColumnNullable*>(column_ptr);
nullable_column->get_null_map_data().push_back(0);
column_ptr = &nullable_column->get_nested_column();
}
@@ -321,7 +322,6 @@ Status
VJsonReader::_write_data_to_column(rapidjson::Value::ConstValueIterator v
break;
case rapidjson::Type::kNullType:
if (slot_desc->is_nullable()) {
- auto* nullable_column =
reinterpret_cast<vectorized::ColumnNullable*>(column_ptr);
nullable_column->insert_default();
} else {
RETURN_IF_ERROR(_append_error_msg(
@@ -329,7 +329,9 @@ Status
VJsonReader::_write_data_to_column(rapidjson::Value::ConstValueIterator v
slot_desc->col_name(), valid));
return Status::OK();
}
- break;
+ // return immediately to prevent from repeatedly insert_data
+ *valid = true;
+ return Status::OK();
default:
// for other type like array or object. we convert it to string to save
json_str = JsonReader::_print_json_value(*value);
diff --git a/regression-test/data/load/stream_load/simple_object_json.json
b/regression-test/data/load/stream_load/simple_object_json.json
index 5a128142ae..a7912466fd 100644
--- a/regression-test/data/load/stream_load/simple_object_json.json
+++ b/regression-test/data/load/stream_load/simple_object_json.json
@@ -7,4 +7,6 @@
{"id": 7, "city": "wuhan", "code": 2345677}
{"id": 8, "city": "chengdu", "code": 2345678}
{"id": 9, "city": "xian", "code": 2345679}
-{"id": 10, "city": "hefei", "code": 23456710}
\ No newline at end of file
+{"id": 10, "city": "hefei", "code": 23456710}
+{"id": 10, "city": null, "code": 23456711}
+{"id": 10, "city": "hefei", "code": null}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]