mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #27298 from ClickHouse/fix-23515
Fix bug from #23515.
This commit is contained in:
commit
bb4c11cd27
@ -342,6 +342,13 @@ static void executeAction(const ExpressionActions::Action & action, ExecutionCon
|
||||
res_column.type = action.node->result_type;
|
||||
res_column.name = action.node->result_name;
|
||||
|
||||
if (action.node->column)
|
||||
{
|
||||
/// Do not execute function if it's result is already known.
|
||||
res_column.column = action.node->column->cloneResized(num_rows);
|
||||
break;
|
||||
}
|
||||
|
||||
ColumnsWithTypeAndName arguments(action.arguments.size());
|
||||
for (size_t i = 0; i < arguments.size(); ++i)
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <Columns/FilterDescription.h>
|
||||
#include <Columns/ColumnsCommon.h>
|
||||
#include <common/range.h>
|
||||
#include <Interpreters/castColumn.h>
|
||||
#include <DataTypes/DataTypeNothing.h>
|
||||
|
||||
#ifdef __SSE2__
|
||||
@ -1043,9 +1044,9 @@ void MergeTreeRangeReader::executePrewhereActionsAndFilterColumns(ReadResult & r
|
||||
/// Filter in WHERE instead
|
||||
else
|
||||
{
|
||||
result.columns[prewhere_column_pos] = result.getFilterHolder()->convertToFullColumnIfConst();
|
||||
if (getSampleBlock().getByName(prewhere_info->prewhere_column_name).type->isNullable())
|
||||
result.columns[prewhere_column_pos] = makeNullable(std::move(result.columns[prewhere_column_pos]));
|
||||
auto type = getSampleBlock().getByName(prewhere_info->prewhere_column_name).type;
|
||||
ColumnWithTypeAndName col(result.getFilterHolder()->convertToFullColumnIfConst(), std::make_shared<DataTypeUInt8>(), "");
|
||||
result.columns[prewhere_column_pos] = castColumn(col, type);
|
||||
result.clearFilter(); // Acting as a flag to not filter in PREWHERE
|
||||
}
|
||||
}
|
||||
|
1
tests/queries/0_stateless/02003_bug_from_23515.reference
Normal file
1
tests/queries/0_stateless/02003_bug_from_23515.reference
Normal file
@ -0,0 +1 @@
|
||||
1
|
10
tests/queries/0_stateless/02003_bug_from_23515.sql
Normal file
10
tests/queries/0_stateless/02003_bug_from_23515.sql
Normal file
@ -0,0 +1,10 @@
|
||||
drop table if exists tab;
|
||||
create table tab (a LowCardinality(String), b LowCardinality(String)) engine = MergeTree partition by a order by tuple() settings min_bytes_for_wide_part = 0, min_rows_for_wide_part = 0;
|
||||
|
||||
insert into tab values ('1', 'a'), ('2', 'b');
|
||||
SELECT a = '1' FROM tab WHERE a = '1' and b='a';
|
||||
|
||||
-- Fuzzed
|
||||
SELECT * FROM tab WHERE (a = '1') AND 0 AND (b = 'a');
|
||||
|
||||
drop table if exists tab;
|
Loading…
Reference in New Issue
Block a user