Skip to content

Commit

Permalink
delete labeltagpropertyexpression file
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Dec 3, 2021
1 parent 26e04d3 commit 0b13e85
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 199 deletions.
1 change: 0 additions & 1 deletion src/common/expression/ExprVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "common/expression/FunctionCallExpression.h"
#include "common/expression/LabelAttributeExpression.h"
#include "common/expression/LabelExpression.h"
#include "common/expression/LabelTagPropertyExpression.h"
#include "common/expression/ListComprehensionExpression.h"
#include "common/expression/LogicalExpression.h"
#include "common/expression/PathBuildExpression.h"
Expand Down
1 change: 0 additions & 1 deletion src/common/expression/Expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "common/expression/FunctionCallExpression.h"
#include "common/expression/LabelAttributeExpression.h"
#include "common/expression/LabelExpression.h"
#include "common/expression/LabelTagPropertyExpression.h"
#include "common/expression/ListComprehensionExpression.h"
#include "common/expression/LogicalExpression.h"
#include "common/expression/PathBuildExpression.h"
Expand Down
55 changes: 0 additions & 55 deletions src/common/expression/LabelTagPropertyExpression.cpp

This file was deleted.

65 changes: 0 additions & 65 deletions src/common/expression/LabelTagPropertyExpression.h

This file was deleted.

12 changes: 6 additions & 6 deletions src/graph/planner/match/LabelIndexSeek.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ StatusOr<SubPlan> LabelIndexSeek::transformNode(NodeContext* nodeCtx) {
const auto& nodeAlias = nodeCtx->info->alias;

if (filter->kind() == Expression::Kind::kLogicalOr) {
auto labelExprs = ExpressionUtils::collectAll(filter, {Expression::Kind::kLabel});
auto exprs = ExpressionUtils::collectAll(filter, {Expression::Kind::kLabelTagProperty});
bool labelMatched = true;
for (auto* labelExpr : labelExprs) {
DCHECK_EQ(labelExpr->kind(), Expression::Kind::kLabel);
if (static_cast<const LabelExpression*>(labelExpr)->name() != nodeAlias) {
for (auto* expr : exprs) {
auto tagPropExpr = static_cast<const LabelTagPropertyExpression*>(expr);
if (static_cast<const PropertyExpression*>(tagPropExpr->label())->prop() != nodeAlias) {
labelMatched = false;
break;
}
Expand All @@ -117,9 +117,9 @@ StatusOr<SubPlan> LabelIndexSeek::transformNode(NodeContext* nodeCtx) {
}
}
if (canBeEmbedded2IndexScan) {
auto* srcFilter = ExpressionUtils::rewriteAttr2LabelTagProp(flattenFilter);
// auto* srcFilter = ExpressionUtils::rewriteAttr2LabelTagProp(flattenFilter);
storage::cpp2::IndexQueryContext ctx;
ctx.set_filter(Expression::encode(*srcFilter));
ctx.set_filter(Expression::encode(*flattenFilter));
scan->setIndexQueryContext({ctx});
whereCtx.reset();
}
Expand Down
23 changes: 9 additions & 14 deletions src/graph/planner/match/MatchSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ Expression* MatchSolver::doRewrite(QueryContext* qctx,
auto alias = aliases.find(labelExpr->name());
DCHECK(alias != aliases.end());
}
auto res = ExpressionUtils::rewriteAttr2LabelTagProp(expr);
return rewriteLabel2VarProp(qctx, res);
return rewriteLabel2VarProp(qctx, expr);
}

Expression* MatchSolver::makeIndexFilter(const std::string& label,
Expand Down Expand Up @@ -162,27 +161,23 @@ Expression* MatchSolver::makeIndexFilter(const std::string& label,
}
propName = la->right()->value().getStr();
} else {
const AttributeExpression* la = nullptr;
if (left->kind() == Expression::Kind::kAttribute &&
const LabelTagPropertyExpression* la = nullptr;
if (left->kind() == Expression::Kind::kLabelTagProperty &&
right->kind() == Expression::Kind::kConstant) {
la = static_cast<const AttributeExpression*>(left);
la = static_cast<const LabelTagPropertyExpression*>(left);
constant = static_cast<const ConstantExpression*>(right);
} else if (right->kind() == Expression::Kind::kAttribute &&
} else if (right->kind() == Expression::Kind::kLabelTagProperty &&
left->kind() == Expression::Kind::kConstant) {
la = static_cast<const AttributeExpression*>(right);
la = static_cast<const LabelTagPropertyExpression*>(right);
constant = static_cast<const ConstantExpression*>(left);
} else {
continue;
}
if (la->left()->kind() != Expression::Kind::kLabelAttribute) {
if (static_cast<const PropertyExpression*>(la->label())->prop() != alias ||
la->sym() != label) {
continue;
}
auto labelAttExpr = static_cast<const LabelAttributeExpression*>(la->left());
if (labelAttExpr->left()->name() != alias ||
labelAttExpr->right()->value().getStr() != label) {
continue;
}
propName = static_cast<const ConstantExpression*>(la->right())->value().getStr();
propName = la->prop();
}

auto* tpExpr =
Expand Down
31 changes: 9 additions & 22 deletions src/graph/validator/MatchValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ Status MatchValidator::validateFilter(const Expression *filter,
auto transformRes = ExpressionUtils::filterTransform(filter);
NG_RETURN_IF_ERROR(transformRes);
// rewrite Attribute to LabelTagProperty
whereClauseCtx.filter = transformRes.value();
whereClauseCtx.filter = ExpressionUtils::rewriteAttr2LabelTagProp(transformRes.value());

auto typeStatus = deduceExprType(whereClauseCtx.filter);
NG_RETURN_IF_ERROR(typeStatus);
Expand Down Expand Up @@ -364,7 +364,7 @@ Status MatchValidator::validateReturn(MatchReturn *ret,
ExpressionUtils::hasAny(column->expr(), {Expression::Kind::kAggregate})) {
retClauseCtx.yield->hasAgg_ = true;
}
// column->setExpr(ExpressionUtils::rewriteAttr2LabelTagProp(column->expr()));
column->setExpr(ExpressionUtils::rewriteAttr2LabelTagProp(column->expr()));
exprs.push_back(column->expr());
columns->addColumn(column->clone().release());
}
Expand Down Expand Up @@ -397,7 +397,6 @@ Status MatchValidator::validateAliases(
static const std::unordered_set<Expression::Kind> kinds = {Expression::Kind::kLabel,
Expression::Kind::kLabelAttribute,
Expression::Kind::kLabelTagProperty,
Expression::Kind::kAttribute,
// primitive props
Expression::Kind::kEdgeSrc,
Expression::Kind::kEdgeDst,
Expand Down Expand Up @@ -795,25 +794,13 @@ Status MatchValidator::checkAlias(
NG_RETURN_IF_ERROR(res);
return Status::OK();
}
// case Expression::Kind::kLabelTagProperty: {
// auto labelExpr = static_cast<const LabelTagPropertyExpression *>(refExpr)->label();
// auto name = static_cast<const VariablePropertyExpression *>(labelExpr)->prop();
// auto res = getAliasType(aliasesUsed, name);
// NG_RETURN_IF_ERROR(res);
// if (res.value() != AliasType::kNode) {
// return Status::SemanticError("The type of `%s' must be tag", name.c_str());
// }
// return Status::OK();
// }
case Expression::Kind::kAttribute: {
auto leftExpr = static_cast<const AttributeExpression *>(refExpr)->left();
if (leftExpr->kind() == Expression::Kind::kLabelAttribute) {
auto name = static_cast<const LabelAttributeExpression *>(leftExpr)->left()->name();
auto res = getAliasType(aliasesUsed, name);
NG_RETURN_IF_ERROR(res);
if (res.value() != AliasType::kNode) {
return Status::SemanticError("The type of `%s' should be tag", name.c_str());
}
case Expression::Kind::kLabelTagProperty: {
auto labelExpr = static_cast<const LabelTagPropertyExpression *>(refExpr)->label();
auto name = static_cast<const VariablePropertyExpression *>(labelExpr)->prop();
auto res = getAliasType(aliasesUsed, name);
NG_RETURN_IF_ERROR(res);
if (res.value() != AliasType::kNode) {
return Status::SemanticError("The type of `%s' should be tag", name.c_str());
}
return Status::OK();
}
Expand Down
8 changes: 6 additions & 2 deletions tests/tck/features/expression/Attribute.feature
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,13 @@ Feature: Attribute
"""
MATCH (v) WHERE id(v) == 'Tim Duncan' RETURN v.name.not_exists_attr
"""
Then a ExecutionError should be raised at runtime: TagName `name' is nonexistent
Then the result should be, in any order:
| v.name.not_exists_attr |
| NULL |
When executing query:
"""
MATCH (v) WHERE id(v) == 'Tim Duncan' RETURN v.player.name.test
"""
Then a SemanticError should be raised at runtime: `v.player.name.ab', expected type with attribute like Date, Time, DateTime, Map, Vertex or Edge but was STRING: v.player.name
Then the result should be, in any order:
| v.player.name.test |
| BAD_TYPE |
6 changes: 4 additions & 2 deletions tests/tck/features/match/SameTagPropname.feature
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,12 @@ Feature: Same Tag Propname
"""
match (v:player) where v.student.height > 190 return v
"""
Then a SemanticError should be raised at runtime: `v.student.height', not found the property `height'
Then the result should be, in any order:
| v |
When executing query:
"""
match (v:player) where v.abc.height > 190 return v.player.name
"""
Then a ExecutionError should be raised at runtime: TagName `abc' is nonexistent
Then the result should be, in any order:
| v.player.name |
Then drop the used space
39 changes: 23 additions & 16 deletions tests/tck/features/match/SeekById.feature
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,29 @@ Feature: Match seek by id
Then the result should be, in any order:
| Name |
| 'James Harden' |
When executing query:
"""
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 the result should be, in any order:
| Name |
| 'James Harden' |
| 'Jonathon Simmons' |
| 'Klay Thompson' |
| 'Dejounte Murray' |
When executing query:
"""
MATCH (v)
WHERE id(v) == 'James Harden'
OR v.player.age == 23
RETURN v.player.name AS Name
"""
Then the result should be, in any order:
| Name |
| 'James Harden' |

Scenario: complicate logical
When executing query:
Expand Down Expand Up @@ -230,22 +253,6 @@ Feature: Match seek by id
RETURN v.player.name AS Name
"""
Then a SemanticError should be raised at runtime:
When executing query:
"""
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 SemanticError should be raised at runtime:
When executing query:
"""
MATCH (v)
WHERE id(v) == 'James Harden'
OR v.player.age == 23
RETURN v.player.name AS Name
"""
Then a SemanticError should be raised at runtime:
When executing query:
"""
MATCH (v)
Expand Down
Loading

0 comments on commit 0b13e85

Please sign in to comment.