mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Fix PREWHERE with distributed IN (#9871)
fix PREWHERE with distributed IN (local mode)
This commit is contained in:
parent
893fda2dbe
commit
adca27cb45
@ -98,8 +98,8 @@ private:
|
||||
throw Exception("Distributed table should have an alias when distributed_product_mode set to local.",
|
||||
ErrorCodes::DISTRIBUTED_IN_JOIN_SUBQUERY_DENIED);
|
||||
|
||||
database_and_table = createTableIdentifier(database, table);
|
||||
database_and_table->setAlias(alias);
|
||||
auto & identifier = database_and_table->as<ASTIdentifier &>();
|
||||
identifier.resetTable(database, table);
|
||||
}
|
||||
else
|
||||
throw Exception("InJoinSubqueriesPreprocessor: unexpected value of 'distributed_product_mode' setting",
|
||||
|
@ -101,6 +101,15 @@ void ASTIdentifier::appendColumnNameImpl(WriteBuffer & ostr) const
|
||||
writeString(name, ostr);
|
||||
}
|
||||
|
||||
void ASTIdentifier::resetTable(const String & database_name, const String & table_name)
|
||||
{
|
||||
auto ast = createTableIdentifier(database_name, table_name);
|
||||
auto & ident = ast->as<ASTIdentifier &>();
|
||||
name.swap(ident.name);
|
||||
name_parts.swap(ident.name_parts);
|
||||
uuid = ident.uuid;
|
||||
}
|
||||
|
||||
ASTPtr createTableIdentifier(const String & database_name, const String & table_name)
|
||||
{
|
||||
assert(database_name != "_temporary_and_external_tables");
|
||||
|
@ -49,6 +49,8 @@ public:
|
||||
return name;
|
||||
}
|
||||
|
||||
void resetTable(const String & database_name, const String & table_name);
|
||||
|
||||
protected:
|
||||
void formatImplWithoutAlias(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
||||
void appendColumnNameImpl(WriteBuffer & ostr) const override;
|
||||
|
@ -0,0 +1,24 @@
|
||||
DROP TABLE IF EXISTS hits;
|
||||
DROP TABLE IF EXISTS visits;
|
||||
DROP TABLE IF EXISTS hits_layer;
|
||||
DROP TABLE IF EXISTS visits_layer;
|
||||
|
||||
CREATE TABLE visits(StartDate Date) ENGINE MergeTree ORDER BY(StartDate);
|
||||
CREATE TABLE hits(EventDate Date, WatchID UInt8) ENGINE MergeTree ORDER BY(EventDate);
|
||||
|
||||
CREATE TABLE visits_layer(StartDate Date) ENGINE Distributed(test_cluster_two_shards_localhost, currentDatabase(), 'visits');
|
||||
CREATE TABLE hits_layer(EventDate Date, WatchID UInt8) ENGINE Distributed(test_cluster_two_shards_localhost, currentDatabase(), 'hits');
|
||||
|
||||
SET distributed_product_mode = 'local';
|
||||
|
||||
SELECT 0 FROM hits_layer AS hl
|
||||
PREWHERE WatchID IN
|
||||
(
|
||||
SELECT 0 FROM visits_layer AS vl
|
||||
)
|
||||
WHERE 0;
|
||||
|
||||
DROP TABLE hits;
|
||||
DROP TABLE visits;
|
||||
DROP TABLE hits_layer;
|
||||
DROP TABLE visits_layer;
|
Loading…
Reference in New Issue
Block a user