From 62d4e08d3718a4b4b20e283602b558ad26c23a13 Mon Sep 17 00:00:00 2001 From: Alexander Taepper Date: Thu, 26 Oct 2023 15:38:42 +0200 Subject: [PATCH] fix: bug when filtering for indexedStringColumns which are not present in some partitions --- .../test/queries/divisionFilter.json | 24 +++++++++++++++++++ .../storage/column/indexed_string_column.cpp | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 endToEndTests/test/queries/divisionFilter.json diff --git a/endToEndTests/test/queries/divisionFilter.json b/endToEndTests/test/queries/divisionFilter.json new file mode 100644 index 000000000..0e467e9d9 --- /dev/null +++ b/endToEndTests/test/queries/divisionFilter.json @@ -0,0 +1,24 @@ +{ + "testCaseName": "Filter by division then aggregate", + "query": { + "action": { + "limit": 100, + "type": "Aggregated" + }, + "filterExpression": { + "children": [ + { + "column": "division", + "value": "Aargau", + "type": "StringEquals" + } + ], + "type": "And" + } + }, + "expectedQueryResult": [ + { + "count": 6 + } + ] +} diff --git a/src/silo/storage/column/indexed_string_column.cpp b/src/silo/storage/column/indexed_string_column.cpp index 8c3343d77..2600efac6 100644 --- a/src/silo/storage/column/indexed_string_column.cpp +++ b/src/silo/storage/column/indexed_string_column.cpp @@ -15,7 +15,7 @@ IndexedStringColumnPartition::IndexedStringColumnPartition( std::optional IndexedStringColumnPartition::filter(const std::string& value ) const { const auto value_id = lookup.getId(value); - if (value_id.has_value()) { + if (value_id.has_value() && indexed_values.contains(value_id.value())) { return &indexed_values.at(value_id.value()); } return std::nullopt;