fix failed code style check

This commit is contained in:
chloro 2024-06-16 15:15:19 +08:00
parent 38f01bd831
commit 27a0815bcc
3 changed files with 12 additions and 14 deletions

View File

@ -72,7 +72,7 @@ Block createBlockFromCollection(const Collection & collection, const DataTypes&
{
if (columns_size == 1)
{
DataTypePtr data_type = value_types[value_types_index];
const DataTypePtr & data_type = value_types[value_types_index];
auto field = convertFieldToTypeStrict(value, *data_type, *block_types[0]);
if (!field)
{
@ -83,7 +83,7 @@ Block createBlockFromCollection(const Collection & collection, const DataTypes&
bool need_insert_null = transform_null_in && block_types[0]->isNullable();
if (!field->isNull() || need_insert_null)
columns[0]->insert(*field);
value_types_index += 1;
continue;
}
@ -94,8 +94,8 @@ Block createBlockFromCollection(const Collection & collection, const DataTypes&
value.getTypeName());
const auto & tuple = value.template get<const Tuple &>();
DataTypePtr value_type = value_types[value_types_index];
DataTypes tuple_value_type = typeid_cast<const DataTypeTuple *>(value_type.get())->getElements();
const DataTypePtr & value_type = value_types[value_types_index];
const DataTypes & tuple_value_type = typeid_cast<const DataTypeTuple *>(value_type.get())->getElements();
size_t tuple_size = tuple.size();
@ -124,7 +124,7 @@ Block createBlockFromCollection(const Collection & collection, const DataTypes&
if (i == tuple_size)
for (i = 0; i < tuple_size; ++i)
columns[i]->insert(tuple_values[i]);
value_types_index += 1;
}
@ -159,7 +159,6 @@ Block getSetElementsForConstantValue(const DataTypePtr & expression_type, const
if (lhs_type_depth == rhs_type_depth)
{
/// 1 in 1; (1, 2) in (1, 2); identity(tuple(tuple(tuple(1)))) in tuple(tuple(tuple(1))); etc.
Array array{value};
DataTypes value_types{value_type};
result_block = createBlockFromCollection(array, value_types, set_element_types, transform_null_in);
@ -167,7 +166,6 @@ Block getSetElementsForConstantValue(const DataTypePtr & expression_type, const
else if (lhs_type_depth + 1 == rhs_type_depth)
{
/// 1 in (1, 2); (1, 2) in ((1, 2), (3, 4))
WhichDataType rhs_which_type(value_type);
if (rhs_which_type.isArray())
@ -186,7 +184,7 @@ Block getSetElementsForConstantValue(const DataTypePtr & expression_type, const
else if (rhs_which_type.isTuple())
{
const DataTypeTuple * value_tuple_type = typeid_cast<const DataTypeTuple *>(value_type.get());
DataTypes value_types = value_tuple_type->getElements();
const DataTypes & value_types = value_tuple_type->getElements();
result_block = createBlockFromCollection(value.get<const Tuple &>(), value_types, set_element_types, transform_null_in);
}
else

View File

@ -138,9 +138,9 @@ static Block createBlockFromCollection(const Collection & collection, const Data
if (tuple_values.empty())
tuple_values.resize(tuple_size);
DataTypePtr value_type = value_types[value_type_index];
DataTypes tuple_value_type = typeid_cast<const DataTypeTuple *>(value_type.get())->getElements();
const DataTypePtr & value_type = value_types[value_type_index];
const DataTypes & tuple_value_type = typeid_cast<const DataTypeTuple *>(value_type.get())->getElements();
size_t i = 0;
for (; i < tuple_size; ++i)
@ -331,7 +331,7 @@ Block createBlockForSet(
auto type_index = right_arg_type->getTypeId();
if (type_index == TypeIndex::Tuple)
{
DataTypes data_types = typeid_cast<const DataTypeTuple *>(right_arg_type.get())->getElements();
const DataTypes & data_types = typeid_cast<const DataTypeTuple *>(right_arg_type.get())->getElements();
block = createBlockFromCollection(right_arg_value.get<const Tuple &>(), data_types, set_element_types, tranform_null_in);
}
else if (type_index == TypeIndex::Array)
@ -340,7 +340,7 @@ Block createBlockForSet(
size_t right_arg_array_size = right_arg_value.get<const Array &>().size();
DataTypes data_types;
data_types.reserve(right_arg_array_size);
for(size_t i = 0; i < right_arg_array_size; ++i)
for (size_t i = 0; i < right_arg_array_size; ++i)
{
data_types.push_back(right_arg_array_type->getNestedType());
}

View File

@ -22,6 +22,6 @@ Field convertFieldToTypeOrThrow(const Field & from_value, const IDataType & to_t
/// Applies stricter rules than convertFieldToType, doesn't allow loss of precision converting to Decimal.
/// Returns `Field` if the conversion was successful and the result is equal to the original value, otherwise returns nullopt.
std::optional<Field> convertFieldToTypeStrict(const Field & from_value, const IDataType & from_type, const IDataType & to_type);
std::optional<Field> convertFieldToTypeStrict(const Field & from_value, const IDataType & from_type, const IDataType & to_type);
}