mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Fix #10437, CR fixes
This commit is contained in:
parent
6e599533a7
commit
8038383f06
@ -161,7 +161,6 @@ protected:
|
||||
private:
|
||||
/* Saving thread data */
|
||||
Context & context;
|
||||
Context insert_context;
|
||||
const StorageID table_id;
|
||||
const String storage_def;
|
||||
StoragePtr table;
|
||||
@ -208,13 +207,11 @@ SystemLog<LogElement>::SystemLog(Context & context_,
|
||||
const String & storage_def_,
|
||||
size_t flush_interval_milliseconds_)
|
||||
: context(context_)
|
||||
, insert_context(Context(context_))
|
||||
, table_id(database_name_, table_name_)
|
||||
, storage_def(storage_def_)
|
||||
, flush_interval_milliseconds(flush_interval_milliseconds_)
|
||||
{
|
||||
assert(database_name_ == DatabaseCatalog::SYSTEM_DATABASE);
|
||||
insert_context.makeQueryContext(); // we need query context to do inserts to target table with MV containing subqueries or joins
|
||||
log = &Poco::Logger::get("SystemLog (" + database_name_ + "." + table_name_ + ")");
|
||||
}
|
||||
|
||||
@ -428,6 +425,10 @@ void SystemLog<LogElement>::flushImpl(const std::vector<LogElement> & to_flush,
|
||||
insert->table_id = table_id;
|
||||
ASTPtr query_ptr(insert.release());
|
||||
|
||||
// we need query context to do inserts to target table with MV containing subqueries or joins
|
||||
auto insert_context = Context(context);
|
||||
insert_context.makeQueryContext();
|
||||
|
||||
InterpreterInsertQuery interpreter(query_ptr, insert_context);
|
||||
BlockIO io = interpreter.execute();
|
||||
|
||||
|
@ -713,7 +713,10 @@ void StorageBuffer::writeBlockToDestination(const Block & block, StoragePtr tabl
|
||||
for (const auto & column : block_to_write)
|
||||
list_of_columns->children.push_back(std::make_shared<ASTIdentifier>(column.name));
|
||||
|
||||
InterpreterInsertQuery interpreter{insert, global_context, allow_materialized};
|
||||
auto insert_context = Context(global_context);
|
||||
insert_context.makeQueryContext();
|
||||
|
||||
InterpreterInsertQuery interpreter{insert, insert_context, allow_materialized};
|
||||
|
||||
auto block_io = interpreter.execute();
|
||||
block_io.out->writePrefix();
|
||||
|
@ -4,6 +4,10 @@ DROP TABLE IF EXISTS expected_times;
|
||||
CREATE TABLE expected_times (QUERY_GROUP_ID String, max_query_duration_ms UInt64) Engine=Memory;
|
||||
INSERT INTO expected_times VALUES('main_dashboard_top_query', 100), ('main_dashboard_bottom_query', 100);
|
||||
|
||||
SET log_queries=1;
|
||||
SELECT 1;
|
||||
SYSTEM FLUSH LOGS;
|
||||
|
||||
CREATE MATERIALIZED VIEW slow_log Engine=Memory AS
|
||||
(
|
||||
SELECT * FROM
|
||||
@ -18,8 +22,6 @@ CREATE MATERIALIZED VIEW slow_log Engine=Memory AS
|
||||
WHERE query_duration_ms > max_query_duration_ms
|
||||
);
|
||||
|
||||
SET log_queries=1;
|
||||
|
||||
SELECT 1 /* QUERY_GROUP_ID:main_dashboard_top_query */;
|
||||
SELECT 1 /* QUERY_GROUP_ID:main_dashboard_bottom_query */;
|
||||
|
||||
|
@ -0,0 +1,3 @@
|
||||
2
|
||||
2
|
||||
2
|
@ -0,0 +1,37 @@
|
||||
DROP TABLE IF EXISTS t1_01361;
|
||||
DROP TABLE IF EXISTS t2_01361;
|
||||
DROP TABLE IF EXISTS mv1_01361;
|
||||
DROP TABLE IF EXISTS b1_01361;
|
||||
|
||||
CREATE TABLE t1_01361 (
|
||||
i UInt32,
|
||||
time DateTime
|
||||
) ENGINE = MergeTree()
|
||||
PARTITION BY time
|
||||
ORDER BY time;
|
||||
|
||||
CREATE TABLE t2_01361 (
|
||||
i UInt32,
|
||||
time DateTime
|
||||
) ENGINE = MergeTree()
|
||||
PARTITION BY time
|
||||
ORDER BY time;
|
||||
|
||||
CREATE MATERIALIZED VIEW mv1_01361
|
||||
TO t2_01361
|
||||
AS SELECT * FROM (SELECT * FROM t1_01361);
|
||||
|
||||
CREATE TABLE b1_01361 AS t1_01361
|
||||
ENGINE = Buffer(currentDatabase(), t1_01361, 1, 0, 0, 1, 1, 1, 1);
|
||||
|
||||
INSERT INTO b1_01361 VALUES (1, now());
|
||||
INSERT INTO b1_01361 VALUES (2, now());
|
||||
|
||||
SELECT count() FROM b1_01361;
|
||||
SELECT count() FROM t1_01361;
|
||||
SELECT count() FROM t2_01361;
|
||||
|
||||
DROP TABLE IF EXISTS t1_01361;
|
||||
DROP TABLE IF EXISTS t2_01361;
|
||||
DROP TABLE IF EXISTS mv1_01361;
|
||||
DROP TABLE IF EXISTS b1_01361;
|
Loading…
Reference in New Issue
Block a user