From cb3759e44b4fb382d66aa3ee1ea1474be9537be2 Mon Sep 17 00:00:00 2001 From: eldenmoon Date: Fri, 20 Dec 2024 10:04:17 +0800 Subject: [PATCH] [refactor](variant) remove duplicated and trivial sanitize 1. could improve serialization performance 2. check is incorrect, example int8 and int16 could be compatible --- be/src/vec/columns/column_object.cpp | 26 ------------------- be/src/vec/columns/column_object.h | 3 --- .../serde/data_type_object_serde.cpp | 1 - 3 files changed, 30 deletions(-) diff --git a/be/src/vec/columns/column_object.cpp b/be/src/vec/columns/column_object.cpp index d67a70d2f630f03..958f99201d28578 100644 --- a/be/src/vec/columns/column_object.cpp +++ b/be/src/vec/columns/column_object.cpp @@ -1354,14 +1354,6 @@ Status find_and_set_leave_value(const IColumn* column, const PathInData& path, TypeIndex base_type_index, rapidjson::Value& root, rapidjson::Document::AllocatorType& allocator, Arena& mem_pool, size_t row) { -#ifndef NDEBUG - // sanitize type and column - if (column->get_name() != type->create_column()->get_name()) { - return Status::InternalError( - "failed to set value for path {}, expected type {}, but got {} at row {}", - path.get_path(), type->get_name(), column->get_name(), row); - } -#endif const auto* nullable = check_and_get_column(column); if (skip_empty_json(nullable, type, base_type_index, row, path)) { return Status::OK(); @@ -1952,24 +1944,6 @@ std::string ColumnObject::debug_string() const { return res.str(); } -Status ColumnObject::sanitize() const { - RETURN_IF_CATCH_EXCEPTION(check_consistency()); - for (const auto& subcolumn : subcolumns) { - if (subcolumn->data.is_finalized()) { - auto column = subcolumn->data.get_least_common_type()->create_column(); - std::string original = subcolumn->data.get_finalized_column().get_name(); - std::string expected = column->get_name(); - if (original != expected) { - return Status::InternalError("Incompatible type between {} and {}, debug_info:", - original, expected, debug_string()); - } - } - } - - VLOG_DEBUG << "sanitized " << debug_string(); - return Status::OK(); -} - ColumnObject::Subcolumn ColumnObject::Subcolumn::cut(size_t start, size_t length) const { Subcolumn new_subcolumn(0, is_nullable); new_subcolumn.insert_range_from(*this, start, length); diff --git a/be/src/vec/columns/column_object.h b/be/src/vec/columns/column_object.h index e4127197a22b025..0f25a5e68d0c422 100644 --- a/be/src/vec/columns/column_object.h +++ b/be/src/vec/columns/column_object.h @@ -428,9 +428,6 @@ class ColumnObject final : public COWHelper { bool empty() const; - // Check if all columns and types are aligned - Status sanitize() const; - std::string debug_string() const; void update_hashes_with_value(uint64_t* __restrict hashes, diff --git a/be/src/vec/data_types/serde/data_type_object_serde.cpp b/be/src/vec/data_types/serde/data_type_object_serde.cpp index fc536d9ef0df7b6..c1e8645a6d2d8e4 100644 --- a/be/src/vec/data_types/serde/data_type_object_serde.cpp +++ b/be/src/vec/data_types/serde/data_type_object_serde.cpp @@ -51,7 +51,6 @@ Status DataTypeObjectSerDe::_write_column_to_mysql(const IColumn& column, if (!variant.is_finalized()) { const_cast(variant).finalize(); } - RETURN_IF_ERROR(variant.sanitize()); if (variant.is_scalar_variant()) { // Serialize scalar types, like int, string, array, faster path const auto& root = variant.get_subcolumn({});