From 0acca1bc48bbabf191baa206ad7d23e84119c0ad Mon Sep 17 00:00:00 2001 From: ryanzryu Date: Mon, 1 Jan 2024 17:02:16 +0800 Subject: [PATCH] [fix](export)fix core when export jsonb field --- be/src/exec/olap_scanner.cpp | 3 ++- be/src/olap/field.h | 2 +- be/src/olap/row_cursor.cpp | 6 +++--- be/src/olap/tablet_schema.h | 3 ++- be/src/runtime/export_sink.cpp | 2 ++ 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/be/src/exec/olap_scanner.cpp b/be/src/exec/olap_scanner.cpp index 1ab514194c81f4..2f024cf366a242 100644 --- a/be/src/exec/olap_scanner.cpp +++ b/be/src/exec/olap_scanner.cpp @@ -518,7 +518,8 @@ void OlapScanner::_convert_row_to_tuple(Tuple* tuple) { case TYPE_OBJECT: case TYPE_QUANTILE_STATE: case TYPE_HLL: - case TYPE_STRING: { + case TYPE_STRING: + case TYPE_JSONB: { Slice* slice = reinterpret_cast(ptr); StringValue* slot = tuple->get_string_slot(slot_desc->tuple_offset()); slot->ptr = slice->data; diff --git a/be/src/olap/field.h b/be/src/olap/field.h index 391f7f45be68c9..526c679a6a8d74 100644 --- a/be/src/olap/field.h +++ b/be/src/olap/field.h @@ -184,7 +184,7 @@ class Field { if (is_null) { return; } - if (type() == OLAP_FIELD_TYPE_STRING) { + if (type() == OLAP_FIELD_TYPE_STRING || type() == OLAP_FIELD_TYPE_JSONB) { auto dst_slice = reinterpret_cast(dst->mutable_cell_ptr()); auto src_slice = reinterpret_cast(src.cell_ptr()); if (dst_slice->size < src_slice->size) { diff --git a/be/src/olap/row_cursor.cpp b/be/src/olap/row_cursor.cpp index e9fe2e9396308e..33f5b0a0c79362 100644 --- a/be/src/olap/row_cursor.cpp +++ b/be/src/olap/row_cursor.cpp @@ -51,7 +51,7 @@ Status RowCursor::_init(const std::vector& columns) { return Status::Error(); } _variable_len += column_schema(cid)->get_variable_len(); - if (_schema->column(cid)->type() == OLAP_FIELD_TYPE_STRING) { + if (_schema->column(cid)->type() == OLAP_FIELD_TYPE_STRING || _schema->column(cid)->type() == OLAP_FIELD_TYPE_JSONB) { ++_string_field_count; } } @@ -91,7 +91,7 @@ Status RowCursor::_init_scan_key(TabletSchemaSPtr schema, _variable_len += scan_keys[cid].length(); } else if (type == OLAP_FIELD_TYPE_CHAR || type == OLAP_FIELD_TYPE_ARRAY) { _variable_len += std::max(scan_keys[cid].length(), column.length()); - } else if (type == OLAP_FIELD_TYPE_STRING) { + } else if (type == OLAP_FIELD_TYPE_STRING || type == OLAP_FIELD_TYPE_JSONB) { ++_string_field_count; } } @@ -221,7 +221,7 @@ Status RowCursor::allocate_memory_for_string_type(TabletSchemaSPtr schema) { char** long_text_ptr = _long_text_buf; for (auto cid : _schema->column_ids()) { fixed_ptr = _fixed_buf + _schema->column_offset(cid); - if (_schema->column(cid)->type() == OLAP_FIELD_TYPE_STRING) { + if (_schema->column(cid)->type() == OLAP_FIELD_TYPE_STRING || _schema->column(cid)->type() == OLAP_FIELD_TYPE_JSONB) { Slice* slice = reinterpret_cast(fixed_ptr + 1); _schema->mutable_column(cid)->set_long_text_buf(long_text_ptr); slice->data = *(long_text_ptr); diff --git a/be/src/olap/tablet_schema.h b/be/src/olap/tablet_schema.h index 2528aecbe19573..6fa42ee05b2445 100644 --- a/be/src/olap/tablet_schema.h +++ b/be/src/olap/tablet_schema.h @@ -58,7 +58,8 @@ class TabletColumn { bool is_length_variable_type() const { return _type == OLAP_FIELD_TYPE_CHAR || _type == OLAP_FIELD_TYPE_VARCHAR || _type == OLAP_FIELD_TYPE_STRING || _type == OLAP_FIELD_TYPE_HLL || - _type == OLAP_FIELD_TYPE_OBJECT || _type == OLAP_FIELD_TYPE_QUANTILE_STATE; + _type == OLAP_FIELD_TYPE_OBJECT || _type == OLAP_FIELD_TYPE_QUANTILE_STATE || + _type == OLAP_FIELD_TYPE_JSONB; } bool has_default_value() const { return _has_default_value; } std::string default_value() const { return _default_value; } diff --git a/be/src/runtime/export_sink.cpp b/be/src/runtime/export_sink.cpp index f709c182ec9e97..61e3f4e4c44663 100644 --- a/be/src/runtime/export_sink.cpp +++ b/be/src/runtime/export_sink.cpp @@ -35,6 +35,8 @@ #include "util/types.h" #include "util/uid_util.h" + + namespace doris { ExportSink::ExportSink(ObjectPool* pool, const RowDescriptor& row_desc,