Skip to content
Snippets Groups Projects
Unverified Commit 0617afe7 authored by jie.wang's avatar jie.wang Committed by GitHub
Browse files

Fix yield $-.prop (#305)


* fix yield input pipe'prop

* add test

* update test

* wrap into func

* fix yield constant bug

* wrap into isAllPropsEmpty()

Co-authored-by: default avatarYee <2520865+yixinglu@users.noreply.github.com>
parent 1286e441
No related branches found
No related tags found
No related merge requests found
......@@ -774,8 +774,7 @@ Status GoValidator::buildColumns() {
}
auto pool = qctx_->objPool();
if (!exprProps_.srcTagProps().empty() || !exprProps_.edgeProps().empty() ||
!exprProps_.dstTagProps().empty()) {
if (!exprProps_.isAllPropsEmpty() || from_.fromType != FromType::kInstantExpr) {
srcAndEdgePropCols_ = pool->add(new YieldColumns());
}
......
......@@ -59,6 +59,12 @@ public:
return !srcTagProps_.empty() || !dstTagProps_.empty();
}
bool isAllPropsEmpty() const {
return inputProps_.empty() && varProps_.empty() &&
srcTagProps_.empty() && edgeProps_.empty() &&
dstTagProps_.empty();
}
void insertInputProp(folly::StringPiece prop);
void insertVarProp(const std::string& outputVar, folly::StringPiece prop);
void insertSrcTagProp(TagID tagId, folly::StringPiece prop);
......
......@@ -202,6 +202,38 @@ class TestGoQuery(NebulaTestSuite):
self.check_column_names(resp, expected_data["column_names"])
self.check_out_of_order_result(resp, expected_data["rows"])
def test_pipe_only_yield_input_prop(self):
stmt = '''GO FROM "Tracy McGrady" OVER like YIELD like._dst as vid \
| GO FROM $-.vid OVER like YIELD $-.vid as id'''
resp = self.execute_query(stmt)
self.check_resp_succeeded(resp)
expected_data = {
"column_names" : ["id"],
"rows" : [
["Kobe Bryant"],
["Grant Hill"],
["Rudy Gay"]
]
}
self.check_column_names(resp, expected_data["column_names"])
self.check_out_of_order_result(resp, expected_data["rows"])
def test_pipe_only_yield_constant(self):
stmt = '''GO FROM "Tracy McGrady" OVER like YIELD like._dst as vid \
| GO FROM $-.vid OVER like YIELD 3'''
resp = self.execute_query(stmt)
self.check_resp_succeeded(resp)
expected_data = {
"column_names" : ["3"],
"rows" : [
[3],
[3],
[3]
]
}
self.check_column_names(resp, expected_data["column_names"])
self.check_out_of_order_result(resp, expected_data["rows"])
def test_assignment_empty_result(self):
stmt = '''$var = GO FROM "-1" OVER like YIELD like._dst as id; \
GO FROM $var.id OVER like'''
......
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