diff --git a/dbms/include/DB/Columns/ColumnConst.h b/dbms/include/DB/Columns/ColumnConst.h index 1a2ce3cba01..477ee793238 100644 --- a/dbms/include/DB/Columns/ColumnConst.h +++ b/dbms/include/DB/Columns/ColumnConst.h @@ -20,6 +20,8 @@ template class ColumnConst : public IColumn { public: + typedef T Type; + ColumnConst(size_t s_, const T & data_) : s(s_), data(data_) {} ColumnPtr cloneEmpty() const { return new ColumnConst(0, data); } diff --git a/dbms/include/DB/Columns/ColumnsNumber.h b/dbms/include/DB/Columns/ColumnsNumber.h index 70b0a289875..bbe971cb3e1 100644 --- a/dbms/include/DB/Columns/ColumnsNumber.h +++ b/dbms/include/DB/Columns/ColumnsNumber.h @@ -2,6 +2,7 @@ #include #include +#include namespace DB @@ -22,4 +23,18 @@ typedef ColumnVector ColumnInt64; typedef ColumnVector ColumnFloat32; typedef ColumnVector ColumnFloat64; + +typedef ColumnConst ColumnConstUInt8; +typedef ColumnConst ColumnConstUInt16; +typedef ColumnConst ColumnConstUInt32; +typedef ColumnConst ColumnConstUInt64; + +typedef ColumnConst ColumnConstInt8; +typedef ColumnConst ColumnConstInt16; +typedef ColumnConst ColumnConstInt32; +typedef ColumnConst ColumnConstInt64; + +typedef ColumnConst ColumnConstFloat32; +typedef ColumnConst ColumnConstFloat64; + } diff --git a/dbms/include/DB/Core/Block.h b/dbms/include/DB/Core/Block.h index 21dbb84a18d..df5f3d534cf 100644 --- a/dbms/include/DB/Core/Block.h +++ b/dbms/include/DB/Core/Block.h @@ -51,6 +51,8 @@ public: ColumnWithNameAndType & getByName(const std::string & name); const ColumnWithNameAndType & getByName(const std::string & name) const; + size_t getPositionByName(const std::string & name) const; + /** Возвращает количество строк в блоке. * Заодно проверяет, что все столбцы кроме констант (которые содержат единственное значение), * содержат одинаковое число значений. diff --git a/dbms/include/DB/Functions/FunctionsArithmetic.h b/dbms/include/DB/Functions/FunctionsArithmetic.h index f2960dc2597..27384bb89ff 100644 --- a/dbms/include/DB/Functions/FunctionsArithmetic.h +++ b/dbms/include/DB/Functions/FunctionsArithmetic.h @@ -36,7 +36,7 @@ struct PlusImpl static void constant_vector(A a, const std::vector & b, std::vector & c) { - size_t size = a.size(); + size_t size = b.size(); for (size_t i = 0; i < size; ++i) c[i] = a + b[i]; } @@ -68,7 +68,7 @@ struct MultiplyImpl static void constant_vector(A a, const std::vector & b, std::vector & c) { - size_t size = a.size(); + size_t size = b.size(); for (size_t i = 0; i < size; ++i) c[i] = a * b[i]; } @@ -100,7 +100,7 @@ struct MinusImpl static void constant_vector(A a, const std::vector & b, std::vector & c) { - size_t size = a.size(); + size_t size = b.size(); for (size_t i = 0; i < size; ++i) c[i] = a - b[i]; } @@ -132,7 +132,7 @@ struct DivideFloatingImpl static void constant_vector(A a, const std::vector & b, std::vector & c) { - size_t size = a.size(); + size_t size = b.size(); for (size_t i = 0; i < size; ++i) c[i] = static_cast(a) / b[i]; } @@ -164,7 +164,7 @@ struct DivideIntegralImpl static void constant_vector(A a, const std::vector & b, std::vector & c) { - size_t size = a.size(); + size_t size = b.size(); for (size_t i = 0; i < size; ++i) c[i] = a / b[i]; } @@ -196,7 +196,7 @@ struct ModuloImpl static void constant_vector(A a, const std::vector & b, std::vector & c) { - size_t size = a.size(); + size_t size = b.size(); for (size_t i = 0; i < size; ++i) c[i] = a % b[i]; } @@ -211,6 +211,148 @@ struct ModuloImpl template