Skip to content

Commit

Permalink
fix null point error
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Dec 28, 2021
1 parent f2e9304 commit b70d257
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 50 deletions.
4 changes: 2 additions & 2 deletions src/common/expression/PropertyExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ void LabelTagPropertyExpression::accept(ExprVisitor* visitor) {
}

std::string LabelTagPropertyExpression::toString() const {
std::string labelStr = label_->toString();
return labelStr.erase(0, 1) + "." + sym_ + "." + prop_;
std::string labelStr = label_ != nullptr ? label_->toString().erase(0, 1) : "";
return labelStr + "." + sym_ + "." + prop_;
}

bool LabelTagPropertyExpression::operator==(const Expression& rhs) const {
Expand Down
4 changes: 2 additions & 2 deletions src/graph/optimizer/rule/IndexScanRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@ Status IndexScanRule::addFilterItem(RelationalExpression* expr,
QueryContext* qctx) const {
// TODO (sky) : Check illegal filter. for example : where c1 == 1 and c1 == 2
Expression::Kind relType;
if (std::is_same<E, EdgePropertyExpression>::value) {
if constexpr (std::is_same<E, EdgePropertyExpression>::value) {
relType = Expression::Kind::kEdgeProperty;
} else if (std::is_same<E, LabelTagPropertyExpression>::value) {
} else if constexpr (std::is_same<E, LabelTagPropertyExpression>::value) {
relType = Expression::Kind::kLabelTagProperty;
} else {
relType = Expression::Kind::kTagProperty;
Expand Down
10 changes: 6 additions & 4 deletions tests/tck/features/match/Base.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,28 @@ Feature: Basic match
Scenario: Une step
When executing query:
"""
MATCH (v1:player{name: "LeBron James"}) -[r]-> (v2) RETURN type(r) AS Type, v2.team.name AS Name
MATCH (v1:player{name: "LeBron James"}) -[r]-> (v2)
RETURN type(r) AS Type, CASE WHEN v2.team.name IS NOT NULL THEN v2.team.name WHEN v2.player.name IS NOT NULL THEN v2.player.name END AS Name
"""
Then the result should be, in any order:
| Type | Name |
| "like" | NULL |
| "like" | "Ray Allen" |
| "serve" | "Cavaliers" |
| "serve" | "Heat" |
| "serve" | "Lakers" |
| "serve" | "Cavaliers" |
When executing query:
"""
MATCH (v1:player{name: "LeBron James"}) -[r:serve|:like]-> (v2) RETURN type(r) AS Type, v2.team.name AS Name
MATCH (v1:player{name: "LeBron James"}) -[r:serve|:like]-> (v2)
RETURN type(r) AS Type, CASE WHEN v2.team.name IS NOT NULL THEN v2.team.name WHEN v2.player.name IS NOT NULL THEN v2.player.name END AS Name
"""
Then the result should be, in any order:
| Type | Name |
| "serve" | "Cavaliers" |
| "serve" | "Heat" |
| "serve" | "Lakers" |
| "serve" | "Cavaliers" |
| "like" | NULL |
| "like" | "Ray Allen" |
When executing query:
"""
MATCH (v1:player{name: "LeBron James"}) -[r:serve]-> (v2)
Expand Down
13 changes: 8 additions & 5 deletions tests/tck/features/match/Base.feature
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,28 @@ Feature: Basic match
Scenario: One step
When executing query:
"""
MATCH (v1:player{name: "LeBron James"}) -[r]-> (v2) RETURN type(r) AS Type, v2.team.name AS Name
MATCH (v1:player{name: "LeBron James"}) -[r]-> (v2)
RETURN type(r) AS Type, CASE WHEN v2.team.name IS NOT NULL THEN v2.team.name WHEN v2.player.name IS NOT NULL THEN v2.player.name END AS Name
"""
Then the result should be, in any order:
| Type | Name |
| "like" | NULL |
| "like" | "Ray Allen" |
| "serve" | "Cavaliers" |
| "serve" | "Heat" |
| "serve" | "Lakers" |
| "serve" | "Cavaliers" |
When executing query:
"""
MATCH (v1:player{name: "LeBron James"}) -[r:serve|:like]-> (v2) RETURN type(r) AS Type, v2.team.name AS Name
MATCH (v1:player{name: "LeBron James"}) -[r:serve|:like]-> (v2)
RETURN type(r) AS Type, CASE WHEN v2.team.name IS NOT NULL THEN v2.team.name WHEN v2.player.name IS NOT NULL THEN v2.player.name END AS Name
"""
Then the result should be, in any order:
| Type | Name |
| "serve" | "Cavaliers" |
| "serve" | "Heat" |
| "serve" | "Lakers" |
| "serve" | "Cavaliers" |
| "like" | NULL |
| "like" | "Ray Allen" |
When executing query:
"""
MATCH (v1:player{name: "LeBron James"}) -[r:serve]-> (v2)
Expand Down Expand Up @@ -635,7 +637,8 @@ Feature: Basic match
"""
MATCH (v:player{name:"Tim Duncan"}) return v.name
"""
Then a SemanticError should be raised at runtime: To get the property of the vertex in `v.name', should use the format `var.tag.prop' When executing query:
Then a SemanticError should be raised at runtime: To get the property of the vertex in `v.name', should use the format `var.tag.prop'
When executing query:
"""
MATCH (v:player)-[]->(b) WHERE v.age > 30 return v.player.name
"""
Expand Down
8 changes: 4 additions & 4 deletions tests/tck/features/match/MatchById.feature
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ Feature: Match By Id
"""
MATCH (v1) -[r]-> (v2)
WHERE id(v1) == "LeBron James"
RETURN type(r) AS Type, v2.team.name AS Name
RETURN type(r) AS Type, CASE WHEN v2.team.name IS NOT NULL THEN v2.team.name WHEN v2.player.name IS NOT NULL THEN v2.player.name END AS Name
"""
Then the result should be, in any order, with relax comparison:
| Type | Name |
| 'like' | NULL |
| 'like' | "Ray Allen" |
| 'serve' | 'Cavaliers' |
| 'serve' | 'Heat' |
| 'serve' | 'Cavaliers' |
Expand All @@ -110,11 +110,11 @@ Feature: Match By Id
"""
MATCH (v1) -[r:serve|:like]-> (v2)
WHERE id(v1) == "LeBron James"
RETURN type(r) AS Type, v2.team.name AS Name
RETURN type(r) AS Type, CASE WHEN v2.team.name IS NOT NULL THEN v2.team.name WHEN v2.player.name IS NOT NULL THEN v2.player.name END AS Name
"""
Then the result should be, in any order, with relax comparison:
| Type | Name |
| 'like' | NULL |
| 'like' | "Ray Allen" |
| 'serve' | 'Cavaliers' |
| 'serve' | 'Heat' |
| 'serve' | 'Cavaliers' |
Expand Down
16 changes: 0 additions & 16 deletions tests/tck/features/match/SeekById.feature
Original file line number Diff line number Diff line change
Expand Up @@ -253,22 +253,6 @@ Feature: Match seek by id
RETURN v.player.name AS Name
"""
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.
When executing query:

This comment has been minimized.

Copy link
@Shylock-Hg

Shylock-Hg Dec 28, 2021

Contributor

Why delete this?

This comment has been minimized.

Copy link
@nevermore3

nevermore3 Dec 28, 2021

Author Contributor

can select the index by introducing tag, this case can get the result, already move this case to line :153

"""
MATCH (v)
WHERE id(v) IN ['James Harden', 'Jonathon Simmons', 'Klay Thompson', 'Dejounte Murray']
OR v.player.age == 23
RETURN v.player.name AS Name
"""
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.
When executing query:
"""
MATCH (v)
WHERE id(v) == 'James Harden'
OR v.player.age == 23
RETURN v.player.name AS Name
"""
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.
When executing query:
"""
MATCH (v)
Expand Down
16 changes: 0 additions & 16 deletions tests/tck/features/match/SeekById.intVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -253,22 +253,6 @@ Feature: Match seek by id
RETURN v.player.name AS Name
"""
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.
When executing query:

This comment has been minimized.

Copy link
@Shylock-Hg

Shylock-Hg Dec 28, 2021

Contributor

ditto

This comment has been minimized.

Copy link
@nevermore3

nevermore3 Dec 28, 2021

Author Contributor

ditto

"""
MATCH (v)
WHERE id(v) IN [hash('James Harden'), hash('Jonathon Simmons'), hash('Klay Thompson'), hash('Dejounte Murray')]
OR v.player.age == 23
RETURN v.player.name AS Name
"""
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.
When executing query:
"""
MATCH (v)
WHERE id(v) == hash('James Harden')
OR v.player.age == 23
RETURN v.player.name AS Name
"""
Then a ExecutionError should be raised at runtime: Scan vertices or edges need to specify a limit number, or limit number can not push down.
When executing query:
"""
MATCH (v)
Expand Down
1 change: 0 additions & 1 deletion tests/tck/features/optimizer/IndexScanRule.feature
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Feature: Match index selection
| 6 | IndexScan | 0 | {"indexCtx": {"columnHints":{"scanType":"RANGE","column":"age","beginValue":"30","endValue":"40","includeBegin":"false","includeEnd":"true"}}} |
| 0 | Start | | |

@jmq
Scenario: or filter embedding
When profiling query:
"""
Expand Down

0 comments on commit b70d257

Please sign in to comment.