Skip to content

Commit

Permalink
Merge branch 'release-5.4' into fix-proxy-5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
solotzg authored Apr 22, 2022
2 parents 785e49e + 95ccdb6 commit 4e982ef
Show file tree
Hide file tree
Showing 2 changed files with 169 additions and 14 deletions.
42 changes: 28 additions & 14 deletions dbms/src/Functions/FunctionsMiscellaneous.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ class FunctionGetSizeOfEnumType : public IFunction

void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result) const override
{
if (auto type = checkAndGetDataType<DataTypeEnum8>(block.getByPosition(arguments[0]).type.get()))
if (const auto * type = checkAndGetDataType<DataTypeEnum8>(block.getByPosition(arguments[0]).type.get()))
block.getByPosition(result).column = DataTypeUInt8().createColumnConst(block.rows(), UInt64(type->getValues().size()));
else if (auto type = checkAndGetDataType<DataTypeEnum16>(block.getByPosition(arguments[0]).type.get()))
else if (const auto * type = checkAndGetDataType<DataTypeEnum16>(block.getByPosition(arguments[0]).type.get()))
block.getByPosition(result).column = DataTypeUInt16().createColumnConst(block.rows(), UInt64(type->getValues().size()));
else
throw Exception("The argument for function " + getName() + " must be Enum", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
Expand Down Expand Up @@ -751,7 +751,7 @@ class FunctionIn : public IFunction
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
bool return_nullable = arguments[0].type->isNullable();
ColumnPtr column_set_ptr = arguments[1].column;
auto * column_set = typeid_cast<const ColumnSet *>(&*column_set_ptr);
const auto * column_set = typeid_cast<const ColumnSet *>(&*column_set_ptr);
return_nullable |= column_set->getData()->containsNullValue();

if (return_nullable)
Expand Down Expand Up @@ -796,6 +796,11 @@ class FunctionIn : public IFunction
materialized_tuple = const_tuple->convertToFullColumn();
tuple = typeid_cast<const ColumnTuple *>(materialized_tuple.get());
}
auto left_column_vector = left_arg.column;
if (left_arg.column->isColumnConst())
{
left_column_vector = left_column_vector->convertToFullColumnIfConst();
}

if (tuple)
{
Expand All @@ -806,7 +811,16 @@ class FunctionIn : public IFunction
block_of_key_columns.insert({tuple_columns[i], tuple_types[i], ""});
}
else
block_of_key_columns.insert(left_arg);
{
if (left_arg.column->isColumnConst())
{
block_of_key_columns.insert({left_column_vector, left_arg.type, ""});
}
else
{
block_of_key_columns.insert(left_arg);
}
}

if constexpr (ignore_null)
{
Expand All @@ -819,14 +833,14 @@ class FunctionIn : public IFunction
if (return_nullable)
{
auto nested_res = column_set->getData()->execute(block_of_key_columns, negative);
if (left_arg.column->isColumnNullable())
if (left_column_vector->isColumnNullable())
{
ColumnPtr result_null_map_column = dynamic_cast<const ColumnNullable &>(*left_arg.column).getNullMapColumnPtr();
ColumnPtr result_null_map_column = dynamic_cast<const ColumnNullable &>(*left_column_vector).getNullMapColumnPtr();
if (set_contains_null)
{
MutableColumnPtr mutable_result_null_map_column = (*std::move(result_null_map_column)).mutate();
NullMap & result_null_map = dynamic_cast<ColumnUInt8 &>(*mutable_result_null_map_column).getData();
auto uint8_column = checkAndGetColumn<ColumnUInt8>(nested_res.get());
const auto * uint8_column = checkAndGetColumn<ColumnUInt8>(nested_res.get());
const auto & data = uint8_column->getData();
for (size_t i = 0, size = result_null_map.size(); i < size; i++)
{
Expand All @@ -841,8 +855,8 @@ class FunctionIn : public IFunction
{
auto col_null_map = ColumnUInt8::create();
ColumnUInt8::Container & vec_null_map = col_null_map->getData();
vec_null_map.assign(block.rows(), (UInt8)0);
auto uint8_column = checkAndGetColumn<ColumnUInt8>(nested_res.get());
vec_null_map.assign(block.rows(), static_cast<UInt8>(0));
const auto * uint8_column = checkAndGetColumn<ColumnUInt8>(nested_res.get());
const auto & data = uint8_column->getData();
for (size_t i = 0, size = vec_null_map.size(); i < size; i++)
{
Expand Down Expand Up @@ -1051,7 +1065,7 @@ void FunctionReplicate::executeImpl(Block & block, const ColumnNumbers & argumen

if (!array_column)
{
auto const_array_column = checkAndGetColumnConst<ColumnArray>(block.getByPosition(arguments[1]).column.get());
const auto * const_array_column = checkAndGetColumnConst<ColumnArray>(block.getByPosition(arguments[1]).column.get());
if (!const_array_column)
throw Exception("Unexpected column for replicate", ErrorCodes::ILLEGAL_COLUMN);
temp_column = const_array_column->convertToFullColumn();
Expand Down Expand Up @@ -1235,7 +1249,7 @@ class FunctionNumericPredicate : public IFunction

void executeImpl(Block & block, const ColumnNumbers & arguments, const size_t result) const override
{
const auto in = block.getByPosition(arguments.front()).column.get();
const auto * const in = block.getByPosition(arguments.front()).column.get();

if (!execute<UInt8>(block, in, result)
&& !execute<UInt16>(block, in, result)
Expand Down Expand Up @@ -1369,7 +1383,7 @@ class FunctionVersion : public IFunction
}

private:
std::string getVersion() const;
static std::string getVersion();
};


Expand Down Expand Up @@ -1877,7 +1891,7 @@ class FunctionThrowIf : public IFunction

void executeImpl(Block & block, const ColumnNumbers & arguments, const size_t result) const override
{
const auto in = block.getByPosition(arguments.front()).column.get();
const auto * const in = block.getByPosition(arguments.front()).column.get();

if (!execute<UInt8>(block, in, result)
&& !execute<UInt16>(block, in, result)
Expand Down Expand Up @@ -1911,7 +1925,7 @@ class FunctionThrowIf : public IFunction
};


std::string FunctionVersion::getVersion() const
std::string FunctionVersion::getVersion()
{
std::ostringstream os;
os << TiFlashBuildInfo::getVersion();
Expand Down
Loading

0 comments on commit 4e982ef

Please sign in to comment.