Fix logical error for invalid prewhere type in StorageMerge.

This commit is contained in:
Nikolai Kochetov 2022-10-25 13:58:29 +00:00
parent 715b923bf9
commit bfb5e6eae4
2 changed files with 9 additions and 3 deletions

View File

@ -520,6 +520,8 @@ QueryPipelineBuilderPtr ReadFromMerge::createSources(
modified_select.setFinal();
}
modified_select.replaceDatabaseAndTable(database_name, table_name);
auto storage_stage
= storage->getQueryProcessingStage(modified_context, QueryProcessingStage::Complete, storage_snapshot, modified_query_info);
if (processed_stage <= storage_stage)
@ -545,6 +547,12 @@ QueryPipelineBuilderPtr ReadFromMerge::createSources(
}
else
{
{
/// Analyze query to check that types are valid (e.g. in PREWHERE).
InterpreterSelectQuery interpreter
(modified_query_info.query, modified_context, SelectQueryOptions(processed_stage).ignoreProjections());
}
storage->read(
plan,
real_column_names,
@ -569,8 +577,6 @@ QueryPipelineBuilderPtr ReadFromMerge::createSources(
}
else if (processed_stage > storage_stage)
{
modified_select.replaceDatabaseAndTable(database_name, table_name);
/// Maximum permissible parallelism is streams_num
modified_context->setSetting("max_threads", streams_num);
modified_context->setSetting("max_streams_to_max_threads_ratio", 1);

View File

@ -65,7 +65,7 @@ SELECT _database, _table, n FROM merge(currentDatabase(), '^t') ORDER BY _databa
--fuzzed LOGICAL_ERROR
CREATE TABLE 01902_db.t4 (n Date) ENGINE=MergeTree ORDER BY n;
INSERT INTO 01902_db.t4 SELECT * FROM numbers(10);
SELECT NULL FROM 01902_db.t_merge WHERE n ORDER BY _table DESC;
SELECT NULL FROM 01902_db.t_merge WHERE n ORDER BY _table DESC; -- {serverError ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER}
DROP DATABASE 01902_db;
DROP DATABASE 01902_db1;