Merge pull request #59351 from ClickHouse/fix-non-redy-set-system-tables

Fix not-ready set for system.tables
This commit is contained in:
Alexey Milovidov 2024-01-30 03:59:18 +01:00 committed by GitHub
commit de341a6d6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View File

@ -693,10 +693,15 @@ public:
{
}
void applyFilters() override;
private:
ContextPtr context;
std::vector<UInt8> columns_mask;
size_t max_block_size;
ColumnPtr filtered_databases_column;
ColumnPtr filtered_tables_column;
};
void StorageSystemTables::read(
@ -723,16 +728,19 @@ void StorageSystemTables::read(
query_plan.addStep(std::move(reading));
}
void ReadFromSystemTables::initializePipeline(QueryPipelineBuilder & pipeline, const BuildQueryPipelineSettings &)
void ReadFromSystemTables::applyFilters()
{
auto filter_actions_dag = ActionsDAG::buildFilterActionsDAG(filter_nodes.nodes);
const ActionsDAG::Node * predicate = nullptr;
if (filter_actions_dag)
predicate = filter_actions_dag->getOutputs().at(0);
ColumnPtr filtered_databases_column = getFilteredDatabases(predicate, context);
ColumnPtr filtered_tables_column = getFilteredTables(predicate, filtered_databases_column, context);
filtered_databases_column = getFilteredDatabases(predicate, context);
filtered_tables_column = getFilteredTables(predicate, filtered_databases_column, context);
}
void ReadFromSystemTables::initializePipeline(QueryPipelineBuilder & pipeline, const BuildQueryPipelineSettings &)
{
Pipe pipe(std::make_shared<TablesBlockSource>(
std::move(columns_mask), getOutputStream().header, max_block_size, std::move(filtered_databases_column), std::move(filtered_tables_column), context));
pipeline.init(std::move(pipe));

View File

@ -9,3 +9,4 @@ $CLICKHOUSE_CLIENT -q "create table t1 (number UInt64) engine = MergeTree order
$CLICKHOUSE_CLIENT -q "insert into t1 select number from numbers(10);"
$CLICKHOUSE_CLIENT --max_threads=2 --max_result_rows=1 --result_overflow_mode=break -q "with tab as (select min(number) from t1 prewhere number in (select number from view(select number, row_number() OVER (partition by number % 2 ORDER BY number DESC) from numbers_mt(1e4)) where number != 2 order by number)) select number from t1 union all select * from tab;" > /dev/null
$CLICKHOUSE_CLIENT -q "SELECT * FROM system.tables WHERE 1 in (SELECT number from numbers(2)) AND database = currentDatabase() format Null"