mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 07:01:59 +00:00
Allow literals for GLOBAL IN
This commit is contained in:
parent
a332d8b01e
commit
194dcc01fb
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
@ -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