mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
update code style
This commit is contained in:
parent
ffb9a67a11
commit
38f01bd831
@ -74,7 +74,8 @@ Block createBlockFromCollection(const Collection & collection, const DataTypes&
|
||||
{
|
||||
DataTypePtr data_type = value_types[value_types_index];
|
||||
auto field = convertFieldToTypeStrict(value, *data_type, *block_types[0]);
|
||||
if (!field) {
|
||||
if (!field)
|
||||
{
|
||||
value_types_index += 1;
|
||||
continue;
|
||||
}
|
||||
@ -94,7 +95,7 @@ Block createBlockFromCollection(const Collection & collection, const DataTypes&
|
||||
|
||||
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();
|
||||
DataTypes tuple_value_type = typeid_cast<const DataTypeTuple *>(value_type.get())->getElements();
|
||||
|
||||
size_t tuple_size = tuple.size();
|
||||
|
||||
@ -169,19 +170,22 @@ Block getSetElementsForConstantValue(const DataTypePtr & expression_type, const
|
||||
|
||||
WhichDataType rhs_which_type(value_type);
|
||||
|
||||
if (rhs_which_type.isArray()) {
|
||||
const DataTypeArray* value_array_type = typeid_cast<const DataTypeArray *>(value_type.get());
|
||||
if (rhs_which_type.isArray())
|
||||
{
|
||||
const DataTypeArray * value_array_type = typeid_cast<const DataTypeArray *>(value_type.get());
|
||||
size_t value_array_size = value.get<const Array &>().size();
|
||||
DataTypes value_types;
|
||||
value_types.reserve(value_array_size);
|
||||
|
||||
for(size_t i = 0; i < value_array_size; ++i) {
|
||||
for (size_t i = 0; i < value_array_size; ++i)
|
||||
{
|
||||
value_types.push_back(value_array_type->getNestedType());
|
||||
}
|
||||
result_block = createBlockFromCollection(value.get<const Array &>(), value_types, set_element_types, transform_null_in);
|
||||
}
|
||||
else if (rhs_which_type.isTuple()) {
|
||||
const DataTypeTuple* value_tuple_type = typeid_cast<const DataTypeTuple *>(value_type.get());
|
||||
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();
|
||||
result_block = createBlockFromCollection(value.get<const Tuple &>(), value_types, set_element_types, transform_null_in);
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ static size_t getTypeDepth(const DataTypePtr & type)
|
||||
/// 33.33 in the set is converted to 33.3, but it is not equal to 33.3 in the column, so the result should still be empty.
|
||||
/// We can not include values that don't represent any possible value from the type of filtered column to the set.
|
||||
template<typename Collection>
|
||||
static Block createBlockFromCollection(const Collection & collection, const DataTypes& value_types, const DataTypes & types, bool transform_null_in)
|
||||
static Block createBlockFromCollection(const Collection & collection, const DataTypes & value_types, const DataTypes & types, bool transform_null_in)
|
||||
{
|
||||
size_t columns_num = types.size();
|
||||
MutableColumns columns(columns_num);
|
||||
@ -140,7 +140,7 @@ static Block createBlockFromCollection(const Collection & collection, const Data
|
||||
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();
|
||||
DataTypes tuple_value_type = typeid_cast<const DataTypeTuple *>(value_type.get())->getElements();
|
||||
|
||||
size_t i = 0;
|
||||
for (; i < tuple_size; ++i)
|
||||
@ -329,16 +329,19 @@ Block createBlockForSet(
|
||||
else if (left_type_depth + 1 == right_type_depth)
|
||||
{
|
||||
auto type_index = right_arg_type->getTypeId();
|
||||
if (type_index == TypeIndex::Tuple) {
|
||||
if (type_index == TypeIndex::Tuple)
|
||||
{
|
||||
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) {
|
||||
else if (type_index == TypeIndex::Array)
|
||||
{
|
||||
const auto* right_arg_array_type = typeid_cast<const DataTypeArray *>(right_arg_type.get());
|
||||
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());
|
||||
}
|
||||
block = createBlockFromCollection(right_arg_value.get<const Array &>(), data_types, set_element_types, tranform_null_in);
|
||||
|
@ -615,7 +615,7 @@ static bool decimalEqualsFloat(Field field, Float64 float_value)
|
||||
return decimal_to_float == float_value;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Field result_value = convertFieldToType(from_value, to_type, &from_type);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user