From fe697a3980907a1b9811dcb081f8a18c4e8ae79f Mon Sep 17 00:00:00 2001 From: wangbo <506340561@qq.com> Date: Tue, 13 Jul 2021 10:58:38 +0800 Subject: [PATCH] [BUG]fix expr's args type and return type check failed (#108) * fix expr's args type and return type check failed * fix mysql_result_writer --- be/src/vec/data_types/data_type.cpp | 2 ++ be/src/vec/functions/function.h | 2 +- be/src/vec/sink/mysql_result_writer.cpp | 14 +++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/be/src/vec/data_types/data_type.cpp b/be/src/vec/data_types/data_type.cpp index 926aef34522d70..d237ba2836fc08 100644 --- a/be/src/vec/data_types/data_type.cpp +++ b/be/src/vec/data_types/data_type.cpp @@ -95,6 +95,8 @@ DataTypePtr IDataType::from_thrift(const doris::PrimitiveType& type, const bool DataTypePtr result; switch (type) { case TYPE_BOOLEAN: + result = std::make_shared(); + break; case TYPE_TINYINT: result = std::make_shared(); break; diff --git a/be/src/vec/functions/function.h b/be/src/vec/functions/function.h index c5677f9a836554..c117eb32c6c129 100644 --- a/be/src/vec/functions/function.h +++ b/be/src/vec/functions/function.h @@ -258,7 +258,7 @@ using FunctionBuilderPtr = std::shared_ptr; class FunctionBuilderImpl : public IFunctionBuilder { public: FunctionBasePtr build(const ColumnsWithTypeAndName& arguments, const DataTypePtr& return_type) const final { - DCHECK_EQ(return_type, get_return_type(arguments)); + DCHECK(return_type->equals(*get_return_type(arguments))); return build_impl(arguments, return_type); } diff --git a/be/src/vec/sink/mysql_result_writer.cpp b/be/src/vec/sink/mysql_result_writer.cpp index dcfcc02fab6dd8..6238f0ebf490a7 100644 --- a/be/src/vec/sink/mysql_result_writer.cpp +++ b/be/src/vec/sink/mysql_result_writer.cpp @@ -87,8 +87,14 @@ Status MysqlResultWriter::_add_one_column(const ColumnPtr& column_ptr) { } } + if constexpr (type == TYPE_BOOLEAN) { + //todo here need to using uint after MysqlRowBuffer support it + buf_ret = _vec_buffers[i]->push_tinyint( + assert_cast&>(*column).get_data()[i]); + } if constexpr (type == TYPE_TINYINT) { - buf_ret = _vec_buffers[i]->push_tinyint(static_cast(column->get_int(i))); + buf_ret = _vec_buffers[i]->push_tinyint( + assert_cast&>(*column).get_data()[i]); } if constexpr (type == TYPE_SMALLINT) { buf_ret = _vec_buffers[i]->push_smallint( @@ -205,6 +211,12 @@ Status MysqlResultWriter::append_block(Block& block) { switch (_output_vexpr_ctxs[i]->root()->result_type()) { case TYPE_BOOLEAN: + if (type_ptr->is_nullable()) { + status = _add_one_column(column_ptr); + } else { + status = _add_one_column(column_ptr); + } + break; case TYPE_TINYINT: { if (type_ptr->is_nullable()) { status = _add_one_column(column_ptr);