diff --git a/src/Functions/queryID.cpp b/src/Functions/queryID.cpp index 814188aead1..b55d3fa0326 100644 --- a/src/Functions/queryID.cpp +++ b/src/Functions/queryID.cpp @@ -32,7 +32,7 @@ public: ColumnPtr executeImpl(const ColumnsWithTypeAndName &, const DataTypePtr &, size_t input_rows_count) const override { - return DataTypeString().createColumnConst(input_rows_count, query_id); + return DataTypeString().createColumnConst(input_rows_count, query_id)->convertToFullColumnIfConst(); } }; diff --git a/tests/queries/0_stateless/01943_query_id_check.reference b/tests/queries/0_stateless/01943_query_id_check.reference index 47c656497ef..324d49f8907 100644 --- a/tests/queries/0_stateless/01943_query_id_check.reference +++ b/tests/queries/0_stateless/01943_query_id_check.reference @@ -1,2 +1,7 @@ CREATE TABLE tmp ENGINE = TinyLog AS SELECT queryID(); CREATE TABLE tmp ENGINE = TinyLog AS SELECT initialQueryID(); +3 +3 +1 +1 +3 diff --git a/tests/queries/0_stateless/01943_query_id_check.sql b/tests/queries/0_stateless/01943_query_id_check.sql index f99d2459b36..6e3d281386d 100644 --- a/tests/queries/0_stateless/01943_query_id_check.sql +++ b/tests/queries/0_stateless/01943_query_id_check.sql @@ -1,3 +1,5 @@ +DROP TABLE IF EXISTS tmp; + CREATE TABLE tmp ENGINE = TinyLog AS SELECT queryID(); SYSTEM FLUSH LOGS; SELECT query FROM system.query_log WHERE query_id = (SELECT * FROM tmp) AND current_database = currentDatabase() LIMIT 1; @@ -8,3 +10,12 @@ SYSTEM FLUSH LOGS; SELECT query FROM system.query_log WHERE initial_query_id = (SELECT * FROM tmp) AND current_database = currentDatabase() LIMIT 1; DROP TABLE tmp; +CREATE TABLE tmp (str String) ENGINE = Log; +INSERT INTO tmp (*) VALUES ('a') +SELECT count() FROM (SELECT initialQueryID() FROM remote('127.0.0.{1..3}', currentDatabase(), 'tmp') GROUP BY queryID()); +SELECT count() FROM (SELECT queryID() FROM remote('127.0.0.{1..3}', currentDatabase(), 'tmp') GROUP BY queryID()); +SELECT count() FROM (SELECT queryID() AS t FROM remote('127.0.0.{1..3}', currentDatabase(), 'tmp') GROUP BY queryID() HAVING t == initialQueryID()); +SELECT count(DISTINCT t) FROM (SELECT initialQueryID() AS t FROM remote('127.0.0.{1..3}', currentDatabase(), 'tmp') GROUP BY queryID()); +SELECT count(DISTINCT t) FROM (SELECT queryID() AS t FROM remote('127.0.0.{1..3}', currentDatabase(), 'tmp') GROUP BY queryID()); +DROP TABLE tmp; + diff --git a/tests/queries/skip_list.json b/tests/queries/skip_list.json index b2f00dcfb87..1b544ea20d1 100644 --- a/tests/queries/skip_list.json +++ b/tests/queries/skip_list.json @@ -175,7 +175,8 @@ "00140_rename", /// Requires investigation "00953_zookeeper_suetin_deduplication_bug", - "01783_http_chunk_size" + "01783_http_chunk_size", + "01943_query_id_check" ], "polymorphic-parts": [ "01508_partition_pruning_long", /// bug, shoud be fixed