Skip to content

Commit

Permalink
Add more tests, remove old code from the bind
Browse files Browse the repository at this point in the history
  • Loading branch information
Dtenwolde committed Nov 7, 2024
1 parent 56e2504 commit eacdfa6
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ unique_ptr<FunctionData>
ShortestPathOperatorData::ShortestPathOperatorBind(
ClientContext &context, ScalarFunction &bound_function,
vector<unique_ptr<Expression>> &arguments) {
// string table_to_scan = ExpressionExecutor::EvaluateScalar(context, *arguments[2]).GetValue<string>();
return make_uniq<ShortestPathOperatorData>(context, "");
return make_uniq<ShortestPathOperatorData>(context);
}
unique_ptr<FunctionData> ShortestPathOperatorData::Copy() const {
return make_uniq<ShortestPathOperatorData>(context, table_to_scan);
return make_uniq<ShortestPathOperatorData>(context);
}

bool ShortestPathOperatorData::Equals(const FunctionData &other_p) const {
auto &other = (const ShortestPathOperatorData &)other_p;
return other.table_to_scan == table_to_scan;
return true;
}

} // namespace core
Expand Down
2 changes: 1 addition & 1 deletion src/core/functions/scalar/iterativelength_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static void IterativeLengthOperatorFunction(DataChunk &args, ExpressionState &st
//------------------------------------------------------------------------------
void CoreScalarFunctions::RegisterIterativeLengthOperatorScalarFunction(DatabaseInstance &db) {
ExtensionUtil::RegisterFunction(
db, ScalarFunction("iterativelengthoperator", {LogicalType::BIGINT, LogicalType::BIGINT, LogicalType::VARCHAR},
db, ScalarFunction("iterativelengthoperator", {LogicalType::BIGINT, LogicalType::BIGINT, LogicalType::BIGINT},
LogicalType::BIGINT, IterativeLengthOperatorFunction,
ShortestPathOperatorData::ShortestPathOperatorBind));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ namespace core {

struct ShortestPathOperatorData final : FunctionData {
ClientContext &context;
string table_to_scan;

ShortestPathOperatorData(ClientContext &context, string table_to_scan)
: context(context), table_to_scan(std::move(table_to_scan)) {}
ShortestPathOperatorData(ClientContext &context)
: context(context) {}
static unique_ptr<FunctionData>
ShortestPathOperatorBind(ClientContext &context, ScalarFunction &bound_function,
vector<unique_ptr<Expression>> &arguments);
Expand Down
171 changes: 152 additions & 19 deletions test/sql/path_finding/parallel_path_finding.test
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ create or replace table snb_pairs as (
select src, dst
from (select a.rowid as src from person a),
(select b.rowid as dst from person b)
using sample reservoir(10 rows) repeatable (300)
using sample reservoir(50 rows) repeatable (300)
);

query III
Expand Down Expand Up @@ -161,16 +161,57 @@ SELECT cast(min(create_csr_edge(
JOIN person c on c.id = k.person2id)
SELECT src, dst, shortestpathoperator(src, dst, csr_id) FROM snb_pairs, csr_cte;
----
11 22 [11, 35, 22]
36 1 NULL
14 7 NULL
0 47 NULL
5 44 [5, 22, 26, 66, 44]
34 43 NULL
5 33 [5, 25, 33]
27 45 NULL
26 29 NULL
36 33 NULL
41 7 NULL
0 1 NULL
14 2 NULL
11 15 NULL
6 5 NULL
24 39 NULL
9 10 NULL
2 15 NULL
27 39 NULL
12 15 NULL
9 29 NULL
4 24 NULL
35 31 NULL
30 10 NULL
34 15 NULL
49 8 NULL
32 12 NULL
40 17 NULL
31 11 NULL
42 30 NULL
25 44 [25, 60, 26, 66, 44]
39 31 NULL
0 22 NULL
32 27 NULL
15 21 NULL
15 14 NULL
31 42 NULL
3 16 NULL
40 21 NULL
10 43 [10, 32, 18, 56, 43]
8 41 NULL
20 15 NULL
2 37 NULL
47 25 NULL
4 48 NULL
46 21 NULL
8 13 NULL
43 31 NULL
37 25 NULL
0 39 [0, 0, 13, 44, 33, 79, 39]
5 26 [5, 22, 26]
5 43 [5, 25, 33, 80, 43]
44 35 NULL
3 27 [3, 11, 9, 31, 27]
30 13 NULL
9 15 NULL
0 46 [0, 0, 13, 46, 46]
2 30 [2, 7, 5, 17, 12, 40, 30]
41 48 NULL
45 9 NULL



query III
Expand Down Expand Up @@ -198,15 +239,107 @@ SELECT cast(min(create_csr_edge(
FROM person_knows_person k
JOIN person a on a.id = k.person1id
JOIN person c on c.id = k.person2id)
SELECT src, dst, shortestpathoperator(src, dst, csr_id) FROM snb_pairs, csr_cte where src > 10;
SELECT src, dst, shortestpathoperator(src, dst, csr_id) FROM snb_pairs, csr_cte where src < 10;
----
11 22 [11, 35, 22]
36 1 NULL
14 7 NULL
34 43 NULL
27 45 NULL
26 29 NULL
36 33 NULL
0 1 NULL
6 5 NULL
9 10 NULL
2 15 NULL
9 29 NULL
4 24 NULL
0 22 NULL
3 16 NULL
8 41 NULL
2 37 NULL
4 48 NULL
8 13 NULL
0 39 [0, 0, 13, 44, 33, 79, 39]
5 26 [5, 22, 26]
5 43 [5, 25, 33, 80, 43]
3 27 [3, 11, 9, 31, 27]
9 15 NULL
0 46 [0, 0, 13, 46, 46]
2 30 [2, 7, 5, 17, 12, 40, 30]


query III
with csr_cte as (
SELECT cast(min(create_csr_edge(
0,
(SELECT count(a.id) FROM person a),
CAST (
(SELECT sum(create_csr_vertex(
0,
(SELECT count(a.id) FROM person a),
sub.dense_id,
sub.cnt))
FROM (
SELECT a.rowid as dense_id, count(k.person1id) as cnt
FROM person a
LEFT JOIN person_knows_person k ON k.person1id = a.id
GROUP BY a.rowid) sub
)
AS BIGINT),
(select count() FROM person_knows_person k JOIN person a on a.id = k.person1id JOIN person c on c.id = k.person2id),
a.rowid,
c.rowid,
k.rowid)) as bigint) as csr_id
FROM person_knows_person k
JOIN person a on a.id = k.person1id
JOIN person c on c.id = k.person2id)
SELECT src, dst, iterativelengthoperator(src, dst, csr_id) FROM snb_pairs, csr_cte;
----
41 7 NULL
0 1 NULL
14 2 NULL
11 15 NULL
6 5 NULL
24 39 NULL
9 10 NULL
2 15 NULL
27 39 NULL
12 15 NULL
9 29 NULL
4 24 NULL
35 31 NULL
30 10 NULL
34 15 NULL
49 8 NULL
32 12 NULL
40 17 NULL
31 11 NULL
42 30 NULL
25 44 2
39 31 NULL
0 22 NULL
32 27 NULL
15 21 NULL
15 14 NULL
31 42 NULL
3 16 NULL
40 21 NULL
10 43 2
8 41 NULL
20 15 NULL
2 37 NULL
47 25 NULL
4 48 NULL
46 21 NULL
8 13 NULL
43 31 NULL
37 25 NULL
0 39 3
5 26 1
5 43 2
44 35 NULL
3 27 2
30 13 NULL
9 15 NULL
0 46 2
2 30 3
41 48 NULL
45 9 NULL



# 0 pair test
Expand Down

0 comments on commit eacdfa6

Please sign in to comment.