Skip to content

Commit

Permalink
[fix](export)fix core when export jsonb field (#29365)
Browse files Browse the repository at this point in the history
Co-authored-by: ryanzryu <[email protected]>
  • Loading branch information
ryanzryu and ryanzryu authored Jan 3, 2024
1 parent df66b1e commit 8f2b829
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion be/src/exec/olap_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Slice*>(ptr);
StringValue* slot = tuple->get_string_slot(slot_desc->tuple_offset());
slot->ptr = slice->data;
Expand Down
2 changes: 1 addition & 1 deletion be/src/olap/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Slice*>(dst->mutable_cell_ptr());
auto src_slice = reinterpret_cast<const Slice*>(src.cell_ptr());
if (dst_slice->size < src_slice->size) {
Expand Down
6 changes: 3 additions & 3 deletions be/src/olap/row_cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Status RowCursor::_init(const std::vector<uint32_t>& columns) {
return Status::Error<INIT_FAILED>();
}
_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;
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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<Slice*>(fixed_ptr + 1);
_schema->mutable_column(cid)->set_long_text_buf(long_text_ptr);
slice->data = *(long_text_ptr);
Expand Down
3 changes: 2 additions & 1 deletion be/src/olap/tablet_schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
2 changes: 2 additions & 0 deletions be/src/runtime/export_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "util/types.h"
#include "util/uid_util.h"



namespace doris {

ExportSink::ExportSink(ObjectPool* pool, const RowDescriptor& row_desc,
Expand Down

0 comments on commit 8f2b829

Please sign in to comment.