-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bug in the cache key of
DISTINCT
(#1403)
The cache key of a DISTINCT operation previously did not change when the subtree stayed the same, but the variables on which the DISTINCT was performed changed. For example, when first executing `SELECT DISTINCT ?x ?y WHERE { ?x wdt:P30 ?y }` and then `SELECT DISTINCT ?x WHERE { ?x wdt:P30 ? }` on Wikidata, the result for the second query would be mistakenly taken from the cache, although those queries have different results. This is now fixed by adding the column indices of the variables to the cache key.
- Loading branch information
Showing
4 changed files
with
43 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2022, University of Freiburg, | ||
// Chair of Algorithms and Data Structures. | ||
// Author: Johannes Kalmbach <[email protected]> | ||
|
||
#include <gmock/gmock.h> | ||
|
||
#include "../util/IndexTestHelpers.h" | ||
#include "engine/Distinct.h" | ||
#include "engine/NeutralElementOperation.h" | ||
|
||
TEST(Distinct, CacheKey) { | ||
// The cache key has to change when the subtree changes or when the | ||
// `keepIndices` (the distinct variables) change. | ||
auto qec = ad_utility::testing::getQec(); | ||
auto d = ad_utility::makeExecutionTree<Distinct>( | ||
ad_utility::testing::getQec(), | ||
ad_utility::makeExecutionTree<NeutralElementOperation>(qec), | ||
std::vector<ColumnIndex>{0, 1}); | ||
Distinct d2(ad_utility::testing::getQec(), | ||
ad_utility::makeExecutionTree<NeutralElementOperation>(qec), {0}); | ||
Distinct d3(ad_utility::testing::getQec(), d, {0}); | ||
|
||
EXPECT_NE(d->getCacheKey(), d2.getCacheKey()); | ||
EXPECT_NE(d->getCacheKey(), d3.getCacheKey()); | ||
EXPECT_NE(d2.getCacheKey(), d3.getCacheKey()); | ||
} |