Skip to content

Commit

Permalink
[BUG]fix expr's args type and return type check failed (apache#108)
Browse files Browse the repository at this point in the history
* fix expr's args type and return type check failed

* fix mysql_result_writer
  • Loading branch information
wangbo authored and HappenLee committed Aug 10, 2021
1 parent 65fd002 commit fe697a3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions be/src/vec/data_types/data_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<DataTypeUInt8>();
break;
case TYPE_TINYINT:
result = std::make_shared<DataTypeInt8>();
break;
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/functions/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ using FunctionBuilderPtr = std::shared_ptr<IFunctionBuilder>;
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);
}

Expand Down
14 changes: 13 additions & 1 deletion be/src/vec/sink/mysql_result_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const ColumnVector<UInt8>&>(*column).get_data()[i]);
}
if constexpr (type == TYPE_TINYINT) {
buf_ret = _vec_buffers[i]->push_tinyint(static_cast<int8_t>(column->get_int(i)));
buf_ret = _vec_buffers[i]->push_tinyint(
assert_cast<const ColumnVector<Int8>&>(*column).get_data()[i]);
}
if constexpr (type == TYPE_SMALLINT) {
buf_ret = _vec_buffers[i]->push_smallint(
Expand Down Expand Up @@ -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<PrimitiveType::TYPE_BOOLEAN, true>(column_ptr);
} else {
status = _add_one_column<PrimitiveType::TYPE_BOOLEAN, false>(column_ptr);
}
break;
case TYPE_TINYINT: {
if (type_ptr->is_nullable()) {
status = _add_one_column<PrimitiveType::TYPE_TINYINT, true>(column_ptr);
Expand Down

0 comments on commit fe697a3

Please sign in to comment.