Fixed style a bit [#CLICKHOUSE-2]

This commit is contained in:
Alexey Milovidov 2018-05-07 05:01:11 +03:00
parent 17d7916fd6
commit 94369e55d3
54 changed files with 282 additions and 520 deletions

View File

@ -1,13 +1,10 @@
function(generate_function_register FUNCTION_AREA) function(generate_function_register FUNCTION_AREA)
foreach(FUNCTION IN LISTS ARGN)
foreach(FUNCTION IN LISTS ARGN) configure_file (registerFunction.h.in register${FUNCTION}.h)
configure_file (registerFunction.h.in register${FUNCTION}.h) configure_file (registerFunction.cpp.in register${FUNCTION}.cpp)
configure_file (registerFunction.cpp.in register${FUNCTION}.cpp) set(REGISTER_HEADERS "${REGISTER_HEADERS}#include \"register${FUNCTION}.h\"\n")
set(REGISTER_HEADERS "${REGISTER_HEADERS} #include \"register${FUNCTION}.h\"\n") set(REGISTER_FUNCTIONS "${REGISTER_FUNCTIONS} register${FUNCTION}(factory);\n")
set(REGISTER_FUNCTIONS "${REGISTER_FUNCTIONS} register${FUNCTION}(factory);\n")
endforeach() endforeach()
configure_file (registerFunctions_area.cpp.in registerFunctions${FUNCTION_AREA}.cpp) configure_file (registerFunctions_area.cpp.in registerFunctions${FUNCTION_AREA}.cpp)
endfunction() endfunction()

View File

@ -242,9 +242,7 @@ private:
auto throw_exception = [&](const std::string & msg) auto throw_exception = [&](const std::string & msg)
{ {
throw Exception{ throw Exception{msg + " '" + std::string(pos, end) + "' at position " + toString(pos - begin), ErrorCodes::SYNTAX_ERROR};
msg + " '" + std::string(pos, end) + "' at position " + toString(pos - begin),
ErrorCodes::SYNTAX_ERROR};
}; };
auto match = [&pos, end](const char * str) mutable auto match = [&pos, end](const char * str) mutable
@ -286,9 +284,7 @@ private:
if (actions.back().type != PatternActionType::SpecificEvent && if (actions.back().type != PatternActionType::SpecificEvent &&
actions.back().type != PatternActionType::AnyEvent && actions.back().type != PatternActionType::AnyEvent &&
actions.back().type != PatternActionType::KleeneStar) actions.back().type != PatternActionType::KleeneStar)
throw Exception{ throw Exception{"Temporal condition should be preceeded by an event condition", ErrorCodes::BAD_ARGUMENTS};
"Temporal condition should be preceeded by an event condition",
ErrorCodes::BAD_ARGUMENTS};
actions.emplace_back(type, duration); actions.emplace_back(type, duration);
} }
@ -301,9 +297,7 @@ private:
throw_exception("Could not parse number"); throw_exception("Could not parse number");
if (event_number > arg_count - 1) if (event_number > arg_count - 1)
throw Exception{ throw Exception{"Event number " + toString(event_number) + " is out of range", ErrorCodes::BAD_ARGUMENTS};
"Event number " + toString(event_number) + " is out of range",
ErrorCodes::BAD_ARGUMENTS};
actions.emplace_back(PatternActionType::SpecificEvent, event_number - 1); actions.emplace_back(PatternActionType::SpecificEvent, event_number - 1);
} }
@ -428,13 +422,10 @@ protected:
break; break;
} }
else else
throw Exception{ throw Exception{"Unknown PatternActionType", ErrorCodes::LOGICAL_ERROR};
"Unknown PatternActionType",
ErrorCodes::LOGICAL_ERROR};
if (++i > sequence_match_max_iterations) if (++i > sequence_match_max_iterations)
throw Exception{ throw Exception{"Pattern application proves too difficult, exceeding max iterations (" + toString(sequence_match_max_iterations) + ")",
"Pattern application proves too difficult, exceeding max iterations (" + toString(sequence_match_max_iterations) + ")",
ErrorCodes::TOO_SLOW}; ErrorCodes::TOO_SLOW};
} }

View File

@ -15,10 +15,10 @@
#include <Poco/Exception.h> #include <Poco/Exception.h>
/// Implementation of Reservoir Sampling algorithm. Incrementally selects from the added objects a random subset of the `sample_count` size. /// Implementation of Reservoir Sampling algorithm. Incrementally selects from the added objects a random subset of the `sample_count` size.
/// Can approximately get quantiles. /// Can approximately get quantiles.
/// The `quantile` call takes O(sample_count log sample_count), if after the previous call `quantile` there was at least one call to insert. Otherwise, O(1). /// The `quantile` call takes O(sample_count log sample_count), if after the previous call `quantile` there was at least one call to insert. Otherwise, O(1).
/// That is, it makes sense to first add, then get quantiles without adding. /// That is, it makes sense to first add, then get quantiles without adding.
namespace DB namespace DB

View File

@ -373,7 +373,8 @@ ConfigProcessor::Files ConfigProcessor::getConfigMergeFiles(const std::string &
std::vector<std::string> merge_dirs; std::vector<std::string> merge_dirs;
merge_dirs.push_back(merge_dir_path.toString()); merge_dirs.push_back(merge_dir_path.toString());
if (merge_dir_path.getBaseName() != "conf") { if (merge_dir_path.getBaseName() != "conf")
{
merge_dir_path.setBaseName("conf"); merge_dir_path.setBaseName("conf");
merge_dirs.push_back(merge_dir_path.toString()); merge_dirs.push_back(merge_dir_path.toString());
} }

View File

@ -165,7 +165,7 @@ public:
/// Parsing of external table used when sending tables via http /// Parsing of external table used when sending tables via http
/// The `handlePart` function will be called for each table passed, /// The `handlePart` function will be called for each table passed,
/// so it's also necessary to call `clean` at the end of the `handlePart`. /// so it's also necessary to call `clean` at the end of the `handlePart`.
class ExternalTablesHandler : public Poco::Net::PartHandler, BaseExternalTable class ExternalTablesHandler : public Poco::Net::PartHandler, BaseExternalTable
{ {
public: public:

View File

@ -121,7 +121,7 @@ public:
continue; continue;
} }
const auto src_len = DB::UTF8::seqLength(*needle_pos); const auto src_len = UTF8::seqLength(*needle_pos);
const auto c_u32 = utf8.convert(needle_pos); const auto c_u32 = utf8.convert(needle_pos);
const auto c_l_u32 = Poco::Unicode::toLower(c_u32); const auto c_l_u32 = Poco::Unicode::toLower(c_u32);
@ -132,9 +132,7 @@ public:
/// @note Unicode standard states it is a rare but possible occasion /// @note Unicode standard states it is a rare but possible occasion
if (!(dst_l_len == dst_u_len && dst_u_len == src_len)) if (!(dst_l_len == dst_u_len && dst_u_len == src_len))
throw DB::Exception{ throw Exception{"UTF8 sequences with different lowercase and uppercase lengths are not supported", ErrorCodes::UNSUPPORTED_PARAMETER};
"UTF8 sequences with different lowercase and uppercase lengths are not supported",
DB::ErrorCodes::UNSUPPORTED_PARAMETER};
cache_actual_len += src_len; cache_actual_len += src_len;
if (cache_actual_len < n) if (cache_actual_len < n)
@ -183,7 +181,7 @@ public:
Poco::Unicode::toLower(utf8.convert(needle_pos))) Poco::Unicode::toLower(utf8.convert(needle_pos)))
{ {
/// @note assuming sequences for lowercase and uppercase have exact same length /// @note assuming sequences for lowercase and uppercase have exact same length
const auto len = DB::UTF8::seqLength(*pos); const auto len = UTF8::seqLength(*pos);
pos += len, needle_pos += len; pos += len, needle_pos += len;
} }
@ -207,7 +205,7 @@ public:
Poco::Unicode::toLower(utf8.convert(pos)) == Poco::Unicode::toLower(utf8.convert(pos)) ==
Poco::Unicode::toLower(utf8.convert(needle_pos))) Poco::Unicode::toLower(utf8.convert(needle_pos)))
{ {
const auto len = DB::UTF8::seqLength(*pos); const auto len = UTF8::seqLength(*pos);
pos += len, needle_pos += len; pos += len, needle_pos += len;
} }
@ -240,7 +238,7 @@ public:
if (mask == 0) if (mask == 0)
{ {
haystack += n; haystack += n;
DB::UTF8::syncForward(haystack, haystack_end); UTF8::syncForward(haystack, haystack_end);
continue; continue;
} }
@ -267,7 +265,7 @@ public:
Poco::Unicode::toLower(utf8.convert(needle_pos))) Poco::Unicode::toLower(utf8.convert(needle_pos)))
{ {
/// @note assuming sequences for lowercase and uppercase have exact same length /// @note assuming sequences for lowercase and uppercase have exact same length
const auto len = DB::UTF8::seqLength(*haystack_pos); const auto len = UTF8::seqLength(*haystack_pos);
haystack_pos += len, needle_pos += len; haystack_pos += len, needle_pos += len;
} }
@ -279,7 +277,7 @@ public:
return haystack; return haystack;
/// first octet was ok, but not the first 16, move to start of next sequence and reapply /// first octet was ok, but not the first 16, move to start of next sequence and reapply
haystack += DB::UTF8::seqLength(*haystack); haystack += UTF8::seqLength(*haystack);
continue; continue;
} }
} }
@ -297,7 +295,7 @@ public:
Poco::Unicode::toLower(utf8.convert(haystack_pos)) == Poco::Unicode::toLower(utf8.convert(haystack_pos)) ==
Poco::Unicode::toLower(utf8.convert(needle_pos))) Poco::Unicode::toLower(utf8.convert(needle_pos)))
{ {
const auto len = DB::UTF8::seqLength(*haystack_pos); const auto len = UTF8::seqLength(*haystack_pos);
haystack_pos += len, needle_pos += len; haystack_pos += len, needle_pos += len;
} }
@ -306,7 +304,7 @@ public:
} }
/// advance to the start of the next sequence /// advance to the start of the next sequence
haystack += DB::UTF8::seqLength(*haystack); haystack += UTF8::seqLength(*haystack);
} }
return haystack_end; return haystack_end;

View File

@ -20,7 +20,7 @@ namespace ErrorCodes
/// Write values in binary form. NOTE: You could use protobuf, but it would be overkill for this case. /// Write values in binary form. NOTE: You could use protobuf, but it would be overkill for this case.
void BlockInfo::write(WriteBuffer & out) const void BlockInfo::write(WriteBuffer & out) const
{ {
/// Set of pairs `FIELD_NUM`, value in binary form. Then 0. /// Set of pairs `FIELD_NUM`, value in binary form. Then 0.
#define WRITE_FIELD(TYPE, NAME, DEFAULT, FIELD_NUM) \ #define WRITE_FIELD(TYPE, NAME, DEFAULT, FIELD_NUM) \
writeVarUInt(FIELD_NUM, out); \ writeVarUInt(FIELD_NUM, out); \
writeBinary(NAME, out); writeBinary(NAME, out);

View File

@ -70,9 +70,7 @@ CacheDictionary::CacheDictionary(const std::string & name, const DictionaryStruc
rnd_engine(randomSeed()) rnd_engine(randomSeed())
{ {
if (!this->source_ptr->supportsSelectiveLoad()) if (!this->source_ptr->supportsSelectiveLoad())
throw Exception{ throw Exception{name + ": source cannot be used with CacheDictionary", ErrorCodes::UNSUPPORTED_METHOD};
name + ": source cannot be used with CacheDictionary",
ErrorCodes::UNSUPPORTED_METHOD};
createAttributes(); createAttributes();
} }
@ -215,9 +213,7 @@ void CacheDictionary::get##TYPE(const std::string & attribute_name, const Padded
{\ {\
auto & attribute = getAttribute(attribute_name);\ auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
const auto null_value = std::get<TYPE>(attribute.null_values);\ const auto null_value = std::get<TYPE>(attribute.null_values);\
\ \
@ -240,9 +236,7 @@ void CacheDictionary::getString(const std::string & attribute_name, const Padded
{ {
auto & attribute = getAttribute(attribute_name); auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
const auto null_value = StringRef{std::get<String>(attribute.null_values)}; const auto null_value = StringRef{std::get<String>(attribute.null_values)};
@ -256,9 +250,7 @@ void CacheDictionary::get##TYPE(\
{\ {\
auto & attribute = getAttribute(attribute_name);\ auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
getItemsNumber<TYPE>(attribute, ids, out, [&] (const size_t row) { return def[row]; });\ getItemsNumber<TYPE>(attribute, ids, out, [&] (const size_t row) { return def[row]; });\
} }
@ -281,9 +273,7 @@ void CacheDictionary::getString(
{ {
auto & attribute = getAttribute(attribute_name); auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
getItemsString(attribute, ids, out, [&] (const size_t row) { return def->getDataAt(row); }); getItemsString(attribute, ids, out, [&] (const size_t row) { return def->getDataAt(row); });
} }
@ -294,9 +284,7 @@ void CacheDictionary::get##TYPE(\
{\ {\
auto & attribute = getAttribute(attribute_name);\ auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
getItemsNumber<TYPE>(attribute, ids, out, [&] (const size_t) { return def; });\ getItemsNumber<TYPE>(attribute, ids, out, [&] (const size_t) { return def; });\
} }
@ -319,9 +307,7 @@ void CacheDictionary::getString(
{ {
auto & attribute = getAttribute(attribute_name); auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
getItemsString(attribute, ids, out, [&] (const size_t) { return StringRef{def}; }); getItemsString(attribute, ids, out, [&] (const size_t) { return StringRef{def}; });
} }
@ -449,9 +435,7 @@ void CacheDictionary::createAttributes()
hierarchical_attribute = &attributes.back(); hierarchical_attribute = &attributes.back();
if (hierarchical_attribute->type != AttributeUnderlyingType::UInt64) if (hierarchical_attribute->type != AttributeUnderlyingType::UInt64)
throw Exception{ throw Exception{name + ": hierarchical attribute must be UInt64.", ErrorCodes::TYPE_MISMATCH};
name + ": hierarchical attribute must be UInt64.",
ErrorCodes::TYPE_MISMATCH};
} }
} }
} }
@ -798,9 +782,7 @@ void CacheDictionary::update(
{ {
const auto id_column = typeid_cast<const ColumnUInt64 *>(block.safeGetByPosition(0).column.get()); const auto id_column = typeid_cast<const ColumnUInt64 *>(block.safeGetByPosition(0).column.get());
if (!id_column) if (!id_column)
throw Exception{ throw Exception{name + ": id column has type different from UInt64.", ErrorCodes::TYPE_MISMATCH};
name + ": id column has type different from UInt64.",
ErrorCodes::TYPE_MISMATCH};
const auto & ids = id_column->getData(); const auto & ids = id_column->getData();
@ -973,10 +955,7 @@ CacheDictionary::Attribute & CacheDictionary::getAttribute(const std::string & a
{ {
const auto it = attribute_index_by_name.find(attribute_name); const auto it = attribute_index_by_name.find(attribute_name);
if (it == std::end(attribute_index_by_name)) if (it == std::end(attribute_index_by_name))
throw Exception{ throw Exception{name + ": no such attribute '" + attribute_name + "'", ErrorCodes::BAD_ARGUMENTS};
name + ": no such attribute '" + attribute_name + "'",
ErrorCodes::BAD_ARGUMENTS
};
return attributes[it->second]; return attributes[it->second];
} }

View File

@ -59,9 +59,7 @@ ComplexKeyCacheDictionary::ComplexKeyCacheDictionary(const std::string & name, c
rnd_engine(randomSeed()) rnd_engine(randomSeed())
{ {
if (!this->source_ptr->supportsSelectiveLoad()) if (!this->source_ptr->supportsSelectiveLoad())
throw Exception{ throw Exception{name + ": source cannot be used with ComplexKeyCacheDictionary", ErrorCodes::UNSUPPORTED_METHOD};
name + ": source cannot be used with ComplexKeyCacheDictionary",
ErrorCodes::UNSUPPORTED_METHOD};
createAttributes(); createAttributes();
} }
@ -78,9 +76,7 @@ void ComplexKeyCacheDictionary::getString(
auto & attribute = getAttribute(attribute_name); auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
const auto null_value = StringRef{std::get<String>(attribute.null_values)}; const auto null_value = StringRef{std::get<String>(attribute.null_values)};
@ -95,9 +91,7 @@ void ComplexKeyCacheDictionary::getString(
auto & attribute = getAttribute(attribute_name); auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
getItemsString(attribute, key_columns, out, [&] (const size_t row) { return def->getDataAt(row); }); getItemsString(attribute, key_columns, out, [&] (const size_t row) { return def->getDataAt(row); });
} }
@ -110,9 +104,7 @@ void ComplexKeyCacheDictionary::getString(
auto & attribute = getAttribute(attribute_name); auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
getItemsString(attribute, key_columns, out, [&] (const size_t) { return StringRef{def}; }); getItemsString(attribute, key_columns, out, [&] (const size_t) { return StringRef{def}; });
} }
@ -248,9 +240,7 @@ void ComplexKeyCacheDictionary::createAttributes()
attributes.push_back(createAttributeWithType(attribute.underlying_type, attribute.null_value)); attributes.push_back(createAttributeWithType(attribute.underlying_type, attribute.null_value));
if (attribute.hierarchical) if (attribute.hierarchical)
throw Exception{ throw Exception{name + ": hierarchical attributes not supported for dictionary of type " + getTypeName(), ErrorCodes::TYPE_MISMATCH};
name + ": hierarchical attributes not supported for dictionary of type " + getTypeName(),
ErrorCodes::TYPE_MISMATCH};
} }
} }
@ -258,9 +248,7 @@ ComplexKeyCacheDictionary::Attribute & ComplexKeyCacheDictionary::getAttribute(c
{ {
const auto it = attribute_index_by_name.find(attribute_name); const auto it = attribute_index_by_name.find(attribute_name);
if (it == std::end(attribute_index_by_name)) if (it == std::end(attribute_index_by_name))
throw Exception{ throw Exception{name + ": no such attribute '" + attribute_name + "'", ErrorCodes::BAD_ARGUMENTS};
name + ": no such attribute '" + attribute_name + "'",
ErrorCodes::BAD_ARGUMENTS};
return attributes[it->second]; return attributes[it->second];
} }

View File

@ -51,9 +51,7 @@ void ComplexKeyHashedDictionary::get##TYPE(\
\ \
const auto & attribute = getAttribute(attribute_name);\ const auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
const auto null_value = std::get<TYPE>(attribute.null_values);\ const auto null_value = std::get<TYPE>(attribute.null_values);\
\ \
@ -82,9 +80,7 @@ void ComplexKeyHashedDictionary::getString(
const auto & attribute = getAttribute(attribute_name); const auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
const auto & null_value = StringRef{std::get<String>(attribute.null_values)}; const auto & null_value = StringRef{std::get<String>(attribute.null_values)};
@ -102,9 +98,7 @@ void ComplexKeyHashedDictionary::get##TYPE(\
\ \
const auto & attribute = getAttribute(attribute_name);\ const auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
getItemsNumber<TYPE>(attribute, key_columns,\ getItemsNumber<TYPE>(attribute, key_columns,\
[&] (const size_t row, const auto value) { out[row] = value; },\ [&] (const size_t row, const auto value) { out[row] = value; },\
@ -131,9 +125,7 @@ void ComplexKeyHashedDictionary::getString(
const auto & attribute = getAttribute(attribute_name); const auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
getItemsImpl<StringRef, StringRef>(attribute, key_columns, getItemsImpl<StringRef, StringRef>(attribute, key_columns,
[&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); }, [&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); },
@ -149,9 +141,7 @@ void ComplexKeyHashedDictionary::get##TYPE(\
\ \
const auto & attribute = getAttribute(attribute_name);\ const auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
getItemsNumber<TYPE>(attribute, key_columns,\ getItemsNumber<TYPE>(attribute, key_columns,\
[&] (const size_t row, const auto value) { out[row] = value; },\ [&] (const size_t row, const auto value) { out[row] = value; },\
@ -178,9 +168,7 @@ void ComplexKeyHashedDictionary::getString(
const auto & attribute = getAttribute(attribute_name); const auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
getItemsImpl<StringRef, StringRef>(attribute, key_columns, getItemsImpl<StringRef, StringRef>(attribute, key_columns,
[&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); }, [&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); },
@ -221,9 +209,7 @@ void ComplexKeyHashedDictionary::createAttributes()
attributes.push_back(createAttributeWithType(attribute.underlying_type, attribute.null_value)); attributes.push_back(createAttributeWithType(attribute.underlying_type, attribute.null_value));
if (attribute.hierarchical) if (attribute.hierarchical)
throw Exception{ throw Exception{name + ": hierarchical attributes not supported for dictionary of type " + getTypeName(), ErrorCodes::TYPE_MISMATCH};
name + ": hierarchical attributes not supported for dictionary of type " + getTypeName(),
ErrorCodes::TYPE_MISMATCH};
} }
} }
@ -238,23 +224,26 @@ void ComplexKeyHashedDictionary::blockToAttributes(const Block & block)
element_count += rows; element_count += rows;
const auto key_column_ptrs = ext::map<Columns>(ext::range(0, keys_size), const auto key_column_ptrs = ext::map<Columns>(ext::range(0, keys_size),
[&](const size_t attribute_idx) { [&](const size_t attribute_idx)
return block.safeGetByPosition(attribute_idx).column; {
}); return block.safeGetByPosition(attribute_idx).column;
});
const auto attribute_column_ptrs = ext::map<Columns>(ext::range(0, attributes_size), const auto attribute_column_ptrs = ext::map<Columns>(ext::range(0, attributes_size),
[&](const size_t attribute_idx) { [&](const size_t attribute_idx)
return block.safeGetByPosition( {
keys_size + attribute_idx).column; return block.safeGetByPosition(keys_size + attribute_idx).column;
}); });
for (const auto row_idx : ext::range(0, rows)) { for (const auto row_idx : ext::range(0, rows))
{
/// calculate key once per row /// calculate key once per row
const auto key = placeKeysInPool(row_idx, key_column_ptrs, keys, keys_pool); const auto key = placeKeysInPool(row_idx, key_column_ptrs, keys, keys_pool);
auto should_rollback = false; auto should_rollback = false;
for (const auto attribute_idx : ext::range(0, attributes_size)) { for (const auto attribute_idx : ext::range(0, attributes_size))
{
const auto &attribute_column = *attribute_column_ptrs[attribute_idx]; const auto &attribute_column = *attribute_column_ptrs[attribute_idx];
auto &attribute = attributes[attribute_idx]; auto &attribute = attributes[attribute_idx];
const auto inserted = setAttributeValue(attribute, key, attribute_column[row_idx]); const auto inserted = setAttributeValue(attribute, key, attribute_column[row_idx]);
@ -354,7 +343,8 @@ void ComplexKeyHashedDictionary::updateData()
void ComplexKeyHashedDictionary::loadData() void ComplexKeyHashedDictionary::loadData()
{ {
if (!source_ptr->hasUpdateField()) { if (!source_ptr->hasUpdateField())
{
auto stream = source_ptr->loadAll(); auto stream = source_ptr->loadAll();
stream->readPrefix(); stream->readPrefix();
@ -367,9 +357,7 @@ void ComplexKeyHashedDictionary::loadData()
updateData(); updateData();
if (require_nonempty && 0 == element_count) if (require_nonempty && 0 == element_count)
throw Exception{ throw Exception{name + ": dictionary source is empty and 'require_nonempty' property is set.", ErrorCodes::DICTIONARY_IS_EMPTY};
name + ": dictionary source is empty and 'require_nonempty' property is set.",
ErrorCodes::DICTIONARY_IS_EMPTY};
} }
template <typename T> template <typename T>
@ -546,9 +534,7 @@ const ComplexKeyHashedDictionary::Attribute & ComplexKeyHashedDictionary::getAtt
{ {
const auto it = attribute_index_by_name.find(attribute_name); const auto it = attribute_index_by_name.find(attribute_name);
if (it == std::end(attribute_index_by_name)) if (it == std::end(attribute_index_by_name))
throw Exception{ throw Exception{name + ": no such attribute '" + attribute_name + "'", ErrorCodes::BAD_ARGUMENTS};
name + ": no such attribute '" + attribute_name + "'",
ErrorCodes::BAD_ARGUMENTS};
return attributes[it->second]; return attributes[it->second];
} }

View File

@ -53,8 +53,7 @@ Block createSampleBlock(const DictionaryStructure & dict_struct)
Block block; Block block;
if (dict_struct.id) if (dict_struct.id)
block.insert(ColumnWithTypeAndName{ block.insert(ColumnWithTypeAndName{ColumnUInt64::create(1, 0), std::make_shared<DataTypeUInt64>(), dict_struct.id->name});
ColumnUInt64::create(1, 0), std::make_shared<DataTypeUInt64>(), dict_struct.id->name});
if (dict_struct.key) if (dict_struct.key)
{ {
@ -109,10 +108,7 @@ DictionarySourcePtr DictionarySourceFactory::create(
Poco::Util::AbstractConfiguration::Keys keys; Poco::Util::AbstractConfiguration::Keys keys;
config.keys(config_prefix, keys); config.keys(config_prefix, keys);
if (keys.size() != 1) if (keys.size() != 1)
throw Exception{ throw Exception{name +": element dictionary.source should have exactly one child element", ErrorCodes::EXCESSIVE_ELEMENT_IN_CONFIG};
name +": element dictionary.source should have exactly one child element",
ErrorCodes::EXCESSIVE_ELEMENT_IN_CONFIG
};
auto sample_block = createSampleBlock(dict_struct); auto sample_block = createSampleBlock(dict_struct);
@ -121,9 +117,7 @@ DictionarySourcePtr DictionarySourceFactory::create(
if ("file" == source_type) if ("file" == source_type)
{ {
if (dict_struct.has_expressions) if (dict_struct.has_expressions)
throw Exception{ throw Exception{"Dictionary source of type `file` does not support attribute expressions", ErrorCodes::LOGICAL_ERROR};
"Dictionary source of type `file` does not support attribute expressions",
ErrorCodes::LOGICAL_ERROR};
const auto filename = config.getString(config_prefix + ".file.path"); const auto filename = config.getString(config_prefix + ".file.path");
const auto format = config.getString(config_prefix + ".file.format"); const auto format = config.getString(config_prefix + ".file.format");
@ -164,9 +158,7 @@ DictionarySourcePtr DictionarySourceFactory::create(
else if ("executable" == source_type) else if ("executable" == source_type)
{ {
if (dict_struct.has_expressions) if (dict_struct.has_expressions)
throw Exception{ throw Exception{"Dictionary source of type `executable` does not support attribute expressions", ErrorCodes::LOGICAL_ERROR};
"Dictionary source of type `executable` does not support attribute expressions",
ErrorCodes::LOGICAL_ERROR};
return std::make_unique<ExecutableDictionarySource>(dict_struct, config, config_prefix + ".executable", sample_block, context); return std::make_unique<ExecutableDictionarySource>(dict_struct, config, config_prefix + ".executable", sample_block, context);
} }
@ -174,9 +166,7 @@ DictionarySourcePtr DictionarySourceFactory::create(
{ {
if (dict_struct.has_expressions) if (dict_struct.has_expressions)
throw Exception{ throw Exception{"Dictionary source of type `http` does not support attribute expressions", ErrorCodes::LOGICAL_ERROR};
"Dictionary source of type `http` does not support attribute expressions",
ErrorCodes::LOGICAL_ERROR};
#if Poco_NetSSL_FOUND #if Poco_NetSSL_FOUND
// Used for https queries // Used for https queries
@ -199,9 +189,7 @@ DictionarySourcePtr DictionarySourceFactory::create(
} }
} }
throw Exception{ throw Exception{name + ": unknown dictionary source type: " + source_type, ErrorCodes::UNKNOWN_ELEMENT_IN_CONFIG};
name + ": unknown dictionary source type: " + source_type,
ErrorCodes::UNKNOWN_ELEMENT_IN_CONFIG};
} }
} }

View File

@ -83,9 +83,7 @@ AttributeUnderlyingType getAttributeUnderlyingType(const std::string & type)
if (it != std::end(dictionary)) if (it != std::end(dictionary))
return it->second; return it->second;
throw Exception{ throw Exception{"Unknown type " + type, ErrorCodes::UNKNOWN_TYPE};
"Unknown type " + type,
ErrorCodes::UNKNOWN_TYPE};
} }
@ -107,9 +105,7 @@ std::string toString(const AttributeUnderlyingType type)
case AttributeUnderlyingType::String: return "String"; case AttributeUnderlyingType::String: return "String";
} }
throw Exception{ throw Exception{"Unknown attribute_type " + toString(static_cast<int>(type)), ErrorCodes::ARGUMENT_OUT_OF_BOUND};
"Unknown attribute_type " + toString(static_cast<int>(type)),
ErrorCodes::ARGUMENT_OUT_OF_BOUND};
} }
@ -118,9 +114,7 @@ DictionarySpecialAttribute::DictionarySpecialAttribute(const Poco::Util::Abstrac
expression{config.getString(config_prefix + ".expression", "")} expression{config.getString(config_prefix + ".expression", "")}
{ {
if (name.empty() && !expression.empty()) if (name.empty() && !expression.empty())
throw Exception{ throw Exception{"Element " + config_prefix + ".name is empty", ErrorCodes::BAD_ARGUMENTS};
"Element " + config_prefix + ".name is empty",
ErrorCodes::BAD_ARGUMENTS};
} }
@ -169,9 +163,7 @@ DictionaryStructure::DictionaryStructure(const Poco::Util::AbstractConfiguration
void DictionaryStructure::validateKeyTypes(const DataTypes & key_types) const void DictionaryStructure::validateKeyTypes(const DataTypes & key_types) const
{ {
if (key_types.size() != key->size()) if (key_types.size() != key->size())
throw Exception{ throw Exception{"Key structure does not match, expected " + getKeyDescription(), ErrorCodes::TYPE_MISMATCH};
"Key structure does not match, expected " + getKeyDescription(),
ErrorCodes::TYPE_MISMATCH};
for (const auto i : ext::range(0, key_types.size())) for (const auto i : ext::range(0, key_types.size()))
{ {
@ -179,10 +171,8 @@ void DictionaryStructure::validateKeyTypes(const DataTypes & key_types) const
const auto & actual_type = key_types[i]->getName(); const auto & actual_type = key_types[i]->getName();
if (expected_type != actual_type) if (expected_type != actual_type)
throw Exception{ throw Exception{"Key type at position " + std::to_string(i) + " does not match, expected " + expected_type +
"Key type at position " + std::to_string(i) + " does not match, expected " + expected_type + ", found " + actual_type, ErrorCodes::TYPE_MISMATCH};
", found " + actual_type,
ErrorCodes::TYPE_MISMATCH};
} }
} }
@ -240,9 +230,7 @@ static void CheckAttributeKeys(const Poco::Util::AbstractConfiguration::Keys & k
for (const auto & key : keys) for (const auto & key : keys)
{ {
if (valid_keys.find(key) == valid_keys.end()) if (valid_keys.find(key) == valid_keys.end())
throw Exception{ throw Exception{"Unknown key '" + key + "' inside attribute section", ErrorCodes::BAD_ARGUMENTS};
"Unknown key '" + key + "' inside attribute section",
ErrorCodes::BAD_ARGUMENTS};
} }
} }
@ -298,19 +286,13 @@ std::vector<DictionaryAttribute> DictionaryStructure::getAttributes(
const auto injective = config.getBool(prefix + "injective", false); const auto injective = config.getBool(prefix + "injective", false);
const auto is_object_id = config.getBool(prefix + "is_object_id", false); const auto is_object_id = config.getBool(prefix + "is_object_id", false);
if (name.empty()) if (name.empty())
throw Exception{ throw Exception{"Properties 'name' and 'type' of an attribute cannot be empty", ErrorCodes::BAD_ARGUMENTS};
"Properties 'name' and 'type' of an attribute cannot be empty",
ErrorCodes::BAD_ARGUMENTS};
if (has_hierarchy && !hierarchy_allowed) if (has_hierarchy && !hierarchy_allowed)
throw Exception{ throw Exception{"Hierarchy not allowed in '" + prefix, ErrorCodes::BAD_ARGUMENTS};
"Hierarchy not allowed in '" + prefix,
ErrorCodes::BAD_ARGUMENTS};
if (has_hierarchy && hierarchical) if (has_hierarchy && hierarchical)
throw Exception{ throw Exception{"Only one hierarchical attribute supported", ErrorCodes::BAD_ARGUMENTS};
"Only one hierarchical attribute supported",
ErrorCodes::BAD_ARGUMENTS};
has_hierarchy = has_hierarchy || hierarchical; has_hierarchy = has_hierarchy || hierarchical;

View File

@ -56,9 +56,7 @@ void ExternalResultDescription::init(const Block & sample_block_)
else if (typeid_cast<const DataTypeDateTime *>(type)) else if (typeid_cast<const DataTypeDateTime *>(type))
types.push_back(ValueType::DateTime); types.push_back(ValueType::DateTime);
else else
throw Exception{ throw Exception{"Unsupported type " + type->getName(), ErrorCodes::UNKNOWN_TYPE};
"Unsupported type " + type->getName(),
ErrorCodes::UNKNOWN_TYPE};
names.emplace_back(column.name); names.emplace_back(column.name);
sample_columns.emplace_back(column.column); sample_columns.emplace_back(column.column);

View File

@ -117,9 +117,7 @@ void FlatDictionary::get##TYPE(const std::string & attribute_name, const PaddedP
{\ {\
const auto & attribute = getAttribute(attribute_name);\ const auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
const auto null_value = std::get<TYPE>(attribute.null_values);\ const auto null_value = std::get<TYPE>(attribute.null_values);\
\ \
@ -144,9 +142,7 @@ void FlatDictionary::getString(const std::string & attribute_name, const PaddedP
{ {
const auto & attribute = getAttribute(attribute_name); const auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
const auto & null_value = std::get<StringRef>(attribute.null_values); const auto & null_value = std::get<StringRef>(attribute.null_values);
@ -162,9 +158,7 @@ void FlatDictionary::get##TYPE(\
{\ {\
const auto & attribute = getAttribute(attribute_name);\ const auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
getItemsNumber<TYPE>(attribute, ids,\ getItemsNumber<TYPE>(attribute, ids,\
[&] (const size_t row, const auto value) { out[row] = value; },\ [&] (const size_t row, const auto value) { out[row] = value; },\
@ -189,9 +183,7 @@ void FlatDictionary::getString(
{ {
const auto & attribute = getAttribute(attribute_name); const auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
getItemsImpl<StringRef, StringRef>(attribute, ids, getItemsImpl<StringRef, StringRef>(attribute, ids,
[&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); }, [&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); },
@ -205,9 +197,7 @@ void FlatDictionary::get##TYPE(\
{\ {\
const auto & attribute = getAttribute(attribute_name);\ const auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
getItemsNumber<TYPE>(attribute, ids,\ getItemsNumber<TYPE>(attribute, ids,\
[&] (const size_t row, const auto value) { out[row] = value; },\ [&] (const size_t row, const auto value) { out[row] = value; },\
@ -232,9 +222,7 @@ void FlatDictionary::getString(
{ {
const auto & attribute = getAttribute(attribute_name); const auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
FlatDictionary::getItemsImpl<StringRef, StringRef>(attribute, ids, FlatDictionary::getItemsImpl<StringRef, StringRef>(attribute, ids,
[&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); }, [&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); },
@ -279,9 +267,7 @@ void FlatDictionary::createAttributes()
hierarchical_attribute = &attributes.back(); hierarchical_attribute = &attributes.back();
if (hierarchical_attribute->type != AttributeUnderlyingType::UInt64) if (hierarchical_attribute->type != AttributeUnderlyingType::UInt64)
throw Exception{ throw Exception{name + ": hierarchical attribute must be UInt64.", ErrorCodes::TYPE_MISMATCH};
name + ": hierarchical attribute must be UInt64.",
ErrorCodes::TYPE_MISMATCH};
} }
} }
} }
@ -374,7 +360,8 @@ void FlatDictionary::updateData()
void FlatDictionary::loadData() void FlatDictionary::loadData()
{ {
if (!source_ptr->hasUpdateField()) { if (!source_ptr->hasUpdateField())
{
auto stream = source_ptr->loadAll(); auto stream = source_ptr->loadAll();
stream->readPrefix(); stream->readPrefix();
@ -387,9 +374,7 @@ void FlatDictionary::loadData()
updateData(); updateData();
if (require_nonempty && 0 == element_count) if (require_nonempty && 0 == element_count)
throw Exception{ throw Exception{name + ": dictionary source is empty and 'require_nonempty' property is set.", ErrorCodes::DICTIONARY_IS_EMPTY};
name + ": dictionary source is empty and 'require_nonempty' property is set.",
ErrorCodes::DICTIONARY_IS_EMPTY};
} }
@ -530,9 +515,7 @@ template <typename T>
void FlatDictionary::resize(Attribute & attribute, const Key id) void FlatDictionary::resize(Attribute & attribute, const Key id)
{ {
if (id >= max_array_size) if (id >= max_array_size)
throw Exception{ throw Exception{name + ": identifier should be less than " + toString(max_array_size), ErrorCodes::ARGUMENT_OUT_OF_BOUND};
name + ": identifier should be less than " + toString(max_array_size),
ErrorCodes::ARGUMENT_OUT_OF_BOUND};
auto & array = *std::get<ContainerPtrType<T>>(attribute.arrays); auto & array = *std::get<ContainerPtrType<T>>(attribute.arrays);
if (id >= array.size()) if (id >= array.size())
@ -586,9 +569,7 @@ const FlatDictionary::Attribute & FlatDictionary::getAttribute(const std::string
{ {
const auto it = attribute_index_by_name.find(attribute_name); const auto it = attribute_index_by_name.find(attribute_name);
if (it == std::end(attribute_index_by_name)) if (it == std::end(attribute_index_by_name))
throw Exception{ throw Exception{name + ": no such attribute '" + attribute_name + "'", ErrorCodes::BAD_ARGUMENTS};
name + ": no such attribute '" + attribute_name + "'",
ErrorCodes::BAD_ARGUMENTS};
return attributes[it->second]; return attributes[it->second];
} }

View File

@ -114,9 +114,7 @@ void HashedDictionary::get##TYPE(const std::string & attribute_name, const Padde
{\ {\
const auto & attribute = getAttribute(attribute_name);\ const auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
const auto null_value = std::get<TYPE>(attribute.null_values);\ const auto null_value = std::get<TYPE>(attribute.null_values);\
\ \
@ -141,9 +139,7 @@ void HashedDictionary::getString(const std::string & attribute_name, const Padde
{ {
const auto & attribute = getAttribute(attribute_name); const auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
const auto & null_value = StringRef{std::get<String>(attribute.null_values)}; const auto & null_value = StringRef{std::get<String>(attribute.null_values)};
@ -159,9 +155,7 @@ void HashedDictionary::get##TYPE(\
{\ {\
const auto & attribute = getAttribute(attribute_name);\ const auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
getItemsNumber<TYPE>(attribute, ids,\ getItemsNumber<TYPE>(attribute, ids,\
[&] (const size_t row, const auto value) { out[row] = value; },\ [&] (const size_t row, const auto value) { out[row] = value; },\
@ -186,9 +180,7 @@ void HashedDictionary::getString(
{ {
const auto & attribute = getAttribute(attribute_name); const auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
getItemsImpl<StringRef, StringRef>(attribute, ids, getItemsImpl<StringRef, StringRef>(attribute, ids,
[&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); }, [&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); },
@ -201,9 +193,7 @@ void HashedDictionary::get##TYPE(\
{\ {\
const auto & attribute = getAttribute(attribute_name);\ const auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
getItemsNumber<TYPE>(attribute, ids,\ getItemsNumber<TYPE>(attribute, ids,\
[&] (const size_t row, const auto value) { out[row] = value; },\ [&] (const size_t row, const auto value) { out[row] = value; },\
@ -228,9 +218,7 @@ void HashedDictionary::getString(
{ {
const auto & attribute = getAttribute(attribute_name); const auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
getItemsImpl<StringRef, StringRef>(attribute, ids, getItemsImpl<StringRef, StringRef>(attribute, ids,
[&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); }, [&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); },
@ -273,9 +261,7 @@ void HashedDictionary::createAttributes()
hierarchical_attribute = &attributes.back(); hierarchical_attribute = &attributes.back();
if (hierarchical_attribute->type != AttributeUnderlyingType::UInt64) if (hierarchical_attribute->type != AttributeUnderlyingType::UInt64)
throw Exception{ throw Exception{name + ": hierarchical attribute must be UInt64.", ErrorCodes::TYPE_MISMATCH};
name + ": hierarchical attribute must be UInt64.",
ErrorCodes::TYPE_MISMATCH};
} }
} }
} }
@ -368,7 +354,8 @@ void HashedDictionary::updateData()
void HashedDictionary::loadData() void HashedDictionary::loadData()
{ {
if (!source_ptr->hasUpdateField()) { if (!source_ptr->hasUpdateField())
{
auto stream = source_ptr->loadAll(); auto stream = source_ptr->loadAll();
stream->readPrefix(); stream->readPrefix();
@ -381,9 +368,7 @@ void HashedDictionary::loadData()
updateData(); updateData();
if (require_nonempty && 0 == element_count) if (require_nonempty && 0 == element_count)
throw Exception{ throw Exception{name + ": dictionary source is empty and 'require_nonempty' property is set.", ErrorCodes::DICTIONARY_IS_EMPTY};
name + ": dictionary source is empty and 'require_nonempty' property is set.",
ErrorCodes::DICTIONARY_IS_EMPTY};
} }
template <typename T> template <typename T>
@ -545,9 +530,7 @@ const HashedDictionary::Attribute & HashedDictionary::getAttribute(const std::st
{ {
const auto it = attribute_index_by_name.find(attribute_name); const auto it = attribute_index_by_name.find(attribute_name);
if (it == std::end(attribute_index_by_name)) if (it == std::end(attribute_index_by_name))
throw Exception{ throw Exception{name + ": no such attribute '" + attribute_name + "'", ErrorCodes::BAD_ARGUMENTS};
name + ": no such attribute '" + attribute_name + "'",
ErrorCodes::BAD_ARGUMENTS};
return attributes[it->second]; return attributes[it->second];
} }

View File

@ -104,17 +104,15 @@ namespace
break; break;
} }
throw Exception{ throw Exception{"Type mismatch, expected String, got type id = " + toString(value.type()) +
"Type mismatch, expected String, got type id = " + toString(value.type()) + " for column " + name, ErrorCodes::TYPE_MISMATCH};
" for column " + name, ErrorCodes::TYPE_MISMATCH};
} }
case ValueType::Date: case ValueType::Date:
{ {
if (value.type() != Poco::MongoDB::ElementTraits<Poco::Timestamp>::TypeId) if (value.type() != Poco::MongoDB::ElementTraits<Poco::Timestamp>::TypeId)
throw Exception{ throw Exception{"Type mismatch, expected Timestamp, got type id = " + toString(value.type()) +
"Type mismatch, expected Timestamp, got type id = " + toString(value.type()) + " for column " + name, ErrorCodes::TYPE_MISMATCH};
" for column " + name, ErrorCodes::TYPE_MISMATCH};
static_cast<ColumnUInt16 &>(column).getData().push_back( static_cast<ColumnUInt16 &>(column).getData().push_back(
UInt16{DateLUT::instance().toDayNum( UInt16{DateLUT::instance().toDayNum(
@ -125,9 +123,8 @@ namespace
case ValueType::DateTime: case ValueType::DateTime:
{ {
if (value.type() != Poco::MongoDB::ElementTraits<Poco::Timestamp>::TypeId) if (value.type() != Poco::MongoDB::ElementTraits<Poco::Timestamp>::TypeId)
throw Exception{ throw Exception{"Type mismatch, expected Timestamp, got type id = " + toString(value.type()) +
"Type mismatch, expected Timestamp, got type id = " + toString(value.type()) + " for column " + name, ErrorCodes::TYPE_MISMATCH};
" for column " + name, ErrorCodes::TYPE_MISMATCH};
static_cast<ColumnUInt32 &>(column).getData().push_back( static_cast<ColumnUInt32 &>(column).getData().push_back(
static_cast<const Poco::MongoDB::ConcreteElement<Poco::Timestamp> &>(value).value().epochTime()); static_cast<const Poco::MongoDB::ConcreteElement<Poco::Timestamp> &>(value).value().epochTime());

View File

@ -24,9 +24,7 @@ MySQLBlockInputStream::MySQLBlockInputStream(
max_block_size{max_block_size} max_block_size{max_block_size}
{ {
if (sample_block.columns() != result.getNumFields()) if (sample_block.columns() != result.getNumFields())
throw Exception{ throw Exception{"mysqlxx::UseQueryResult contains " + toString(result.getNumFields()) + " columns while " + toString(sample_block.columns()) + " expected",
"mysqlxx::UseQueryResult contains " + toString(result.getNumFields()) + " columns while " +
toString(sample_block.columns()) + " expected",
ErrorCodes::NUMBER_OF_COLUMNS_DOESNT_MATCH}; ErrorCodes::NUMBER_OF_COLUMNS_DOESNT_MATCH};
description.init(sample_block); description.init(sample_block);

View File

@ -29,10 +29,8 @@ ODBCBlockInputStream::ODBCBlockInputStream(
log(&Logger::get("ODBCBlockInputStream")) log(&Logger::get("ODBCBlockInputStream"))
{ {
if (sample_block.columns() != result.columnCount()) if (sample_block.columns() != result.columnCount())
throw Exception{ throw Exception{"RecordSet contains " + toString(result.columnCount()) + " columns while " +
"RecordSet contains " + toString(result.columnCount()) + " columns while " + toString(sample_block.columns()) + " expected", ErrorCodes::NUMBER_OF_COLUMNS_DOESNT_MATCH};
toString(sample_block.columns()) + " expected",
ErrorCodes::NUMBER_OF_COLUMNS_DOESNT_MATCH};
description.init(sample_block); description.init(sample_block);
} }

View File

@ -102,9 +102,7 @@ void RangeHashedDictionary::createAttributes()
attributes.push_back(createAttributeWithType(attribute.underlying_type, attribute.null_value)); attributes.push_back(createAttributeWithType(attribute.underlying_type, attribute.null_value));
if (attribute.hierarchical) if (attribute.hierarchical)
throw Exception{ throw Exception{name + ": hierarchical attributes not supported by " + getName() + " dictionary.", ErrorCodes::BAD_ARGUMENTS};
name + ": hierarchical attributes not supported by " + getName() + " dictionary.",
ErrorCodes::BAD_ARGUMENTS};
} }
} }
@ -136,9 +134,7 @@ void RangeHashedDictionary::loadData()
stream->readSuffix(); stream->readSuffix();
if (require_nonempty && 0 == element_count) if (require_nonempty && 0 == element_count)
throw Exception{ throw Exception{name + ": dictionary source is empty and 'require_nonempty' property is set.", ErrorCodes::DICTIONARY_IS_EMPTY};
name + ": dictionary source is empty and 'require_nonempty' property is set.",
ErrorCodes::DICTIONARY_IS_EMPTY};
} }
template <typename T> template <typename T>
@ -284,7 +280,8 @@ void RangeHashedDictionary::setAttributeValueImpl(Attribute & attribute, const K
auto & values = it->second; auto & values = it->second;
const auto insert_it = std::lower_bound(std::begin(values), std::end(values), range, const auto insert_it = std::lower_bound(std::begin(values), std::end(values), range,
[] (const Value<T> & lhs, const Range & range) { [] (const Value<T> & lhs, const Range & range)
{
return lhs.range < range; return lhs.range < range;
}); });
@ -342,9 +339,7 @@ const RangeHashedDictionary::Attribute & RangeHashedDictionary::getAttribute(con
{ {
const auto it = attribute_index_by_name.find(attribute_name); const auto it = attribute_index_by_name.find(attribute_name);
if (it == std::end(attribute_index_by_name)) if (it == std::end(attribute_index_by_name))
throw Exception{ throw Exception{name + ": no such attribute '" + attribute_name + "'", ErrorCodes::BAD_ARGUMENTS};
name + ": no such attribute '" + attribute_name + "'",
ErrorCodes::BAD_ARGUMENTS};
return attributes[it->second]; return attributes[it->second];
} }
@ -353,9 +348,7 @@ const RangeHashedDictionary::Attribute & RangeHashedDictionary::getAttributeWith
{ {
const auto & attribute = getAttribute(name); const auto & attribute = getAttribute(name);
if (attribute.type != type) if (attribute.type != type)
throw Exception{ throw Exception{name + ": type mismatch: attribute " + name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
return attribute; return attribute;
} }

View File

@ -68,9 +68,7 @@ void TrieDictionary::get##TYPE(\
\ \
const auto & attribute = getAttribute(attribute_name);\ const auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
const auto null_value = std::get<TYPE>(attribute.null_values);\ const auto null_value = std::get<TYPE>(attribute.null_values);\
\ \
@ -99,9 +97,7 @@ void TrieDictionary::getString(
const auto & attribute = getAttribute(attribute_name); const auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
const auto & null_value = StringRef{std::get<String>(attribute.null_values)}; const auto & null_value = StringRef{std::get<String>(attribute.null_values)};
@ -119,9 +115,7 @@ void TrieDictionary::get##TYPE(\
\ \
const auto & attribute = getAttribute(attribute_name);\ const auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
getItemsNumber<TYPE>(attribute, key_columns,\ getItemsNumber<TYPE>(attribute, key_columns,\
[&] (const size_t row, const auto value) { out[row] = value; },\ [&] (const size_t row, const auto value) { out[row] = value; },\
@ -148,9 +142,7 @@ void TrieDictionary::getString(
const auto & attribute = getAttribute(attribute_name); const auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
getItemsImpl<StringRef, StringRef>(attribute, key_columns, getItemsImpl<StringRef, StringRef>(attribute, key_columns,
[&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); }, [&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); },
@ -166,9 +158,7 @@ void TrieDictionary::get##TYPE(\
\ \
const auto & attribute = getAttribute(attribute_name);\ const auto & attribute = getAttribute(attribute_name);\
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\ if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::TYPE))\
throw Exception{\ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};\
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),\
ErrorCodes::TYPE_MISMATCH};\
\ \
getItemsNumber<TYPE>(attribute, key_columns,\ getItemsNumber<TYPE>(attribute, key_columns,\
[&] (const size_t row, const auto value) { out[row] = value; },\ [&] (const size_t row, const auto value) { out[row] = value; },\
@ -195,9 +185,7 @@ void TrieDictionary::getString(
const auto & attribute = getAttribute(attribute_name); const auto & attribute = getAttribute(attribute_name);
if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String)) if (!isAttributeTypeConvertibleTo(attribute.type, AttributeUnderlyingType::String))
throw Exception{ throw Exception{name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type), ErrorCodes::TYPE_MISMATCH};
name + ": type mismatch: attribute " + attribute_name + " has type " + toString(attribute.type),
ErrorCodes::TYPE_MISMATCH};
getItemsImpl<StringRef, StringRef>(attribute, key_columns, getItemsImpl<StringRef, StringRef>(attribute, key_columns,
[&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); }, [&] (const size_t, const StringRef value) { out->insertData(value.data, value.size); },
@ -238,9 +226,7 @@ void TrieDictionary::createAttributes()
attributes.push_back(createAttributeWithType(attribute.underlying_type, attribute.null_value)); attributes.push_back(createAttributeWithType(attribute.underlying_type, attribute.null_value));
if (attribute.hierarchical) if (attribute.hierarchical)
throw Exception{ throw Exception{name + ": hierarchical attributes not supported for dictionary of type " + getTypeName(), ErrorCodes::TYPE_MISMATCH};
name + ": hierarchical attributes not supported for dictionary of type " + getTypeName(),
ErrorCodes::TYPE_MISMATCH};
} }
} }
@ -290,9 +276,7 @@ void TrieDictionary::loadData()
stream->readSuffix(); stream->readSuffix();
if (require_nonempty && 0 == element_count) if (require_nonempty && 0 == element_count)
throw Exception{ throw Exception{name + ": dictionary source is empty and 'require_nonempty' property is set.", ErrorCodes::DICTIONARY_IS_EMPTY};
name + ": dictionary source is empty and 'require_nonempty' property is set.",
ErrorCodes::DICTIONARY_IS_EMPTY};
} }
template <typename T> template <typename T>
@ -338,16 +322,12 @@ void TrieDictionary::calculateBytesAllocated()
void TrieDictionary::validateKeyTypes(const DataTypes & key_types) const void TrieDictionary::validateKeyTypes(const DataTypes & key_types) const
{ {
if (key_types.size() != 1) if (key_types.size() != 1)
throw Exception{ throw Exception{"Expected a single IP address", ErrorCodes::TYPE_MISMATCH};
"Expected a single IP address",
ErrorCodes::TYPE_MISMATCH};
const auto & actual_type = key_types[0]->getName(); const auto & actual_type = key_types[0]->getName();
if (actual_type != "UInt32" && actual_type != "FixedString(16)") if (actual_type != "UInt32" && actual_type != "FixedString(16)")
throw Exception{ throw Exception{"Key does not match, expected either UInt32 or FixedString(16)", ErrorCodes::TYPE_MISMATCH};
"Key does not match, expected either UInt32 or FixedString(16)",
ErrorCodes::TYPE_MISMATCH};
} }
@ -526,9 +506,7 @@ const TrieDictionary::Attribute & TrieDictionary::getAttribute(const std::string
{ {
const auto it = attribute_index_by_name.find(attribute_name); const auto it = attribute_index_by_name.find(attribute_name);
if (it == std::end(attribute_index_by_name)) if (it == std::end(attribute_index_by_name))
throw Exception{ throw Exception{name + ": no such attribute '" + attribute_name + "'", ErrorCodes::BAD_ARGUMENTS};
name + ": no such attribute '" + attribute_name + "'",
ErrorCodes::BAD_ARGUMENTS};
return attributes[it->second]; return attributes[it->second];
} }

View File

@ -2,77 +2,77 @@ include(${ClickHouse_SOURCE_DIR}/cmake/dbms_glob_sources.cmake)
include(${ClickHouse_SOURCE_DIR}/cmake/dbms_generate_function.cmake) include(${ClickHouse_SOURCE_DIR}/cmake/dbms_generate_function.cmake)
generate_function_register(Arithmetic generate_function_register(Arithmetic
FunctionPlus FunctionPlus
FunctionMinus FunctionMinus
FunctionMultiply FunctionMultiply
FunctionDivideFloating FunctionDivideFloating
FunctionDivideIntegral FunctionDivideIntegral
FunctionDivideIntegralOrZero FunctionDivideIntegralOrZero
FunctionModulo FunctionModulo
FunctionNegate FunctionNegate
FunctionAbs FunctionAbs
FunctionBitAnd FunctionBitAnd
FunctionBitOr FunctionBitOr
FunctionBitXor FunctionBitXor
FunctionBitNot FunctionBitNot
FunctionBitShiftLeft FunctionBitShiftLeft
FunctionBitShiftRight FunctionBitShiftRight
FunctionBitRotateLeft FunctionBitRotateLeft
FunctionBitRotateRight FunctionBitRotateRight
FunctionLeast FunctionLeast
FunctionGreatest FunctionGreatest
FunctionBitTest FunctionBitTest
FunctionBitTestAny FunctionBitTestAny
FunctionBitTestAll FunctionBitTestAll
FunctionGCD FunctionGCD
FunctionLCM FunctionLCM
FunctionIntExp2 FunctionIntExp2
FunctionIntExp10 FunctionIntExp10
) )
generate_function_register(Array generate_function_register(Array
FunctionArray FunctionArray
FunctionArrayElement FunctionArrayElement
FunctionHas FunctionHas
FunctionIndexOf FunctionIndexOf
FunctionCountEqual FunctionCountEqual
FunctionArrayEnumerate FunctionArrayEnumerate
FunctionArrayEnumerateUniq FunctionArrayEnumerateUniq
FunctionArrayUniq FunctionArrayUniq
FunctionEmptyArrayUInt8 FunctionEmptyArrayUInt8
FunctionEmptyArrayUInt16 FunctionEmptyArrayUInt16
FunctionEmptyArrayUInt32 FunctionEmptyArrayUInt32
FunctionEmptyArrayUInt64 FunctionEmptyArrayUInt64
FunctionEmptyArrayInt8 FunctionEmptyArrayInt8
FunctionEmptyArrayInt16 FunctionEmptyArrayInt16
FunctionEmptyArrayInt32 FunctionEmptyArrayInt32
FunctionEmptyArrayInt64 FunctionEmptyArrayInt64
FunctionEmptyArrayFloat32 FunctionEmptyArrayFloat32
FunctionEmptyArrayFloat64 FunctionEmptyArrayFloat64
FunctionEmptyArrayDate FunctionEmptyArrayDate
FunctionEmptyArrayDateTime FunctionEmptyArrayDateTime
FunctionEmptyArrayString FunctionEmptyArrayString
FunctionEmptyArrayToSingle FunctionEmptyArrayToSingle
FunctionRange FunctionRange
FunctionArrayReduce FunctionArrayReduce
FunctionArrayReverse FunctionArrayReverse
FunctionArrayConcat FunctionArrayConcat
FunctionArraySlice FunctionArraySlice
FunctionArrayPushBack FunctionArrayPushBack
FunctionArrayPushFront FunctionArrayPushFront
FunctionArrayPopBack FunctionArrayPopBack
FunctionArrayPopFront FunctionArrayPopFront
FunctionArrayHasAll FunctionArrayHasAll
FunctionArrayHasAny FunctionArrayHasAny
FunctionArrayIntersect FunctionArrayIntersect
FunctionArrayResize FunctionArrayResize
) )
generate_function_register(Projection generate_function_register(Projection
FunctionOneOrZero FunctionOneOrZero
FunctionProject FunctionProject
FunctionBuildProjectionComposition FunctionBuildProjectionComposition
FunctionRestoreProjection FunctionRestoreProjection
) )

View File

@ -1114,17 +1114,13 @@ public:
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{ {
if (arguments.size() < 2) if (arguments.size() < 2)
throw Exception{ throw Exception{"Number of arguments for function " + getName() + " doesn't match: passed "
"Number of arguments for function " + getName() + " doesn't match: passed " + toString(arguments.size()) + ", should be at least 2.", ErrorCodes::TOO_LESS_ARGUMENTS_FOR_FUNCTION};
+ toString(arguments.size()) + ", should be at least 2.",
ErrorCodes::TOO_LESS_ARGUMENTS_FOR_FUNCTION};
const auto first_arg = arguments.front().get(); const auto first_arg = arguments.front().get();
if (!first_arg->isInteger()) if (!first_arg->isInteger())
throw Exception{ throw Exception{"Illegal type " + first_arg->getName() + " of first argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
"Illegal type " + first_arg->getName() + " of first argument of function " + getName(),
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
for (const auto i : ext::range(1, arguments.size())) for (const auto i : ext::range(1, arguments.size()))
@ -1132,9 +1128,7 @@ public:
const auto pos_arg = arguments[i].get(); const auto pos_arg = arguments[i].get();
if (!pos_arg->isUnsignedInteger()) if (!pos_arg->isUnsignedInteger())
throw Exception{ throw Exception{"Illegal type " + pos_arg->getName() + " of " + toString(i) + " argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
"Illegal type " + pos_arg->getName() + " of " + toString(i) + " argument of function " + getName(),
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
} }
return std::make_shared<DataTypeUInt8>(); return std::make_shared<DataTypeUInt8>();
@ -1152,9 +1146,7 @@ public:
&& !execute<Int16>(block, arguments, result, value_col) && !execute<Int16>(block, arguments, result, value_col)
&& !execute<Int32>(block, arguments, result, value_col) && !execute<Int32>(block, arguments, result, value_col)
&& !execute<Int64>(block, arguments, result, value_col)) && !execute<Int64>(block, arguments, result, value_col))
throw Exception{ throw Exception{"Illegal column " + value_col->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_COLUMN};
"Illegal column " + value_col->getName() + " of argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN};
} }
private: private:
@ -1255,9 +1247,7 @@ private:
&& !addToMaskImpl<UInt16>(mask, pos_col) && !addToMaskImpl<UInt16>(mask, pos_col)
&& !addToMaskImpl<UInt32>(mask, pos_col) && !addToMaskImpl<UInt32>(mask, pos_col)
&& !addToMaskImpl<UInt64>(mask, pos_col)) && !addToMaskImpl<UInt64>(mask, pos_col))
throw Exception{ throw Exception{"Illegal column " + pos_col->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_COLUMN};
"Illegal column " + pos_col->getName() + " of argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN};
} }
return mask; return mask;

View File

@ -1962,8 +1962,7 @@ DataTypePtr FunctionRange::getReturnTypeImpl(const DataTypes & arguments) const
const DataTypePtr & arg = arguments.front(); const DataTypePtr & arg = arguments.front();
if (!arg->isUnsignedInteger()) if (!arg->isUnsignedInteger())
throw Exception{ throw Exception{"Illegal type " + arg->getName() + " of argument of function " + getName(),
"Illegal type " + arg->getName() + " of argument of function " + getName(),
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT}; ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
return std::make_shared<DataTypeArray>(arg); return std::make_shared<DataTypeArray>(arg);
@ -1982,17 +1981,15 @@ bool FunctionRange::executeInternal(Block & block, const IColumn * arg, const si
{ {
const auto sum = lhs + rhs; const auto sum = lhs + rhs;
if (sum < lhs) if (sum < lhs)
throw Exception{ throw Exception{"A call to function " + getName() + " overflows, investigate the values of arguments you are passing",
"A call to function " + getName() + " overflows, investigate the values of arguments you are passing",
ErrorCodes::ARGUMENT_OUT_OF_BOUND}; ErrorCodes::ARGUMENT_OUT_OF_BOUND};
return sum; return sum;
}); });
if (total_values > max_elements) if (total_values > max_elements)
throw Exception{ throw Exception{"A call to function " + getName() + " would produce " + std::to_string(total_values) +
"A call to function " + getName() + " would produce " + std::to_string(total_values) + " array elements, which is greater than the allowed maximum of " + std::to_string(max_elements),
" array elements, which is greater than the allowed maximum of " + std::to_string(max_elements),
ErrorCodes::ARGUMENT_OUT_OF_BOUND}; ErrorCodes::ARGUMENT_OUT_OF_BOUND};
auto data_col = ColumnVector<T>::create(total_values); auto data_col = ColumnVector<T>::create(total_values);
@ -2027,9 +2024,7 @@ void FunctionRange::executeImpl(Block & block, const ColumnNumbers & arguments,
!executeInternal<UInt32>(block, col, result) && !executeInternal<UInt32>(block, col, result) &&
!executeInternal<UInt64>(block, col, result)) !executeInternal<UInt64>(block, col, result))
{ {
throw Exception{ throw Exception{"Illegal column " + col->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_COLUMN};
"Illegal column " + col->getName() + " of argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN};
} }
} }

View File

@ -1166,10 +1166,8 @@ private:
|| executeConst(block, arguments, result) || executeConst(block, arguments, result)
|| executeString(block, arguments, result) || executeString(block, arguments, result)
|| executeGeneric(block, arguments, result))) || executeGeneric(block, arguments, result)))
throw Exception{ throw Exception{"Illegal column " + block.getByPosition(arguments[0]).column->getName()
"Illegal column " + block.getByPosition(arguments[0]).column->getName() + " of first argument of function " + getName(), ErrorCodes::ILLEGAL_COLUMN};
+ " of first argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN};
} }
}; };

View File

@ -779,10 +779,8 @@ private:
const auto column_string = checkAndGetColumnConst<ColumnString>(column_string_untyped); const auto column_string = checkAndGetColumnConst<ColumnString>(column_string_untyped);
if (!column_string || !legal_types) if (!column_string || !legal_types)
throw Exception{ throw Exception{"Illegal columns " + col_left_untyped->getName() + " and " + col_right_untyped->getName()
"Illegal columns " + col_left_untyped->getName() + " and " + col_right_untyped->getName() + " of arguments of function " + getName(), ErrorCodes::ILLEGAL_COLUMN};
+ " of arguments of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN};
StringRef string_value = column_string->getDataAt(0); StringRef string_value = column_string->getDataAt(0);

View File

@ -942,9 +942,7 @@ public:
{ {
const auto src_n = column_fixed_string->getN(); const auto src_n = column_fixed_string->getN();
if (src_n > n) if (src_n > n)
throw Exception{ throw Exception{"String too long for type FixedString(" + toString(n) + ")", ErrorCodes::TOO_LARGE_STRING_SIZE};
"String too long for type FixedString(" + toString(n) + ")",
ErrorCodes::TOO_LARGE_STRING_SIZE};
auto column_fixed = ColumnFixedString::create(n); auto column_fixed = ColumnFixedString::create(n);

View File

@ -638,20 +638,19 @@ public:
if (arguments.size() == 1) if (arguments.size() == 1)
{ {
if (!arguments[0].type->isDateOrDateTime()) if (!arguments[0].type->isDateOrDateTime())
throw Exception{ throw Exception("Illegal type " + arguments[0].type->getName() + " of argument of function " + getName() +
"Illegal type " + arguments[0].type->getName() + " of argument of function " + getName() + ". Should be a date or a date with time", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
". Should be a date or a date with time", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
} }
else if (arguments.size() == 2) else if (arguments.size() == 2)
{ {
if (!checkDataType<DataTypeDateTime>(arguments[0].type.get()) if (!checkDataType<DataTypeDateTime>(arguments[0].type.get())
|| !checkDataType<DataTypeString>(arguments[1].type.get())) || !checkDataType<DataTypeString>(arguments[1].type.get()))
throw Exception{ throw Exception(
"Function " + getName() + " supports 1 or 2 arguments. The 1st argument " "Function " + getName() + " supports 1 or 2 arguments. The 1st argument "
"must be of type Date or DateTime. The 2nd argument (optional) must be " "must be of type Date or DateTime. The 2nd argument (optional) must be "
"a constant string with timezone name. The timezone argument is allowed " "a constant string with timezone name. The timezone argument is allowed "
"only when the 1st argument has the type DateTime", "only when the 1st argument has the type DateTime",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT}; ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
} }
else else
throw Exception("Number of arguments for function " + getName() + " doesn't match: passed " throw Exception("Number of arguments for function " + getName() + " doesn't match: passed "
@ -953,21 +952,20 @@ public:
if (arguments.size() == 2) if (arguments.size() == 2)
{ {
if (!arguments[0].type->isDateOrDateTime()) if (!arguments[0].type->isDateOrDateTime())
throw Exception{ throw Exception{"Illegal type " + arguments[0].type->getName() + " of argument of function " + getName() +
"Illegal type " + arguments[0].type->getName() + " of argument of function " + getName() +
". Should be a date or a date with time", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT}; ". Should be a date or a date with time", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
} }
else else
{ {
if (!checkDataType<DataTypeDateTime>(arguments[0].type.get()) if (!checkDataType<DataTypeDateTime>(arguments[0].type.get())
|| !checkDataType<DataTypeString>(arguments[2].type.get())) || !checkDataType<DataTypeString>(arguments[2].type.get()))
throw Exception{ throw Exception(
"Function " + getName() + " supports 2 or 3 arguments. The 1st argument " "Function " + getName() + " supports 2 or 3 arguments. The 1st argument "
"must be of type Date or DateTime. The 2nd argument must be number. " "must be of type Date or DateTime. The 2nd argument must be number. "
"The 3rd argument (optional) must be " "The 3rd argument (optional) must be "
"a constant string with timezone name. The timezone argument is allowed " "a constant string with timezone name. The timezone argument is allowed "
"only when the 1st argument has the type DateTime", "only when the 1st argument has the type DateTime",
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT}; ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
} }
if (checkDataType<DataTypeDate>(arguments[0].type.get())) if (checkDataType<DataTypeDate>(arguments[0].type.get()))
@ -1299,8 +1297,7 @@ public:
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
if (!checkDataType<DataTypeDateTime>(arguments[0].type.get())) if (!checkDataType<DataTypeDateTime>(arguments[0].type.get()))
throw Exception{ throw Exception{"Illegal type " + arguments[0].type->getName() + " of argument of function " + getName() +
"Illegal type " + arguments[0].type->getName() + " of argument of function " + getName() +
". Should be DateTime", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT}; ". Should be DateTime", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
String time_zone_name = extractTimeZoneNameFromFunctionArguments(arguments, 1, 0); String time_zone_name = extractTimeZoneNameFromFunctionArguments(arguments, 1, 0);

View File

@ -702,24 +702,18 @@ public:
{ {
const auto arg_count = arguments.size(); const auto arg_count = arguments.size();
if (arg_count != 1 && arg_count != 2) if (arg_count != 1 && arg_count != 2)
throw Exception{ throw Exception{"Number of arguments for function " + getName() + " doesn't match: passed " +
"Number of arguments for function " + getName() + " doesn't match: passed " + toString(arg_count) + ", should be 1 or 2.", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH};
toString(arg_count) + ", should be 1 or 2.",
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH};
const auto first_arg = arguments.front().get(); const auto first_arg = arguments.front().get();
if (!checkDataType<DataTypeString>(first_arg)) if (!checkDataType<DataTypeString>(first_arg))
throw Exception{ throw Exception{"Illegal type " + first_arg->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
"Illegal type " + first_arg->getName() + " of argument of function " + getName(),
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
if (arg_count == 2) if (arg_count == 2)
{ {
const auto second_arg = arguments.back().get(); const auto second_arg = arguments.back().get();
if (!second_arg->isInteger()) if (!second_arg->isInteger())
throw Exception{ throw Exception{"Illegal type " + second_arg->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
"Illegal type " + second_arg->getName() + " of argument of function " + getName(),
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
} }
return std::make_shared<DataTypeUInt64>(); return std::make_shared<DataTypeUInt64>();
@ -762,19 +756,15 @@ private:
block.getByPosition(result).column = std::move(col_to); block.getByPosition(result).column = std::move(col_to);
} }
else else
throw Exception{ throw Exception{"Illegal column " + block.getByPosition(arguments[0]).column->getName() +
"Illegal column " + block.getByPosition(arguments[0]).column->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_COLUMN};
" of argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN};
} }
void executeTwoArgs(Block & block, const ColumnNumbers & arguments, const size_t result) const void executeTwoArgs(Block & block, const ColumnNumbers & arguments, const size_t result) const
{ {
const auto level_col = block.getByPosition(arguments.back()).column.get(); const auto level_col = block.getByPosition(arguments.back()).column.get();
if (!level_col->isColumnConst()) if (!level_col->isColumnConst())
throw Exception{ throw Exception{"Second argument of function " + getName() + " must be an integral constant", ErrorCodes::ILLEGAL_COLUMN};
"Second argument of function " + getName() + " must be an integral constant",
ErrorCodes::ILLEGAL_COLUMN};
const auto level = level_col->get64(0); const auto level = level_col->get64(0);
@ -796,10 +786,8 @@ private:
block.getByPosition(result).column = std::move(col_to); block.getByPosition(result).column = std::move(col_to);
} }
else else
throw Exception{ throw Exception{"Illegal column " + block.getByPosition(arguments[0]).column->getName() +
"Illegal column " + block.getByPosition(arguments[0]).column->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_COLUMN};
" of argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN};
} }
}; };

View File

@ -79,9 +79,7 @@ private:
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{ {
if (!arguments.front()->isNumber()) if (!arguments.front()->isNumber())
throw Exception{ throw Exception{"Illegal type " + arguments.front()->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
"Illegal type " + arguments.front()->getName() + " of argument of function " + getName(),
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
return std::make_shared<DataTypeFloat64>(); return std::make_shared<DataTypeFloat64>();
} }
@ -140,9 +138,7 @@ private:
!execute<Float32>(block, arg, result) && !execute<Float32>(block, arg, result) &&
!execute<Float64>(block, arg, result)) !execute<Float64>(block, arg, result))
{ {
throw Exception{ throw Exception{"Illegal column " + arg->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_COLUMN};
"Illegal column " + arg->getName() + " of argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN};
} }
} }
}; };
@ -204,8 +200,7 @@ private:
const auto check_argument_type = [this] (const IDataType * arg) const auto check_argument_type = [this] (const IDataType * arg)
{ {
if (!arg->isNumber()) if (!arg->isNumber())
throw Exception{ throw Exception{"Illegal type " + arg->getName() + " of argument of function " + getName(),
"Illegal type " + arg->getName() + " of argument of function " + getName(),
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT}; ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
}; };
@ -352,8 +347,7 @@ private:
} }
else else
{ {
throw Exception{ throw Exception{"Illegal column " + block.getByPosition(arguments[1]).column->getName() +
"Illegal column " + block.getByPosition(arguments[1]).column->getName() +
" of second argument of function " + getName(), " of second argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN}; ErrorCodes::ILLEGAL_COLUMN};
} }
@ -377,8 +371,7 @@ private:
} }
else else
{ {
throw Exception{ throw Exception{"Illegal column " + block.getByPosition(arguments[1]).column->getName() +
"Illegal column " + block.getByPosition(arguments[1]).column->getName() +
" of second argument of function " + getName(), " of second argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN}; ErrorCodes::ILLEGAL_COLUMN};
} }
@ -402,8 +395,7 @@ private:
!executeLeft<Float32>(block, arguments, result, left_arg) && !executeLeft<Float32>(block, arguments, result, left_arg) &&
!executeLeft<Float64>(block, arguments, result, left_arg)) !executeLeft<Float64>(block, arguments, result, left_arg))
{ {
throw Exception{ throw Exception{"Illegal column " + left_arg->getName() + " of argument of function " + getName(),
"Illegal column " + left_arg->getName() + " of argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN}; ErrorCodes::ILLEGAL_COLUMN};
} }
} }

View File

@ -715,8 +715,7 @@ public:
{ {
const auto arg = arguments[arg_idx].get(); const auto arg = arguments[arg_idx].get();
if (!arg->isStringOrFixedString()) if (!arg->isStringOrFixedString())
throw Exception{ throw Exception{"Illegal type " + arg->getName() + " of argument " + std::to_string(arg_idx + 1) + " of function " + getName(),
"Illegal type " + arg->getName() + " of argument " + std::to_string(arg_idx + 1) + " of function " + getName(),
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT}; ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
} }
@ -1017,12 +1016,10 @@ private:
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
{ {
if (!arguments[0]->isString()) if (!arguments[0]->isString())
throw Exception{ throw Exception{"Illegal type " + arguments[0]->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
"Illegal type " + arguments[0]->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
if (!arguments[1]->isString()) if (!arguments[1]->isString())
throw Exception{ throw Exception{"Illegal type " + arguments[1]->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
"Illegal type " + arguments[1]->getName() + " of argument of function " + getName(), ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT};
return std::make_shared<DataTypeString>(); return std::make_shared<DataTypeString>();
} }
@ -1081,8 +1078,7 @@ private:
block.getByPosition(result).column = std::move(col_res); block.getByPosition(result).column = std::move(col_res);
} }
else else
throw Exception{ throw Exception{"Illegal column " + block.getByPosition(arguments[0]).column->getName() + " of argument of function " + getName(),
"Illegal column " + block.getByPosition(arguments[0]).column->getName() + " of argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN}; ErrorCodes::ILLEGAL_COLUMN};
} }
}; };

View File

@ -72,9 +72,7 @@ public:
{ {
const auto args_size = arguments.size(); const auto args_size = arguments.size();
if (args_size != 3 && args_size != 4) if (args_size != 3 && args_size != 4)
throw Exception{ throw Exception{"Number of arguments for function " + getName() + " doesn't match: passed " + toString(args_size) + ", should be 3 or 4",
"Number of arguments for function " + getName() + " doesn't match: passed " +
toString(args_size) + ", should be 3 or 4",
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH}; ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH};
const DataTypePtr & type_x = arguments[0]; const DataTypePtr & type_x = arguments[0];
@ -180,9 +178,7 @@ public:
&& !executeNum<Float64>(in, out, default_column) && !executeNum<Float64>(in, out, default_column)
&& !executeString(in, out, default_column)) && !executeString(in, out, default_column))
{ {
throw Exception{ throw Exception{"Illegal column " + in->getName() + " of first argument of function " + getName(), ErrorCodes::ILLEGAL_COLUMN};
"Illegal column " + in->getName() + " of first argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN};
} }
block.getByPosition(result).column = std::move(column_result); block.getByPosition(result).column = std::move(column_result);
@ -246,8 +242,7 @@ private:
&& !executeNumToNumWithConstDefault<T, Float64>(in, out_untyped) && !executeNumToNumWithConstDefault<T, Float64>(in, out_untyped)
&& !executeNumToStringWithConstDefault<T>(in, out_untyped)) && !executeNumToStringWithConstDefault<T>(in, out_untyped))
{ {
throw Exception{ throw Exception{"Illegal column " + in->getName() + " of elements of array of second argument of function " + getName(),
"Illegal column " + in->getName() + " of elements of array of second argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN}; ErrorCodes::ILLEGAL_COLUMN};
} }
} }
@ -265,8 +260,7 @@ private:
&& !executeNumToNumWithNonConstDefault<T, Float64>(in, out_untyped, default_untyped) && !executeNumToNumWithNonConstDefault<T, Float64>(in, out_untyped, default_untyped)
&& !executeNumToStringWithNonConstDefault<T>(in, out_untyped, default_untyped)) && !executeNumToStringWithNonConstDefault<T>(in, out_untyped, default_untyped))
{ {
throw Exception{ throw Exception{"Illegal column " + in->getName() + " of elements of array of second argument of function " + getName(),
"Illegal column " + in->getName() + " of elements of array of second argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN}; ErrorCodes::ILLEGAL_COLUMN};
} }
} }
@ -284,11 +278,8 @@ private:
if (!default_untyped) if (!default_untyped)
{ {
if (!executeStringToString(in, out_untyped)) if (!executeStringToString(in, out_untyped))
{ throw Exception{"Illegal column " + in->getName() + " of elements of array of second argument of function " + getName(),
throw Exception{
"Illegal column " + in->getName() + " of elements of array of second argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN}; ErrorCodes::ILLEGAL_COLUMN};
}
} }
else if (default_untyped->isColumnConst()) else if (default_untyped->isColumnConst())
{ {
@ -304,8 +295,7 @@ private:
&& !executeStringToNumWithConstDefault<Float64>(in, out_untyped) && !executeStringToNumWithConstDefault<Float64>(in, out_untyped)
&& !executeStringToStringWithConstDefault(in, out_untyped)) && !executeStringToStringWithConstDefault(in, out_untyped))
{ {
throw Exception{ throw Exception{"Illegal column " + in->getName() + " of elements of array of second argument of function " + getName(),
"Illegal column " + in->getName() + " of elements of array of second argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN}; ErrorCodes::ILLEGAL_COLUMN};
} }
} }
@ -323,8 +313,7 @@ private:
&& !executeStringToNumWithNonConstDefault<Float64>(in, out_untyped, default_untyped) && !executeStringToNumWithNonConstDefault<Float64>(in, out_untyped, default_untyped)
&& !executeStringToStringWithNonConstDefault(in, out_untyped, default_untyped)) && !executeStringToStringWithNonConstDefault(in, out_untyped, default_untyped))
{ {
throw Exception{ throw Exception{"Illegal column " + in->getName() + " of elements of array of second argument of function " + getName(),
"Illegal column " + in->getName() + " of elements of array of second argument of function " + getName(),
ErrorCodes::ILLEGAL_COLUMN}; ErrorCodes::ILLEGAL_COLUMN};
} }
} }

View File

@ -8,9 +8,7 @@ namespace DB
void registerFunctions@FUNCTION_AREA@(FunctionFactory & factory) void registerFunctions@FUNCTION_AREA@(FunctionFactory & factory)
{ {
@REGISTER_FUNCTIONS@ @REGISTER_FUNCTIONS@
} }
} }

View File

@ -85,8 +85,8 @@ void ReadBufferAIO::setMaxBytes(size_t max_bytes_read_)
bool ReadBufferAIO::nextImpl() bool ReadBufferAIO::nextImpl()
{ {
/// If the end of the file has already been reached by calling this function, /// If the end of the file has already been reached by calling this function,
/// then the current call is wrong. /// then the current call is wrong.
if (is_eof) if (is_eof)
return false; return false;

View File

@ -49,7 +49,7 @@ Block PartLogElement::createBlock()
/// Is there an error during the execution or commit /// Is there an error during the execution or commit
{ColumnUInt16::create(), std::make_shared<DataTypeUInt16>(), "error"}, {ColumnUInt16::create(), std::make_shared<DataTypeUInt16>(), "error"},
{ColumnString::create(), std::make_shared<DataTypeString>(), "exception"}, {ColumnString::create(), std::make_shared<DataTypeString>(), "exception"},
}; };
} }
void PartLogElement::appendToBlock(Block & block) const void PartLogElement::appendToBlock(Block & block) const

View File

@ -730,7 +730,8 @@ public:
return String(1, value); return String(1, value);
} }
void set(char x) { void set(char x)
{
value = x; value = x;
changed = true; changed = true;
} }

View File

@ -6,13 +6,14 @@
namespace DB namespace DB
{ {
std::ostream & operator<<(std::ostream & stream, const Token & what)
std::ostream & operator<<(std::ostream & stream, const Token & what) { {
stream << "Token (type="<< static_cast<int>(what.type) <<"){"<< std::string{what.begin, what.end} << "}"; stream << "Token (type="<< static_cast<int>(what.type) <<"){"<< std::string{what.begin, what.end} << "}";
return stream; return stream;
} }
std::ostream & operator<<(std::ostream & stream, const Expected & what) { std::ostream & operator<<(std::ostream & stream, const Expected & what)
{
stream << "Expected {variants="; stream << "Expected {variants=";
dumpValue(stream, what.variants) dumpValue(stream, what.variants)
<< "; max_parsed_pos=" << what.max_parsed_pos << "}"; << "; max_parsed_pos=" << what.max_parsed_pos << "}";

View File

@ -259,7 +259,8 @@ int Server::main(const std::vector<std::string> & /*args*/)
/* already_loaded = */ false); /* already_loaded = */ false);
/// Reload config in SYSTEM RELOAD CONFIG query. /// Reload config in SYSTEM RELOAD CONFIG query.
global_context->setConfigReloadCallback([&]() { global_context->setConfigReloadCallback([&]()
{
main_config_reloader->reload(); main_config_reloader->reload();
users_config_reloader->reload(); users_config_reloader->reload();
}); });

View File

@ -26,11 +26,7 @@ void AlterCommand::apply(ColumnsDescription & columns_description) const
if (type == ADD_COLUMN) if (type == ADD_COLUMN)
{ {
if (columns_description.getAll().contains(column_name)) if (columns_description.getAll().contains(column_name))
{ throw Exception{"Cannot add column " + column_name + ": column with this name already exists", ErrorCodes::ILLEGAL_COLUMN};
throw Exception{
"Cannot add column " + column_name + ": column with this name already exists",
ErrorCodes::ILLEGAL_COLUMN};
}
const auto add_column = [this] (NamesAndTypesList & columns) const auto add_column = [this] (NamesAndTypesList & columns)
{ {
@ -196,17 +192,13 @@ void AlterCommands::validate(IStorage * table, const Context & context)
if (command.type == AlterCommand::ADD_COLUMN) if (command.type == AlterCommand::ADD_COLUMN)
{ {
if (std::end(all_columns) != column_it) if (std::end(all_columns) != column_it)
throw Exception{ throw Exception{"Cannot add column " + column_name + ": column with this name already exists", ErrorCodes::ILLEGAL_COLUMN};
"Cannot add column " + column_name + ": column with this name already exists",
ErrorCodes::ILLEGAL_COLUMN};
} }
else if (command.type == AlterCommand::MODIFY_COLUMN) else if (command.type == AlterCommand::MODIFY_COLUMN)
{ {
if (std::end(all_columns) == column_it) if (std::end(all_columns) == column_it)
throw Exception{ throw Exception{"Wrong column name. Cannot find column " + column_name + " to modify", ErrorCodes::ILLEGAL_COLUMN};
"Wrong column name. Cannot find column " + column_name + " to modify",
ErrorCodes::ILLEGAL_COLUMN};
all_columns.erase(column_it); all_columns.erase(column_it);
defaults.erase(column_name); defaults.erase(column_name);

View File

@ -63,16 +63,13 @@ namespace
const char * user_pw_end = strchr(address.data(), '@'); const char * user_pw_end = strchr(address.data(), '@');
const char * colon = strchr(address.data(), ':'); const char * colon = strchr(address.data(), ':');
if (!user_pw_end || !colon) if (!user_pw_end || !colon)
throw Exception{ throw Exception{"Shard address '" + address + "' does not match to 'user[:password]@host:port#default_database' pattern",
"Shard address '" + address + "' does not match to 'user[:password]@host:port#default_database' pattern",
ErrorCodes::INCORRECT_FILE_NAME}; ErrorCodes::INCORRECT_FILE_NAME};
const bool has_pw = colon < user_pw_end; const bool has_pw = colon < user_pw_end;
const char * host_end = has_pw ? strchr(user_pw_end + 1, ':') : colon; const char * host_end = has_pw ? strchr(user_pw_end + 1, ':') : colon;
if (!host_end) if (!host_end)
throw Exception{ throw Exception{"Shard address '" + address + "' does not contain port", ErrorCodes::INCORRECT_FILE_NAME};
"Shard address '" + address + "' does not contain port",
ErrorCodes::INCORRECT_FILE_NAME};
const char * has_db = strchr(address.data(), '#'); const char * has_db = strchr(address.data(), '#');
const char * port_end = has_db ? has_db : address_end; const char * port_end = has_db ? has_db : address_end;

View File

@ -774,10 +774,7 @@ void MergeTreeData::clearOldPartsFromFilesystem()
void MergeTreeData::setPath(const String & new_full_path) void MergeTreeData::setPath(const String & new_full_path)
{ {
if (Poco::File{new_full_path}.exists()) if (Poco::File{new_full_path}.exists())
throw Exception{ throw Exception{"Target path already exists: " + new_full_path, ErrorCodes::DIRECTORY_ALREADY_EXISTS};
"Target path already exists: " + new_full_path,
/// @todo existing target can also be a file, not directory
ErrorCodes::DIRECTORY_ALREADY_EXISTS};
Poco::File(full_path).renameTo(new_full_path); Poco::File(full_path).renameTo(new_full_path);

View File

@ -30,7 +30,7 @@ struct BlockWithPartition
using BlocksWithPartition = std::vector<BlockWithPartition>; using BlocksWithPartition = std::vector<BlockWithPartition>;
/** Writes new parts of data to the merge tree. /** Writes new parts of data to the merge tree.
*/ */
class MergeTreeDataWriter class MergeTreeDataWriter
{ {

View File

@ -260,7 +260,7 @@ std::string MergedBlockOutputStream::getPartPath() const
return part_path; return part_path;
} }
/// If data is pre-sorted. /// If data is pre-sorted.
void MergedBlockOutputStream::write(const Block & block) void MergedBlockOutputStream::write(const Block & block)
{ {
writeImpl(block, nullptr); writeImpl(block, nullptr);

View File

@ -233,7 +233,7 @@ Date column must exist in the table and have type Date (not DateTime).
It is used for internal data partitioning and works like some kind of index. It is used for internal data partitioning and works like some kind of index.
If your source data doesn't have a column of type Date, but has a DateTime column, you may add values for Date column while loading, If your source data doesn't have a column of type Date, but has a DateTime column, you may add values for Date column while loading,
or you may INSERT your source data to a table of type Log and then transform it with INSERT INTO t SELECT toDate(time) AS date, * FROM ... or you may INSERT your source data to a table of type Log and then transform it with INSERT INTO t SELECT toDate(time) AS date, * FROM ...
If your source data doesn't have any date or time, you may just pass any constant for a date column while loading. If your source data doesn't have any date or time, you may just pass any constant for a date column while loading.
Next parameter is optional sampling expression. Sampling expression is used to implement SAMPLE clause in query for approximate query execution. Next parameter is optional sampling expression. Sampling expression is used to implement SAMPLE clause in query for approximate query execution.

View File

@ -30,9 +30,7 @@ StorageJoin::StorageJoin(
{ {
for (const auto & key : key_names) for (const auto & key : key_names)
if (!getColumns().hasPhysical(key)) if (!getColumns().hasPhysical(key))
throw Exception{ throw Exception{"Key column (" + key + ") does not exist in table declaration.", ErrorCodes::NO_SUCH_COLUMN_IN_TABLE};
"Key column (" + key + ") does not exist in table declaration.",
ErrorCodes::NO_SUCH_COLUMN_IN_TABLE};
/// NOTE StorageJoin doesn't use join_use_nulls setting. /// NOTE StorageJoin doesn't use join_use_nulls setting.

View File

@ -10,9 +10,9 @@
/** This program tests merge-selecting algorithm. /** This program tests merge-selecting algorithm.
* Usage: * Usage:
clickhouse-client --query=" clickhouse-client --query="
SELECT bytes, now() - modification_time, level, name SELECT bytes, now() - modification_time, level, name
FROM system.parts FROM system.parts
WHERE table = 'visits' AND active AND partition = '201610'" | ./merge_selector2 WHERE table = 'visits' AND active AND partition = '201610'" | ./merge_selector2
*/ */
int main(int, char **) int main(int, char **)