diff --git a/src/engine/Describe.cpp b/src/engine/Describe.cpp index 8fbc18b44d..9ca7ebac19 100644 --- a/src/engine/Describe.cpp +++ b/src/engine/Describe.cpp @@ -26,20 +26,33 @@ std::vector Describe::getChildren() { // _____________________________________________________________________________ string Describe::getCacheKeyImpl() const { // The cache key must represent the `resources_` as well as the `subtree_`. - std::string resourceKey; + std::string result = absl::StrCat("DESCRIBE ", subtree_->getCacheKey(), " "); for (const auto& resource : describe_.resources_) { if (std::holds_alternative(resource)) { - resourceKey.append( + result.append( std::get(resource).toStringRepresentation()); } else { - resourceKey.append(absl::StrCat( + result.append(absl::StrCat( "column #", subtree_->getVariableColumnOrNullopt(std::get(resource)) .value_or(static_cast(-1)), " ")); } } - return absl::StrCat("DESCRIBE ", subtree_->getCacheKey(), resourceKey); + + const auto& defaultGraphs = describe_.datasetClauses_.defaultGraphs_; + if (defaultGraphs.has_value()) { + // The graphs are stored as a hash set, but we need a deterministic order. + std::vector graphIdVec; + std::ranges::transform(defaultGraphs.value(), + std::back_inserter(graphIdVec), + &TripleComponent::toRdfLiteral); + std::ranges::sort(graphIdVec); + absl::StrAppend(&result, + "\nFiltered by Graphs:", + absl::StrJoin(graphIdVec, " ")); + } + return result; } // _____________________________________________________________________________ diff --git a/test/engine/DescribeTest.cpp b/test/engine/DescribeTest.cpp index b273a6f7d0..1684eab5c8 100644 --- a/test/engine/DescribeTest.cpp +++ b/test/engine/DescribeTest.cpp @@ -115,7 +115,19 @@ TEST(Describe, simpleMembers) { using namespace ::testing; EXPECT_THAT(describe.getCacheKey(), AllOf(HasSubstr("DESCRIBE"), HasSubstr(""), - Not(HasSubstr("

")), HasSubstr("Neutral Element"))); + Not(HasSubstr("

")), HasSubstr("Neutral Element"), Not(HasSubstr("Filtered")))); + { + auto parsedDescribe2 = parsedDescribe; + parsedDescribe2.datasetClauses_.defaultGraphs_.emplace( + {TripleComponent::Iri::fromIriref("")}); + Describe describe2{ + qec, ad_utility::makeExecutionTree(qec), + parsedDescribe2}; + EXPECT_THAT(describe2.getCacheKey(), + AllOf(HasSubstr("DESCRIBE"), HasSubstr(""), + Not(HasSubstr("

")), HasSubstr("Neutral Element"), + HasSubstr("Filtered by Graphs:"))); + } auto col = makeAlwaysDefinedColumn; using V = Variable;