mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #10196 from azat/Distributed-GLOBAL-IN
Allow literals for GLOBAL IN
This commit is contained in:
commit
0cc91b9cab
@ -2,6 +2,7 @@
|
||||
|
||||
#include <Parsers/IAST.h>
|
||||
#include <Parsers/ASTSubquery.h>
|
||||
#include <Parsers/ASTLiteral.h>
|
||||
#include <Parsers/ASTFunction.h>
|
||||
#include <Parsers/ASTTablesInSelectQuery.h>
|
||||
#include <Parsers/ASTSelectQuery.h>
|
||||
@ -166,7 +167,19 @@ private:
|
||||
{
|
||||
if (func.name == "globalIn" || func.name == "globalNotIn")
|
||||
{
|
||||
data.addExternalStorage(func.arguments->children[1]);
|
||||
ASTPtr & ast = func.arguments->children[1];
|
||||
|
||||
/// Literal can use regular IN
|
||||
if (ast->as<ASTLiteral>())
|
||||
{
|
||||
if (func.name == "globalIn")
|
||||
func.name = "in";
|
||||
else
|
||||
func.name = "notIn";
|
||||
return;
|
||||
}
|
||||
|
||||
data.addExternalStorage(ast);
|
||||
data.has_global_subqueries = true;
|
||||
}
|
||||
}
|
||||
|
@ -99,3 +99,5 @@ merge()
|
||||
distributed_group_by_no_merge
|
||||
33
|
||||
33
|
||||
GLOBAL IN
|
||||
1
|
||||
|
@ -82,6 +82,10 @@ select count() from merge_dist_01223;
|
||||
select 'distributed_group_by_no_merge';
|
||||
select count() from merge_dist_01223 settings distributed_group_by_no_merge=1;
|
||||
|
||||
-- global in
|
||||
select 'GLOBAL IN';
|
||||
select distinct * from dist_01223 where key global in (select toInt32(1));
|
||||
|
||||
drop table merge_dist_01223;
|
||||
drop table dist_01223;
|
||||
drop table dist_layer_01223;
|
||||
|
@ -0,0 +1,6 @@
|
||||
GLOBAL IN
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
GLOBAL NOT IN
|
10
tests/queries/0_stateless/01226_dist_on_dist_global_in.sql
Normal file
10
tests/queries/0_stateless/01226_dist_on_dist_global_in.sql
Normal file
@ -0,0 +1,10 @@
|
||||
SELECT 'GLOBAL IN';
|
||||
select * from remote('localhost', system.one) where dummy global in (0);
|
||||
select * from remote('localhost', system.one) where toUInt64(dummy) global in numbers(1);
|
||||
select * from remote('localhost', system.one) where dummy global in system.one;
|
||||
select * from remote('localhost', system.one) where dummy global in (select 0);
|
||||
SELECT 'GLOBAL NOT IN';
|
||||
select * from remote('localhost', system.one) where dummy global not in (0);
|
||||
select * from remote('localhost', system.one) where toUInt64(dummy) global not in numbers(1);
|
||||
select * from remote('localhost', system.one) where dummy global not in system.one;
|
||||
select * from remote('localhost', system.one) where dummy global not in (select 0);
|
@ -0,0 +1,3 @@
|
||||
2
|
||||
2
|
||||
2
|
@ -0,0 +1,6 @@
|
||||
-- Test from the issue https://github.com/ClickHouse/ClickHouse/issues/2610
|
||||
drop table if exists data_01227;
|
||||
create table data_01227 (key Int) Engine=MergeTree() order by key;
|
||||
insert into data_01227 select * from numbers(10);
|
||||
select * from remote('127.1', currentDatabase(), data_01227) prewhere key global in (select key from data_01227 prewhere key = 2);
|
||||
select * from cluster('test_cluster_two_shards', currentDatabase(), data_01227) prewhere key global in (select key from data_01227 prewhere key = 2);
|
@ -1,4 +0,0 @@
|
||||
GLOBAL IN distributed_group_by_no_merge
|
||||
1
|
||||
GLOBAL IN
|
||||
1
|
@ -1,18 +0,0 @@
|
||||
create table if not exists data_01224 (key Int) Engine=Memory();
|
||||
create table if not exists dist_layer_01224 as data_01224 Engine=Distributed(test_cluster_two_shards, currentDatabase(), data_01224);
|
||||
create table if not exists dist_01224 as data_01224 Engine=Distributed(test_cluster_two_shards, currentDatabase(), dist_layer_01224);
|
||||
|
||||
select * from dist_01224;
|
||||
insert into data_01224 select * from numbers(3);
|
||||
|
||||
-- "Table expression is undefined, Method: ExpressionAnalyzer::interpretSubquery"
|
||||
select 'GLOBAL IN distributed_group_by_no_merge';
|
||||
select distinct * from dist_01224 where key global in (1) settings distributed_group_by_no_merge=1;
|
||||
|
||||
-- requires #9923
|
||||
select 'GLOBAL IN';
|
||||
select distinct * from dist_01224 where key global in (1);
|
||||
|
||||
drop table dist_01224;
|
||||
drop table dist_layer_01224;
|
||||
drop table data_01224;
|
Loading…
Reference in New Issue
Block a user