From 2406caf5247d91f5441860a500d84b3d5de24e55 Mon Sep 17 00:00:00 2001 From: RobinTF <83676088+RobinTF@users.noreply.github.com> Date: Wed, 12 Feb 2025 15:07:55 +0100 Subject: [PATCH 1/2] Support empty transitive path --- src/engine/TransitivePathBase.h | 2 +- src/engine/TransitivePathImpl.h | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/engine/TransitivePathBase.h b/src/engine/TransitivePathBase.h index 71607eed5e..8059afe06a 100644 --- a/src/engine/TransitivePathBase.h +++ b/src/engine/TransitivePathBase.h @@ -117,7 +117,7 @@ class TransitivePathBase : public Operation { TransitivePathSide leftSide, TransitivePathSide rightSide, size_t minDist, size_t maxDist); - virtual ~TransitivePathBase() = 0; + ~TransitivePathBase() override = 0; /** * Returns a new TransitivePath operation that uses the fact that leftop diff --git a/src/engine/TransitivePathImpl.h b/src/engine/TransitivePathImpl.h index 6898468595..05b2ea72cd 100644 --- a/src/engine/TransitivePathImpl.h +++ b/src/engine/TransitivePathImpl.h @@ -142,7 +142,7 @@ class TransitivePathImpl : public TransitivePathBase { for (auto& pair : result) { co_yield pair; } - }; + } protected: /** @@ -155,13 +155,6 @@ class TransitivePathImpl : public TransitivePathBase { * @return Result The result of the TransitivePath operation */ ProtoResult computeResult(bool requestLaziness) override { - if (minDist_ == 0 && !isBoundOrId() && lhs_.isVariable() && - rhs_.isVariable()) { - AD_THROW( - "This query might have to evaluate the empty path, which is " - "currently " - "not supported"); - } auto [startSide, targetSide] = decideDirection(); // In order to traverse the graph represented by this result, we need random // access across the whole table, so it doesn't make sense to lazily compute From f21e5611708a6b9e2f2ce86f217792b016173c44 Mon Sep 17 00:00:00 2001 From: RobinTF <83676088+RobinTF@users.noreply.github.com> Date: Wed, 12 Feb 2025 15:50:49 +0100 Subject: [PATCH 2/2] Add Unit Tests --- test/TransitivePathTest.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/test/TransitivePathTest.cpp b/test/TransitivePathTest.cpp index 2e6da1855b..fd05e7b7d8 100644 --- a/test/TransitivePathTest.cpp +++ b/test/TransitivePathTest.cpp @@ -627,28 +627,36 @@ TEST_P(TransitivePathTest, maxLength2ToId) { } // _____________________________________________________________________________ -TEST_P(TransitivePathTest, zeroLengthException) { +TEST_P(TransitivePathTest, zeroLength) { auto sub = makeIdTableFromVector({ {0, 2}, {2, 4}, {4, 7}, {0, 7}, - {3, 3}, - {7, 0}, - // Disconnected component. {10, 11}, }); + auto expected = makeIdTableFromVector({{0, 0}, + {0, 2}, + {0, 4}, + {0, 7}, + {2, 2}, + {2, 4}, + {2, 7}, + {4, 4}, + {4, 7}, + {10, 10}, + {10, 11}, + {7, 7}, + {11, 11}}); + TransitivePathSide left(std::nullopt, 0, Variable{"?start"}, 0); TransitivePathSide right(std::nullopt, 1, Variable{"?target"}, 1); auto T = makePathUnbound(std::move(sub), {Variable{"?start"}, Variable{"?target"}}, left, right, 0, std::numeric_limits::max()); - AD_EXPECT_THROW_WITH_MESSAGE( - T->computeResultOnlyForTesting(requestLaziness()), - ::testing::ContainsRegex("This query might have to evaluate the empty " - "path, which is currently " - "not supported")); + auto resultTable = T->computeResultOnlyForTesting(requestLaziness()); + assertResultMatchesIdTable(resultTable, expected); } // _____________________________________________________________________________