mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #32178 from kssenii/fix-window-view-tests
Fix window view tests
This commit is contained in:
commit
d38d2ba14f
@ -142,6 +142,7 @@ namespace
|
||||
|
||||
bool is_time_column_func_now = false;
|
||||
String window_id_name;
|
||||
String now_timezone;
|
||||
|
||||
void visit(ASTFunction & node, ASTPtr & node_ptr)
|
||||
{
|
||||
@ -150,6 +151,16 @@ namespace
|
||||
if (const auto * t = node.arguments->children[0]->as<ASTFunction>();
|
||||
t && t->name == "now")
|
||||
{
|
||||
if (!t->children.empty())
|
||||
{
|
||||
const auto & children = t->children[0]->as<ASTExpressionList>()->children;
|
||||
if (!children.empty())
|
||||
{
|
||||
const auto * timezone_ast = children[0]->as<ASTLiteral>();
|
||||
if (timezone_ast)
|
||||
now_timezone = timezone_ast->value.safeGet<String>();
|
||||
}
|
||||
}
|
||||
is_time_column_func_now = true;
|
||||
node_ptr->children[0]->children[0] = std::make_shared<ASTIdentifier>("____timestamp");
|
||||
window_id_name = node.getColumnName();
|
||||
@ -609,7 +620,10 @@ std::shared_ptr<ASTCreateQuery> StorageWindowView::getInnerTableCreateQuery(
|
||||
auto node = ast->clone();
|
||||
/// now() -> ____timestamp
|
||||
if (is_time_column_func_now)
|
||||
{
|
||||
time_now_visitor.visit(node);
|
||||
function_now_timezone = time_now_data.now_timezone;
|
||||
}
|
||||
/// TUMBLE/HOP -> WINDOW_ID
|
||||
func_window_visitor.visit(node);
|
||||
to_identifier_visitor.visit(node);
|
||||
@ -640,7 +654,10 @@ std::shared_ptr<ASTCreateQuery> StorageWindowView::getInnerTableCreateQuery(
|
||||
|
||||
ASTPtr order_by_ptr = order_by;
|
||||
if (is_time_column_func_now)
|
||||
{
|
||||
time_now_visitor.visit(order_by_ptr);
|
||||
function_now_timezone = time_now_data.now_timezone;
|
||||
}
|
||||
to_identifier_visitor.visit(order_by_ptr);
|
||||
|
||||
for (auto & child : order_by->arguments->children)
|
||||
@ -829,7 +846,6 @@ void StorageWindowView::threadFuncFireProc()
|
||||
std::unique_lock lock(fire_signal_mutex);
|
||||
UInt32 timestamp_now = std::time(nullptr);
|
||||
|
||||
LOG_TRACE(log, "Processing time. Now: {}. Next fire time: {}", timestamp_now, next_fire_signal);
|
||||
while (next_fire_signal <= timestamp_now)
|
||||
{
|
||||
try
|
||||
@ -862,7 +878,6 @@ void StorageWindowView::threadFuncFireEvent()
|
||||
|
||||
while (!fire_signal.empty())
|
||||
{
|
||||
LOG_TRACE(log, "Fire signals: {}", fire_signal.size());
|
||||
fire(fire_signal.front());
|
||||
fire_signal.pop_front();
|
||||
}
|
||||
@ -970,15 +985,21 @@ StorageWindowView::StorageWindowView(
|
||||
else
|
||||
window_column_name = std::regex_replace(window_id_name, std::regex("WINDOW_ID"), "HOP");
|
||||
|
||||
auto generate_inner_table_name = [](const String & table_name) { return ".inner." + table_name; };
|
||||
auto generate_inner_table_name = [](const StorageID & storage_id)
|
||||
{
|
||||
if (storage_id.hasUUID())
|
||||
return ".inner." + toString(storage_id.uuid);
|
||||
return ".inner." + storage_id.table_name;
|
||||
};
|
||||
|
||||
if (attach_)
|
||||
{
|
||||
inner_table_id = StorageID(table_id_.database_name, generate_inner_table_name(table_id_.table_name));
|
||||
inner_table_id = StorageID(table_id_.database_name, generate_inner_table_name(table_id_));
|
||||
}
|
||||
else
|
||||
{
|
||||
auto inner_create_query
|
||||
= getInnerTableCreateQuery(inner_query, query.storage, table_id_.database_name, generate_inner_table_name(table_id_.table_name));
|
||||
= getInnerTableCreateQuery(inner_query, query.storage, table_id_.database_name, generate_inner_table_name(table_id_));
|
||||
|
||||
auto create_context = Context::createCopy(context_);
|
||||
InterpreterCreateQuery create_interpreter(inner_create_query, create_context);
|
||||
@ -1165,7 +1186,11 @@ void StorageWindowView::writeIntoWindowView(
|
||||
{
|
||||
ColumnWithTypeAndName column;
|
||||
column.name = "____timestamp";
|
||||
column.type = std::make_shared<DataTypeDateTime>();
|
||||
const auto & timezone = window_view.function_now_timezone;
|
||||
if (timezone.empty())
|
||||
column.type = std::make_shared<DataTypeDateTime>();
|
||||
else
|
||||
column.type = std::make_shared<DataTypeDateTime>(timezone);
|
||||
column.column = column.type->createColumnConst(0, Field(std::time(nullptr)));
|
||||
|
||||
auto adding_column_dag = ActionsDAG::makeAddingColumnActions(std::move(column));
|
||||
|
@ -206,6 +206,8 @@ private:
|
||||
BackgroundSchedulePool::TaskHolder clean_cache_task;
|
||||
BackgroundSchedulePool::TaskHolder fire_task;
|
||||
|
||||
String function_now_timezone;
|
||||
|
||||
ASTPtr innerQueryParser(ASTSelectQuery & inner_query);
|
||||
void eventTimeParser(const ASTCreateQuery & query);
|
||||
|
||||
|
@ -1,22 +1,22 @@
|
||||
---TUMBLE---
|
||||
||---WINDOW COLUMN NAME---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nORDER BY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01047.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nORDER BY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nSETTINGS index_granularity = 8192
|
||||
||---WINDOW COLUMN ALIAS---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nORDER BY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01047.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nORDER BY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nSETTINGS index_granularity = 8192
|
||||
||---IDENTIFIER---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `b` Int32,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`, b)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01047.`.inner.wv`\n(\n `b` Int32,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`, b)\nSETTINGS index_granularity = 8192
|
||||
||---FUNCTION---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `plus(a, b)` Int64,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`, `plus(a, b)`)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01047.`.inner.wv`\n(\n `plus(a, b)` Int64,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`, `plus(a, b)`)\nSETTINGS index_granularity = 8192
|
||||
||---PARTITION---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(____timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPARTITION BY `WINDOW_ID(____timestamp, toIntervalSecond(\'1\'))`\nORDER BY `WINDOW_ID(____timestamp, toIntervalSecond(\'1\'))`\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01047.`.inner.wv`\n(\n `WINDOW_ID(____timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPARTITION BY `WINDOW_ID(____timestamp, toIntervalSecond(\'1\'))`\nORDER BY `WINDOW_ID(____timestamp, toIntervalSecond(\'1\'))`\nSETTINGS index_granularity = 8192
|
||||
---HOP---
|
||||
||---WINDOW COLUMN NAME---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nORDER BY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01047.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nORDER BY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nSETTINGS index_granularity = 8192
|
||||
||---WINDOW COLUMN ALIAS---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nORDER BY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01047.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nORDER BY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nSETTINGS index_granularity = 8192
|
||||
||---IDENTIFIER---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `b` Int32,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`, b)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01047.`.inner.wv`\n(\n `b` Int32,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`, b)\nSETTINGS index_granularity = 8192
|
||||
||---FUNCTION---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `plus(a, b)` Int64,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`, `plus(a, b)`)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01047.`.inner.wv`\n(\n `plus(a, b)` Int64,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`, `plus(a, b)`)\nSETTINGS index_granularity = 8192
|
||||
||---PARTITION---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(____timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPARTITION BY `WINDOW_ID(____timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY `WINDOW_ID(____timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01047.`.inner.wv`\n(\n `WINDOW_ID(____timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPARTITION BY `WINDOW_ID(____timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY `WINDOW_ID(____timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nSETTINGS index_granularity = 8192
|
||||
|
@ -1,71 +1,75 @@
|
||||
-- Tags: no-parallel
|
||||
|
||||
SET allow_experimental_window_view = 1;
|
||||
DROP DATABASE IF EXISTS test_01047;
|
||||
CREATE DATABASE test_01047 ENGINE=Ordinary;
|
||||
|
||||
DROP TABLE IF EXISTS mt;
|
||||
DROP TABLE IF EXISTS test_01047.mt;
|
||||
|
||||
CREATE TABLE mt(a Int32, b Int32, timestamp DateTime) ENGINE=MergeTree ORDER BY tuple();
|
||||
CREATE TABLE test_01047.mt(a Int32, b Int32, timestamp DateTime) ENGINE=MergeTree ORDER BY tuple();
|
||||
|
||||
SELECT '---TUMBLE---';
|
||||
SELECT '||---WINDOW COLUMN NAME---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv ENGINE AggregatingMergeTree ORDER BY TUMBLE(timestamp, INTERVAL '1' SECOND) AS SELECT count(a), TUMBLE_END(wid) AS count FROM mt GROUP BY TUMBLE(timestamp, INTERVAL '1' SECOND) as wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01047.wv;
|
||||
DROP TABLE IF EXISTS test_01047.`.inner.wv`;
|
||||
CREATE WINDOW VIEW test_01047.wv ENGINE AggregatingMergeTree ORDER BY TUMBLE(timestamp, INTERVAL '1' SECOND) AS SELECT count(a), TUMBLE_END(wid) AS count FROM test_01047.mt GROUP BY TUMBLE(timestamp, INTERVAL '1' SECOND) as wid;
|
||||
SHOW CREATE TABLE test_01047.`.inner.wv`;
|
||||
|
||||
SELECT '||---WINDOW COLUMN ALIAS---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv ENGINE AggregatingMergeTree ORDER BY wid AS SELECT count(a) AS count, TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid FROM mt GROUP BY wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01047.wv;
|
||||
DROP TABLE IF EXISTS test_01047.`.inner.wv`;
|
||||
CREATE WINDOW VIEW test_01047.wv ENGINE AggregatingMergeTree ORDER BY wid AS SELECT count(a) AS count, TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid FROM test_01047.mt GROUP BY wid;
|
||||
SHOW CREATE TABLE test_01047.`.inner.wv`;
|
||||
|
||||
SELECT '||---IDENTIFIER---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv ENGINE AggregatingMergeTree ORDER BY (TUMBLE(timestamp, INTERVAL '1' SECOND), b) PRIMARY KEY TUMBLE(timestamp, INTERVAL '1' SECOND) AS SELECT count(a) AS count FROM mt GROUP BY b, TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01047.wv;
|
||||
DROP TABLE IF EXISTS test_01047.`.inner.wv`;
|
||||
CREATE WINDOW VIEW test_01047.wv ENGINE AggregatingMergeTree ORDER BY (TUMBLE(timestamp, INTERVAL '1' SECOND), b) PRIMARY KEY TUMBLE(timestamp, INTERVAL '1' SECOND) AS SELECT count(a) AS count FROM test_01047.mt GROUP BY b, TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid;
|
||||
SHOW CREATE TABLE test_01047.`.inner.wv`;
|
||||
|
||||
SELECT '||---FUNCTION---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv ENGINE AggregatingMergeTree ORDER BY (TUMBLE(timestamp, INTERVAL '1' SECOND), plus(a, b)) PRIMARY KEY TUMBLE(timestamp, INTERVAL '1' SECOND) AS SELECT count(a) AS count FROM mt GROUP BY plus(a, b) as _type, TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01047.wv;
|
||||
DROP TABLE IF EXISTS test_01047.`.inner.wv`;
|
||||
CREATE WINDOW VIEW test_01047.wv ENGINE AggregatingMergeTree ORDER BY (TUMBLE(timestamp, INTERVAL '1' SECOND), plus(a, b)) PRIMARY KEY TUMBLE(timestamp, INTERVAL '1' SECOND) AS SELECT count(a) AS count FROM test_01047.mt GROUP BY plus(a, b) as _type, TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid;
|
||||
SHOW CREATE TABLE test_01047.`.inner.wv`;
|
||||
|
||||
SELECT '||---PARTITION---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv ENGINE AggregatingMergeTree ORDER BY wid PARTITION BY wid AS SELECT count(a) AS count, TUMBLE(now(), INTERVAL '1' SECOND) AS wid FROM mt GROUP BY wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01047.wv;
|
||||
DROP TABLE IF EXISTS test_01047.`.inner.wv`;
|
||||
CREATE WINDOW VIEW test_01047.wv ENGINE AggregatingMergeTree ORDER BY wid PARTITION BY wid AS SELECT count(a) AS count, TUMBLE(now(), INTERVAL '1' SECOND) AS wid FROM test_01047.mt GROUP BY wid;
|
||||
SHOW CREATE TABLE test_01047.`.inner.wv`;
|
||||
|
||||
|
||||
SELECT '---HOP---';
|
||||
SELECT '||---WINDOW COLUMN NAME---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv ENGINE AggregatingMergeTree ORDER BY HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS SELECT count(a) AS count, HOP_END(wid) FROM mt GROUP BY HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) as wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01047.wv;
|
||||
DROP TABLE IF EXISTS test_01047.`.inner.wv`;
|
||||
CREATE WINDOW VIEW test_01047.wv ENGINE AggregatingMergeTree ORDER BY HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS SELECT count(a) AS count, HOP_END(wid) FROM test_01047.mt GROUP BY HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) as wid;
|
||||
SHOW CREATE TABLE test_01047.`.inner.wv`;
|
||||
|
||||
SELECT '||---WINDOW COLUMN ALIAS---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv ENGINE AggregatingMergeTree ORDER BY wid AS SELECT count(a) AS count, HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid FROM mt GROUP BY wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01047.wv;
|
||||
DROP TABLE IF EXISTS test_01047.`.inner.wv`;
|
||||
CREATE WINDOW VIEW test_01047.wv ENGINE AggregatingMergeTree ORDER BY wid AS SELECT count(a) AS count, HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid FROM test_01047.mt GROUP BY wid;
|
||||
SHOW CREATE TABLE test_01047.`.inner.wv`;
|
||||
|
||||
SELECT '||---IDENTIFIER---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv ENGINE AggregatingMergeTree ORDER BY (HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND), b) PRIMARY KEY HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS SELECT count(a) AS count FROM mt GROUP BY b, HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01047.wv;
|
||||
DROP TABLE IF EXISTS test_01047.`.inner.wv`;
|
||||
CREATE WINDOW VIEW test_01047.wv ENGINE AggregatingMergeTree ORDER BY (HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND), b) PRIMARY KEY HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS SELECT count(a) AS count FROM test_01047.mt GROUP BY b, HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid;
|
||||
SHOW CREATE TABLE test_01047.`.inner.wv`;
|
||||
|
||||
SELECT '||---FUNCTION---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv ENGINE AggregatingMergeTree ORDER BY (HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND), plus(a, b)) PRIMARY KEY HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS SELECT count(a) AS count FROM mt GROUP BY plus(a, b) as _type, HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01047.wv;
|
||||
DROP TABLE IF EXISTS test_01047.`.inner.wv`;
|
||||
CREATE WINDOW VIEW test_01047.wv ENGINE AggregatingMergeTree ORDER BY (HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND), plus(a, b)) PRIMARY KEY HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS SELECT count(a) AS count FROM test_01047.mt GROUP BY plus(a, b) as _type, HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid;
|
||||
SHOW CREATE TABLE test_01047.`.inner.wv`;
|
||||
|
||||
SELECT '||---PARTITION---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv ENGINE AggregatingMergeTree ORDER BY wid PARTITION BY wid AS SELECT count(a) AS count, HOP_END(wid) FROM mt GROUP BY HOP(now(), INTERVAL '1' SECOND, INTERVAL '3' SECOND) as wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01047.wv;
|
||||
DROP TABLE IF EXISTS test_01047.`.inner.wv`;
|
||||
CREATE WINDOW VIEW test_01047.wv ENGINE AggregatingMergeTree ORDER BY wid PARTITION BY wid AS SELECT count(a) AS count, HOP_END(wid) FROM test_01047.mt GROUP BY HOP(now(), INTERVAL '1' SECOND, INTERVAL '3' SECOND) as wid;
|
||||
SHOW CREATE TABLE test_01047.`.inner.wv`;
|
||||
|
||||
DROP TABLE wv;
|
||||
DROP TABLE mt;
|
||||
DROP TABLE test_01047.wv;
|
||||
DROP TABLE test_01047.mt;
|
||||
|
@ -1,26 +1,26 @@
|
||||
---TUMBLE---
|
||||
||---WINDOW COLUMN NAME---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(1))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(1))`\nORDER BY tuple(`WINDOW_ID(timestamp, toIntervalSecond(1))`)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01048.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(1))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(1))`\nORDER BY tuple(`WINDOW_ID(timestamp, toIntervalSecond(1))`)\nSETTINGS index_granularity = 8192
|
||||
||---WINDOW COLUMN ALIAS---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nORDER BY tuple(`WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01048.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nORDER BY tuple(`WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`)\nSETTINGS index_granularity = 8192
|
||||
||---IDENTIFIER---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `b` Int32,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`, b)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `b` Int32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`, b)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01048.`.inner.wv`\n(\n `b` Int32,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`, b)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01048.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `b` Int32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`, b)\nSETTINGS index_granularity = 8192
|
||||
||---FUNCTION---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `plus(a, b)` Int64,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`, `plus(a, b)`)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `plus(a, b)` Int64,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`, `plus(a, b)`)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01048.`.inner.wv`\n(\n `plus(a, b)` Int64,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`, `plus(a, b)`)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01048.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))` UInt32,\n `plus(a, b)` Int64,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'))`, `plus(a, b)`)\nSETTINGS index_granularity = 8192
|
||||
||---TimeZone---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), \'Asia/Shanghai\')` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), \'Asia/Shanghai\')`\nORDER BY tuple(`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), \'Asia/Shanghai\')`)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01048.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), \'Asia/Shanghai\')` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), \'Asia/Shanghai\')`\nORDER BY tuple(`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), \'Asia/Shanghai\')`)\nSETTINGS index_granularity = 8192
|
||||
---HOP---
|
||||
||---WINDOW COLUMN NAME---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(1), toIntervalSecond(3))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(1), toIntervalSecond(3))`\nORDER BY tuple(`WINDOW_ID(timestamp, toIntervalSecond(1), toIntervalSecond(3))`)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01048.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(1), toIntervalSecond(3))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(1), toIntervalSecond(3))`\nORDER BY tuple(`WINDOW_ID(timestamp, toIntervalSecond(1), toIntervalSecond(3))`)\nSETTINGS index_granularity = 8192
|
||||
||---WINDOW COLUMN ALIAS---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY tuple(`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01048.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY tuple(`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`)\nSETTINGS index_granularity = 8192
|
||||
||---IDENTIFIER---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `b` Int32,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`, b)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `b` Int32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`, b)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01048.`.inner.wv`\n(\n `b` Int32,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`, b)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01048.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `b` Int32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`, b)\nSETTINGS index_granularity = 8192
|
||||
||---FUNCTION---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `plus(a, b)` Int64,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`, `plus(a, b)`)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01048.`.inner.wv`\n(\n `plus(a, b)` Int64,\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`, `plus(a, b)`)\nSETTINGS index_granularity = 8192
|
||||
||---TimeZone---
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(1), toIntervalSecond(3), \'Asia/Shanghai\')` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(1), toIntervalSecond(3), \'Asia/Shanghai\')`\nORDER BY tuple(`WINDOW_ID(timestamp, toIntervalSecond(1), toIntervalSecond(3), \'Asia/Shanghai\')`)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE default.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `plus(a, b)` Int64,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`, `plus(a, b)`)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01048.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(1), toIntervalSecond(3), \'Asia/Shanghai\')` UInt32,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(1), toIntervalSecond(3), \'Asia/Shanghai\')`\nORDER BY tuple(`WINDOW_ID(timestamp, toIntervalSecond(1), toIntervalSecond(3), \'Asia/Shanghai\')`)\nSETTINGS index_granularity = 8192
|
||||
CREATE TABLE test_01048.`.inner.wv`\n(\n `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))` UInt32,\n `plus(a, b)` Int64,\n `count(a)` AggregateFunction(count, Int32)\n)\nENGINE = AggregatingMergeTree\nPRIMARY KEY `WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`\nORDER BY (`WINDOW_ID(timestamp, toIntervalSecond(\'1\'), toIntervalSecond(\'3\'))`, `plus(a, b)`)\nSETTINGS index_granularity = 8192
|
||||
|
@ -1,93 +1,82 @@
|
||||
-- Tags: no-parallel
|
||||
|
||||
SET allow_experimental_window_view = 1;
|
||||
DROP DATABASE IF EXISTS test_01048;
|
||||
CREATE DATABASE test_01048 ENGINE=Ordinary;
|
||||
|
||||
DROP TABLE IF EXISTS mt;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.mt;
|
||||
|
||||
CREATE TABLE mt(a Int32, b Int32, timestamp DateTime) ENGINE=MergeTree ORDER BY tuple();
|
||||
CREATE TABLE test_01048.mt(a Int32, b Int32, timestamp DateTime) ENGINE=MergeTree ORDER BY tuple();
|
||||
|
||||
SELECT '---TUMBLE---';
|
||||
SELECT '||---WINDOW COLUMN NAME---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv AS SELECT count(a) AS count, TUMBLE_END(wid) as wend FROM mt GROUP BY TUMBLE(timestamp, INTERVAL 1 SECOND) as wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.wv;
|
||||
CREATE WINDOW VIEW test_01048.wv AS SELECT count(a) AS count, TUMBLE_END(wid) as wend FROM test_01048.mt GROUP BY TUMBLE(timestamp, INTERVAL 1 SECOND) as wid;
|
||||
SHOW CREATE TABLE test_01048.`.inner.wv`;
|
||||
|
||||
SELECT '||---WINDOW COLUMN ALIAS---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv AS SELECT count(a) AS count, TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid FROM mt GROUP BY wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.wv;
|
||||
CREATE WINDOW VIEW test_01048.wv AS SELECT count(a) AS count, TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid FROM test_01048.mt GROUP BY wid;
|
||||
SHOW CREATE TABLE test_01048.`.inner.wv`;
|
||||
|
||||
SELECT '||---IDENTIFIER---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv AS SELECT count(a) AS count FROM mt GROUP BY b, TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.wv;
|
||||
CREATE WINDOW VIEW test_01048.wv AS SELECT count(a) AS count FROM test_01048.mt GROUP BY b, TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid;
|
||||
SHOW CREATE TABLE test_01048.`.inner.wv`;
|
||||
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv AS SELECT count(a) AS count FROM mt GROUP BY TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid, b;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.wv;
|
||||
CREATE WINDOW VIEW test_01048.wv AS SELECT count(a) AS count FROM test_01048.mt GROUP BY TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid, b;
|
||||
SHOW CREATE TABLE test_01048.`.inner.wv`;
|
||||
|
||||
SELECT '||---FUNCTION---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv AS SELECT count(a) AS count FROM mt GROUP BY plus(a, b) as _type, TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.wv;
|
||||
CREATE WINDOW VIEW test_01048.wv AS SELECT count(a) AS count FROM test_01048.mt GROUP BY plus(a, b) as _type, TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid;
|
||||
SHOW CREATE TABLE test_01048.`.inner.wv`;
|
||||
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv AS SELECT count(a) AS count FROM mt GROUP BY TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid, plus(a, b);
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.wv;
|
||||
CREATE WINDOW VIEW test_01048.wv AS SELECT count(a) AS count FROM test_01048.mt GROUP BY TUMBLE(timestamp, INTERVAL '1' SECOND) AS wid, plus(a, b);
|
||||
SHOW CREATE TABLE test_01048.`.inner.wv`;
|
||||
|
||||
SELECT '||---TimeZone---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv AS SELECT count(a) AS count, TUMBLE(timestamp, INTERVAL '1' SECOND, 'Asia/Shanghai') AS wid FROM mt GROUP BY wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.wv;
|
||||
CREATE WINDOW VIEW test_01048.wv AS SELECT count(a) AS count, TUMBLE(timestamp, INTERVAL '1' SECOND, 'Asia/Shanghai') AS wid FROM test_01048.mt GROUP BY wid;
|
||||
SHOW CREATE TABLE test_01048.`.inner.wv`;
|
||||
|
||||
|
||||
SELECT '---HOP---';
|
||||
SELECT '||---WINDOW COLUMN NAME---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv AS SELECT count(a) AS count, HOP_END(wid) as wend FROM mt GROUP BY HOP(timestamp, INTERVAL 1 SECOND, INTERVAL 3 SECOND) as wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.wv;
|
||||
CREATE WINDOW VIEW test_01048.wv AS SELECT count(a) AS count, HOP_END(wid) as wend FROM test_01048.mt GROUP BY HOP(timestamp, INTERVAL 1 SECOND, INTERVAL 3 SECOND) as wid;
|
||||
SHOW CREATE TABLE test_01048.`.inner.wv`;
|
||||
|
||||
SELECT '||---WINDOW COLUMN ALIAS---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv AS SELECT count(a) AS count, HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid FROM mt GROUP BY wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.wv;
|
||||
CREATE WINDOW VIEW test_01048.wv AS SELECT count(a) AS count, HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid FROM test_01048.mt GROUP BY wid;
|
||||
SHOW CREATE TABLE test_01048.`.inner.wv`;
|
||||
|
||||
SELECT '||---IDENTIFIER---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv AS SELECT count(a) AS count FROM mt GROUP BY b, HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.wv;
|
||||
CREATE WINDOW VIEW test_01048.wv AS SELECT count(a) AS count FROM test_01048.mt GROUP BY b, HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid;
|
||||
SHOW CREATE TABLE test_01048.`.inner.wv`;
|
||||
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv AS SELECT count(a) AS count FROM mt GROUP BY HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid, b;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.wv;
|
||||
CREATE WINDOW VIEW test_01048.wv AS SELECT count(a) AS count FROM test_01048.mt GROUP BY HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid, b;
|
||||
SHOW CREATE TABLE test_01048.`.inner.wv`;
|
||||
|
||||
SELECT '||---FUNCTION---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv AS SELECT count(a) AS count FROM mt GROUP BY plus(a, b) as _type, HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.wv;
|
||||
CREATE WINDOW VIEW test_01048.wv AS SELECT count(a) AS count FROM test_01048.mt GROUP BY plus(a, b) as _type, HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid;
|
||||
SHOW CREATE TABLE test_01048.`.inner.wv`;
|
||||
|
||||
SELECT '||---TimeZone---';
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv AS SELECT count(a) AS count, HOP_END(wid) as wend FROM mt GROUP BY HOP(timestamp, INTERVAL 1 SECOND, INTERVAL 3 SECOND, 'Asia/Shanghai') as wid;
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.wv;
|
||||
CREATE WINDOW VIEW test_01048.wv AS SELECT count(a) AS count, HOP_END(wid) as wend FROM test_01048.mt GROUP BY HOP(timestamp, INTERVAL 1 SECOND, INTERVAL 3 SECOND, 'Asia/Shanghai') as wid;
|
||||
SHOW CREATE TABLE test_01048.`.inner.wv`;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
CREATE WINDOW VIEW wv AS SELECT count(a) AS count FROM mt GROUP BY HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid, plus(a, b);
|
||||
SHOW CREATE TABLE `.inner.wv`;
|
||||
DROP TABLE IF EXISTS test_01048.wv;
|
||||
CREATE WINDOW VIEW test_01048.wv AS SELECT count(a) AS count FROM test_01048.mt GROUP BY HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid, plus(a, b);
|
||||
SHOW CREATE TABLE test_01048.`.inner.wv`;
|
||||
|
||||
DROP TABLE wv;
|
||||
DROP TABLE mt;
|
||||
DROP TABLE test_01048.wv;
|
||||
DROP TABLE test_01048.mt;
|
||||
|
@ -3,11 +3,10 @@ SET allow_experimental_window_view = 1;
|
||||
DROP TABLE IF EXISTS mt;
|
||||
DROP TABLE IF EXISTS dst;
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
|
||||
CREATE TABLE dst(count UInt64) Engine=MergeTree ORDER BY tuple();
|
||||
CREATE TABLE mt(a Int32) ENGINE=MergeTree ORDER BY tuple();
|
||||
CREATE WINDOW VIEW wv TO dst AS SELECT count(a) AS count FROM mt GROUP BY TUMBLE(now(), INTERVAL '1' SECOND, 'US/Samoa') AS wid;
|
||||
CREATE WINDOW VIEW wv TO dst AS SELECT count(a) AS count FROM mt GROUP BY TUMBLE(now('US/Samoa'), INTERVAL '1' SECOND, 'US/Samoa') AS wid;
|
||||
|
||||
INSERT INTO mt VALUES (1);
|
||||
SELECT sleep(2);
|
||||
|
@ -3,11 +3,10 @@ SET allow_experimental_window_view = 1;
|
||||
DROP TABLE IF EXISTS mt;
|
||||
DROP TABLE IF EXISTS dst;
|
||||
DROP TABLE IF EXISTS wv;
|
||||
DROP TABLE IF EXISTS `.inner.wv`;
|
||||
|
||||
CREATE TABLE dst(count UInt64) Engine=MergeTree ORDER BY tuple();
|
||||
CREATE TABLE mt(a Int32) ENGINE=MergeTree ORDER BY tuple();
|
||||
CREATE WINDOW VIEW wv TO dst AS SELECT count(a) AS count FROM mt GROUP BY HOP(now(), INTERVAL '1' SECOND, INTERVAL '1' SECOND, 'US/Samoa') AS wid;
|
||||
CREATE WINDOW VIEW wv TO dst AS SELECT count(a) AS count FROM mt GROUP BY HOP(now('US/Samoa'), INTERVAL '1' SECOND, INTERVAL '1' SECOND, 'US/Samoa') AS wid;
|
||||
|
||||
INSERT INTO mt VALUES (1);
|
||||
SELECT sleep(2);
|
||||
|
Loading…
Reference in New Issue
Block a user