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

support cypher parameter #2798

Closed
wants to merge 2 commits into from
Closed

Conversation

czpmango
Copy link
Contributor

@czpmango czpmango commented Sep 7, 2021

@czpmango czpmango added the type/enhancement Type: make the code neat or more efficient label Sep 7, 2021
@czpmango czpmango self-assigned this Sep 7, 2021
@czpmango czpmango added the ready-for-testing PR: ready for the CI test label Sep 7, 2021
src/common/expression/ParameterExpression.h Outdated Show resolved Hide resolved
src/interface/graph.thrift Outdated Show resolved Hide resolved
src/graph/service/RequestContext.h Outdated Show resolved Hide resolved
src/graph/service/RequestContext.h Outdated Show resolved Hide resolved
src/graph/context/QueryContext.cpp Show resolved Hide resolved
src/graph/context/QueryContext.h Outdated Show resolved Hide resolved
@czpmango czpmango force-pushed the new-param branch 2 times, most recently from 508a41a to d656073 Compare September 9, 2021 09:45
@czpmango czpmango force-pushed the new-param branch 3 times, most recently from 78b4919 to fab02c1 Compare September 23, 2021 02:20
Copy link
Contributor

@yixinglu yixinglu left a comment

Choose a reason for hiding this comment

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

Does this PR not take into account the implementation of parameter binding after the execution plan has been optimized?

src/graph/service/GraphService.cpp Show resolved Hide resolved
src/graph/service/GraphService.cpp Outdated Show resolved Hide resolved
tests/Makefile Outdated Show resolved Hide resolved
src/common/expression/ParameterExpression.cpp Show resolved Hide resolved
tests/tck/features/yield/parameter.feature Show resolved Hide resolved
@czpmango czpmango added the wip Solution: work in progress label Sep 23, 2021
@Sophie-Xie Sophie-Xie added this to the v2.6.0 milestone Sep 27, 2021
@czpmango czpmango force-pushed the new-param branch 2 times, most recently from c8dbfc8 to d8cc949 Compare September 28, 2021 09:04
@czpmango czpmango removed the wip Solution: work in progress label Sep 28, 2021
@codecov-commenter
Copy link

codecov-commenter commented Sep 28, 2021

Codecov Report

Merging #2798 (5497494) into master (3c7d00e) will decrease coverage by 0.08%.
The diff coverage is 87.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2798      +/-   ##
==========================================
- Coverage   84.42%   84.34%   -0.09%     
==========================================
  Files        1284     1286       +2     
  Lines      113589   113765     +176     
==========================================
+ Hits        95899    95951      +52     
- Misses      17690    17814     +124     
Impacted Files Coverage Δ
src/common/expression/ExprVisitor.h 100.00% <ø> (ø)
src/common/expression/Expression.h 100.00% <ø> (ø)
...c/common/expression/test/ExpressionContextMock.cpp 100.00% <ø> (ø)
src/common/expression/test/TestBase.h 85.84% <ø> (ø)
src/graph/service/GraphService.h 100.00% <ø> (ø)
src/graph/visitor/DeduceTypeVisitor.h 100.00% <ø> (ø)
src/graph/visitor/ExtractFilterExprVisitor.cpp 69.38% <0.00%> (-2.96%) ⬇️
src/graph/visitor/ExtractFilterExprVisitor.h 100.00% <ø> (ø)
src/graph/visitor/ExtractPropExprVisitor.h 100.00% <ø> (ø)
src/graph/visitor/FindVisitor.h 100.00% <ø> (ø)
... and 86 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c7d00e...5497494. Read the comment docs.

@czpmango
Copy link
Contributor Author

Does this PR not take into account the implementation of parameter binding after the execution plan has been optimized?

Parameter push-down is currently not supported.
refer #2593 for more detail.

src/graph/service/GraphService.cpp Outdated Show resolved Hide resolved
src/graph/service/GraphService.cpp Outdated Show resolved Hide resolved
When executing query:
"""
$p1=GO FROM "Tim Duncan" OVER like WHERE like.likeness>$p1 yield like._dst as dst;
GO FROM $p1.dst OVER like YIELD DISTINCT $$.player.name AS name
Copy link
Contributor

Choose a reason for hiding this comment

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

 $p1=GO FROM "Tim Duncan" OVER like WHERE like.likeness>$p1 yield like._dst as dst;
 GO FROM $p1.dst OVER like Where like.age > $p1 YIELD DISTINCT $$.player.name AS name.

What is the behavior of this test case?
We need more test cases.

Copy link
Contributor Author

@czpmango czpmango Sep 29, 2021

Choose a reason for hiding this comment

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

$p1 started as a parameter and was rewritten as a variable, just consistent with what we talked about earlier.

Such as what test cases?

Copy link
Contributor

Choose a reason for hiding this comment

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

Where did you do the rewriting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Expression rewriting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The implementation layer is the same as VariableExpression, it is based on valueMap_, so there is no need to do rewriting. valueMap_ is automatically written to at runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

 $p1=GO FROM "Tim Duncan" OVER like WHERE like.likeness>$p1 yield like._dst as dst;
 GO FROM $p1.dst OVER like Where like.age > $p1 YIELD DISTINCT $$.player.name AS name.

What is the behavior of this test case? We need more test cases.

Variables and parameters with the same name are not supported for the time being, just consistent with our offline discussion.

// The ParameterExpression use for parameterized statement
namespace nebula {

class ParameterExpression : public Expression {
Copy link
Contributor

Choose a reason for hiding this comment

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

I doubt if we need this one.

Copy link
Contributor Author

@czpmango czpmango Sep 29, 2021

Choose a reason for hiding this comment

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

Is needed.
Such as lookupValidators or some visitor or scenes that require expression rewriting.

Some Example :

  • rewrite ParameterExpression to ConstantExpression
  • EvaluableExprVisitor determines whether expressions are evaluable by their specific types. Code likes that:
void visit(VariableExpression *) override { isEvaluable_ = false; }
  • If ParameterExpression and VariableExpression are unified, then we must use if-else whenever we need to distinguish them, I don't think this is a good code design pattern.

jievince
jievince previously approved these changes Sep 29, 2021
Copy link
Contributor

@jievince jievince left a comment

Choose a reason for hiding this comment

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

LGTM now

@@ -224,7 +224,7 @@ Feature: Go Yield Vertex And Edge Sentence
"""
GO FROM $var OVER like YIELD edge as e
"""
Then a SyntaxError should be raised at runtime: syntax error near `OVER'
Then a SyntaxError should be raised at runtime: can not go from a nonexist parameter near `FROM'
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens to this test case? Why do you need modify it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Go from parameter.

src/graph/context/QueryContext.h Outdated Show resolved Hide resolved
src/graph/validator/Validator.cpp Outdated Show resolved Hide resolved
tests/tck/features/yield/parameter.feature Show resolved Hide resolved
src/parser/parser.yy Show resolved Hide resolved
@@ -2003,6 +2021,27 @@ fetch_vertices_sentence
| KW_FETCH KW_PROP KW_ON STAR vid_ref_expression yield_clause {
$$ = new FetchVerticesSentence($5, $6);
}
| KW_FETCH KW_PROP KW_ON name_label_list VARIABLE yield_clause {
Copy link
Contributor

Choose a reason for hiding this comment

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

extend vid_ref_expression to check whether VARIABLE is parameter

Copy link
Contributor

Choose a reason for hiding this comment

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

vid_ref_ex}r_wrapper:
| vid_ref_expression {
if () {
throw exception("illegal variable")
}
return $$
|

@Sophie-Xie Sophie-Xie removed this from the v2.6.0 milestone Oct 8, 2021
@Sophie-Xie Sophie-Xie added this to the v2.7.0 milestone Oct 9, 2021
@czpmango czpmango force-pushed the new-param branch 6 times, most recently from f3b717d to 86116aa Compare October 12, 2021 11:05
@Sophie-Xie Sophie-Xie modified the milestones: v2.7.0, v3.0.0 Oct 15, 2021
fix aysn block

revert nebula-python url

disable homonymic parameter variable

support sdk interface of map/list

support go from parameter

support list and map

fix tck

support fetch

small fix for point initialization

fix tck

add tck

support subgraph

support find path

add tck
@Sophie-Xie Sophie-Xie added the doc affected PR: improvements or additions to documentation label Nov 12, 2021
@czpmango czpmango closed this Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc affected PR: improvements or additions to documentation ready-for-testing PR: ready for the CI test type/enhancement Type: make the code neat or more efficient
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants