Skip to content
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
16 changes: 14 additions & 2 deletions src/binder/bind_expression/bind_comparison_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "catalog/catalog.h"
#include "common/exception/binder.h"
#include "function/built_in_function_utils.h"
#include "function/struct/vector_struct_functions.h"
#include "transaction/transaction.h"
#include <format>

Expand Down Expand Up @@ -42,8 +43,19 @@ std::shared_ptr<Expression> ExpressionBinder::bindComparisonExpression(
DASSERT(children.size() == 2);
if (isNodeOrRel(*children[0]) && isNodeOrRel(*children[1])) {
expression_vector newChildren;
newChildren.push_back(children[0]->constCast<NodeOrRelExpression>().getInternalID());
newChildren.push_back(children[1]->constCast<NodeOrRelExpression>().getInternalID());
// For pattern expressions (NODE/REL), use getInternalID() directly
// For non-pattern expressions (VARIABLE, FUNCTION, etc.), extract the _ID field
for (const auto& child : children) {
if (child->expressionType == ExpressionType::PATTERN) {
newChildren.push_back(child->constCast<NodeOrRelExpression>().getInternalID());
} else {
expression_vector extractChildren;
extractChildren.push_back(child);
extractChildren.push_back(createLiteralExpression(InternalKeyword::ID));
newChildren.push_back(
bindScalarFunctionExpression(extractChildren, StructExtractFunctions::name));
}
}
return bindComparisonExpression(expressionType, newChildren);
}

Expand Down
3 changes: 2 additions & 1 deletion src/function/pattern/label_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ std::shared_ptr<Expression> LabelFunction::rewriteFunc(const RewriteFunctionBind
return expressionBinder->createNullLiteralExpression();
}
expression_vector children;
if (argument->expressionType == ExpressionType::VARIABLE) {
// For non-pattern expressions (VARIABLE, FUNCTION, etc.), extract the _LABEL field
if (argument->expressionType != ExpressionType::PATTERN) {
children.push_back(input.arguments[0]);
children.push_back(expressionBinder->createLiteralExpression(InternalKeyword::LABEL));
return expressionBinder->bindScalarFunctionExpression(children,
Expand Down
21 changes: 21 additions & 0 deletions test/test_files/function/comparison.test
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,24 @@ False
-STATEMENT MATCH (a:person), (b:person) WHERE a.fName = "Alice" AND b.fName = "Bob" RETURN ID(a) >= ID(b);
---- 1
False

-LOG EqualityInPatternExpressions
-STATEMENT MATCH p = (n)-[:knows]->(m:person {ID: 2}) WITH nodes(p) AS ns RETURN ns[1] = ns[1];
---- 3
True
True
True

-LOG InequalityInPatternExpressions
-STATEMENT MATCH p = (n)-[:knows]->(m:person {ID: 2}) WITH nodes(p) AS ns RETURN ns[1] <> ns[2];
---- 3
True
True
True

-LOG FalseEqualityInPatternExpressions
-STATEMENT MATCH p = (n)-[:knows]->(m:person {ID: 2}) WITH nodes(p) AS ns RETURN ns[1] = ns[2];
---- 3
False
False
False
6 changes: 6 additions & 0 deletions test/test_files/function/label.test
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ workAt
-STATEMENT RETURN labels(null);
---- 1

-LOG LabelOnPathNodeExtract
-STATEMENT MATCH p = (n)-[:knows]->(m:person {ID: 2}) WITH nodes(p) AS ns RETURN label(ns[1]);
---- 3
person
person
person
Loading