mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-11 17:02:25 +00:00
Improve aliased_column_distributed_bug, fix check
This commit is contained in:
parent
db187c6b2d
commit
910787c5b6
@ -138,8 +138,6 @@ struct SelectQueryOptions
|
||||
shard_count = shard_count_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool hasShardInfo() const { return shard_num.has_value() || shard_count.has_value(); }
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -976,7 +976,8 @@ TreeRewriterResultPtr TreeRewriter::analyzeSelect(
|
||||
result.required_source_columns_before_expanding_alias_columns = result.required_source_columns.getNames();
|
||||
|
||||
/// rewrite filters for select query, must go after getArrayJoinedColumns
|
||||
if (settings.optimize_respect_aliases && result.metadata_snapshot && !select_options.hasShardInfo())
|
||||
bool is_initiator = getContext()->getClientInfo().distributed_depth == 0;
|
||||
if (settings.optimize_respect_aliases && result.metadata_snapshot && is_initiator)
|
||||
{
|
||||
/// If query is changed, we need to redo some work to correct name resolution.
|
||||
if (replaceAliasColumnsInQuery(query, result.metadata_snapshot->getColumns(), result.array_join_result_to_source, getContext()))
|
||||
|
@ -0,0 +1,20 @@
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
@ -1,10 +1,15 @@
|
||||
DROP TABLE IF EXISTS click_storage;
|
||||
DROP TABLE IF EXISTS click_storage_dst;
|
||||
|
||||
CREATE TABLE click_storage ( `PhraseID` UInt64, `PhraseProcessedID` UInt64 ALIAS if(PhraseID > 0, PhraseID, 0) ) ENGINE = MergeTree() ORDER BY tuple();
|
||||
CREATE TABLE click_storage ( `PhraseID` UInt64, `PhraseProcessedID` UInt64 ALIAS if(PhraseID > 5, PhraseID, 0) ) ENGINE = MergeTree() ORDER BY tuple();
|
||||
INSERT INTO click_storage SELECT number AS PhraseID from numbers(10);
|
||||
|
||||
CREATE TABLE click_storage_dst ( `PhraseID` UInt64, `PhraseProcessedID` UInt64 ) ENGINE = Distributed(test_shard_localhost, currentDatabase(), 'click_storage');
|
||||
|
||||
SET prefer_localhost_replica = 1;
|
||||
SELECT materialize(PhraseProcessedID) FROM click_storage_dst;
|
||||
|
||||
SET prefer_localhost_replica = 0;
|
||||
SELECT materialize(PhraseProcessedID) FROM click_storage_dst;
|
||||
|
||||
DROP TABLE IF EXISTS click_storage;
|
||||
|
Loading…
Reference in New Issue
Block a user