Skip to content

Commit

Permalink
fix issue TuGraph-family#473
Browse files Browse the repository at this point in the history
  • Loading branch information
kehuang19 authored and tugraph committed Nov 9, 2023
1 parent 85dc4ce commit 4f9f3e9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/cypher/arithmetic/arithmetic_expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ struct ArithOperandNode {
if (type == AR_OPERAND_CONSTANT) {
return Entry(constant);
} else if (type == AR_OPERAND_VARIADIC) {
CYPHER_THROW_ASSERT(record.values.size() > (size_t)variadic.alias_idx);
const auto &entry = record.values[variadic.alias_idx];
switch (entry.type) {
case Entry::NODE:
Expand Down
8 changes: 7 additions & 1 deletion src/cypher/execution_plan/ops/op_project.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ class Project : public OpBase {
const auto &return_body = stmt->return_clause ? std::get<1>(*stmt->return_clause)
: std::get<1>(*stmt->with_clause);
const auto &return_items = std::get<0>(return_body);
std::unordered_set<std::string> distinct_alias;
for (auto &item : return_items) {
auto &expr = std::get<0>(item);
auto &var = std::get<1>(item);
ArithExprNode ae(expr, sym_tab_);
return_elements_.emplace_back(ae);
return_alias_.emplace_back(var.empty() ? expr.ToString(false) : var);
auto alias = var.empty() ? expr.ToString(false) : var;
if (distinct_alias.find(alias) != distinct_alias.end()) {
throw lgraph::CypherException("Duplicate alias: " + alias);
}
distinct_alias.emplace(alias);
return_alias_.emplace_back(alias);
if (!var.empty()) modifies.emplace_back(var);
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/test_cypher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2209,6 +2209,9 @@ int test_fix_crash_issues(cypher::RTContext *ctx) {
expected_exception_any(ctx, "MATCH p=(n)-[e]->(m) RETURN p LIMIT 5");
ctx->graph_ = graph;
// issue #312 & #464 end
// issue #473
expected_exception_any(ctx, "MATCH (movie)<-[r]-(n) WITH n,n MATCH (n1) RETURN n1 LIMIT 1");
expected_exception_any(ctx, "MATCH (movie)<-[r]-(n) return n,n limit 1");
return 0;
}

Expand Down

0 comments on commit 4f9f3e9

Please sign in to comment.