Skip to content
Snippets Groups Projects
Unverified Commit c3eedb7c authored by Yichen Wang's avatar Yichen Wang Committed by GitHub
Browse files

fix yield running constrain (#481)


* fix yield running constrain

* add test cases for yield without chosen space

* add more cases for yield with no space chosen

* fix bug caused by int vid PR

* fix

Co-authored-by: default avatarYee <2520865+yixinglu@users.noreply.github.com>
parent 491df426
No related branches found
No related tags found
No related merge requests found
......@@ -18,9 +18,15 @@ namespace nebula {
namespace graph {
YieldValidator::YieldValidator(Sentence *sentence, QueryContext *qctx)
: Validator(sentence, qctx) {}
: Validator(sentence, qctx) {
setNoSpaceRequired();
}
Status YieldValidator::validateImpl() {
if (qctx_->vctx()->spaceChosen()) {
space_ = vctx_->whichSpace();
}
auto yield = static_cast<YieldSentence *>(sentence_);
NG_RETURN_IF_ERROR(validateYieldAndBuildOutputs(yield->yield()));
NG_RETURN_IF_ERROR(validateWhere(yield->where()));
......
......@@ -101,8 +101,13 @@ DeduceTypeVisitor::DeduceTypeVisitor(QueryContext *qctx,
: qctx_(qctx), vctx_(vctx), inputs_(inputs), space_(space) {
DCHECK(qctx != nullptr);
DCHECK(vctx != nullptr);
auto vidType = vctx_->whichSpace().spaceDesc.vid_type.get_type();
vidType_ = SchemaUtil::propTypeToValueType(vidType);
// stand alone YIELD queries can be run without a space
if (!vctx->spaceChosen()) {
vidType_ = Value::Type::__EMPTY__;
} else {
auto vidType = vctx_->whichSpace().spaceDesc.vid_type.get_type();
vidType_ = SchemaUtil::propTypeToValueType(vidType);
}
}
void DeduceTypeVisitor::visit(ConstantExpression *expr) {
......
Feature: Yield
Background:
Given an empty graph
Scenario: base
When executing query:
"""
YIELD 1+1 AS sum
"""
Then the result should be, in any order:
| sum |
| 2 |
When executing query:
"""
YIELD 1+1, '1+1', (int)3.14, (string)(1+1), (string)true
"""
Then the result should be, in any order:
| (1+1) | 1+1 | (INT)3.14 | (STRING)(1+1) | (STRING)true |
| 2 | "1+1" | 3 | "2" | "true" |
Scenario: hash call
When executing query:
"""
YIELD hash("Boris")
"""
Then the result should be, in any order:
| hash(Boris) |
| 9126854228122744212 |
When executing query:
"""
YIELD hash(123)
"""
Then the result should be, in any order:
| hash(123) |
| 123 |
Scenario: logical
When executing query:
"""
YIELD NOT FALSE OR FALSE AND FALSE XOR FALSE
"""
Then the result should be, in any order:
| ((!(false) OR (false AND false)) XOR false) |
| true |
Scenario: tagProp
When executing query:
"""
YIELD $$.dummyTag.p
"""
Then a ExecutionError should be raised at runtime: TagName `dummyTag' is nonexistent
When executing query:
"""
YIELD $^.dummyTag.p
"""
Then a ExecutionError should be raised at runtime: TagName `dummyTag' is nonexistent
When executing query:
"""
YIELD $-.dummyTag.p
"""
Then a SemanticError should be raised at runtime: Not supported expression `$-.dummyTag.p' for props deduction.
Scenario: label expr
When executing query:
"""
YIELD name
"""
Then a SemanticError should be raised at runtime: Invalid label identifiers: name
Scenario: with go from
When executing query:
"""
GO FROM "Boris Diaw" OVER serve
YIELD $^.player.name as name, serve.start_year as start, $$.team.name as team;
"""
Then a SemanticError should be raised at runtime: Space was not chosen.
# Copyright (c) 2020 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License,
# attached with Common Clause Condition 1.0, found in the LICENSES directory.
Feature: Yield
@skip
Scenario: yield without chosen space
Given an empty graph
When executing query:
"""
YIELD 1+1 AS sum
"""
Then the result should be, in any order:
| sum |
| 2 |
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment