Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add id(a) support to front-end #131

Merged
merged 1 commit into from
May 2, 2021
Merged

Add id(a) support to front-end #131

merged 1 commit into from
May 2, 2021

Conversation

andyfengHKU
Copy link
Contributor

@andyfengHKU andyfengHKU commented Apr 18, 2021

This PR add node id comparison support for front-end and should solve issue #102 and issue #127
Example MATCH (a)->(b) WHERE id(a) = id(b) RETURN *

  • id(a) binds to a logical property expression a._id
  • Change back-end node value vector name from a to a._id
    • Scan(a) -> Scan(a._id)
    • Extend(a to b) -> Extend(a._id to b._id)
    • ScanNodePR(a.name from a) -> ScanNodeProperty(a.name from a._id)
  • Rewrite self loop edge (a)->(a) as (a)->(anonymou) WHERE a._id = anonymous._id

@@ -1,45 +1,36 @@
#pragma once

#include <string>
#include <utility>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this include

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -1,31 +1,30 @@
#pragma once

#include <string>
#include <utility>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

};

const string DataTypeNames[] = {
"REL", "NODE", "LABEL", "BOOL", "INT32", "INT64", "DOUBLE", "STRING", "UNKNOWN"};
"REL", "NODE", "LABEL", "BOOL", "INT32", "INT64", "DOUBLE", "STRING", "NODE_ID", "UNKNOWN"};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"UNSTRUCTURED"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@queryproc queryproc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple PR to understand, just change the terminology used.
Let's add end-to-end tests that use the id() comparison operations as part of this PR.

@@ -15,6 +15,12 @@ class LogicalRelExpression : public LogicalExpression {

inline string getDstNodeName() const { return dstNode->name; }

inline bool isSelfLoopRel() const { return srcNode->name == dstNode->name; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is selfLoop part of adding id() comparison support?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because selfLoop edge is rewrite as a regular edge with an ID equal filter (which is also an ID comparison)

@@ -17,9 +17,9 @@ LogicalExpression::LogicalExpression(
}

LogicalExpression::LogicalExpression(
ExpressionType expressionType, DataType dataType, const string& variableName)
ExpressionType expressionType, DataType dataType, const string& propertyOrFunctionName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only function name allowed here is id()?

if (FUNCTION == expression->expressionType && COUNT_STAR == expression->variableName &&
1 != expressions.size()) {
if (FUNCTION == expression->expressionType &&
FUNCTION_COUNT_STAR == expression->propertyOrFunctionName && 1 != expressions.size()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flip the !=
expressions.size() != 1 reads better.

@@ -299,18 +307,18 @@ void Enumerator::appendNecessaryScans(shared_ptr<LogicalExpression> expression,
void Enumerator::appendScanNodeProperty(
const string& nodeName, const string& propertyName, LogicalPlan& plan) {
auto queryNode = mergedQueryGraph->getQueryNode(nodeName);
auto scanProperty = make_shared<LogicalScanNodeProperty>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use queryNode->name for consistency.

label_t boundNodeVarLabel;
string nbrNodeVarName;
label_t nbrNodeVarLabel;
string boundNodeIDPropertyName;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boundAttributeName where attribute is ID or property works. (otherwise add or in the name).

If you use the term attribute then use it everywhere where you refer to NodeIDPropertyname.

This terminology is used in existing scan and read operators. We have a ScanAttribute operator shared by ScanNodeID, ScanStructuredProperty, and ScanUnstructuredProperty. So you won't be introducing the term attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants