From 90333ac9aaf37b214154cbcfef21037b034dfa79 Mon Sep 17 00:00:00 2001 From: memo Date: Mon, 28 Oct 2019 11:15:52 +0800 Subject: [PATCH] modified getReturnType --- dbms/src/Functions/array/arrayCompact.cpp | 50 ++++++++++++----------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/dbms/src/Functions/array/arrayCompact.cpp b/dbms/src/Functions/array/arrayCompact.cpp index bd3d8fa303e..09a0dce3d75 100644 --- a/dbms/src/Functions/array/arrayCompact.cpp +++ b/dbms/src/Functions/array/arrayCompact.cpp @@ -22,31 +22,33 @@ namespace DB { WhichDataType which(expression_return); - if (which.isNativeUInt()) - return std::make_shared(std::make_shared()); + if (which.isUInt8()) { return std::make_shared(std::make_shared()); } + else if (which.isUInt16()) { return std::make_shared(std::make_shared()); } + else if (which.isUInt32()) { return std::make_shared(std::make_shared()); } + else if (which.isUInt64()) { return std::make_shared(std::make_shared()); } + else if (which.isInt8()) { return std::make_shared(std::make_shared()); } + else if (which.isInt16()) { return std::make_shared(std::make_shared()); } + else if (which.isInt32()) { return std::make_shared(std::make_shared()); } + else if (which.isInt64()) { return std::make_shared(std::make_shared()); } + else if (which.isFloat32()) { return std::make_shared(std::make_shared()); } + else if (which.isFloat64()) { return std::make_shared(std::make_shared()); } - if (which.isNativeInt()) - return std::make_shared(std::make_shared()); - - if (which.isFloat()) - return std::make_shared(std::make_shared()); throw Exception("arrayCompact cannot add values of type " + expression_return->getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); } - - template + template static bool executeType(const ColumnPtr & mapped, const ColumnArray & array, ColumnPtr & res_ptr) { - const ColumnVector * column = checkAndGetColumn>(&*mapped); + const ColumnVector * column = checkAndGetColumn>(&*mapped); if (!column) return false; const IColumn::Offsets & offsets = array.getOffsets(); - const typename ColumnVector::Container & data = column->getData(); - auto column_data = ColumnVector::create(data.size()); - typename ColumnVector::Container & res_values = column_data->getData(); + const typename ColumnVector::Container & data = column->getData(); + auto column_data = ColumnVector::create(data.size()); + typename ColumnVector::Container & res_values = column_data->getData(); auto column_offsets = ColumnArray::ColumnOffsets::create(offsets.size()); IColumn::Offsets & res_offsets = column_offsets->getData(); @@ -79,16 +81,16 @@ namespace DB { ColumnPtr res; - if (executeType< UInt8 , UInt64>(mapped, array, res) || - executeType< UInt16, UInt64>(mapped, array, res) || - executeType< UInt32, UInt64>(mapped, array, res) || - executeType< UInt64, UInt64>(mapped, array, res) || - executeType< Int8 , Int64>(mapped, array, res) || - executeType< Int16, Int64>(mapped, array, res) || - executeType< Int32, Int64>(mapped, array, res) || - executeType< Int64, Int64>(mapped, array, res) || - executeType(mapped, array, res) || - executeType(mapped, array, res)) + if (executeType< UInt8 >(mapped, array, res) || + executeType< UInt16>(mapped, array, res) || + executeType< UInt32>(mapped, array, res) || + executeType< UInt64>(mapped, array, res) || + executeType< Int8 >(mapped, array, res) || + executeType< Int16 >(mapped, array, res) || + executeType< Int32 >(mapped, array, res) || + executeType< Int64 >(mapped, array, res) || + executeType(mapped, array, res) || + executeType(mapped, array, res)) return res; else throw Exception("Unexpected column for arrayCompact: " + mapped->getName(), ErrorCodes::ILLEGAL_COLUMN); @@ -104,4 +106,4 @@ namespace DB factory.registerFunction(); } -} +} \ No newline at end of file