Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doc examples #2471

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/planner/plan/plan_subquery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ void QueryPlanner::planSubqueryIfNecessary(
if (ExpressionVisitor::hasSubquery(*expression)) {
auto expressionCollector = std::make_unique<ExpressionCollector>();
for (auto& expr : expressionCollector->collectTopLevelSubqueryExpressions(expression)) {
if (plan.getSchema()->isExpressionInScope(*expr)) {
continue;
}
planSubquery(expr, plan);
}
}
Expand Down
19 changes: 14 additions & 5 deletions test/test_files/demo_db/demo_db.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@

-CASE DemoDBTest

-LOG CountSubquery
-STATEMENT MATCH (a:User) RETURN a.name, COUNT { MATCH (a)<-[:Follows]-(b:User) } AS num_follower ORDER BY num_follower;
---- 4
Adam|0
Karissa|1
Noura|1
Zhang|2

-LOG Limit1
-STATEMENT MATCH (u:User) RETURN u.name ORDER BY u.age DESC LIMIT 3;
---- 3
Expand Down Expand Up @@ -119,13 +127,14 @@ Noura|{_NODES: [{_ID: 0:2, _LABEL: User, name: Zhang, age: 50}], _RELS: [(0:0)-{
Zhang|{_NODES: [], _RELS: [(0:0)-{_LABEL: Follows, _ID: 2:1, since: 2020}->(0:2)]}
Zhang|{_NODES: [{_ID: 0:1, _LABEL: User, name: Karissa, age: 40}], _RELS: [(0:0)-{_LABEL: Follows, _ID: 2:0, since: 2020}->(0:1),(0:1)-{_LABEL: Follows, _ID: 2:2, since: 2021}->(0:2)]}

-LOG VarLengthFilter
-STATEMENT MATCH p = (a:User)-[:Follows*1..2 (r, _ | WHERE r.since < 2022) ]->(b:User) WHERE a.name = 'Adam' RETURN DISTINCT b.name;
-LOG RecursiveJoinFilter
-STATEMENT MATCH p = (a:User)-[:Follows*1..2 (r, n | WHERE r.since < 2022 AND n.age > 45) ]->(b:User)
WHERE a.name = 'Adam' RETURN DISTINCT b.name, COUNT(*);
---- 2
Karissa
Zhang
Karissa|1
Zhang|1

-LOG VarLengthFilter2
-LOG RecursiveJoinFilter2
-STATEMENT MATCH (a:User)-[e:Follows*1..2 (r, n | WHERE r.since > 2020 | {r.since}, {n.name})]->(b:User)
WHERE a.age > 0
RETURN nodes(e), rels(e);
Expand Down
32 changes: 28 additions & 4 deletions test/test_files/demo_db/demo_db_delete.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,39 @@
-STATEMENT MATCH (u:User) RETURN COUNT(*)
---- 1
5
-STATEMENT MATCH (u:User) WHERE u.name = 'Alice' DELETE u
---- ok
-STATEMENT MATCH (u:User) WHERE u.name = 'Alice' DELETE u RETURN u.*;
---- 1
Alice|35
-STATEMENT MATCH (u:User) RETURN COUNT(*)
---- 1
4

-CASE DeleteRelTest
-STATEMENT MATCH (u:User)-[f:Follows]->(u1:User) WHERE u.name = 'Adam' AND u1.name = 'Karissa' DELETE f
---- ok
-STATEMENT MATCH (u:User)-[f:Follows]->(u1:User) WHERE u.name = 'Adam' AND u1.name = 'Karissa' DELETE f RETURN f.*;
---- 1
2020
-STATEMENT MATCH (u:User)-[f:Follows]->(u1:User) WHERE u.name='Adam' RETURN u1.name
---- 1
Zhang

-CASE DetachDelete
-STATEMENT MATCH ()-[]->() RETURN COUNT(*)
---- 1
8
-STATEMENT MATCH (u:User) WHERE u.name = 'Adam' DETACH DELETE u RETURN u;
---- 1
{_ID: 0:0, _LABEL: User, name: Adam, age: 30}
-STATEMENT MATCH ()-[]->() RETURN COUNT(*)
---- 1
5

-CASE DeleteAllTest
-STATEMENT MATCH (u:User) DETACH DELETE u RETURN u.*;
---- 4
Adam|30
Karissa|40
Noura|25
Zhang|50
-STATEMENT MATCH ()-[]->() RETURN COUNT(*)
---- 1
0
4 changes: 2 additions & 2 deletions test/test_files/exceptions/binder/binder_error.test
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,12 @@ Binder exception: Invalid number of arguments for macro ADD5.
---- error
Binder exception: Invalid number of arguments for macro ADD4.

-CASE CopyToNPYFormat
-LOG CopyToNPYFormat
-STATEMENT COPY (MATCH (a:person) RETURN a) TO 'person.npy';
---- error
Binder exception: COPY TO currently only supports csv and parquet files.

-CASE InvalidArgCast
-LOG InvalidArgCast
-STATEMENT RETURN cast("[sdf, fsd, fad]", "STRING[]", "3rd arg");
---- error
Binder exception: Invalid number of arguments for given function CAST. Expected: 2, Actual: 3.
Expand Down