Merge branch 'master' of github.com:ClickHouse/ClickHouse into dictionary_status

This commit is contained in:
Guillaume Tassery 2020-03-12 09:11:44 +01:00
commit 245d90a894
63 changed files with 867 additions and 215 deletions

View File

@ -14,5 +14,6 @@ ClickHouse is an open-source column-oriented database management system that all
## Upcoming Events
* [ClickHouse Workshop in Novosibirsk](https://2020.codefest.ru/lecture/1628) on March 28, 2020.
* [Talks on Saint HighLoad++ in St. Petersburg](https://www.highload.ru/spb/2020/abstracts/6647) on April 6, 2020.
* [Yandex C++ Open-Source Sprints in Moscow](https://events.yandex.ru/events/otkrytyj-kod-v-yandek-28-03-2020) on March 28, 2020.
* [ClickHouse Workshop in Novosibirsk](https://2020.codefest.ru/lecture/1628) on March 28, 2020.
* [Talks on Saint HighLoad++ in St. Petersburg](https://www.highload.ru/spb/2020/abstracts/6647) on April 6, 2020.

View File

@ -401,6 +401,7 @@ private:
auto input = std::make_unique<Node>("input()", next_flag++, GLOBAL_LEVEL);
auto values = std::make_unique<Node>("values()", next_flag++, GLOBAL_LEVEL);
auto numbers = std::make_unique<Node>("numbers()", next_flag++, GLOBAL_LEVEL);
auto zeros = std::make_unique<Node>("zeros()", next_flag++, GLOBAL_LEVEL);
auto merge = std::make_unique<Node>("merge()", next_flag++, DATABASE_LEVEL);
auto remote = std::make_unique<Node>("remote()", next_flag++, GLOBAL_LEVEL);
ext::push_back(remote->aliases, "remoteSecure()", "cluster()");
@ -409,7 +410,7 @@ private:
auto jdbc = std::make_unique<Node>("jdbc()", next_flag++, GLOBAL_LEVEL);
auto hdfs = std::make_unique<Node>("hdfs()", next_flag++, GLOBAL_LEVEL);
auto s3 = std::make_unique<Node>("s3()", next_flag++, GLOBAL_LEVEL);
auto table_functions = std::make_unique<Node>("TABLE FUNCTIONS", std::move(file), std::move(url), std::move(input), std::move(values), std::move(numbers), std::move(merge), std::move(remote), std::move(mysql), std::move(odbc), std::move(jdbc), std::move(hdfs), std::move(s3));
auto table_functions = std::make_unique<Node>("TABLE FUNCTIONS", std::move(file), std::move(url), std::move(input), std::move(values), std::move(numbers), std::move(zeros), std::move(merge), std::move(remote), std::move(mysql), std::move(odbc), std::move(jdbc), std::move(hdfs), std::move(s3));
ext::push_back(all, std::move(table_functions));
flags_to_keyword_tree_ = std::make_unique<Node>("ALL", std::move(all));

View File

@ -129,6 +129,7 @@ enum class AccessType
input,
values,
numbers,
zeros,
merge,
remote,
mysql,
@ -288,6 +289,7 @@ namespace impl
ACCESS_TYPE_TO_KEYWORD_CASE(input);
ACCESS_TYPE_TO_KEYWORD_CASE(values);
ACCESS_TYPE_TO_KEYWORD_CASE(numbers);
ACCESS_TYPE_TO_KEYWORD_CASE(zeros);
ACCESS_TYPE_TO_KEYWORD_CASE(merge);
ACCESS_TYPE_TO_KEYWORD_CASE(remote);
ACCESS_TYPE_TO_KEYWORD_CASE(mysql);

View File

@ -91,14 +91,21 @@ void QueryNormalizer::visit(ASTIdentifier & node, ASTPtr & ast, Data & data)
return;
}
/// We are alias for other column (node.name), but we are alias by
/// ourselves to some other column
auto & alias_node = it_alias->second;
/// Let's replace it with the corresponding tree node.
if (current_asts.count(alias_node.get()))
String our_alias_or_name = alias_node->getAliasOrColumnName();
std::optional<String> our_name = IdentifierSemantic::getColumnName(alias_node);
String node_alias = ast->tryGetAlias();
if (current_asts.count(alias_node.get()) /// We have loop of multiple aliases
|| (node.name == our_alias_or_name && our_name && node_alias == *our_name)) /// Our alias points to node.name, direct loop
throw Exception("Cyclic aliases", ErrorCodes::CYCLIC_ALIASES);
String my_alias = ast->tryGetAlias();
if (!my_alias.empty() && my_alias != alias_node->getAliasOrColumnName())
/// Let's replace it with the corresponding tree node.
if (!node_alias.empty() && node_alias != our_alias_or_name)
{
/// Avoid infinite recursion here
auto opt_name = IdentifierSemantic::getColumnName(alias_node);
@ -108,7 +115,7 @@ void QueryNormalizer::visit(ASTIdentifier & node, ASTPtr & ast, Data & data)
{
/// In a construct like "a AS b", where a is an alias, you must set alias b to the result of substituting alias a.
ast = alias_node->clone();
ast->setAlias(my_alias);
ast->setAlias(node_alias);
}
}
else

View File

@ -0,0 +1,24 @@
#include <gtest/gtest.h>
#include <Interpreters/QueryNormalizer.h>
#include <Parsers/IAST.h>
#include <Parsers/queryToString.h>
#include <Parsers/ExpressionListParsers.h>
#include <Parsers/parseQuery.h>
using namespace DB;
TEST(QueryNormalizer, SimpleCycleAlias)
{
String query = "a as b, b as a";
ParserExpressionList parser(false);
ASTPtr ast = parseQuery(parser, query, 0);
Aliases aliases;
aliases["a"] = parseQuery(parser, "b as a", 0)->children[0];
aliases["b"] = parseQuery(parser, "a as b", 0)->children[0];
Settings settings;
QueryNormalizer::Data normalizer_data(aliases, settings);
EXPECT_THROW(QueryNormalizer(normalizer_data).visit(ast), Exception);
}

View File

@ -0,0 +1,132 @@
#include <Storages/System/StorageSystemZeros.h>
#include <Processors/Sources/SourceWithProgress.h>
#include <Processors/Pipe.h>
#include <DataTypes/DataTypesNumber.h>
#include <Columns/ColumnsNumber.h>
namespace DB
{
namespace
{
struct ZerosState
{
std::atomic<UInt64> num_generated_rows = 0;
};
using ZerosStatePtr = std::shared_ptr<ZerosState>;
/// Source which generates zeros.
/// Uses state to share the number of generated rows between threads.
/// If state is nullptr, then limit is ignored.
class ZerosSource : public SourceWithProgress
{
public:
ZerosSource(UInt64 block_size, UInt64 limit_, ZerosStatePtr state_)
: SourceWithProgress(createHeader()), limit(limit_), state(std::move(state_))
{
column = createColumn(block_size);
}
String getName() const override { return "Zeros"; }
protected:
Chunk generate() override
{
auto column_ptr = column;
size_t column_size = column_ptr->size();
if (state)
{
auto generated_rows = state->num_generated_rows.fetch_add(column_size, std::memory_order_acquire);
if (generated_rows >= limit)
return {};
if (generated_rows + column_size > limit)
{
column_size = limit - generated_rows;
column_ptr = createColumn(column_size);
}
}
progress({column->size(), column->byteSize()});
return { Columns {std::move(column_ptr)}, column_size };
}
private:
UInt64 limit;
ZerosStatePtr state;
ColumnPtr column;
static Block createHeader()
{
return { ColumnWithTypeAndName(ColumnUInt8::create(), std::make_shared<DataTypeUInt8>(), "zero") };
}
static ColumnPtr createColumn(size_t size)
{
auto column_ptr = ColumnUInt8::create();
/// It is probably the fastest method to create zero column, cause resize_fill uses memset internally.
column_ptr->getData().resize_fill(size);
return column_ptr;
}
};
}
StorageSystemZeros::StorageSystemZeros(const std::string & name_, bool multithreaded_, std::optional<UInt64> limit_)
: IStorage({"system", name_}), multithreaded(multithreaded_), limit(limit_)
{
setColumns(ColumnsDescription({{"zero", std::make_shared<DataTypeUInt8>()}}));
}
Pipes StorageSystemZeros::read(
const Names & column_names,
const SelectQueryInfo &,
const Context & /*context*/,
QueryProcessingStage::Enum /*processed_stage*/,
size_t max_block_size,
unsigned num_streams)
{
check(column_names);
bool use_multiple_streams = multithreaded;
if (limit && *limit < max_block_size)
{
max_block_size = static_cast<size_t>(*limit);
use_multiple_streams = false;
}
if (!use_multiple_streams)
num_streams = 1;
Pipes res;
res.reserve(num_streams);
ZerosStatePtr state;
if (limit)
state = std::make_shared<ZerosState>();
for (size_t i = 0; i < num_streams; ++i)
{
auto source = std::make_shared<ZerosSource>(max_block_size, limit ? *limit : 0, state);
if (limit && i == 0)
source->addTotalRowsApprox(*limit);
res.emplace_back(std::move(source));
}
return res;
}
}

View File

@ -0,0 +1,43 @@
#pragma once
#include <ext/shared_ptr_helper.h>
#include <optional>
#include <Storages/IStorage.h>
namespace DB
{
/** Implements a table engine for the system table "zeros".
* The table contains the only column zero UInt8.
* From this table, you can read non-materialized zeros.
*
* You could also specify a limit (how many zeros to give).
* If multithreaded is specified, zeros will be generated in several streams.
*/
class StorageSystemZeros : public ext::shared_ptr_helper<StorageSystemZeros>, public IStorage
{
friend struct ext::shared_ptr_helper<StorageSystemZeros>;
public:
std::string getName() const override { return "SystemZeros"; }
Pipes read(
const Names & column_names,
const SelectQueryInfo & query_info,
const Context & context,
QueryProcessingStage::Enum processed_stage,
size_t max_block_size,
unsigned num_streams) override;
bool hasEvenlyDistributedRead() const override { return true; }
private:
bool multithreaded;
std::optional<UInt64> limit;
protected:
/// If even_distribution is true, numbers are distributed evenly between streams.
/// Otherwise, streams concurrently increment atomic.
StorageSystemZeros(const std::string & name_, bool multithreaded_, std::optional<UInt64> limit_ = std::nullopt);
};
}

View File

@ -39,6 +39,7 @@
#include <Storages/System/StorageSystemContributors.h>
#include <Storages/System/StorageSystemDisks.h>
#include <Storages/System/StorageSystemStoragePolicies.h>
#include <Storages/System/StorageSystemZeros.h>
#ifdef OS_LINUX
#include <Storages/System/StorageSystemStackTrace.h>
@ -53,6 +54,8 @@ void attachSystemTablesLocal(IDatabase & system_database)
system_database.attachTable("one", StorageSystemOne::create("one"));
system_database.attachTable("numbers", StorageSystemNumbers::create("numbers", false));
system_database.attachTable("numbers_mt", StorageSystemNumbers::create("numbers_mt", true));
system_database.attachTable("zeros", StorageSystemZeros::create("zeros", false));
system_database.attachTable("zeros_mt", StorageSystemZeros::create("zeros_mt", true));
system_database.attachTable("databases", StorageSystemDatabases::create("databases"));
system_database.attachTable("tables", StorageSystemTables::create("tables"));
system_database.attachTable("columns", StorageSystemColumns::create("columns"));

View File

@ -0,0 +1,56 @@
#include <TableFunctions/ITableFunction.h>
#include <TableFunctions/TableFunctionZeros.h>
#include <TableFunctions/TableFunctionFactory.h>
#include <Parsers/ASTFunction.h>
#include <Parsers/ASTLiteral.h>
#include <Common/typeid_cast.h>
#include <Storages/System/StorageSystemZeros.h>
#include <Access/AccessFlags.h>
#include <Interpreters/evaluateConstantExpression.h>
#include <Interpreters/Context.h>
#include "registerTableFunctions.h"
namespace DB
{
namespace ErrorCodes
{
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
}
template <bool multithreaded>
StoragePtr TableFunctionZeros<multithreaded>::executeImpl(const ASTPtr & ast_function, const Context & context, const std::string & table_name) const
{
if (const auto * function = ast_function->as<ASTFunction>())
{
auto arguments = function->arguments->children;
if (arguments.size() != 1)
throw Exception("Table function '" + getName() + "' requires 'length'.", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
UInt64 length = evaluateArgument(context, arguments[0]);
context.checkAccess(AccessType::zeros);
auto res = StorageSystemZeros::create(table_name, multithreaded, length);
res->startup();
return res;
}
throw Exception("Table function '" + getName() + "' requires 'limit'.", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
}
void registerTableFunctionZeros(TableFunctionFactory & factory)
{
factory.registerFunction<TableFunctionZeros<true>>();
factory.registerFunction<TableFunctionZeros<false>>();
}
template <bool multithreaded>
UInt64 TableFunctionZeros<multithreaded>::evaluateArgument(const Context & context, ASTPtr & argument) const
{
return evaluateConstantExpressionOrIdentifierAsLiteral(argument, context)->as<ASTLiteral &>().value.safeGet<UInt64>();
}
}

View File

@ -0,0 +1,27 @@
#pragma once
#include <TableFunctions/ITableFunction.h>
#include <Core/Types.h>
namespace DB
{
/* zeros(limit), zeros_mt(limit)
* - the same as SELECT zero FROM system.zeros LIMIT limit.
* Used for testing purposes, as a simple example of table function.
*/
template <bool multithreaded>
class TableFunctionZeros : public ITableFunction
{
public:
static constexpr auto name = multithreaded ? "zeros_mt" : "zeros";
std::string getName() const override { return name; }
private:
StoragePtr executeImpl(const ASTPtr & ast_function, const Context & context, const std::string & table_name) const override;
UInt64 evaluateArgument(const Context & context, ASTPtr & argument) const;
};
}

View File

@ -11,6 +11,7 @@ void registerTableFunctions()
registerTableFunctionMerge(factory);
registerTableFunctionRemote(factory);
registerTableFunctionNumbers(factory);
registerTableFunctionZeros(factory);
registerTableFunctionFile(factory);
registerTableFunctionURL(factory);
registerTableFunctionValues(factory);

View File

@ -8,6 +8,7 @@ class TableFunctionFactory;
void registerTableFunctionMerge(TableFunctionFactory & factory);
void registerTableFunctionRemote(TableFunctionFactory & factory);
void registerTableFunctionNumbers(TableFunctionFactory & factory);
void registerTableFunctionZeros(TableFunctionFactory & factory);
void registerTableFunctionFile(TableFunctionFactory & factory);
void registerTableFunctionURL(TableFunctionFactory & factory);
void registerTableFunctionValues(TableFunctionFactory & factory);

View File

@ -7,6 +7,6 @@
</stop_conditions>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore([[number], [number]])</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore([[], [number]])</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore([[zero], [zero]])</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore([[], [zero]])</query>
</test>

View File

@ -6,13 +6,13 @@
</any_of>
</stop_conditions>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(if(rand() % 2, toDateTime('2019-02-04 01:24:31'), toDate('2019-02-04')))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(multiIf(rand() % 2, toDateTime('2019-02-04 01:24:31'), toDate('2019-02-04')))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(if(rand() % 2, [toDateTime('2019-02-04 01:24:31')], [toDate('2019-02-04')]))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(multiIf(rand() % 2, [toDateTime('2019-02-04 01:24:31')], [toDate('2019-02-04')]))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(if(rand() % 2, toDateTime('2019-02-04 01:24:31'), toDate('2019-02-04')))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(multiIf(rand() % 2, toDateTime('2019-02-04 01:24:31'), toDate('2019-02-04')))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(if(rand() % 2, [toDateTime('2019-02-04 01:24:31')], [toDate('2019-02-04')]))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(multiIf(rand() % 2, [toDateTime('2019-02-04 01:24:31')], [toDate('2019-02-04')]))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(if(rand() % 2, toDateTime(rand()), toDate(rand())))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(multiIf(rand() % 2, toDateTime(rand()), toDate(rand())))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(if(rand() % 2, [toDateTime(rand())], [toDate(rand())]))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(multiIf(rand() % 2, [toDateTime(rand())], [toDate(rand())]))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(if(rand() % 2, toDateTime(rand()), toDate(rand())))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(multiIf(rand() % 2, toDateTime(rand()), toDate(rand())))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(if(rand() % 2, [toDateTime(rand())], [toDate(rand())]))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(multiIf(rand() % 2, [toDateTime(rand())], [toDate(rand())]))</query>
</test>

View File

@ -46,8 +46,8 @@
<substitution>
<name>table_slow</name>
<values>
<value>numbers(100000)</value>
<value>numbers_mt(1000000)</value>
<value>zeros(100000)</value>
<value>zeros_mt(1000000)</value>
</values>
</substitution>
</substitutions>

View File

@ -11,7 +11,7 @@
-->
<create_query>CREATE TABLE empty_strings (s String) ENGINE = Log;</create_query>
<fill_query>INSERT INTO empty_strings SELECT '' FROM numbers_mt(100000000);</fill_query>
<fill_query>INSERT INTO empty_strings SELECT '' FROM zeros_mt(100000000);</fill_query>
<query>SELECT count() FROM empty_strings</query>

View File

@ -11,6 +11,6 @@
-->
<create_query>CREATE TABLE empty_strings (s String) ENGINE = Log;</create_query>
<query>INSERT INTO empty_strings SELECT '' FROM numbers(100000000);</query>
<query>INSERT INTO empty_strings SELECT '' FROM zeros(100000000);</query>
<drop_query>DROP TABLE IF EXISTS empty_strings</drop_query>
</test>

View File

@ -17,9 +17,6 @@
<substitution>
<name>expr</name>
<values>
<value>1 / rand()</value>
<value>rand() / 0xFFFFFFFF</value>
<value>0xFFFFFFFF / rand()</value>
<value>toFloat64(number)</value>
<value>toFloat64(number % 2)</value>
<value>toFloat64(number % 10)</value>
@ -33,8 +30,6 @@
<value>number / 3</value>
<value>number / 7</value>
<value>number / 16</value>
<value>toFloat64(rand())</value>
<value>toFloat64(rand64())</value>
<value>toFloat32(number)</value>
<value>toFloat32(number % 2)</value>
<value>toFloat32(number % 10)</value>
@ -44,13 +39,24 @@
<value>toFloat32(number % 100 + 0.5)</value>
<value>toFloat32(number % 100 + 0.123)</value>
<value>toFloat32(number % 1000 + 0.123456)</value>
<value>toFloat32(rand())</value>
<value>toFloat32(rand64())</value>
<value>reinterpretAsFloat32(reinterpretAsString(rand()))</value>
<value>reinterpretAsFloat64(reinterpretAsString(rand64()))</value>
</values>
</substitution>
<substitution>
<name>expr_zero</name>
<values>
<value>1 / rand()</value>
<value>rand() / 0xFFFFFFFF</value>
<value>0xFFFFFFFF / rand()</value>
<value>toFloat64(rand())</value>
<value>toFloat64(rand64())</value>
<value>toFloat32(rand())</value>
<value>toFloat32(rand64())</value>
<value>reinterpretAsFloat32(reinterpretAsString(rand()))</value>
<value>reinterpretAsFloat64(reinterpretAsString(rand64()))</value>
</values>
</substitution>
</substitutions>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(toString({expr}))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(toString({expr_zero}))</query>
</test>

View File

@ -17,19 +17,25 @@
<substitution>
<name>expr</name>
<values>
<value>toString(1 / rand())</value>
<value>toString(rand() / 0xFFFFFFFF)</value>
<value>toString(0xFFFFFFFF / rand())</value>
<value>toString(number)</value>
<value>toString(number % 10)</value>
<value>toString(rand())</value>
<value>toString(rand64())</value>
<value>concat(toString(rand(1)), '.', toString(rand(2)))</value>
<value>concat(toString(rand(1)), 'e', toString(rand(2) % 100))</value>
<value>concat(toString(rand64(1)), toString(rand64(2)), toString(rand64(3)))</value>
</values>
</substitution>
<substitution>
<name>expr_zero</name>
<values>
<value>toString(1 / rand())</value>
<value>toString(rand() / 0xFFFFFFFF)</value>
<value>toString(0xFFFFFFFF / rand())</value>
<value>toString(rand())</value>
<value>toString(rand64())</value>
<value>concat(toString(rand(1)), '.', toString(rand(2)))</value>
<value>concat(toString(rand(1)), 'e', toString(rand(2) % 100))</value>
<value>concat(toString(rand64(1)), toString(rand64(2)), toString(rand64(3)))</value>
</values>
</substitution>
</substitutions>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(toFloat64({expr}))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(toFloat64({expr_zero}))</query>
</test>

View File

@ -8,6 +8,6 @@
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(MACNumToString(number))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(MACStringToNum(MACNumToString(number)))</query>
<query>SELECT count() FROM numbers_mt(10000000) WHERE NOT ignore(MACNumToString(rand64()))</query>
<query>SELECT count() FROM numbers_mt(10000000) WHERE NOT ignore(MACStringToNum(MACNumToString(rand64())))</query>
<query>SELECT count() FROM zeros_mt(10000000) WHERE NOT ignore(MACNumToString(rand64()))</query>
<query>SELECT count() FROM zeros_mt(10000000) WHERE NOT ignore(MACStringToNum(MACNumToString(rand64())))</query>
</test>

View File

@ -10,8 +10,8 @@
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(geohashEncode((number % 150)*1.1 - 75, (number * 3.14 % 300)*1.1 - 150))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(geohashDecode(toString(number % 1000000)))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(geohashEncode(1.0/rand(), 2.0/rand()))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(geohashDecode(toString(rand() % 1000000)))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(geohashEncode(1.0/rand(), 2.0/rand()))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(geohashDecode(toString(rand() % 1000000)))</query>
<!-- erroneus values -->
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(geohashEncode(number + 91.0, number + 181.0))</query>

View File

@ -47,8 +47,8 @@
<substitution>
<name>table_slow</name>
<values>
<value>numbers(100000)</value>
<value>numbers_mt(1000000)</value>
<value>zeros(100000)</value>
<value>zeros_mt(1000000)</value>
</values>
</substitution>
<substitution>

View File

@ -45,8 +45,8 @@
<substitution>
<name>table</name>
<values>
<value>numbers(100000000)</value>
<value>numbers_mt(1000000000)</value>
<value>zeros(100000000)</value>
<value>zeros_mt(1000000000)</value>
</values>
</substitution>
<substitution>

View File

@ -9,6 +9,6 @@
<!-- lon [-180; 180], lat [-90; 90] -->
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(greatCircleDistance((rand(1) % 360) * 1. - 180, (number % 150) * 1.2 - 90, (number % 360) + toFloat64(rand(2)) / 4294967296 - 180, (rand(3) % 180) * 1. - 90))</query>
<!-- 55.755830, 37.617780 is center of Moscow -->
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(greatCircleDistance(55. + toFloat64(rand(1)) / 4294967296, 37. + toFloat64(rand(2)) / 4294967296, 55. + toFloat64(rand(3)) / 4294967296, 37. + toFloat64(rand(4)) / 4294967296))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(greatCircleDistance(55. + toFloat64(rand(1)) / 4294967296, 37. + toFloat64(rand(2)) / 4294967296, 55. + toFloat64(rand(3)) / 4294967296, 37. + toFloat64(rand(4)) / 4294967296))</query>
</test>

View File

@ -8,5 +8,5 @@
</stop_conditions>
<!-- Moscow coordinates, maximum precision. NOTE: H3 library is extraordinary slow. -->
<query>SELECT count() FROM numbers(100000) WHERE NOT ignore(geoToH3(37.62 + rand(1) / 0x100000000, 55.75 + rand(2) / 0x100000000, 15))</query>
<query>SELECT count() FROM zeros(100000) WHERE NOT ignore(geoToH3(37.62 + rand(1) / 0x100000000, 55.75 + rand(2) / 0x100000000, 15))</query>
</test>

View File

@ -7,10 +7,10 @@
</stop_conditions>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(rand() % 2 ? [1, 2, 3] : [4, 5])</query>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(rand() % 2 ? [1, 2, 3] : materialize([4, 5]))</query>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(rand() % 2 ? materialize([1, 2, 3]) : materialize([4, 5]))</query>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(rand() % 2 ? [1, 2, 3] : [400, 500])</query>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(rand() % 2 ? [1, 2, 3] : materialize([400, 500]))</query>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(rand() % 2 ? materialize([1, 2, 3]) : materialize([400, 500]))</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(rand() % 2 ? [1, 2, 3] : [4, 5])</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(rand() % 2 ? [1, 2, 3] : materialize([4, 5]))</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(rand() % 2 ? materialize([1, 2, 3]) : materialize([4, 5]))</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(rand() % 2 ? [1, 2, 3] : [400, 500])</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(rand() % 2 ? [1, 2, 3] : materialize([400, 500]))</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(rand() % 2 ? materialize([1, 2, 3]) : materialize([400, 500]))</query>
</test>

View File

@ -7,10 +7,10 @@
</stop_conditions>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(rand() % 2 ? ['Hello', 'World'] : ['a', 'b', 'c'])</query>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(rand() % 2 ? materialize(['Hello', 'World']) : ['a', 'b', 'c'])</query>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(rand() % 2 ? ['Hello', 'World'] : materialize(['a', 'b', 'c']))</query>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(rand() % 2 ? materialize(['Hello', 'World']) : materialize(['a', 'b', 'c']))</query>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(rand() % 2 ? materialize(['', '']) : emptyArrayString())</query>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(rand() % 2 ? materialize(['https://github.com/ClickHouse/ClickHouse/pull/1070', 'https://www.google.ru/search?newwindow=1&amp;site=&amp;source=hp&amp;q=zookeeper+wire+protocol+exists&amp;oq=zookeeper+wire+protocol+exists&amp;gs_l=psy-ab.3...330.6300.0.6687.33.28.0.0.0.0.386.4838.0j5j9j5.19.0....0...1.1.64.psy-ab..14.17.4448.0..0j35i39k1j0i131k1j0i22i30k1j0i19k1j33i21k1.r_3uFoNOrSU']) : emptyArrayString())</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(rand() % 2 ? ['Hello', 'World'] : ['a', 'b', 'c'])</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(rand() % 2 ? materialize(['Hello', 'World']) : ['a', 'b', 'c'])</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(rand() % 2 ? ['Hello', 'World'] : materialize(['a', 'b', 'c']))</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(rand() % 2 ? materialize(['Hello', 'World']) : materialize(['a', 'b', 'c']))</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(rand() % 2 ? materialize(['', '']) : emptyArrayString())</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(rand() % 2 ? materialize(['https://github.com/ClickHouse/ClickHouse/pull/1070', 'https://www.google.ru/search?newwindow=1&amp;site=&amp;source=hp&amp;q=zookeeper+wire+protocol+exists&amp;oq=zookeeper+wire+protocol+exists&amp;gs_l=psy-ab.3...330.6300.0.6687.33.28.0.0.0.0.386.4838.0j5j9j5.19.0....0...1.1.64.psy-ab..14.17.4448.0..0j35i39k1j0i131k1j0i22i30k1j0i19k1j33i21k1.r_3uFoNOrSU']) : emptyArrayString())</query>
</test>

View File

@ -6,8 +6,8 @@
</any_of>
</stop_conditions>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(rand() % 2 ? 'hello' : 'world')</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(rand() % 2 ? 'hello' : '')</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(rand() % 2 ? toFixedString('hello', 5) : toFixedString('world', 5))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(rand() % 2 ? '' : toFixedString('world', 5))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(rand() % 2 ? 'hello' : 'world')</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(rand() % 2 ? 'hello' : '')</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(rand() % 2 ? toFixedString('hello', 5) : toFixedString('world', 5))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(rand() % 2 ? '' : toFixedString('world', 5))</query>
</test>

View File

@ -31,18 +31,18 @@
<allow_simdjson>0</allow_simdjson>
</settings>
<query>SELECT 'rapidjson-1', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractString(materialize({json}), 'sparam'))</query>
<query>SELECT 'rapidjson-2', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractString(materialize({json}), 'sparam', 'nested_1'))</query>
<query>SELECT 'rapidjson-3', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractInt(materialize({json}), 'nparam'))</query>
<query>SELECT 'rapidjson-4', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractUInt(materialize({json}), 'nparam'))</query>
<query>SELECT 'rapidjson-5', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractFloat(materialize({json}), 'fparam'))</query>
<query>SELECT 'rapidjson-1', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractString(materialize({json}), 'sparam'))</query>
<query>SELECT 'rapidjson-2', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractString(materialize({json}), 'sparam', 'nested_1'))</query>
<query>SELECT 'rapidjson-3', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractInt(materialize({json}), 'nparam'))</query>
<query>SELECT 'rapidjson-4', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractUInt(materialize({json}), 'nparam'))</query>
<query>SELECT 'rapidjson-5', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractFloat(materialize({json}), 'fparam'))</query>
<query>SELECT 'rapidjson-6', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractString(materialize({long_json}), 'sparam'))</query>
<query>SELECT 'rapidjson-7', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractString(materialize({long_json}), 'sparam', 'nested_1'))</query>
<query>SELECT 'rapidjson-8', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractInt(materialize({long_json}), 'nparam'))</query>
<query>SELECT 'rapidjson-9', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractUInt(materialize({long_json}), 'nparam'))</query>
<query>SELECT 'rapidjson-10', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractRaw(materialize({long_json}), 'fparam'))</query>
<query>SELECT 'rapidjson-11', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractFloat(materialize({long_json}), 'fparam'))</query>
<query>SELECT 'rapidjson-12', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractFloat(materialize({long_json}), 'fparam', 'nested_2', -2))</query>
<query>SELECT 'rapidjson-13', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractBool(materialize({long_json}), 'bparam'))</query>
<query>SELECT 'rapidjson-6', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractString(materialize({long_json}), 'sparam'))</query>
<query>SELECT 'rapidjson-7', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractString(materialize({long_json}), 'sparam', 'nested_1'))</query>
<query>SELECT 'rapidjson-8', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractInt(materialize({long_json}), 'nparam'))</query>
<query>SELECT 'rapidjson-9', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractUInt(materialize({long_json}), 'nparam'))</query>
<query>SELECT 'rapidjson-10', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractRaw(materialize({long_json}), 'fparam'))</query>
<query>SELECT 'rapidjson-11', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractFloat(materialize({long_json}), 'fparam'))</query>
<query>SELECT 'rapidjson-12', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractFloat(materialize({long_json}), 'fparam', 'nested_2', -2))</query>
<query>SELECT 'rapidjson-13', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractBool(materialize({long_json}), 'bparam'))</query>
</test>

View File

@ -31,19 +31,19 @@
<allow_simdjson>1</allow_simdjson>
</settings>
<query>SELECT 'simdjson-1', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractString(materialize({json}), 'sparam'))</query>
<query>SELECT 'simdjson-2', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractString(materialize({json}), 'sparam', 'nested_1'))</query>
<query>SELECT 'simdjson-3', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractInt(materialize({json}), 'nparam'))</query>
<query>SELECT 'simdjson-4', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractUInt(materialize({json}), 'nparam'))</query>
<query>SELECT 'simdjson-5', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractFloat(materialize({json}), 'fparam'))</query>
<query>SELECT 'simdjson-1', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractString(materialize({json}), 'sparam'))</query>
<query>SELECT 'simdjson-2', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractString(materialize({json}), 'sparam', 'nested_1'))</query>
<query>SELECT 'simdjson-3', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractInt(materialize({json}), 'nparam'))</query>
<query>SELECT 'simdjson-4', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractUInt(materialize({json}), 'nparam'))</query>
<query>SELECT 'simdjson-5', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractFloat(materialize({json}), 'fparam'))</query>
<query>SELECT 'simdjson-6', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractString(materialize({long_json}), 'sparam'))</query>
<query>SELECT 'simdjson-7', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractString(materialize({long_json}), 'sparam', 'nested_1'))</query>
<query>SELECT 'simdjson-8', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractInt(materialize({long_json}), 'nparam'))</query>
<query>SELECT 'simdjson-9', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractUInt(materialize({long_json}), 'nparam'))</query>
<query>SELECT 'simdjson-10', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractRaw(materialize({long_json}), 'fparam'))</query>
<query>SELECT 'simdjson-11', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractFloat(materialize({long_json}), 'fparam'))</query>
<query>SELECT 'simdjson-12', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractFloat(materialize({long_json}), 'fparam', 'nested_2', -2))</query>
<query>SELECT 'simdjson-13', count() FROM numbers(1000000) WHERE NOT ignore(JSONExtractBool(materialize({long_json}), 'bparam'))</query>
<query>SELECT 'simdjson-6', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractString(materialize({long_json}), 'sparam'))</query>
<query>SELECT 'simdjson-7', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractString(materialize({long_json}), 'sparam', 'nested_1'))</query>
<query>SELECT 'simdjson-8', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractInt(materialize({long_json}), 'nparam'))</query>
<query>SELECT 'simdjson-9', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractUInt(materialize({long_json}), 'nparam'))</query>
<query>SELECT 'simdjson-10', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractRaw(materialize({long_json}), 'fparam'))</query>
<query>SELECT 'simdjson-11', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractFloat(materialize({long_json}), 'fparam'))</query>
<query>SELECT 'simdjson-12', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractFloat(materialize({long_json}), 'fparam', 'nested_2', -2))</query>
<query>SELECT 'simdjson-13', count() FROM zeros(1000000) WHERE NOT ignore(JSONExtractBool(materialize({long_json}), 'bparam'))</query>
</test>

View File

@ -17,34 +17,34 @@
</settings>
<query>SELECT count() FROM
(SELECT materialize(1) AS x1, materialize(1) AS x2, materialize(1) AS x3, materialize(1) AS x4, materialize(1) AS x5, materialize(1) AS x6, materialize(1) AS x7, materialize(1) AS x8, materialize(1) AS x9, materialize(1) AS x10 FROM numbers(20000000))
(SELECT materialize(1) AS x1, materialize(1) AS x2, materialize(1) AS x3, materialize(1) AS x4, materialize(1) AS x5, materialize(1) AS x6, materialize(1) AS x7, materialize(1) AS x8, materialize(1) AS x9, materialize(1) AS x10 FROM zeros(20000000))
WHERE NOT ignore(and(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10))</query>
<query>SELECT count() FROM
(SELECT materialize(0) AS x1, materialize(0) AS x2, materialize(0) AS x3, materialize(0) AS x4, materialize(0) AS x5, materialize(0) AS x6, materialize(0) AS x7, materialize(0) AS x8, materialize(0) AS x9, materialize(0) AS x10 FROM numbers(150000000))
(SELECT materialize(0) AS x1, materialize(0) AS x2, materialize(0) AS x3, materialize(0) AS x4, materialize(0) AS x5, materialize(0) AS x6, materialize(0) AS x7, materialize(0) AS x8, materialize(0) AS x9, materialize(0) AS x10 FROM zeros(150000000))
WHERE NOT ignore(and(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10))</query>
<query>SELECT count() FROM
(SELECT materialize(0) AS x1, materialize(0) AS x2, materialize(0) AS x3, materialize(0) AS x4, materialize(0) AS x5, materialize(0) AS x6, materialize(0) AS x7, materialize(0) AS x8, materialize(0) AS x9, materialize(0) AS x10 FROM numbers(20000000))
(SELECT materialize(0) AS x1, materialize(0) AS x2, materialize(0) AS x3, materialize(0) AS x4, materialize(0) AS x5, materialize(0) AS x6, materialize(0) AS x7, materialize(0) AS x8, materialize(0) AS x9, materialize(0) AS x10 FROM zeros(20000000))
WHERE NOT ignore(or(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10))</query>
<query>SELECT count() FROM
(SELECT materialize(1) AS x1, materialize(1) AS x2, materialize(1) AS x3, materialize(1) AS x4, materialize(1) AS x5, materialize(1) AS x6, materialize(1) AS x7, materialize(1) AS x8, materialize(1) AS x9, materialize(1) AS x10 FROM numbers(100000000))
(SELECT materialize(1) AS x1, materialize(1) AS x2, materialize(1) AS x3, materialize(1) AS x4, materialize(1) AS x5, materialize(1) AS x6, materialize(1) AS x7, materialize(1) AS x8, materialize(1) AS x9, materialize(1) AS x10 FROM zeros(100000000))
WHERE NOT ignore(or(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10))</query>
<query>SELECT count() FROM
(SELECT materialize(1) AS x1, materialize(1) AS x2, materialize(1) AS x3, materialize(1) AS x4, materialize(1) AS x5, materialize(1) AS x6, materialize(1) AS x7, materialize(1) AS x8, materialize(1) AS x9, materialize(1) AS x10 FROM numbers(500000000))
(SELECT materialize(1) AS x1, materialize(1) AS x2, materialize(1) AS x3, materialize(1) AS x4, materialize(1) AS x5, materialize(1) AS x6, materialize(1) AS x7, materialize(1) AS x8, materialize(1) AS x9, materialize(1) AS x10 FROM zeros(500000000))
WHERE NOT ignore(xor(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10))</query>
<query>SELECT count() FROM
(SELECT materialize(toUInt8(1)) AS x1, materialize(toUInt16(1)) AS x2, materialize(toUInt32(1)) AS x3, materialize(toUInt64(1)) AS x4, materialize(toInt8(1)) AS x5, materialize(toInt16(1)) AS x6, materialize(toInt32(1)) AS x7, materialize(toInt64(1)) AS x8, materialize(toFloat32(1)) AS x9, materialize(toFloat64(1)) AS x10 FROM numbers(20000000))
(SELECT materialize(toUInt8(1)) AS x1, materialize(toUInt16(1)) AS x2, materialize(toUInt32(1)) AS x3, materialize(toUInt64(1)) AS x4, materialize(toInt8(1)) AS x5, materialize(toInt16(1)) AS x6, materialize(toInt32(1)) AS x7, materialize(toInt64(1)) AS x8, materialize(toFloat32(1)) AS x9, materialize(toFloat64(1)) AS x10 FROM zeros(20000000))
WHERE NOT ignore(and(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10))</query>
<query>SELECT count() FROM
(SELECT materialize(toUInt8(0)) AS x1, materialize(toUInt16(0)) AS x2, materialize(toUInt32(0)) AS x3, materialize(toUInt64(0)) AS x4, materialize(toInt8(0)) AS x5, materialize(toInt16(0)) AS x6, materialize(toInt32(0)) AS x7, materialize(toInt64(0)) AS x8, materialize(toFloat32(0)) AS x9, materialize(toFloat64(0)) AS x10 FROM numbers(40000000))
(SELECT materialize(toUInt8(0)) AS x1, materialize(toUInt16(0)) AS x2, materialize(toUInt32(0)) AS x3, materialize(toUInt64(0)) AS x4, materialize(toInt8(0)) AS x5, materialize(toInt16(0)) AS x6, materialize(toInt32(0)) AS x7, materialize(toInt64(0)) AS x8, materialize(toFloat32(0)) AS x9, materialize(toFloat64(0)) AS x10 FROM zeros(40000000))
WHERE NOT ignore(and(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10))</query>
<query>SELECT count() FROM
(SELECT materialize(toUInt8(0)) AS x1, materialize(toUInt16(0)) AS x2, materialize(toUInt32(0)) AS x3, materialize(toUInt64(0)) AS x4, materialize(toInt8(0)) AS x5, materialize(toInt16(0)) AS x6, materialize(toInt32(0)) AS x7, materialize(toInt64(0)) AS x8, materialize(toFloat32(0)) AS x9, materialize(toFloat64(0)) AS x10 FROM numbers(20000000))
(SELECT materialize(toUInt8(0)) AS x1, materialize(toUInt16(0)) AS x2, materialize(toUInt32(0)) AS x3, materialize(toUInt64(0)) AS x4, materialize(toInt8(0)) AS x5, materialize(toInt16(0)) AS x6, materialize(toInt32(0)) AS x7, materialize(toInt64(0)) AS x8, materialize(toFloat32(0)) AS x9, materialize(toFloat64(0)) AS x10 FROM zeros(20000000))
WHERE NOT ignore(or(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10))</query>
<query>SELECT count() FROM
(SELECT materialize(toUInt8(1)) AS x1, materialize(toUInt16(1)) AS x2, materialize(toUInt32(1)) AS x3, materialize(toUInt64(1)) AS x4, materialize(toInt8(1)) AS x5, materialize(toInt16(1)) AS x6, materialize(toInt32(1)) AS x7, materialize(toInt64(1)) AS x8, materialize(toFloat32(1)) AS x9, materialize(toFloat64(1)) AS x10 FROM numbers(20000000))
(SELECT materialize(toUInt8(1)) AS x1, materialize(toUInt16(1)) AS x2, materialize(toUInt32(1)) AS x3, materialize(toUInt64(1)) AS x4, materialize(toInt8(1)) AS x5, materialize(toInt16(1)) AS x6, materialize(toInt32(1)) AS x7, materialize(toInt64(1)) AS x8, materialize(toFloat32(1)) AS x9, materialize(toFloat64(1)) AS x10 FROM zeros(20000000))
WHERE NOT ignore(or(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10))</query>
<query>SELECT count() FROM
(SELECT materialize(toUInt8(1)) AS x1, materialize(toUInt16(1)) AS x2, materialize(toUInt32(1)) AS x3, materialize(toUInt64(1)) AS x4, materialize(toInt8(1)) AS x5, materialize(toInt16(1)) AS x6, materialize(toInt32(1)) AS x7, materialize(toInt64(1)) AS x8, materialize(toFloat32(1)) AS x9, materialize(toFloat64(1)) AS x10 FROM numbers(20000000))
(SELECT materialize(toUInt8(1)) AS x1, materialize(toUInt16(1)) AS x2, materialize(toUInt32(1)) AS x3, materialize(toUInt64(1)) AS x4, materialize(toInt8(1)) AS x5, materialize(toInt16(1)) AS x6, materialize(toInt32(1)) AS x7, materialize(toInt64(1)) AS x8, materialize(toFloat32(1)) AS x9, materialize(toFloat64(1)) AS x10 FROM zeros(20000000))
WHERE NOT ignore(xor(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10))</query>
</test>

View File

@ -16,26 +16,26 @@
<max_threads>1</max_threads>
</settings>
<query>SELECT count() FROM (SELECT materialize(1) AS x1, materialize(1) AS x2, materialize(1) AS x3 FROM numbers(100000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(0) AS x1, materialize(0) AS x2, materialize(0) AS x3 FROM numbers(200000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(0) AS x1, materialize(0) AS x2, materialize(0) AS x3 FROM numbers(100000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(1) AS x1, materialize(1) AS x2, materialize(1) AS x3 FROM numbers(100000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(1) AS x1, materialize(1) AS x2, materialize(1) AS x3 FROM zeros(100000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(0) AS x1, materialize(0) AS x2, materialize(0) AS x3 FROM zeros(200000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(0) AS x1, materialize(0) AS x2, materialize(0) AS x3 FROM zeros(100000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(1) AS x1, materialize(1) AS x2, materialize(1) AS x3 FROM zeros(100000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<!-- Check with bigger types -->
<query>SELECT count() FROM (SELECT materialize(1) AS x1, materialize(toUInt32(1)) AS x2, materialize(toUInt64(1)) AS x3 FROM numbers(50000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(0) AS x1, materialize(toUInt32(0)) AS x2, materialize(toUInt64(0)) AS x3 FROM numbers(100000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(0) AS x1, materialize(toUInt32(0)) AS x2, materialize(toUInt64(0)) AS x3 FROM numbers(50000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(1) AS x1, materialize(toUInt32(1)) AS x2, materialize(toUInt64(1)) AS x3 FROM numbers(100000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(1) AS x1, materialize(toUInt32(1)) AS x2, materialize(toUInt64(1)) AS x3 FROM zeros(50000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(0) AS x1, materialize(toUInt32(0)) AS x2, materialize(toUInt64(0)) AS x3 FROM zeros(100000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(0) AS x1, materialize(toUInt32(0)) AS x2, materialize(toUInt64(0)) AS x3 FROM zeros(50000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(1) AS x1, materialize(toUInt32(1)) AS x2, materialize(toUInt64(1)) AS x3 FROM zeros(100000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(1)) AS x1, materialize(toNullable(1)) AS x2, materialize(toNullable(1)) AS x3 FROM numbers(20000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(0)) AS x1, materialize(toNullable(0)) AS x2, materialize(toNullable(0)) AS x3 FROM numbers(50000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(0)) AS x1, materialize(toNullable(0)) AS x2, materialize(toNullable(0)) AS x3 FROM numbers(20000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(1)) AS x1, materialize(toNullable(1)) AS x2, materialize(toNullable(1)) AS x3 FROM numbers(50000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(1)) AS x1, materialize(toNullable(1)) AS x2, materialize(toNullable(1)) AS x3 FROM zeros(20000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(0)) AS x1, materialize(toNullable(0)) AS x2, materialize(toNullable(0)) AS x3 FROM zeros(50000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(0)) AS x1, materialize(toNullable(0)) AS x2, materialize(toNullable(0)) AS x3 FROM zeros(20000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(1)) AS x1, materialize(toNullable(1)) AS x2, materialize(toNullable(1)) AS x3 FROM zeros(50000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(toUInt16(1))) AS x1, materialize(toNullable(toUInt32(1))) AS x2, materialize(toNullable(toUInt64(1))) AS x3 FROM numbers(20000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(toUInt16(0))) AS x1, materialize(toNullable(toUInt32(0))) AS x2, materialize(toNullable(toUInt64(0))) AS x3 FROM numbers(50000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(toUInt16(0))) AS x1, materialize(toNullable(toUInt32(0))) AS x2, materialize(toNullable(toUInt64(0))) AS x3 FROM numbers(20000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(toUInt16(1))) AS x1, materialize(toNullable(toUInt32(1))) AS x2, materialize(toNullable(toUInt64(1))) AS x3 FROM numbers(50000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(toUInt16(1))) AS x1, materialize(toNullable(toUInt32(1))) AS x2, materialize(toNullable(toUInt64(1))) AS x3 FROM zeros(20000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(toUInt16(0))) AS x1, materialize(toNullable(toUInt32(0))) AS x2, materialize(toNullable(toUInt64(0))) AS x3 FROM zeros(50000000)) WHERE NOT ignore(and(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(toUInt16(0))) AS x1, materialize(toNullable(toUInt32(0))) AS x2, materialize(toNullable(toUInt64(0))) AS x3 FROM zeros(20000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<query>SELECT count() FROM (SELECT materialize(toNullable(toUInt16(1))) AS x1, materialize(toNullable(toUInt32(1))) AS x2, materialize(toNullable(toUInt64(1))) AS x3 FROM zeros(50000000)) WHERE NOT ignore(or(x1,x2,x3))</query>
<!-- We have to check the high performing XOR function against in-memory data to avoid the overhead of data generating code -->
<create_query>CREATE DATABASE IF NOT EXISTS test_logical_functions</create_query>
@ -44,10 +44,10 @@
<create_query>CREATE TABLE test_logical_functions._4_1_Mixed (x1 UInt16, x2 UInt32, x3 UInt64, x4 UInt8) ENGINE = Memory</create_query>
<create_query>CREATE TABLE test_logical_functions._4_1_Nullable_UInt8 (x1 Nullable(UInt8), x2 Nullable(UInt8), x3 Nullable(UInt8), x4 Nullable(UInt8)) ENGINE = Memory</create_query>
<create_query>CREATE TABLE test_logical_functions._4_1_Nullable_Mixed (x1 Nullable(UInt16), x2 Nullable(UInt32), x3 Nullable(UInt64), x4 Nullable(Float64)) ENGINE = Memory</create_query>
<fill_query>INSERT INTO test_logical_functions._4_1_UInt8 SELECT materialize(1), materialize(1), materialize(1), materialize(1) FROM numbers(500000000)</fill_query>
<fill_query>INSERT INTO test_logical_functions._4_1_Mixed SELECT materialize(1), materialize(1), materialize(1), materialize(1) FROM numbers(150000000)</fill_query>
<fill_query>INSERT INTO test_logical_functions._4_1_Nullable_UInt8 SELECT materialize(1), materialize(1), materialize(1), materialize(1) FROM numbers(150000000)</fill_query>
<fill_query>INSERT INTO test_logical_functions._4_1_Nullable_Mixed SELECT materialize(1), materialize(1), materialize(1), materialize(1.0) FROM numbers(50000000)</fill_query>
<fill_query>INSERT INTO test_logical_functions._4_1_UInt8 SELECT materialize(1), materialize(1), materialize(1), materialize(1) FROM zeros(500000000)</fill_query>
<fill_query>INSERT INTO test_logical_functions._4_1_Mixed SELECT materialize(1), materialize(1), materialize(1), materialize(1) FROM zeros(150000000)</fill_query>
<fill_query>INSERT INTO test_logical_functions._4_1_Nullable_UInt8 SELECT materialize(1), materialize(1), materialize(1), materialize(1) FROM zeros(150000000)</fill_query>
<fill_query>INSERT INTO test_logical_functions._4_1_Nullable_Mixed SELECT materialize(1), materialize(1), materialize(1), materialize(1.0) FROM zeros(50000000)</fill_query>
<query>SELECT count() FROM test_logical_functions._4_1_UInt8 WHERE NOT ignore(xor(x1,x2,x3,x4))</query>
<query>SELECT count() FROM test_logical_functions._4_1_Mixed WHERE NOT ignore(xor(x1,x2,x3,x4))</query>

View File

@ -25,8 +25,8 @@
<create_query>CREATE TABLE test_logical_functions._2_0_UInt8 (x1 UInt8, x2 UInt8) ENGINE = Memory</create_query>
<create_query>CREATE TABLE test_logical_functions._2_1_UInt8 (x1 UInt8, x2 UInt8) ENGINE = Memory</create_query>
<fill_query>INSERT INTO test_logical_functions._2_0_UInt8 SELECT materialize(0) AS x1, materialize(0) AS x2 FROM numbers(1000000000)</fill_query>
<fill_query>INSERT INTO test_logical_functions._2_1_UInt8 SELECT materialize(1) AS x1, materialize(1) AS x2 FROM numbers(1000000000)</fill_query>
<fill_query>INSERT INTO test_logical_functions._2_0_UInt8 SELECT materialize(0) AS x1, materialize(0) AS x2 FROM zeros(1000000000)</fill_query>
<fill_query>INSERT INTO test_logical_functions._2_1_UInt8 SELECT materialize(1) AS x1, materialize(1) AS x2 FROM zeros(1000000000)</fill_query>
<query>SELECT count() FROM test_logical_functions._2_1_UInt8 WHERE NOT ignore(and(x1,x2))</query>
<query>SELECT count() FROM test_logical_functions._2_0_UInt8 WHERE NOT ignore(and(x1,x2))</query>
@ -34,20 +34,20 @@
<query>SELECT count() FROM test_logical_functions._2_1_UInt8 WHERE NOT ignore(or(x1,x2))</query>
<query>SELECT count() FROM test_logical_functions._2_1_UInt8 WHERE NOT ignore(xor(x1,x2))</query>
<query>SELECT count() FROM (SELECT toNullable(materialize(1)) AS x1, toNullable(materialize(1)) AS x2 FROM numbers(30000000)) WHERE NOT ignore(and(x1,x2))</query>
<query>SELECT count() FROM (SELECT toNullable(materialize(0)) AS x1, toNullable(materialize(0)) AS x2 FROM numbers(40000000)) WHERE NOT ignore(and(x1,x2))</query>
<query>SELECT count() FROM (SELECT toNullable(materialize(0)) AS x1, toNullable(materialize(0)) AS x2 FROM numbers(40000000)) WHERE NOT ignore(or(x1,x2))</query>
<query>SELECT count() FROM (SELECT toNullable(materialize(1)) AS x1, toNullable(materialize(1)) AS x2 FROM numbers(30000000)) WHERE NOT ignore(or(x1,x2))</query>
<query>SELECT count() FROM (SELECT toNullable(materialize(1)) AS x1, toNullable(materialize(1)) AS x2 FROM numbers(100000000)) WHERE NOT ignore(xor(x1,x2))</query>
<query>SELECT count() FROM (SELECT toNullable(materialize(1)) AS x1, toNullable(materialize(1)) AS x2 FROM zeros(30000000)) WHERE NOT ignore(and(x1,x2))</query>
<query>SELECT count() FROM (SELECT toNullable(materialize(0)) AS x1, toNullable(materialize(0)) AS x2 FROM zeros(40000000)) WHERE NOT ignore(and(x1,x2))</query>
<query>SELECT count() FROM (SELECT toNullable(materialize(0)) AS x1, toNullable(materialize(0)) AS x2 FROM zeros(40000000)) WHERE NOT ignore(or(x1,x2))</query>
<query>SELECT count() FROM (SELECT toNullable(materialize(1)) AS x1, toNullable(materialize(1)) AS x2 FROM zeros(30000000)) WHERE NOT ignore(or(x1,x2))</query>
<query>SELECT count() FROM (SELECT toNullable(materialize(1)) AS x1, toNullable(materialize(1)) AS x2 FROM zeros(100000000)) WHERE NOT ignore(xor(x1,x2))</query>
<!-- Check with bigger types: UInt16, UInt32, UInt64, Float64 -->
<query>SELECT count() FROM (SELECT materialize(toUInt16(1)) AS x1, materialize(toUInt32(1)) AS x2 FROM numbers(200000000)) WHERE NOT ignore(and(x1,x2))</query>
<query>SELECT count() FROM (SELECT materialize(toUInt32(1)) AS x1, materialize(toUInt64(1)) AS x2 FROM numbers(100000000)) WHERE NOT ignore(and(x1,x2))</query>
<query>SELECT count() FROM (SELECT materialize(toUInt64(1)) AS x1, materialize(0.1) AS x2 FROM numbers(100000000)) WHERE NOT ignore(and(x1,x2))</query>
<query>SELECT count() FROM (SELECT materialize(toUInt16(1)) AS x1, materialize(toUInt32(1)) AS x2 FROM numbers(200000000)) WHERE NOT ignore(or(x1,x2))</query>
<query>SELECT count() FROM (SELECT materialize(toUInt32(1)) AS x1, materialize(toUInt64(1)) AS x2 FROM numbers(100000000)) WHERE NOT ignore(or(x1,x2))</query>
<query>SELECT count() FROM (SELECT materialize(toUInt64(1)) AS x1, materialize(0.1) AS x2 FROM numbers(100000000)) WHERE NOT ignore(or(x1,x2))</query>
<query>SELECT count() FROM (SELECT materialize(toUInt64(1)) AS x1, materialize(toUInt64(1)) AS x2 FROM numbers(100000000)) WHERE NOT ignore(xor(x1,x2))</query>
<query>SELECT count() FROM (SELECT materialize(toUInt16(1)) AS x1, materialize(toUInt32(1)) AS x2 FROM zeros(200000000)) WHERE NOT ignore(and(x1,x2))</query>
<query>SELECT count() FROM (SELECT materialize(toUInt32(1)) AS x1, materialize(toUInt64(1)) AS x2 FROM zeros(100000000)) WHERE NOT ignore(and(x1,x2))</query>
<query>SELECT count() FROM (SELECT materialize(toUInt64(1)) AS x1, materialize(0.1) AS x2 FROM zeros(100000000)) WHERE NOT ignore(and(x1,x2))</query>
<query>SELECT count() FROM (SELECT materialize(toUInt16(1)) AS x1, materialize(toUInt32(1)) AS x2 FROM zeros(200000000)) WHERE NOT ignore(or(x1,x2))</query>
<query>SELECT count() FROM (SELECT materialize(toUInt32(1)) AS x1, materialize(toUInt64(1)) AS x2 FROM zeros(100000000)) WHERE NOT ignore(or(x1,x2))</query>
<query>SELECT count() FROM (SELECT materialize(toUInt64(1)) AS x1, materialize(0.1) AS x2 FROM zeros(100000000)) WHERE NOT ignore(or(x1,x2))</query>
<query>SELECT count() FROM (SELECT materialize(toUInt64(1)) AS x1, materialize(toUInt64(1)) AS x2 FROM zeros(100000000)) WHERE NOT ignore(xor(x1,x2))</query>
<drop_query>DROP TABLE test_logical_functions._2_0_UInt8</drop_query>
<drop_query>DROP TABLE test_logical_functions._2_1_UInt8</drop_query>

View File

@ -190,7 +190,7 @@
rand64(691) % 5 as c691, rand64(692) % 5 as c692, rand64(693) % 5 as c693, rand64(694) % 5 as c694, rand64(695) % 5 as c695,
rand64(696) % 5 as c696, rand64(697) % 5 as c697, rand64(698) % 5 as c698, rand64(699) % 5 as c699, rand64(700) % 5 as c700,
rand64(701) % 5 as c701
FROM system.numbers
FROM system.zeros
LIMIT 1048576
</create_query>

View File

@ -7,11 +7,11 @@
</stop_conditions>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(randomPrintableASCII(10))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(randomPrintableASCII(100))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(randomPrintableASCII(1000))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(randomPrintableASCII(10000))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(randomPrintableASCII(rand() % 10))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(randomPrintableASCII(rand() % 100))</query>
<query>SELECT count() FROM numbers(1000000) WHERE NOT ignore(randomPrintableASCII(rand() % 1000))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(randomPrintableASCII(10))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(randomPrintableASCII(100))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(randomPrintableASCII(1000))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(randomPrintableASCII(10000))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(randomPrintableASCII(rand() % 10))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(randomPrintableASCII(rand() % 100))</query>
<query>SELECT count() FROM zeros(1000000) WHERE NOT ignore(randomPrintableASCII(rand() % 1000))</query>
</test>

View File

@ -10,9 +10,9 @@
</stop_conditions>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(roundDuration(rand() % 65536))</query>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(roundDown(rand() % 65536, [0, 1, 10, 30, 60, 120, 180, 240, 300, 600, 1200, 1800, 3600, 7200, 18000, 36000]))</query>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(roundAge(rand() % 100))</query>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(roundDown(rand() % 100, [0, 1, 18, 25, 35, 45, 55]))</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(roundDuration(rand() % 65536))</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(roundDown(rand() % 65536, [0, 1, 10, 30, 60, 120, 180, 240, 300, 600, 1200, 1800, 3600, 7200, 18000, 36000]))</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(roundAge(rand() % 100))</query>
<query>SELECT count() FROM zeros(10000000) WHERE NOT ignore(roundDown(rand() % 100, [0, 1, 18, 25, 35, 45, 55]))</query>
<query>SELECT count() FROM numbers(10000000) WHERE NOT ignore(roundDown(rand() % 65536, (SELECT groupArray(number) FROM numbers(65536))))</query>
</test>

View File

@ -17,8 +17,8 @@
<substitution>
<name>table</name>
<values>
<value>numbers(10000000)</value>
<value>numbers_mt(100000000)</value>
<value>zeros(10000000)</value>
<value>zeros_mt(100000000)</value>
</values>
</substitution>
<substitution>

View File

@ -14,7 +14,7 @@
</stop_conditions>
<query>SELECT count() FROM test_in WHERE a IN (SELECT rand(1) FROM numbers(100000)) SETTINGS max_rows_to_read = 1, read_overflow_mode = 'break'</query>
<query>SELECT count() FROM test_in WHERE a IN (SELECT rand(1) FROM zeros(100000)) SETTINGS max_rows_to_read = 1, read_overflow_mode = 'break'</query>
<drop_query>DROP TABLE IF EXISTS test_in</drop_query>
</test>

View File

@ -22,19 +22,19 @@
<create_query>CREATE TABLE rand_unlimited_10m_64 (key UInt64) Engine = Memory</create_query>
<fill_query>INSERT INTO rand_unlimited_10m_8 SELECT rand() AS x FROM numbers(10000000)</fill_query>
<fill_query>INSERT INTO rand_unlimited_10m_8 SELECT rand() AS x FROM zeros(10000000)</fill_query>
<fill_query>INSERT INTO rand_1k_10m_16 SELECT rand()%1000 AS x FROM numbers(10000000)</fill_query>
<fill_query>INSERT INTO rand_100k_10m_16 SELECT rand()%100000 AS x FROM numbers(10000000)</fill_query>
<fill_query>INSERT INTO rand_unlimited_10m_16 SELECT rand() AS x FROM numbers(10000000)</fill_query>
<fill_query>INSERT INTO rand_1k_10m_16 SELECT rand()%1000 AS x FROM zeros(10000000)</fill_query>
<fill_query>INSERT INTO rand_100k_10m_16 SELECT rand()%100000 AS x FROM zeros(10000000)</fill_query>
<fill_query>INSERT INTO rand_unlimited_10m_16 SELECT rand() AS x FROM zeros(10000000)</fill_query>
<fill_query>INSERT INTO rand_1k_10m_32 SELECT rand()%1000 AS x FROM numbers(10000000)</fill_query>
<fill_query>INSERT INTO rand_100k_10m_32 SELECT rand()%100000 AS x FROM numbers(10000000)</fill_query>
<fill_query>INSERT INTO rand_unlimited_10m_32 SELECT rand() AS x FROM numbers(10000000)</fill_query>
<fill_query>INSERT INTO rand_1k_10m_32 SELECT rand()%1000 AS x FROM zeros(10000000)</fill_query>
<fill_query>INSERT INTO rand_100k_10m_32 SELECT rand()%100000 AS x FROM zeros(10000000)</fill_query>
<fill_query>INSERT INTO rand_unlimited_10m_32 SELECT rand() AS x FROM zeros(10000000)</fill_query>
<fill_query>INSERT INTO rand_1k_10m_64 SELECT rand()%1000 AS x FROM numbers(10000000)</fill_query>
<fill_query>INSERT INTO rand_100k_10m_64 SELECT rand()%100000 AS x FROM numbers(10000000)</fill_query>
<fill_query>INSERT INTO rand_unlimited_10m_64 SELECT rand() AS x FROM numbers(10000000)</fill_query>
<fill_query>INSERT INTO rand_1k_10m_64 SELECT rand()%1000 AS x FROM zeros(10000000)</fill_query>
<fill_query>INSERT INTO rand_100k_10m_64 SELECT rand()%100000 AS x FROM zeros(10000000)</fill_query>
<fill_query>INSERT INTO rand_unlimited_10m_64 SELECT rand() AS x FROM zeros(10000000)</fill_query>
<query>SELECT sum(key) FROM (SELECT * FROM rand_unlimited_10m_8 ORDER BY key)</query>

View File

@ -15,7 +15,7 @@
<create_query>CREATE TABLE strings (short String, long String) ENGINE Memory</create_query>
<fill_query> INSERT INTO hits_10m_words SELECT DISTINCT arrayJoin(splitByString(' ', SearchPhrase)) AS word, UserID FROM hits_10m_single WHERE length(word) > 0</fill_query>
<fill_query> INSERT INTO strings SELECT toString(rand()) a, a || a || a || a || a || a || a || a || a || a || a || a FROM numbers(1000000)</fill_query>
<fill_query> INSERT INTO strings SELECT toString(rand()) a, a || a || a || a || a || a || a || a || a || a || a || a FROM zeros(1000000)</fill_query>
<settings>
<max_threads>1</max_threads>

View File

@ -15,7 +15,7 @@
<create_query>CREATE TABLE strings (short String, long String) ENGINE Memory</create_query>
<fill_query>INSERT INTO hits_10m_words SELECT DISTINCT arrayJoin(splitByString(' ', SearchPhrase)) AS word, UserID FROM hits_10m_single WHERE length(word) > 0</fill_query>
<fill_query>INSERT INTO strings SELECT toString(rand()) a, a || a || a || a || a || a || a || a || a || a || a || a FROM numbers(1000000)</fill_query>
<fill_query>INSERT INTO strings SELECT toString(rand()) a, a || a || a || a || a || a || a || a || a || a || a || a FROM zeros(1000000)</fill_query>
<settings>
<max_threads>1</max_threads>

View File

@ -15,8 +15,8 @@
Мы запускаем этот запрос и наблюдаем, с какой скоростью он выполняется. Через несколько секунд, когда скорость стабилизируется, прерываем выполнение.
В качестве скорости выполнения запроса указывается количество обработанных исходных (прочитанных из таблицы) данных в единицу времени.
Например, в таблице numbers читаемые нами данные - это числа типа UInt64 (8 байт). Если мы обрабатываем миллиард таких чисел в секунду, то отобразится скорость - 8 GB/sec. -->
<query>SELECT count() FROM numbers(100000000) WHERE NOT ignore(rand())</query>
<query>SELECT count() FROM numbers_mt(1600000000) WHERE NOT ignore(rand())</query>
<query>SELECT count() FROM zeros(100000000) WHERE NOT ignore(rand())</query>
<query>SELECT count() FROM zeros_mt(1600000000) WHERE NOT ignore(rand())</query>
<!-- 10. Некриптографическая хэш-функция для целых чисел 64bit -> 64bit. -->
<query>SELECT count() FROM numbers(100000000) WHERE NOT ignore(intHash64(number))</query>
<query>SELECT count() FROM numbers_mt(1600000000) WHERE NOT ignore(intHash64(number))</query>
@ -56,6 +56,6 @@
<!-- 35. Кэш-промахи, осуществляемые из многих процессорных ядер. -->
<!-- <query>SELECT number % (intDiv(100000000, {THREADS})) AS k, count() FROM numbers_mt(1600000000) GROUP BY k</query> -->
<!-- 46. Запрос, требующий много бесполезных копирований. -->
<query>SELECT count() FROM numbers(100000000) WHERE NOT ignore(materialize('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') AS s, concat(s,s,s,s,s,s,s,s,s,s) AS t, concat(t,t,t,t,t,t,t,t,t,t) AS u) SETTINGS max_block_size = 1000</query>
<query>SELECT count() FROM zeros(100000000) WHERE NOT ignore(materialize('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') AS s, concat(s,s,s,s,s,s,s,s,s,s) AS t, concat(t,t,t,t,t,t,t,t,t,t) AS u) SETTINGS max_block_size = 1000</query>
</test>

View File

@ -19,7 +19,7 @@
<fill_query>INSERT INTO array_data SELECT number % 1024, arrayWithConstant(16, number) from numbers(10000000)</fill_query>
<query>SELECT countMerge(v) FROM (SELECT countState() v FROM numbers(1000000000)) FORMAT Null</query>
<query>SELECT countMerge(v) FROM (SELECT countState() v FROM zeros(1000000000)) FORMAT Null</query>
<query>SELECT countMerge(v) FROM (SELECT number % 1024 k, countState() v FROM numbers(1000000000) GROUP BY k) FORMAT Null</query>
<query>SELECT sumArray(v) FROM array_data FORMAT Null</query>

View File

@ -16,5 +16,5 @@
</substitution>
</substitutions>
<query>SELECT count() FROM numbers(2000000) WHERE NOT ignore(visitParamExtractRaw(materialize({param}), 'myparam'))</query>
<query>SELECT count() FROM zeros(2000000) WHERE NOT ignore(visitParamExtractRaw(materialize({param}), 'myparam'))</query>
</test>

View File

@ -59,6 +59,8 @@ ${CLICKHOUSE_CLIENT} --query="KILL MUTATION WHERE database = 'test' AND table =
wait
${CLICKHOUSE_CLIENT} --query="SELECT * FROM test.kill_mutation"
# must always be empty
${CLICKHOUSE_CLIENT} --query="SELECT * FROM system.mutations WHERE table = 'kill_mutation' AND database = 'test' AND is_done = 0"
${CLICKHOUSE_CLIENT} --query="DROP TABLE test.kill_mutation"

View File

@ -2,6 +2,7 @@
0000000000 1 1 Code: 6,
waiting test kill_mutation_r1 0000000000
Mutation 0000000000 was killed
0
*** Create and kill invalid mutation that blocks another mutation ***
0000000001 1 1 Code: 6,
waiting test kill_mutation_r1 0000000001

View File

@ -36,12 +36,17 @@ ${CLICKHOUSE_CLIENT} --query="KILL MUTATION WHERE database = 'test' AND table =
wait
${CLICKHOUSE_CLIENT} --query="SELECT mutation_id FROM system.mutations WHERE database = 'test' AND table = 'kill_mutation_r1'"
# No active mutations exists
${CLICKHOUSE_CLIENT} --query="SELECT count() FROM system.mutations WHERE database = 'test' AND table = 'kill_mutation_r1'"
${CLICKHOUSE_CLIENT} --query="SELECT '*** Create and kill invalid mutation that blocks another mutation ***'"
${CLICKHOUSE_CLIENT} --query="SYSTEM SYNC REPLICA test.kill_mutation_r1"
${CLICKHOUSE_CLIENT} --query="SYSTEM SYNC REPLICA test.kill_mutation_r2"
# Should be empty, but in case of problems we will see some diagnostics
${CLICKHOUSE_CLIENT} --query="SELECT * FROM system.replication_queue WHERE table like 'kill_mutation_r%'"
${CLICKHOUSE_CLIENT} --query="ALTER TABLE test.kill_mutation_r1 DELETE WHERE toUInt32(s) = 1"
# good mutation, but blocked with wrong mutation
@ -63,7 +68,12 @@ ${CLICKHOUSE_CLIENT} --query="KILL MUTATION WHERE database = 'test' AND table =
wait
${CLICKHOUSE_CLIENT} --query="SYSTEM SYNC REPLICA test.kill_mutation_r1"
${CLICKHOUSE_CLIENT} --query="SYSTEM SYNC REPLICA test.kill_mutation_r2"
${CLICKHOUSE_CLIENT} --query="SELECT * FROM test.kill_mutation_r2"
# must be empty
${CLICKHOUSE_CLIENT} --query="SELECT * FROM system.mutations WHERE table = 'kill_mutation' AND database = 'test' AND is_done = 0"
${CLICKHOUSE_CLIENT} --query="DROP TABLE test.kill_mutation_r1"

View File

@ -20,7 +20,7 @@ function thread1()
function thread2()
{
while true; do $CLICKHOUSE_CLIENT -n --query "ALTER TABLE alter_table ADD COLUMN h String; ALTER TABLE alter_table MODIFY COLUMN h UInt64; ALTER TABLE alter_table DROP COLUMN h;"; done
while true; do $CLICKHOUSE_CLIENT -n --query "ALTER TABLE alter_table ADD COLUMN h String DEFAULT '0'; ALTER TABLE alter_table MODIFY COLUMN h UInt64; ALTER TABLE alter_table DROP COLUMN h;"; done
}
function thread3()

View File

@ -0,0 +1,32 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS mt_compact"
# Checks that granularity correctly computed from small parts.
$CLICKHOUSE_CLIENT -q "CREATE TABLE mt_compact(a Int, s String) ENGINE = MergeTree ORDER BY a
SETTINGS min_rows_for_wide_part = 1000,
index_granularity = 14;"
$CLICKHOUSE_CLIENT -q "SYSTEM STOP MERGES mt_compact"
$CLICKHOUSE_CLIENT --max_block_size=1 --min_insert_block_size_rows=1 -q \
"INSERT INTO mt_compact SELECT number, 'aaa' FROM numbers(100);"
$CLICKHOUSE_CLIENT -q "SELECT count() FROM system.parts WHERE table = 'mt_compact' AND database = currentDatabase() AND active"
$CLICKHOUSE_CLIENT -q "SYSTEM START MERGES mt_compact"
# Retry because already started concurrent merges may interrupt optimize
for i in {0..10}; do
$CLICKHOUSE_CLIENT -q "OPTIMIZE TABLE mt_compact FINAL SETTINGS optimize_throw_if_noop=1" 2>/dev/null
if [ $? -eq 0 ]; then
break
fi
sleep 0.1
done
$CLICKHOUSE_CLIENT -q "SELECT count(), sum(marks) FROM system.parts WHERE table = 'mt_compact' AND database = currentDatabase() AND active"
$CLICKHOUSE_CLIENT -q "DROP TABLE mt_compact"

View File

@ -1,21 +0,0 @@
drop table if exists mt_compact;
-- Checks that granularity correctly computed from small parts.
create table mt_compact(a Int, s String) engine = MergeTree order by a
settings min_rows_for_wide_part = 1000,
index_granularity = 14;
system stop merges mt_compact;
set max_block_size = 1;
set min_insert_block_size_rows=1;
insert into mt_compact select number, 'aaa' from numbers(100);
select count() from system.parts where table = 'mt_compact' and database = currentDatabase() and active;
system start merges mt_compact;
optimize table mt_compact final;
select count(), sum(marks) from system.parts where table = 'mt_compact' and database = currentDatabase() and active;
drop table mt_compact;

View File

@ -0,0 +1,48 @@
0
0
0
0
0
0
0
0
0
0
-
0
0
0
0
0
0
0
0
0
0
-
0
0
0
0
0
0
0
0
0
0
-
0
0
0
0
0
0
0
0
0
0
-
0 1000000000
0 1000000000
0 1000000000
0 1000000000

View File

@ -0,0 +1,12 @@
select zero from system.zeros limit 10 settings max_block_size = 3;
select '-';
select zero from system.zeros_mt limit 10 settings max_block_size = 3, max_threads = 2;
select '-';
select zero from zeros(10) settings max_block_size = 3;
select '-';
select zero from zeros_mt(10) settings max_block_size = 3, max_threads=3;
select '-';
select sum(zero), count() from (select * from system.zeros limit 1000000000);
select sum(zero), count() from (select * from system.zeros_mt limit 1000000000);
select sum(zero), count() from zeros(1000000000);
select sum(zero), count() from zeros_mt(1000000000);

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,21 @@
DROP TABLE IF EXISTS table_with_cyclic_defaults;
CREATE TABLE table_with_cyclic_defaults (a DEFAULT b, b DEFAULT a) ENGINE = Memory; --{serverError 174}
CREATE TABLE table_with_cyclic_defaults (a DEFAULT b + 1, b DEFAULT a * a) ENGINE = Memory; --{serverError 174}
CREATE TABLE table_with_cyclic_defaults (a DEFAULT b, b DEFAULT toString(c), c DEFAULT concat(a, '1')) ENGINE = Memory; --{serverError 174}
CREATE TABLE table_with_cyclic_defaults (a DEFAULT b, b DEFAULT c, c DEFAULT a * b) ENGINE = Memory; --{serverError 174}
CREATE TABLE table_with_cyclic_defaults (a String DEFAULT b, b String DEFAULT a) ENGINE = Memory; --{serverError 174}
CREATE TABLE table_with_cyclic_defaults (a String) ENGINE = Memory;
ALTER TABLE table_with_cyclic_defaults ADD COLUMN c String DEFAULT b, ADD COLUMN b String DEFAULT c; --{serverError 174}
ALTER TABLE table_with_cyclic_defaults ADD COLUMN b String DEFAULT a, MODIFY COLUMN a DEFAULT b; --{serverError 174}
SELECT 1;
DROP TABLE IF EXISTS table_with_cyclic_defaults;

View File

@ -28,6 +28,8 @@ then
cp -r ../docker/test/performance-comparison/config /output ||:
rm /output/unit_tests_dbms ||:
rm /output/clickhouse-odbc-bridge ||:
cp -r ../docker/test/performance-comparison /output/scripts ||:
fi
# May be set for split build or for performance test.

View File

@ -1,6 +1,6 @@
# DateTime {#data_type-datetime}
Allows to store an instant in time, that can be expressed as a calendar date and a time of a day. `DateTime` allows to take into account time zones for stored values.
Allows to store an instant in time, that can be expressed as a calendar date and a time of a day.
Syntax:
@ -12,21 +12,17 @@ Supported range of values: [1970-01-01 00:00:00, 2105-12-31 23:59:59].
Resolution: 1 second.
SELECT toDateTime(0)
FORMAT TSV
0000-00-00 00:00:00
## Usage Remarks
A moment of time is stored as [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time), independently of time zones and daylight savings. Additionally `DateTime` can store time zone, that affects how `DateTime` values are displayed in text format and how input strings are parsed for storage. The `tzdata` package, containing [IANA Time Zone Database](https://www.iana.org/time-zones), should be installed in the system. Use the `timedatectl list-timezones` command to list timezones known by a local system.
The point in time is saved as a [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time), regardless of the time zone or daylight saving time. Additionally, the `DateTime` type can store time zone that is the same for the entire column, that affects how the values of the `DateTime` type values are displayed in text format and how the values specified as strings are parsed ('2020-01-01 05:00:01'). The time zone is not stored in the rows of the table (or in resultset), but is stored in the column metadata.
A list of supported time zones can be found in the [IANA Time Zone Database](https://www.iana.org/time-zones).
The `tzdata` package, containing [IANA Time Zone Database](https://www.iana.org/time-zones), should be installed in the system. Use the `timedatectl list-timezones` command to list timezones known by a local system.
You can explicitly set a time zone for `DateTime`-type columns when creating a table. If the time zone isn't set, ClickHouse uses the value of the [timezone](../operations/server_settings/settings.md#server_settings-timezone) parameter in the server settings or the operating system settings at the moment of the ClickHouse server start.
The [clickhouse-client](../interfaces/cli.md) applies the server time zone by default if a time zone isn't explicitly set when initializing the data type. To use the client time zone, run `clickhouse-client` with the `--use_client_time_zone` parameter.
ClickHouse outputs values in `YYYY-MM-DD hh:mm:ss` text format by default. You can change the format with the [formatDateTime](../query_language/functions/date_time_functions.md#formatdatetime) function.
ClickHouse outputs values in `YYYY-MM-DD hh:mm:ss` text format by default. You can change the output with the [formatDateTime](../query_language/functions/date_time_functions.md#formatdatetime) function.
When inserting data into ClickHouse, you can use different formats of date and time strings, depending on the value of the [date_time_input_format](../operations/settings/settings.md#settings-date_time_input_format) setting.
@ -40,13 +36,13 @@ CREATE TABLE dt
`timestamp` DateTime('Europe/Moscow'),
`event_id` UInt8
)
ENGINE = TinyLog
ENGINE = TinyLog;
```
```sql
INSERT INTO dt Values (1546300800, 1), ('2019-01-01 00:00:00', 2)
INSERT INTO dt Values (1546300800, 1), ('2019-01-01 00:00:00', 2);
```
```sql
SELECT * FROM dt
SELECT * FROM dt;
```
```text
┌───────────timestamp─┬─event_id─┐
@ -55,7 +51,10 @@ SELECT * FROM dt
└─────────────────────┴──────────┘
```
Unix timestamp `1546300800` represents the `'2019-01-01 00:00:00'` date and time in `Europe/London` (UTC+0) time zone, but the `timestamp` column stores values in the `Europe/Moscow` (UTC+3) timezone, so the value inserted as Unix timestamp is formatted as `2019-01-01 03:00:00`.
* When inserting datetime as an integer, it is treated as Unix Timestamp (UTC). `1546300800` represents `'2019-01-01 00:00:00'` UTC. However, as `timestamp` column has `Europe/Moscow` (UTC+3) timezone specified, when outputting as string the value will be shown as `'2019-01-01 03:00:00'`
* When inserting string value as datetime, it is treated as being in column timezone. `'2019-01-01 00:00:00'` will be treated as being in `Europe/Moscow` timezone and saved as `1546290000`.
**2.** Filtering on `DateTime` values
```sql
SELECT * FROM dt WHERE timestamp = toDateTime('2019-01-01 00:00:00', 'Europe/Moscow')
@ -65,8 +64,17 @@ SELECT * FROM dt WHERE timestamp = toDateTime('2019-01-01 00:00:00', 'Europe/Mos
│ 2019-01-01 00:00:00 │ 2 │
└─────────────────────┴──────────┘
```
`DateTime` column values can be filtered using a string value in `WHERE` predicate. It will be converted to `DateTime` automatically:
```sql
SELECT * FROM dt WHERE timestamp = '2019-01-01 00:00:00'
```
```text
┌───────────timestamp─┬─event_id─┐
│ 2019-01-01 03:00:00 │ 1 │
└─────────────────────┴──────────┘
```
**2.** Getting a time zone for a `DateTime`-type value:
**3.** Getting a time zone for a `DateTime`-type column:
```sql
SELECT toDateTime(now(), 'Europe/Moscow') AS column, toTypeName(column) AS x
@ -77,6 +85,21 @@ SELECT toDateTime(now(), 'Europe/Moscow') AS column, toTypeName(column) AS x
└─────────────────────┴───────────────────────────┘
```
**4.** Timezone conversion
```sql
SELECT
toDateTime(timestamp, 'Europe/London') as lon_time,
toDateTime(timestamp, 'Europe/Moscow') as mos_time
FROM dt
```
```text
┌───────────lon_time──┬────────────mos_time─┐
│ 2019-01-01 00:00:00 │ 2019-01-01 03:00:00 │
│ 2018-12-31 21:00:00 │ 2019-01-01 00:00:00 │
└─────────────────────┴─────────────────────┘
```
## See Also
- [Type conversion functions](../query_language/functions/type_conversion_functions.md)

View File

@ -0,0 +1,89 @@
# DateTime64 {#data_type-datetime64}
Allows to store an instant in time, that can be expressed as a calendar date and a time of a day, with defined sub-second precision
Tick size (precision): 10<sup>-precision</sup> seconds
Syntax:
```sql
DateTime64(precision, [timezone])
```
Internally, stores data as number of 'ticks' since epoch start (1970-01-01 00:00:00 UTC) as Int64. The tick resolution is determined by the precision parameter. Additionally, the `DateTime64` type can store time zone that is the same for the entire column, that affects how the values of the `DateTime64` type values are displayed in text format and how the values specified as strings are parsed ('2020-01-01 05:00:01.000'). The time zone is not stored in the rows of the table (or in resultset), but is stored in the column metadata. See details in [DateTime](datetime.md).
## Examples
**1.** Creating a table with `DateTime64`-type column and inserting data into it:
```sql
CREATE TABLE dt
(
`timestamp` DateTime64(3, 'Europe/Moscow'),
`event_id` UInt8
)
ENGINE = TinyLog
```
```sql
INSERT INTO dt Values (1546300800000, 1), ('2019-01-01 00:00:00', 2)
```
```sql
SELECT * FROM dt
```
```text
┌───────────────timestamp─┬─event_id─┐
│ 2019-01-01 03:00:00.000 │ 1 │
│ 2019-01-01 00:00:00.000 │ 2 │
└─────────────────────────┴──────────┘
```
* When inserting datetime as an integer, it is treated as an appropriately scaled Unix Timestamp (UTC). `1546300800000` (with precision 3) represents `'2019-01-01 00:00:00'` UTC. However, as `timestamp` column has `Europe/Moscow` (UTC+3) timezone specified, when outputting as string the value will be shown as `'2019-01-01 03:00:00'`
* When inserting string value as datetime, it is treated as being in column timezone. `'2019-01-01 00:00:00'` will be treated as being in `Europe/Moscow` timezone and stored as `1546290000000`.
**2.** Filtering on `DateTime64` values
```sql
SELECT * FROM dt WHERE timestamp = toDateTime64('2019-01-01 00:00:00', 3, 'Europe/Moscow')
```
```text
┌───────────────timestamp─┬─event_id─┐
│ 2019-01-01 00:00:00.000 │ 2 │
└─────────────────────────┴──────────┘
```
Unlike `DateTime`, `DateTime64` values are not converted from `String` automatically
**3.** Getting a time zone for a `DateTime64`-type value:
```sql
SELECT toDateTime64(now(), 3, 'Europe/Moscow') AS column, toTypeName(column) AS x
```
```text
┌──────────────────column─┬─x──────────────────────────────┐
│ 2019-10-16 04:12:04.000 │ DateTime64(3, 'Europe/Moscow') │
└─────────────────────────┴────────────────────────────────┘
```
**4.** Timezone conversion
```sql
SELECT
toDateTime64(timestamp, 3, 'Europe/London') as lon_time,
toDateTime64(timestamp, 3, 'Europe/Moscow') as mos_time
FROM dt
```
```text
┌───────────────lon_time──┬────────────────mos_time─┐
│ 2019-01-01 00:00:00.000 │ 2019-01-01 03:00:00.000 │
│ 2018-12-31 21:00:00.000 │ 2019-01-01 00:00:00.000 │
└─────────────────────────┴─────────────────────────┘
```
## See Also
- [Type conversion functions](../query_language/functions/type_conversion_functions.md)
- [Functions for working with dates and times](../query_language/functions/date_time_functions.md)
- [Functions for working with arrays](../query_language/functions/array_functions.md)
- [The `date_time_input_format` setting](../operations/settings/settings.md#settings-date_time_input_format)
- [The `timezone` server configuration parameter](../operations/server_settings/settings.md#server_settings-timezone)
- [Operators for working with dates and times](../query_language/operators.md#operators-datetime)
- [`Date` data type](date.md)
- [`DateTime` data type](datetime.md)

View File

@ -40,8 +40,8 @@
- [AORM](https://github.com/TanVD/AORM)
- C#
- [ClickHouse.Ado](https://github.com/killwort/ClickHouse-Net)
- [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net)
- [ClickHouse.Client](https://github.com/DarkWanderer/ClickHouse.Client)
- [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net)
- Elixir
- [clickhousex](https://github.com/appodeal/clickhousex/)
- Nim

View File

@ -78,6 +78,7 @@
- C#
- [ADO.NET](https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/ado-net-overview)
- [ClickHouse.Ado](https://github.com/killwort/ClickHouse-Net)
- [ClickHouse.Client](https://github.com/DarkWanderer/ClickHouse.Client)
- [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net)
- [ClickHouse.Net.Migrations](https://github.com/ilyabreev/ClickHouse.Net.Migrations)
- Elixir

View File

@ -1,6 +1,6 @@
# DateTime {#data_type-datetime}
Позволяет хранить момент времени, который может быть представлен как календарная дата и время. `DateTime` позволяет учесть часовой пояс для хранимых значений.
Позволяет хранить момент времени, который может быть представлен как календарная дата и время.
Синтаксис:
@ -14,13 +14,15 @@ DateTime([timezone])
## Использование
Момент времени сохраняется как Unix timestamp, независимо от часового пояса и переходов на летнее/зимнее время. Дополнительно, `DateTime` позволяет хранить часовой пояс, который влияет на то, как буду отображаться значения типа `DateTime` в текстовом виде и как будут парситься входные строки. Список поддержанных временных зон можно найти в [IANA Time Zone Database](https://www.iana.org/time-zones).
Момент времени сохраняется как [Unix timestamp](https://ru.wikipedia.org/wiki/Unix-%D0%B2%D1%80%D0%B5%D0%BC%D1%8F), независимо от часового пояса и переходов на летнее/зимнее время. Дополнительно, тип `DateTime` позволяет хранить часовой пояс, единый для всей колонки, который влияет на то, как будут отображаться значения типа `DateTime` в текстовом виде и как будут парситься значения заданные в виде строк ('2020-01-01 05:00:01'). Часовой пояс не хранится в строках таблицы (выборки), а хранится в метаданных колонки.
Список поддерживаемых временных зон можно найти в [IANA Time Zone Database](https://www.iana.org/time-zones).
Пакет `tzdata`, содержащий [базу данных часовых поясов IANA](https://www.iana.org/time-zones), должен быть установлен в системе. Используйте команду `timedatectl list-timezones` для получения списка часовых поясов, известных локальной системе.
Часовой пояс для столбца типа `DateTime` можно в явном виде установить при создании таблицы. Если часовой пояс не установлен, то ClickHouse использует значение параметра [timezone](../operations/server_settings/settings.md#server_settings-timezone), установленное в конфигурации сервера или в настройках операционной системы на момент запуска сервера.
Консольный клиент ClickHouse по умолчанию использует часовой пояс сервера, если для значения `DateTime` часовой пояс не был задан в явном виде при инициализации типа данных. Чтобы использовать часовой пояс клиента, запустите [clickhouse-client](../interfaces/cli.md) с параметром `--use_client_time_zone`.
ClickHouse по умолчанию выводит значение в формате `YYYY-MM-DD hh:mm:ss`. Формат можно поменять с помощь функции [formatDateTime](../query_language/functions/date_time_functions.md#formatdatetime).
ClickHouse отображает значения типа `DateTime` в формате `YYYY-MM-DD hh:mm:ss`. Отображение можно поменять с помощью функции [formatDateTime](../query_language/functions/date_time_functions.md#formatdatetime).
При вставке данных в ClickHouse, можно использовать различные форматы даты и времени в зависимости от значения настройки [date_time_input_format](../operations/settings/settings.md#settings-date_time_input_format).
@ -28,18 +30,19 @@ ClickHouse по умолчанию выводит значение в форма
**1.** Создание таблицы с столбцом типа `DateTime` и вставка данных в неё:
```sql
CREATE TABLE dt
(
`timestamp` DateTime('Europe/Moscow'),
`event_id` UInt8
)
ENGINE = TinyLog
ENGINE = TinyLog;
```
```sql
INSERT INTO dt Values (1546300800, 1), ('2019-01-01 00:00:00', 2)
INSERT INTO dt Values (1546300800, 1), ('2019-01-01 00:00:00', 2);
```
```sql
SELECT * FROM dt
SELECT * FROM dt;
```
```text
┌───────────timestamp─┬─event_id─┐
@ -48,7 +51,10 @@ SELECT * FROM dt
└─────────────────────┴──────────┘
```
Unix timestamp `1546300800` в часовом поясе `Europe/London (UTC+0)` представляет время `'2019-01-01 00:00:00'`, однако столбец `timestamp` хранит время в часовом поясе `Europe/Moscow (UTC+3)`, таким образом значение, вставленное в виде Unix timestamp, представляет время `2019-01-01 03:00:00`.
* При вставке даты-времени как целого числа, оно трактуется как Unix Timestamp (UTC). Unix timestamp `1546300800` в часовом поясе `Europe/London (UTC+0)` представляет время `'2019-01-01 00:00:00'`. Однако, столбец `timestamp` имеет тип `DateTime('Europe/Moscow (UTC+3)')`, так что при выводе в виде строки время отобразится как `2019-01-01 03:00:00`.
* При вставке даты-времени в виде строки, время трактуется соответственно часовому поясу установленному для колонки. `'2019-01-01 00:00:00'` трактуется как время по Москве (и в базу сохраняется `1546290000`)
**2.** Фильтрация по значениям даты-времени
```sql
SELECT * FROM dt WHERE timestamp = toDateTime('2019-01-01 00:00:00', 'Europe/Moscow')
@ -58,8 +64,17 @@ SELECT * FROM dt WHERE timestamp = toDateTime('2019-01-01 00:00:00', 'Europe/Mos
│ 2019-01-01 00:00:00 │ 2 │
└─────────────────────┴──────────┘
```
Фильтровать по колонке типа `DateTime` можно, указывая строковое значение в фильтре `WHERE`. Конвертация будет выполнена автоматически:
```sql
SELECT * FROM dt WHERE timestamp = '2019-01-01 00:00:00'
```
```text
┌───────────timestamp─┬─event_id─┐
│ 2019-01-01 03:00:00 │ 1 │
└─────────────────────┴──────────┘
```
**2.** Получение часового пояса для значения типа `DateTime`:
**3.** Получение часового пояса для колонки типа `DateTime`:
```sql
SELECT toDateTime(now(), 'Europe/Moscow') AS column, toTypeName(column) AS x
@ -70,6 +85,21 @@ SELECT toDateTime(now(), 'Europe/Moscow') AS column, toTypeName(column) AS x
└─────────────────────┴───────────────────────────┘
```
**4.** Конвертация часовых поясов
```sql
SELECT
toDateTime(timestamp, 'Europe/London') as lon_time,
toDateTime(timestamp, 'Europe/Moscow') as mos_time
FROM dt
```
```text
┌───────────lon_time──┬────────────mos_time─┐
│ 2019-01-01 00:00:00 │ 2019-01-01 03:00:00 │
│ 2018-12-31 21:00:00 │ 2019-01-01 00:00:00 │
└─────────────────────┴─────────────────────┘
```
## See Also
- [Функции преобразования типов](../query_language/functions/type_conversion_functions.md)

View File

@ -0,0 +1,90 @@
# DateTime64 {#data_type-datetime64}
Позволяет хранить момент времени, который может быть представлен как календарная дата и время, с заданной суб-секундной точностью.
Размер тика/точность: 10<sup>-precision</sup> секунд, где precision - целочисленный параметр типа.
Синтаксис:
```sql
DateTime64(precision, [timezone])
```
Данные хранятся в виде количества 'тиков', прошедших с момента начала эпохи (1970-01-01 00:00:00 UTC), в Int64. Размер тика определяется параметром precision. Дополнительно, тип `DateTime64` позволяет хранить часовой пояс, единый для всей колонки, который влияет на то, как будут отображаться значения типа `DateTime64` в текстовом виде и как будут парситься значения заданные в виде строк ('2020-01-01 05:00:01.000'). Часовой пояс не хранится в строках таблицы (выборки), а хранится в метаданных колонки. Подробнее см. [DateTime](datetime.md).
## Пример
**1.** Создание таблицы с столбцом типа `DateTime64` и вставка данных в неё:
```sql
CREATE TABLE dt
(
`timestamp` DateTime64(3, 'Europe/Moscow'),
`event_id` UInt8
)
ENGINE = TinyLog
```
```sql
INSERT INTO dt Values (1546300800000, 1), ('2019-01-01 00:00:00', 2)
```
```sql
SELECT * FROM dt
```
```text
┌───────────────timestamp─┬─event_id─┐
│ 2019-01-01 03:00:00.000 │ 1 │
│ 2019-01-01 00:00:00.000 │ 2 │
└─────────────────────────┴──────────┘
```
* При вставке даты-времени как числа (аналогично 'Unix timestamp'), время трактуется как UTC. Unix timestamp `1546300800` в часовом поясе `Europe/London (UTC+0)` представляет время `'2019-01-01 00:00:00'`. Однако, столбец `timestamp` имеет тип `DateTime('Europe/Moscow (UTC+3)')`, так что при выводе в виде строки время отобразится как `2019-01-01 03:00:00`.
* При вставке даты-времени в виде строки, время трактуется соответственно часовому поясу установленному для колонки. `'2019-01-01 00:00:00'` трактуется как время по Москве (и в базу сохраняется `'2018-12-31 21:00:00'` в виде Unix Timestamp)
**2.** Фильтрация по значениям даты-времени
```sql
SELECT * FROM dt WHERE timestamp = toDateTime64('2019-01-01 00:00:00', 3, 'Europe/Moscow')
```
```text
┌───────────────timestamp─┬─event_id─┐
│ 2019-01-01 00:00:00.000 │ 2 │
└─────────────────────────┴──────────┘
```
В отличие от типа `DateTime`, `DateTime64` не конвертируется из строк автоматически
**3.** Получение часового пояса для значения типа `DateTime64`:
```sql
SELECT toDateTime64(now(), 3, 'Europe/Moscow') AS column, toTypeName(column) AS x
```
```text
┌──────────────────column─┬─x──────────────────────────────┐
│ 2019-10-16 04:12:04.000 │ DateTime64(3, 'Europe/Moscow') │
└─────────────────────────┴────────────────────────────────┘
```
**4.** Конвертация часовых поясов
```sql
SELECT
toDateTime64(timestamp, 3, 'Europe/London') as lon_time,
toDateTime64(timestamp, 3, 'Europe/Moscow') as mos_time
FROM dt
```
```text
┌───────────────lon_time──┬────────────────mos_time─┐
│ 2019-01-01 00:00:00.000 │ 2019-01-01 03:00:00.000 │
│ 2018-12-31 21:00:00.000 │ 2019-01-01 00:00:00.000 │
└─────────────────────────┴─────────────────────────┘
```
## See Also
- [Функции преобразования типов](../query_language/functions/type_conversion_functions.md)
- [Функции для работы с датой и временем](../query_language/functions/date_time_functions.md)
- [Функции для работы с массивами](../query_language/functions/array_functions.md)
- [Настройка `date_time_input_format`](../operations/settings/settings.md#settings-date_time_input_format)
- [Конфигурационный параметр сервера `timezone`](../operations/server_settings/settings.md#server_settings-timezone)
- [Операторы для работы с датой и временем](../query_language/operators.md#operators-datetime)
- [Тип данных `Date`](date.md)
- [Тип данных `DateTime`](datetime.md)

View File

@ -38,8 +38,8 @@
- [AORM](https://github.com/TanVD/AORM)
- C#
- [ClickHouse.Ado](https://github.com/killwort/ClickHouse-Net)
- [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net)
- [ClickHouse.Client](https://github.com/DarkWanderer/ClickHouse.Client)
- [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net)
- Elixir
- [clickhousex](https://github.com/appodeal/clickhousex/)
- Nim

View File

@ -77,6 +77,7 @@
- C#
- [ADO.NET](https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/ado-net-overview)
- [ClickHouse.Ado](https://github.com/killwort/ClickHouse-Net)
- [ClickHouse.Client](https://github.com/DarkWanderer/ClickHouse.Client)
- [ClickHouse.Net](https://github.com/ilyabreev/ClickHouse.Net)
- [ClickHouse.Net.Migrations](https://github.com/ilyabreev/ClickHouse.Net.Migrations)
- Elixir