diff --git a/duckpgq/src/duckpgq/functions/tablefunctions/match.cpp b/duckpgq/src/duckpgq/functions/tablefunctions/match.cpp index 161dccf1..2fbe3c38 100644 --- a/duckpgq/src/duckpgq/functions/tablefunctions/match.cpp +++ b/duckpgq/src/duckpgq/functions/tablefunctions/match.cpp @@ -48,9 +48,9 @@ void PGQMatchFunction::CheckInheritance( const auto itr = std::find(tableref->sub_labels.begin(), tableref->sub_labels.end(), element->label); - const auto idx_of_element = std::distance(tableref->sub_labels.begin(), itr); + const auto idx_of_label = std::distance(tableref->sub_labels.begin(), itr); auto constant_expression_idx_label = make_uniq( - Value::INTEGER(static_cast(idx_of_element))); + Value::INTEGER(static_cast(idx_of_label))); vector> power_of_children; power_of_children.push_back(std::move(constant_expression_two)); @@ -58,7 +58,7 @@ void PGQMatchFunction::CheckInheritance( auto power_of_term = make_uniq("power", std::move(power_of_children)); auto bigint_cast = - make_uniq(LogicalType::BIGINT, std::move(power_of_term)); + make_uniq(LogicalType::INTEGER, std::move(power_of_term)); auto subcategory_colref = make_uniq( tableref->discriminator, element->variable_binding); vector> and_children; @@ -69,7 +69,7 @@ void PGQMatchFunction::CheckInheritance( make_uniq("&", std::move(and_children)); auto constant_expression_idx_label_comparison = make_uniq( - Value::INTEGER(static_cast(idx_of_element + 1))); + Value::INTEGER(static_cast(pow(2, idx_of_label)))); auto subset_compare = make_uniq( ExpressionType::COMPARE_EQUAL, std::move(and_expression), diff --git a/test/sql/pattern-matching/inheritance_support.test b/test/sql/pattern-matching/inheritance_support.test index 71cfd52f..6e8ebba5 100644 --- a/test/sql/pattern-matching/inheritance_support.test +++ b/test/sql/pattern-matching/inheritance_support.test @@ -25,13 +25,13 @@ statement ok INSERT INTO Person VALUES (0, 'Daniel'), (1, 'Tavneet'), (2, 'Gabor'), (3, 'Peter'), (4, 'David'); statement ok -INSERT INTO worksAt VALUES (0,1), (0,2), (0,3), (3,0), (1,2), (1,3), (2,3), (4,3); +INSERT INTO worksAt VALUES (0,1), (0,2), (0,3), (1,2), (1,3), (2,3), (3,0), (4,3); statement ok -INSERT INTO University VALUES ('VU', 0, 2), ('UvA', 1, 2); +INSERT INTO University VALUES ('VU', 0, 1), ('UvA', 1, 1); statement ok -INSERT INTO Company VALUES ('EY', 2, 4), ('CWI', 3, 4); +INSERT INTO Company VALUES ('EY', 2, 2), ('CWI', 3, 2); statement ok INSERT INTO Organisation (SELECT * from university union select * from company); @@ -58,10 +58,10 @@ FROM GRAPH_TABLE(pg 0 Daniel 1 UvA 0 Daniel 2 EY 0 Daniel 3 CWI -3 Peter 0 VU 1 Tavneet 2 EY 1 Tavneet 3 CWI 2 Gabor 3 CWI +3 Peter 0 VU 4 David 3 CWI query IIIII @@ -71,39 +71,37 @@ FROM GRAPH_TABLE(pg COLUMNS (p.id, p.name, u.id, u.name, u.mask) ) result ---- -0 Daniel 1 UvA 2 -0 Daniel 2 EY 4 -0 Daniel 3 CWI 4 -3 Peter 0 VU 2 -1 Tavneet 2 EY 4 -1 Tavneet 3 CWI 4 -2 Gabor 3 CWI 4 -4 David 3 CWI 4 - +0 Daniel 1 UvA 1 +0 Daniel 2 EY 2 +0 Daniel 3 CWI 2 +1 Tavneet 2 EY 2 +1 Tavneet 3 CWI 2 +2 Gabor 3 CWI 2 +3 Peter 0 VU 1 +4 David 3 CWI 2 -query IIII --SELECT * -FROM GRAPH_TABLE(pg +query IIIII +-FROM GRAPH_TABLE(pg MATCH (p:Person)-[w:worksAt]->(u:university) COLUMNS (p.id, p.name, u.id, u.name, u.mask) ) result ---- -0 Daniel 1 UvA -3 Peter 0 VU +0 Daniel 1 UvA 1 +3 Peter 0 VU 1 -query IIII +query IIIII -SELECT * FROM GRAPH_TABLE(pg MATCH (p:Person)-[w:worksAt]->(u:company) COLUMNS (p.id, p.name, u.id, u.name, u.mask) ) result ---- -0 Daniel 3 CWI -1 Tavneet 3 CWI -2 Gabor 3 CWI -4 David 3 CWI -0 Daniel 2 EY -1 Tavneet 2 EY +0 Daniel 3 CWI 2 +1 Tavneet 3 CWI 2 +2 Gabor 3 CWI 2 +4 David 3 CWI 2 +0 Daniel 2 EY 2 +1 Tavneet 2 EY 2 # Should work with different capitalization query IIII @@ -130,21 +128,21 @@ FROM GRAPH_TABLE(pg 1 UvA 0 Daniel 2 EY 0 Daniel 3 CWI 0 Daniel -0 VU 3 Peter 2 EY 1 Tavneet 3 CWI 1 Tavneet 3 CWI 2 Gabor +0 VU 3 Peter 3 CWI 4 David query IIII -SELECT * FROM GRAPH_TABLE(pg - MATCH (p:university)<-[w:worksAt]-(u:person) - COLUMNS (p.id, p.name, u.id, u.mask) + MATCH (u:university)<-[w:worksAt]-(p:person) + COLUMNS (p.id, p.name, u.name, u.mask) ) result ---- -1 UvA 0 Daniel -0 VU 3 Peter +0 Daniel UvA 1 +3 Peter VU 1 statement ok -drop property graph pg; diff --git a/test/sql/snb/snb-projected.test b/test/sql/snb/snb-projected.test_slow similarity index 98% rename from test/sql/snb/snb-projected.test rename to test/sql/snb/snb-projected.test_slow index 17a5cb3b..acf402de 100644 --- a/test/sql/snb/snb-projected.test +++ b/test/sql/snb/snb-projected.test_slow @@ -102,3 +102,4 @@ query IIIIIIII COLUMNS(a.firstName, a.lastName, a.birthday, a.locationIP, a.browserUsed, c.id, a.gender, a.creationDate) ) tmp; ---- +Ivan Dobrunov 1988-10-21 31.28.20.134 Firefox 865 female 2010-02-09 17:26:35.413