提交 77b4ad6f 编写于 作者: A Alexey Arno

Various cleanups

上级 b630f30a
......@@ -125,6 +125,7 @@ typedef std::list<Block> BlocksList;
/// Сравнить типы столбцов у блоков. Порядок столбцов имеет значение. Имена не имеют значения.
bool blocksHaveEqualStructure(const Block & lhs, const Block & rhs);
/// Проверить, что типы столбцов у блоков совместимые. Порядок имеет значение. Имена не имеют значения.
bool blocksHaveCompatibleStructure(const Block& lhs, const Block& rhs);
}
......
......@@ -5,6 +5,8 @@
namespace DB
{
/** Проверить, что типы совместимые.
*/
bool typesAreCompatible(const IDataType& lhs, const IDataType& rhs);
}
......@@ -59,7 +59,9 @@ public:
size_t subquery_depth_ = 0,
BlockInputStreamPtr input = nullptr);
/// Выполнить запрос, получить поток блоков для чтения
/** Выполнить запрос, возможно являющиийся цепочкой UNION ALL.
* Получить поток блоков для чтения
*/
BlockInputStreamPtr execute();
/** Выполнить запрос, записать результат в нужном формате в buf.
......@@ -88,6 +90,7 @@ private:
/// Вынимает данные из таблицы. Возвращает стадию, до которой запрос был обработан в Storage.
QueryProcessingStage::Enum executeFetchColumns(BlockInputStreams & streams);
/// Выполнить один запрос SELECT из цепочки UNION ALL.
BlockInputStreamPtr executeSingleQuery();
void executeWhere( BlockInputStreams & streams, ExpressionActionsPtr expression);
......@@ -115,7 +118,7 @@ private:
ExpressionAnalyzerPtr query_analyzer;
BlockInputStreams streams;
/// true, если это голова цепочки запросов SELECT объединённых ключевыми словами UNION ALL.
/// Проверить, что запрос SELECT - первый элемент цепочки UNION ALL.
bool is_union_all_head;
/// Таблица, откуда читать данные, если не подзапрос.
......
......@@ -380,8 +380,8 @@ bool blocksHaveCompatibleStructure(const Block & lhs, const Block & rhs)
for (size_t i = 0; i < columns; ++i)
{
const auto & lhs_type = *lhs.getByPosition(i).type;
const auto & rhs_type = *rhs.getByPosition(i).type;
const IDataType & lhs_type = *lhs.getByPosition(i).type;
const IDataType & rhs_type = *rhs.getByPosition(i).type;
if (!typesAreCompatible(lhs_type, rhs_type))
return false;
......
......@@ -11,17 +11,17 @@
namespace
{
#define REGISTER_COMPATIBLE_TYPES(T, U) \
{ T.getName(), U.getName() }, \
{ U.getName(), T.getName() } \
#define REGISTER_COMPATIBLE_TYPES(T, U) \
{ T.getName(), U.getName() }, \
{ U.getName(), T.getName() } \
std::vector<std::pair<std::string, std::string> > init()
{
std::vector<std::pair<std::string, std::string> > types_desc =
std::vector<std::pair<std::string, std::string> > types_compatibility_list =
{
REGISTER_COMPATIBLE_TYPES(DB::DataTypeString(), DB::DataTypeFixedString(1)),
REGISTER_COMPATIBLE_TYPES(DB::DataTypeFloat32(), DB::DataTypeFloat64()),
REGISTER_COMPATIBLE_TYPES(DB::DataTypeString(), DB::DataTypeFixedString(1)),
REGISTER_COMPATIBLE_TYPES(DB::DataTypeFloat32(), DB::DataTypeFloat64()),
REGISTER_COMPATIBLE_TYPES(DB::DataTypeInt8(), DB::DataTypeUInt8()),
REGISTER_COMPATIBLE_TYPES(DB::DataTypeInt8(), DB::DataTypeInt16()),
......@@ -43,8 +43,10 @@ std::vector<std::pair<std::string, std::string> > init()
REGISTER_COMPATIBLE_TYPES(DB::DataTypeInt64(), DB::DataTypeUInt64())
};
std::sort(types_desc.begin(), types_desc.end());
return types_desc;
std::sort(types_compatibility_list.begin(), types_compatibility_list.end());
return types_compatibility_list;
}
}
......@@ -54,12 +56,13 @@ namespace DB
bool typesAreCompatible(const IDataType & lhs, const IDataType & rhs)
{
static const auto types_desc = init();
static const auto types_compatibility_list = init();
if (lhs.getName() == rhs.getName())
return true;
return std::binary_search(types_desc.begin(), types_desc.end(), std::make_pair(lhs.getName(), rhs.getName()));
return std::binary_search(types_compatibility_list.begin(), types_compatibility_list.end(),
std::make_pair(lhs.getName(), rhs.getName()));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册