Skip to content

Commit

Permalink
Try out if that fixes the error...
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Kalmbach <[email protected]>
  • Loading branch information
joka921 committed Jan 10, 2025
1 parent eced22b commit 70319f7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
22 changes: 16 additions & 6 deletions src/engine/CheckUsePatternTrick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ void addValuesClause(ParsedQuery::GraphPattern& graphPattern,
for (const auto& foundValue : foundClauses) {
addValuesClause(graphPattern, foundValue, false);
}

if (foundClauses.empty()) {
for (auto& pattern : graphPattern._graphPatterns) {
addValuesClauseToPattern(pattern, std::nullopt);
}
}
}

// __________________________________________________________________________
Expand All @@ -145,9 +151,9 @@ bool addValuesClauseToPattern(parsedQuery::GraphPatternOperation& operation,
addValuesClause(pattern, result);
return false;
};
// TODO<joka921> Don't pass an optional to this function.
AD_CORRECTNESS_CHECK(result.has_value());
const auto& variables = result.value()._inlineValues._variables;
const std::vector<Variable> emptyVars{};
const auto& variables =
result.has_value() ? result.value()._inlineValues._variables : emptyVars;
auto anyVar = [&](auto f) { return ql::ranges::any_of(variables, f); };
return operation.visit([&](auto&& arg) -> bool {
using T = std::decay_t<decltype(arg)>;
Expand All @@ -169,6 +175,9 @@ bool addValuesClauseToPattern(parsedQuery::GraphPatternOperation& operation,
})) {
return check(arg.get()._rootGraphPattern);

Check warning on line 176 in src/engine/CheckUsePatternTrick.cpp

View check run for this annotation

Codecov / codecov/patch

src/engine/CheckUsePatternTrick.cpp#L173-L176

Added lines #L173 - L176 were not covered by tests
} else {
// Also recurse into the subquery, but not with the given `VALUES`
// clause.
addValuesClause(arg.get()._rootGraphPattern, std::nullopt);
return false;
}
} else if constexpr (std::is_same_v<T, p::Bind>) {
Expand Down Expand Up @@ -200,9 +209,10 @@ bool addValuesClauseToPattern(parsedQuery::GraphPatternOperation& operation,
static_assert(
std::is_same_v<T, p::TransPath> || std::is_same_v<T, p::PathQuery> ||
std::is_same_v<T, p::Describe> || std::is_same_v<T, p::SpatialQuery>);
// The `TransPath` is set up later in the query planning, when this
// function should not be called anymore.
AD_FAIL();
// TODO<joka921> This is just an optimization, so we can always just omit
// it, but it would be nice to also apply this optimization for those
// types of queries.
return false;
}
});
}
Expand Down
7 changes: 5 additions & 2 deletions src/engine/QueryPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,15 @@ std::vector<QueryPlanner::SubtreePlan> QueryPlanner::createExecutionTrees(
}

// _____________________________________________________________________________
QueryExecutionTree QueryPlanner::createExecutionTree(ParsedQuery& pq,
QueryExecutionTree QueryPlanner::createExecutionTree(ParsedQuery& pqIn,
bool isSubquery) {
try {
ParsedQuery copy;
if (!isSubquery) {
checkUsePatternTrick::addValuesClause(pq._rootGraphPattern);
copy = pqIn;
checkUsePatternTrick::addValuesClause(copy._rootGraphPattern);
}
auto& pq = isSubquery ? pqIn : copy;
auto lastRow = createExecutionTrees(pq, isSubquery);
auto minInd = findCheapestExecutionTree(lastRow);
LOG(DEBUG) << "Done creating execution plan" << std::endl;
Expand Down

0 comments on commit 70319f7

Please sign in to comment.