This is an automated email from the ASF dual-hosted git repository. eldenmoon pushed a commit to branch variant in repository https://gitbox.apache.org/repos/asf/doris.git
commit 007c1eda5c4ab2b398074b88fbc6167ba30b1f7b Author: eldenmoon <[email protected]> AuthorDate: Wed Aug 16 11:17:13 2023 +0800 variant cast remove dependancy of schema util --- be/src/vec/functions/function_cast.h | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/be/src/vec/functions/function_cast.h b/be/src/vec/functions/function_cast.h index 936773954b..11ae15d8da 100644 --- a/be/src/vec/functions/function_cast.h +++ b/be/src/vec/functions/function_cast.h @@ -22,6 +22,7 @@ #include <cctz/time_zone.h> #include <fmt/format.h> +#include <gen_cpp/FrontendService_types.h> #include <glog/logging.h> #include <stddef.h> #include <stdint.h> @@ -59,7 +60,6 @@ #include "vec/columns/columns_common.h" #include "vec/columns/columns_number.h" #include "vec/common/assert_cast.h" -#include "vec/common/schema_util.h" #include "vec/common/string_buffer.hpp" #include "vec/common/string_ref.h" #include "vec/core/block.h" @@ -1840,7 +1840,7 @@ private: } struct ConvertImplGenericFromVariant { - static Status execute(FunctionContext* context, Block& block, + static Status execute(const FunctionCast* fn, FunctionContext* context, Block& block, const ColumnNumbers& arguments, const size_t result, size_t input_rows_count) { auto& data_type_to = block.get_by_position(result).type; @@ -1854,11 +1854,19 @@ private: if (variant.is_scalar_variant()) { ColumnPtr nested = variant.get_root(); auto nested_from_type = variant.get_root_type(); + DCHECK(nested_from_type->is_nullable()); DCHECK(!data_type_to->is_nullable()); // dst type nullable has been removed, so we should remove the inner nullable of root column - RETURN_IF_ERROR(schema_util::cast_column( - {remove_nullable(nested), remove_nullable(nested_from_type), ""}, - data_type_to, &col_to)); + auto wrapper = fn->prepare_impl(context, remove_nullable(nested_from_type), data_type_to, true); + Block tmp_block {{remove_nullable(nested), remove_nullable(nested_from_type), ""}}; + tmp_block.insert({nullptr, data_type_to, ""}); + /// Perform the requested conversion. + RETURN_IF_ERROR( + wrapper(context, tmp_block, {0}, 1, input_rows_count)); + col_to = tmp_block.get_by_position(1).column; + // RETURN_IF_ERROR(schema_util::cast_column( + // {nested, nested_from_type, ""}, + // make_nullable(data_type_to), &col_to)); // fill nullmap of dst // Note: here we should return the nullable result column col_to = wrap_in_nullable( @@ -1911,7 +1919,11 @@ private: // create cresponding type convert from variant WrapperType create_variant_wrapper(const DataTypeObject& from_type, const DataTypePtr& to_type) const { - return &ConvertImplGenericFromVariant::execute; + return [this](FunctionContext* context, Block& block, + const ColumnNumbers& arguments, const size_t result, + size_t input_rows_count) -> Status { + return ConvertImplGenericFromVariant::execute(this, context, block, arguments, result, input_rows_count); + }; } //TODO(Amory) . Need support more cast for key , value for map --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
