From 658a2d0dc010154c1cb486ea044b0135fe366512 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Tue, 23 Jun 2020 21:52:32 +0300 Subject: [PATCH] Fix anotehr one nullable prewhere column. --- src/Storages/MergeTree/MergeTreeRangeReader.cpp | 2 ++ tests/queries/0_stateless/00752_low_cardinality_mv_2.reference | 1 + tests/queries/0_stateless/00752_low_cardinality_mv_2.sql | 1 + 3 files changed, 4 insertions(+) diff --git a/src/Storages/MergeTree/MergeTreeRangeReader.cpp b/src/Storages/MergeTree/MergeTreeRangeReader.cpp index 667b0b2da96..fcc72b1717f 100644 --- a/src/Storages/MergeTree/MergeTreeRangeReader.cpp +++ b/src/Storages/MergeTree/MergeTreeRangeReader.cpp @@ -914,6 +914,8 @@ void MergeTreeRangeReader::executePrewhereActionsAndFilterColumns(ReadResult & r else { result.columns[prewhere_column_pos] = result.getFilterHolder()->convertToFullColumnIfConst(); + if (getSampleBlock().getByName(prewhere->prewhere_column_name).type->isNullable()) + result.columns[prewhere_column_pos] = makeNullable(std::move(result.columns[prewhere_column_pos])); result.clearFilter(); // Acting as a flag to not filter in PREWHERE } } diff --git a/tests/queries/0_stateless/00752_low_cardinality_mv_2.reference b/tests/queries/0_stateless/00752_low_cardinality_mv_2.reference index b362d0138a0..2f1f0fc0b33 100644 --- a/tests/queries/0_stateless/00752_low_cardinality_mv_2.reference +++ b/tests/queries/0_stateless/00752_low_cardinality_mv_2.reference @@ -1 +1,2 @@ +1 c 2018-10-10 15:45:00 3 10 2018-10-10 15:54:21 1 1 diff --git a/tests/queries/0_stateless/00752_low_cardinality_mv_2.sql b/tests/queries/0_stateless/00752_low_cardinality_mv_2.sql index 354fce8f814..71950469a47 100644 --- a/tests/queries/0_stateless/00752_low_cardinality_mv_2.sql +++ b/tests/queries/0_stateless/00752_low_cardinality_mv_2.sql @@ -5,6 +5,7 @@ CREATE TABLE radacct ( radacctid UInt64, f3gppchargingid Nullable(String), f3gpp insert into radacct values (1, 'a', 'b', 'c', 'd', 'e', 2, 'a', 'b', 'c', 'd', 'e', 'f', 3, 4, 5, 6, 7, 'a', 'Stop', 'c', 'd', 'e', 'f', 'g', 'h', '2018-10-10 15:54:21', '2018-10-10 15:54:21', 8, 'a', 9, 10, 'a', 'b', '2018-10-10 15:54:21', 'a', 'b', 11, 12, '2018-10-10', 'a', 'b', 'c', 'd', 'e'); +SELECT any(acctstatustype = 'Stop') FROM radacct WHERE (acctstatustype = 'Stop') AND ((acctinputoctets + acctoutputoctets) > 0); create materialized view mv_traffic_by_tadig15min Engine=AggregatingMergeTree partition by tadig order by (ts,tadig) populate as select toStartOfFifteenMinutes(timestamp) ts,toDayOfWeek(timestamp) dow, tadig, sumState(acctinputoctets+acctoutputoctets) traffic_bytes,maxState(timestamp) last_stop, minState(radacctid) min_radacctid,maxState(radacctid) max_radacctid from radacct where acctstatustype='Stop' and acctinputoctets+acctoutputoctets > 0 group by tadig,ts,dow; select tadig, ts, dow, sumMerge(traffic_bytes), maxMerge(last_stop), minMerge(min_radacctid), maxMerge(max_radacctid) from mv_traffic_by_tadig15min group by tadig, ts, dow;