mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-30 05:30:51 +00:00
dbms: Cleanup [#METR-19266]
This commit is contained in:
parent
06428778c3
commit
989b3d87fd
@ -160,8 +160,6 @@ void FunctionMultiIf::executeImpl(Block & block, const ColumnNumbers & args, siz
|
|||||||
/// of the originating column.
|
/// of the originating column.
|
||||||
ColumnWithTypeAndName elem;
|
ColumnWithTypeAndName elem;
|
||||||
elem.type = std::make_shared<DataTypeUInt64>();
|
elem.type = std::make_shared<DataTypeUInt64>();
|
||||||
/// A pretty far-fetched name to make sure no conflict may occur.
|
|
||||||
elem.name = "BranchTracker(" + block.dumpStructure() + ")";
|
|
||||||
|
|
||||||
size_t tracker = non_nullable_block.columns();
|
size_t tracker = non_nullable_block.columns();
|
||||||
non_nullable_block.insert(elem);
|
non_nullable_block.insert(elem);
|
||||||
|
@ -99,17 +99,25 @@ DataTypePtr FunctionIsNotNull::getReturnTypeImpl(const DataTypes & arguments) co
|
|||||||
|
|
||||||
void FunctionIsNotNull::executeImpl(Block & block, const ColumnNumbers & arguments, size_t result)
|
void FunctionIsNotNull::executeImpl(Block & block, const ColumnNumbers & arguments, size_t result)
|
||||||
{
|
{
|
||||||
ColumnWithTypeAndName temp_res;
|
Block temp_block
|
||||||
temp_res.type = std::make_shared<DataTypeUInt8>();
|
{
|
||||||
temp_res.name = "isNull(" + block.getByPosition(arguments[0]).name + ")";
|
block.getByPosition(arguments[0]),
|
||||||
|
{
|
||||||
|
nullptr,
|
||||||
|
std::make_shared<DataTypeUInt8>(),
|
||||||
|
""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
nullptr,
|
||||||
|
std::make_shared<DataTypeUInt8>(),
|
||||||
|
""
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
size_t temp_res_num = block.columns();
|
FunctionIsNull{}.executeImpl(temp_block, {0}, 1);
|
||||||
block.insert(temp_res);
|
FunctionNot{}.executeImpl(temp_block, {1}, 2);
|
||||||
|
|
||||||
FunctionIsNull{}.executeImpl(block, arguments, temp_res_num);
|
block.getByPosition(result).column = std::move(temp_block.getByPosition(2).column);
|
||||||
FunctionNot{}.executeImpl(block, {temp_res_num}, result);
|
|
||||||
|
|
||||||
block.erase(temp_res_num);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implementation of coalesce.
|
/// Implementation of coalesce.
|
||||||
@ -150,33 +158,33 @@ void FunctionCoalesce::executeImpl(Block & block, const ColumnNumbers & argument
|
|||||||
FunctionIsNotNull is_not_null;
|
FunctionIsNotNull is_not_null;
|
||||||
ColumnNumbers multi_if_args;
|
ColumnNumbers multi_if_args;
|
||||||
|
|
||||||
|
Block temp_block = block;
|
||||||
|
|
||||||
for (size_t i = 0; i < arguments.size(); ++i)
|
for (size_t i = 0; i < arguments.size(); ++i)
|
||||||
{
|
{
|
||||||
ColumnWithTypeAndName elem;
|
size_t res_pos = temp_block.columns();
|
||||||
elem.type = std::make_shared<DataTypeUInt8>();
|
temp_block.insert({nullptr, std::make_shared<DataTypeUInt8>(), ""});
|
||||||
elem.name = "isNotNull(" + block.getByPosition(arguments[i]).name + ")";
|
|
||||||
|
|
||||||
size_t res_pos = block.columns();
|
is_not_null.executeImpl(temp_block, {arguments[i]}, res_pos);
|
||||||
block.insert(elem);
|
|
||||||
|
|
||||||
is_not_null.executeImpl(block, { arguments[i] }, res_pos);
|
|
||||||
|
|
||||||
multi_if_args.push_back(res_pos);
|
multi_if_args.push_back(res_pos);
|
||||||
multi_if_args.push_back(arguments[i]);
|
multi_if_args.push_back(arguments[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Argument corresponding to the fallback NULL value.
|
/// Argument corresponding to the fallback NULL value.
|
||||||
multi_if_args.push_back(block.columns());
|
multi_if_args.push_back(temp_block.columns());
|
||||||
|
|
||||||
/// Append a fallback NULL column.
|
/// Append a fallback NULL column.
|
||||||
ColumnWithTypeAndName elem;
|
ColumnWithTypeAndName elem;
|
||||||
elem.column = std::make_shared<ColumnNull>(block.rowsInFirstColumn(), Null());
|
elem.column = std::make_shared<ColumnNull>(temp_block.rowsInFirstColumn(), Null());
|
||||||
elem.type = std::make_shared<DataTypeNull>();
|
elem.type = std::make_shared<DataTypeNull>();
|
||||||
elem.name = "NULL";
|
elem.name = "NULL";
|
||||||
|
|
||||||
block.insert(elem);
|
temp_block.insert(elem);
|
||||||
|
|
||||||
FunctionMultiIf{}.executeImpl(block, multi_if_args, result);
|
FunctionMultiIf{}.executeImpl(temp_block, multi_if_args, result);
|
||||||
|
|
||||||
|
block.getByPosition(result).column = std::move(temp_block.getByPosition(result).column);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implementation of ifNull.
|
/// Implementation of ifNull.
|
||||||
@ -210,15 +218,15 @@ void FunctionIfNull::executeImpl(Block & block, const ColumnNumbers & arguments,
|
|||||||
{
|
{
|
||||||
/// ifNull(col1, col2) == multiIf(isNotNull(col1), col1, col2)
|
/// ifNull(col1, col2) == multiIf(isNotNull(col1), col1, col2)
|
||||||
|
|
||||||
ColumnWithTypeAndName elem;
|
Block temp_block = block;
|
||||||
elem.type = std::make_shared<DataTypeUInt8>();
|
|
||||||
elem.name = "isNotNull(" + block.getByPosition(arguments[0]).name + ")";
|
|
||||||
|
|
||||||
size_t res_pos = block.columns();
|
size_t res_pos = temp_block.columns();
|
||||||
block.insert(elem);
|
temp_block.insert({nullptr, std::make_shared<DataTypeUInt8>(), ""});
|
||||||
|
|
||||||
FunctionIsNotNull{}.executeImpl(block, {arguments[0]}, res_pos);
|
FunctionIsNotNull{}.executeImpl(temp_block, {arguments[0]}, res_pos);
|
||||||
FunctionMultiIf{}.executeImpl(block, {res_pos, arguments[0], arguments[1]}, result);
|
FunctionMultiIf{}.executeImpl(temp_block, {res_pos, arguments[0], arguments[1]}, result);
|
||||||
|
|
||||||
|
block.getByPosition(result).column = std::move(temp_block.getByPosition(result).column);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implementation of nullIf.
|
/// Implementation of nullIf.
|
||||||
@ -252,27 +260,27 @@ void FunctionNullIf::executeImpl(Block & block, const ColumnNumbers & arguments,
|
|||||||
{
|
{
|
||||||
/// nullIf(col1, col2) == multiIf(col1 == col2, NULL, col1)
|
/// nullIf(col1, col2) == multiIf(col1 == col2, NULL, col1)
|
||||||
|
|
||||||
ColumnWithTypeAndName elem;
|
Block temp_block = block;
|
||||||
elem.type = std::make_shared<DataTypeUInt8>();
|
|
||||||
elem.name = "equals(" + block.getByPosition(arguments[0]).name + "," + block.getByPosition(arguments[1]).name + ")";
|
|
||||||
|
|
||||||
size_t res_pos = block.columns();
|
size_t res_pos = temp_block.columns();
|
||||||
block.insert(elem);
|
temp_block.insert({nullptr, std::make_shared<DataTypeUInt8>(), ""});
|
||||||
|
|
||||||
FunctionEquals{}.execute(block, {arguments[0], arguments[1]}, res_pos);
|
FunctionEquals{}.execute(temp_block, {arguments[0], arguments[1]}, res_pos);
|
||||||
|
|
||||||
/// Argument corresponding to the NULL value.
|
/// Argument corresponding to the NULL value.
|
||||||
size_t null_pos = block.columns();
|
size_t null_pos = temp_block.columns();
|
||||||
|
|
||||||
/// Append a NULL column.
|
/// Append a NULL column.
|
||||||
ColumnWithTypeAndName null_elem;
|
ColumnWithTypeAndName null_elem;
|
||||||
null_elem.column = std::make_shared<ColumnNull>(block.rowsInFirstColumn(), Null());
|
null_elem.column = std::make_shared<ColumnNull>(temp_block.rowsInFirstColumn(), Null());
|
||||||
null_elem.type = std::make_shared<DataTypeNull>();
|
null_elem.type = std::make_shared<DataTypeNull>();
|
||||||
null_elem.name = "NULL";
|
null_elem.name = "NULL";
|
||||||
|
|
||||||
block.insert(null_elem);
|
temp_block.insert(null_elem);
|
||||||
|
|
||||||
FunctionMultiIf{}.executeImpl(block, {res_pos, null_pos, arguments[0]}, result);
|
FunctionMultiIf{}.executeImpl(temp_block, {res_pos, null_pos, arguments[0]}, result);
|
||||||
|
|
||||||
|
block.getByPosition(result).column = std::move(temp_block.getByPosition(result).column);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implementation of assumeNotNull.
|
/// Implementation of assumeNotNull.
|
||||||
|
Loading…
Reference in New Issue
Block a user