Skip to content

Commit

Permalink
rewrite attribute expresion to labeltagprop for unwind.
Browse files Browse the repository at this point in the history
  • Loading branch information
xtcyclist committed Dec 14, 2022
1 parent 9097f5f commit 4220333
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
13 changes: 2 additions & 11 deletions src/common/expression/AttributeExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,8 @@ const Value &AttributeExpression::eval(ExpressionContext &ctx) {
case Value::Type::MAP:
return lvalue.getMap().at(rvalue.getStr());
case Value::Type::VERTEX: {
if (rvalue.getStr() == kVid) {
result_ = lvalue.getVertex().vid;
return result_;
}
for (auto &tag : lvalue.getVertex().tags) {
auto iter = tag.props.find(rvalue.getStr());
if (iter != tag.props.end()) {
return iter->second;
}
}
return Value::kNullValue;
LOG(ERROR) << "Var.tar.prop cannot be evaluated as an attribute expression.";
return Value::kNullBadType;
}
case Value::Type::EDGE: {
DCHECK(!rvalue.getStr().empty());
Expand Down
6 changes: 0 additions & 6 deletions src/graph/executor/query/UnwindExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ folly::Future<Status> UnwindExecutor::execute() {
ds.colNames = unwind->colNames();
for (; iter->valid(); iter->next()) {
const Value &list = unwindExpr->eval(ctx(iter.get()));
if (!list.isList()) {
std::stringstream ss;
ss << "Unwind on types other than list for " << unwindExpr->toString()
<< ". This is not supported.";
return Status::Error(ss.str());
}
std::vector<Value> vals = extractList(list);
for (auto &v : vals) {
Row row;
Expand Down
3 changes: 2 additions & 1 deletion src/graph/validator/MatchValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,8 @@ Status MatchValidator::validateUnwind(const UnwindClause *unwindClause,
return Status::SemanticError("Expression in UNWIND must be aliased (use AS)");
}
unwindCtx.alias = unwindClause->alias();
unwindCtx.unwindExpr = unwindClause->expr()->clone();
unwindCtx.unwindExpr = ExpressionUtils::rewriteAttr2LabelTagProp(unwindClause->expr()->clone(),
unwindCtx.aliasesAvailable);
if (ExpressionUtils::hasAny(unwindCtx.unwindExpr, {Expression::Kind::kAggregate})) {
return Status::SemanticError("Can't use aggregating expressions in unwind clause, `%s'",
unwindCtx.unwindExpr->toString().c_str());
Expand Down

0 comments on commit 4220333

Please sign in to comment.