diff --git a/src/context/Iterator.cpp b/src/context/Iterator.cpp index 523c27edc23f93f7404ddde84c36ff4d5a9faeee..a9ed83304c68df6eba3818f04e95d4b4ba3f3552 100644 --- a/src/context/Iterator.cpp +++ b/src/context/Iterator.cpp @@ -265,7 +265,7 @@ Value GetNeighborsIter::getVertex() const { return Value::kNullBadType; } Vertex vertex; - vertex.vid = vidVal.getStr(); + vertex.vid = vidVal; auto& tagPropMap = dsIndices_[segment].tagPropsMap; for (auto& tagProp : tagPropMap) { auto& row = *(iter_->row_); @@ -304,17 +304,17 @@ Value GetNeighborsIter::getEdge() const { } edge.type = type.getInt(); - auto& src = getColumn(kVid); - if (!SchemaUtil::isValidVid(src)) { + auto& srcVal = getColumn(kVid); + if (!SchemaUtil::isValidVid(srcVal)) { return Value::kNullBadType; } - edge.src = src.getStr(); + edge.src = srcVal; - auto& dst = getEdgeProp(edgeName, kDst); - if (!SchemaUtil::isValidVid(dst)) { + auto& dstVal = getEdgeProp(edgeName, kDst); + if (!SchemaUtil::isValidVid(dstVal)) { return Value::kNullBadType; } - edge.dst = dst.getStr(); + edge.dst = dstVal; auto& rank = getEdgeProp(edgeName, kRank); if (!rank.isInt()) { @@ -530,7 +530,7 @@ Value PropIter::getVertex() const { return Value::kNullValue; } Vertex vertex; - vertex.vid = vidVal.getStr(); + vertex.vid = vidVal; auto& tagPropsMap = dsIndex_.propsMap; bool isVertexProps = true; auto& row = *(iter_->row_); @@ -585,17 +585,17 @@ Value PropIter::getEdge() const { } edge.type = type.getInt(); - auto& src = getEdgeProp(edgeName, kSrc); - if (!SchemaUtil::isValidVid(src)) { + auto& srcVal = getEdgeProp(edgeName, kSrc); + if (!SchemaUtil::isValidVid(srcVal)) { return Value::kNullBadType; } - edge.src = src.getStr(); + edge.src = srcVal; - auto& dst = getEdgeProp(edgeName, kDst); - if (!SchemaUtil::isValidVid(dst)) { + auto& dstVal = getEdgeProp(edgeName, kDst); + if (!SchemaUtil::isValidVid(dstVal)) { return Value::kNullBadType; } - edge.dst = dst.getStr(); + edge.dst = dstVal; auto rank = getEdgeProp(edgeName, kRank); if (!rank.isInt()) { diff --git a/src/executor/algo/ConjunctPathExecutor.cpp b/src/executor/algo/ConjunctPathExecutor.cpp index 58510280aa7d558d63c79dc4fc1b8d4c2cc81b99..b24f4e3e04345bf2d1c9f97726a10ccaad772c9f 100644 --- a/src/executor/algo/ConjunctPathExecutor.cpp +++ b/src/executor/algo/ConjunctPathExecutor.cpp @@ -125,7 +125,7 @@ std::multimap<Value, Path> ConjunctPathExecutor::buildBfsInterimPath( for (auto& v : meets) { VLOG(1) << "Meet at: " << v; Path start; - start.src = Vertex(v.getStr(), {}); + start.src = Vertex(v, {}); if (hists.empty()) { // Happens at one step path situation when meet at starts VLOG(1) << "Start: " << start; diff --git a/src/executor/query/DataCollectExecutor.cpp b/src/executor/query/DataCollectExecutor.cpp index 86e29077d13de9817a8bae9a3ae2ec59e54fdef5..637a880d10d384495ff7a8f79f5bb9437e20d8de 100644 --- a/src/executor/query/DataCollectExecutor.cpp +++ b/src/executor/query/DataCollectExecutor.cpp @@ -61,44 +61,41 @@ Status DataCollectExecutor::collectSubgraph(const std::vector<std::string>& vars DataSet ds; ds.colNames = std::move(colNames_); // the subgraph not need duplicate vertices or edges, so dedup here directly - std::unordered_set<std::string> vids; - std::unordered_set<std::tuple<std::string, std::string, int64_t, std::string>> edgeKeys; + std::unordered_set<Value> uniqueVids; + std::unordered_set<std::tuple<Value, std::string, int64_t, Value>> uniqueEdges; for (auto& var : vars) { auto& hist = ectx_->getHistory(var); for (auto& result : hist) { auto iter = result.iter(); - if (iter->isGetNeighborsIter()) { - List vertices; - List edges; - auto* gnIter = static_cast<GetNeighborsIter*>(iter.get()); - auto originVertices = gnIter->getVertices(); - for (auto& v : originVertices.values) { - if (!v.isVertex()) { - continue; - } - if (vids.emplace(v.getVertex().vid).second) { - vertices.emplace_back(std::move(v)); - } - } - auto originEdges = gnIter->getEdges(); - for (auto& e : originEdges.values) { - if (!e.isEdge()) { - continue; - } - auto edgeKey = std::make_tuple(e.getEdge().src, - e.getEdge().name, - e.getEdge().ranking, - e.getEdge().dst); - if (edgeKeys.emplace(std::move(edgeKey)).second) { - edges.emplace_back(std::move(e)); - } - } - ds.rows.emplace_back(Row({std::move(vertices), std::move(edges)})); - } else { + if (!iter->isGetNeighborsIter()) { std::stringstream msg; msg << "Iterator should be kind of GetNeighborIter, but was: " << iter->kind(); return Status::Error(msg.str()); } + List vertices; + List edges; + auto* gnIter = static_cast<GetNeighborsIter*>(iter.get()); + auto originVertices = gnIter->getVertices(); + for (auto& v : originVertices.values) { + if (!v.isVertex()) { + continue; + } + if (uniqueVids.emplace(v.getVertex().vid).second) { + vertices.emplace_back(std::move(v)); + } + } + auto originEdges = gnIter->getEdges(); + for (auto& e : originEdges.values) { + if (!e.isEdge()) { + continue; + } + auto edgeKey = std::make_tuple( + e.getEdge().src, e.getEdge().name, e.getEdge().ranking, e.getEdge().dst); + if (uniqueEdges.emplace(std::move(edgeKey)).second) { + edges.emplace_back(std::move(e)); + } + } + ds.rows.emplace_back(Row({std::move(vertices), std::move(edges)})); } } result_.setDataSet(std::move(ds)); @@ -143,7 +140,7 @@ Status DataCollectExecutor::collectMToN(const std::vector<std::string>& vars, auto* seqIter = static_cast<SequentialIter*>(iter.get()); for (; seqIter->valid(); seqIter->next()) { if (distinct && !unique.emplace(seqIter->row()).second) { - continue; + continue; } ds.rows.emplace_back(seqIter->moveRow()); } diff --git a/src/executor/test/DataCollectTest.cpp b/src/executor/test/DataCollectTest.cpp index 79915532b934a21b46fe07b0cb2ab43eefc32433..a80dbbdc1b55b74afe08672ef5839042e69f9eb6 100644 --- a/src/executor/test/DataCollectTest.cpp +++ b/src/executor/test/DataCollectTest.cpp @@ -144,8 +144,8 @@ TEST_F(DataCollectTest, CollectSubgraph) { auto iter = input.iter(); auto* gNIter = static_cast<GetNeighborsIter*>(iter.get()); Row row; - std::unordered_set<std::string> vids; - std::unordered_set<std::tuple<std::string, int64_t, int64_t, std::string>> edgeKeys; + std::unordered_set<Value> vids; + std::unordered_set<std::tuple<Value, int64_t, int64_t, Value>> edgeKeys; List vertices; List edges; auto originVertices = gNIter->getVertices(); diff --git a/src/parser/Clauses.cpp b/src/parser/Clauses.cpp index f0619df092e34e25657c1396c7749b9469490897..9044188c9fb64fc92f2895bb17660d8713bce2ec 100644 --- a/src/parser/Clauses.cpp +++ b/src/parser/Clauses.cpp @@ -25,19 +25,6 @@ std::string StepClause::toString() const { } -std::string SourceNodeList::toString() const { - std::string buf; - buf.reserve(256); - for (auto id : nodes_) { - buf += std::to_string(id); - buf += ","; - } - if (!buf.empty()) { - buf.resize(buf.size() - 1); - } - return buf; -} - std::string VertexIDList::toString() const { std::string buf; buf.reserve(256); diff --git a/src/parser/Clauses.h b/src/parser/Clauses.h index c4a47f2d7e96af2ece61a75a4ceaf69ed9ff8bc3..f20b7fb88f9c1744948b9c8c9bf366e9d9e03efa 100644 --- a/src/parser/Clauses.h +++ b/src/parser/Clauses.h @@ -48,23 +48,6 @@ private: }; -class SourceNodeList final { -public: - void addNodeId(int64_t id) { - nodes_.emplace_back(id); - } - - const std::vector<int64_t>& nodeIds() const { - return nodes_; - } - - std::string toString() const; - -private: - std::vector<int64_t> nodes_; -}; - - class VertexIDList final { public: void add(Expression *expr) { diff --git a/src/parser/parser.yy b/src/parser/parser.yy index a0edacb568caf97efc176e68791993b35cc18723..ad6982d423bf0eed69faab9ed6032903c6e5d25f 100644 --- a/src/parser/parser.yy +++ b/src/parser/parser.yy @@ -988,7 +988,10 @@ vid_list ; vid - : function_call_expression { + : unary_integer { + $$ = new ConstantExpression($1); + } + | function_call_expression { $$ = $1; } | uuid_expression { @@ -998,9 +1001,6 @@ vid $$ = new ConstantExpression(*$1); delete $1; } - | legal_integer { - $$ = new ConstantExpression($1); - } ; unary_integer diff --git a/src/planner/Mutate.cpp b/src/planner/Mutate.cpp index e47a1ea86c43932ea74e10f7b79ce4bf5b751874..f944e1fe51244f9dcc9647b2cb0849f3b0232c83 100644 --- a/src/planner/Mutate.cpp +++ b/src/planner/Mutate.cpp @@ -52,15 +52,15 @@ std::unique_ptr<PlanNodeDescription> Update::explain() const { std::unique_ptr<PlanNodeDescription> UpdateVertex::explain() const { auto desc = Update::explain(); - addDescription("vid", folly::to<std::string>(vId_), desc.get()); + addDescription("vid", vId_.toString(), desc.get()); addDescription("tagId", folly::to<std::string>(tagId_), desc.get()); return desc; } std::unique_ptr<PlanNodeDescription> UpdateEdge::explain() const { auto desc = Update::explain(); - addDescription("srcId", srcId_, desc.get()); - addDescription("dstId", dstId_, desc.get()); + addDescription("srcId", srcId_.toString(), desc.get()); + addDescription("dstId", dstId_.toString(), desc.get()); addDescription("rank", folly::to<std::string>(rank_), desc.get()); addDescription("edgeType", folly::to<std::string>(edgeType_), desc.get()); return desc; diff --git a/src/planner/Mutate.h b/src/planner/Mutate.h index 9b6cc85022779640b1c374876ad90b310cfd8bb9..5cf1decc735951b3addd47fb798c3fff72224d3c 100644 --- a/src/planner/Mutate.h +++ b/src/planner/Mutate.h @@ -193,7 +193,7 @@ public: PlanNode* input, GraphSpaceID spaceId, std::string name, - std::string vId, + Value vId, TagID tagId, bool insertable, std::vector<storage::cpp2::UpdatedProp> updatedProps, @@ -215,7 +215,7 @@ public: std::unique_ptr<PlanNodeDescription> explain() const override; - const std::string& getVId() const { + const Value& getVId() const { return vId_; } @@ -228,7 +228,7 @@ private: PlanNode* input, GraphSpaceID spaceId, std::string name, - std::string vId, + Value vId, TagID tagId, bool insertable, std::vector<storage::cpp2::UpdatedProp> updatedProps, @@ -249,7 +249,7 @@ private: tagId_(tagId) {} private: - std::string vId_; + Value vId_; TagID tagId_{-1}; }; @@ -259,8 +259,8 @@ public: PlanNode* input, GraphSpaceID spaceId, std::string name, - std::string srcId, - std::string dstId, + Value srcId, + Value dstId, EdgeType edgeType, int64_t rank, bool insertable, @@ -285,11 +285,11 @@ public: std::unique_ptr<PlanNodeDescription> explain() const override; - const std::string& getSrcId() const { + const Value& getSrcId() const { return srcId_; } - const std::string& getDstId() const { + const Value& getDstId() const { return dstId_; } @@ -310,8 +310,8 @@ private: PlanNode* input, GraphSpaceID spaceId, std::string name, - std::string srcId, - std::string dstId, + Value srcId, + Value dstId, EdgeType edgeType, int64_t rank, bool insertable, @@ -335,8 +335,8 @@ private: edgeType_(edgeType) {} private: - std::string srcId_; - std::string dstId_; + Value srcId_; + Value dstId_; int64_t rank_{0}; EdgeType edgeType_{-1}; }; diff --git a/src/util/SchemaUtil.cpp b/src/util/SchemaUtil.cpp index 30bd6f169eaff686b2f8b1b94307b3d1862a7334..d0acdb95c41a4d2fabe05c3b2151c157d29f67fe 100644 --- a/src/util/SchemaUtil.cpp +++ b/src/util/SchemaUtil.cpp @@ -159,14 +159,14 @@ Status SchemaUtil::setTTLCol(SchemaPropItem* schemaProp, meta::cpp2::Schema& sch } // static -StatusOr<VertexID> SchemaUtil::toVertexID(Expression *expr) { +StatusOr<Value> SchemaUtil::toVertexID(Expression *expr, Value::Type vidType) { QueryExpressionContext ctx; - auto vertexId = expr->eval(ctx(nullptr)); - if (vertexId.type() != Value::Type::STRING) { - LOG(ERROR) << "Wrong vertex id type"; - return Status::Error("Wrong vertex id type"); + auto vidVal = expr->eval(ctx(nullptr)); + if (vidVal.type() != vidType) { + LOG(ERROR) << expr->toString() << " is the wrong vertex id type: " << vidVal.typeName(); + return Status::Error("Wrong vertex id type: %s", expr->toString().c_str()); } - return vertexId.getStr(); + return vidVal; } // static @@ -178,8 +178,8 @@ SchemaUtil::toValueVec(std::vector<Expression*> exprs) { for (auto *expr : exprs) { auto value = expr->eval(ctx(nullptr)); if (value.isNull() && value.getNull() != NullType::__NULL__) { - LOG(ERROR) << "Wrong value type: " << value.type();; - return Status::Error("Wrong value type"); + LOG(ERROR) << expr->toString() << " is the wrong value type: " << value.typeName(); + return Status::Error("Wrong value type: %s", expr->toString().c_str()); } values.emplace_back(std::move(value)); } diff --git a/src/util/SchemaUtil.h b/src/util/SchemaUtil.h index 0bace3833725383a15f4bbe45cbffcd4607cfd84..94ded6571c45bf44d2c954144729e541de870be9 100644 --- a/src/util/SchemaUtil.h +++ b/src/util/SchemaUtil.h @@ -37,7 +37,7 @@ public: static Status setTTLCol(SchemaPropItem* schemaProp, meta::cpp2::Schema& schema); - static StatusOr<VertexID> toVertexID(Expression *expr); + static StatusOr<Value> toVertexID(Expression *expr, Value::Type vidType); static StatusOr<std::vector<Value>> toValueVec(std::vector<Expression*> exprs); diff --git a/src/validator/FetchEdgesValidator.cpp b/src/validator/FetchEdgesValidator.cpp index 8776d1ed0ddf3ebddf764c52048191f4aa305dc9..28a397d77edf7ffc7b14261901baf8bd27930466 100644 --- a/src/validator/FetchEdgesValidator.cpp +++ b/src/validator/FetchEdgesValidator.cpp @@ -99,7 +99,7 @@ Status FetchEdgesValidator::prepareEdges() { // from ref, eval in execute if (sentence->isRef()) { srcRef_ = sentence->ref()->srcid(); - auto result = checkRef(srcRef_, Value::Type::STRING); + auto result = checkRef(srcRef_, vidType_); NG_RETURN_IF_ERROR(result); inputVar_ = std::move(result).value(); rankRef_ = sentence->ref()->rank(); @@ -112,7 +112,7 @@ Status FetchEdgesValidator::prepareEdges() { } } dstRef_ = sentence->ref()->dstid(); - result = checkRef(dstRef_, Value::Type::STRING); + result = checkRef(dstRef_, vidType_); NG_RETURN_IF_ERROR(result); if (inputVar_ != result.value()) { return Status::SemanticError("Can't refer to different variable as key at same time."); @@ -130,17 +130,20 @@ Status FetchEdgesValidator::prepareEdges() { for (const auto &key : keys) { DCHECK(ExpressionUtils::isConstExpr(key->srcid())); auto src = key->srcid()->eval(dummy); - if (!SchemaUtil::isValidVid(src, space_.spaceDesc.vid_type)) { - return Status::NotSupported("src is not a vertex id"); + if (src.type() != vidType_) { + std::stringstream ss; + ss << "the src should be type of " << vidType_ << ", but was`" << src.type() << "'"; + return Status::SemanticError(ss.str()); } auto ranking = key->rank(); DCHECK(ExpressionUtils::isConstExpr(key->dstid())); auto dst = key->dstid()->eval(dummy); - if (!SchemaUtil::isValidVid(dst, space_.spaceDesc.vid_type)) { - return Status::NotSupported("dst is not a vertex id"); + if (dst.type() != vidType_) { + std::stringstream ss; + ss << "the dst should be type of " << vidType_ << ", but was`" << dst.type() << "'"; + return Status::SemanticError(ss.str()); } - edgeKeys_.emplace_back(nebula::Row( - {std::move(src).getStr(), ranking, std::move(dst).getStr()})); + edgeKeys_.emplace_back(nebula::Row({std::move(src), ranking, std::move(dst)})); } } return Status::OK(); @@ -238,11 +241,11 @@ Status FetchEdgesValidator::preparePropertiesWithoutYield() { // insert the reserved properties be compatible with 1.0 propNames.emplace_back(kSrc); colNames_.emplace_back(edgeTypeName_ + "." + kSrc); - outputs_.emplace_back(colNames_.back(), Value::Type::STRING); + outputs_.emplace_back(colNames_.back(), vidType_); geColNames_.emplace_back(colNames_.back()); propNames.emplace_back(kDst); colNames_.emplace_back(edgeTypeName_ + "." + kDst); - outputs_.emplace_back(colNames_.back(), Value::Type::STRING); + outputs_.emplace_back(colNames_.back(), vidType_); geColNames_.emplace_back(colNames_.back()); propNames.emplace_back(kRank); colNames_.emplace_back(edgeTypeName_ + "." + kRank); diff --git a/src/validator/FetchVerticesValidator.cpp b/src/validator/FetchVerticesValidator.cpp index 38f96764706a3a41ac2c58d1de985cc21e459e3b..6f7d4c4096c81d7cf871bd159c7966b42d182c37 100644 --- a/src/validator/FetchVerticesValidator.cpp +++ b/src/validator/FetchVerticesValidator.cpp @@ -101,7 +101,7 @@ Status FetchVerticesValidator::prepareVertices() { // from ref, eval when execute if (sentence->isRef()) { srcRef_ = sentence->ref(); - auto result = checkRef(srcRef_, Value::Type::STRING); + auto result = checkRef(srcRef_, vidType_); NG_RETURN_IF_ERROR(result); inputVar_ = std::move(result).value(); return Status::OK(); @@ -115,10 +115,13 @@ Status FetchVerticesValidator::prepareVertices() { for (const auto vid : vids) { DCHECK(ExpressionUtils::isConstExpr(vid)); auto v = vid->eval(dummy); - if (!SchemaUtil::isValidVid(v, space_.spaceDesc.vid_type)) { - return Status::NotSupported("Not a vertex id"); + if (v.type() != vidType_) { + std::stringstream ss; + ss << "`" << vid->toString() << "', the vid should be type of " << vidType_ + << ", but was`" << v.type() << "'"; + return Status::SemanticError(ss.str()); } - srcVids_.emplace_back(nebula::Row({std::move(v).getStr()})); + srcVids_.emplace_back(nebula::Row({std::move(v)})); } return Status::OK(); } @@ -142,7 +145,7 @@ Status FetchVerticesValidator::preparePropertiesWithYield(const YieldClause *yie outputs_.reserve(yieldSize + 1); colNames_.emplace_back(VertexID); gvColNames_.emplace_back(colNames_.back()); - outputs_.emplace_back(VertexID, Value::Type::STRING); // kVid + outputs_.emplace_back(VertexID, vidType_); // kVid dedup_ = yield->isDistinct(); ExpressionProps exprProps; @@ -220,7 +223,7 @@ Status FetchVerticesValidator::preparePropertiesWithYield(const YieldClause *yie Status FetchVerticesValidator::preparePropertiesWithoutYield() { // empty for all tag and properties props_.clear(); - outputs_.emplace_back(VertexID, Value::Type::STRING); + outputs_.emplace_back(VertexID, vidType_); colNames_.emplace_back(VertexID); gvColNames_.emplace_back(colNames_.back()); for (const auto &tagSchema : tagsSchema_) { diff --git a/src/validator/GoValidator.cpp b/src/validator/GoValidator.cpp index ae6ecc96caebb730b213c3b2ba24c942e8fde2ad..6f241a8906cf097213ff13f70710e73f4f16ea96 100644 --- a/src/validator/GoValidator.cpp +++ b/src/validator/GoValidator.cpp @@ -91,7 +91,7 @@ Status GoValidator::validateYield(YieldClause* yield) { newCols->addColumn(col); auto colName = deduceColName(col); colNames_.emplace_back(colName); - outputs_.emplace_back(colName, Value::Type::STRING); + outputs_.emplace_back(colName, vidType_); NG_RETURN_IF_ERROR(deduceProps(col->expr(), exprProps_)); } @@ -115,7 +115,7 @@ Status GoValidator::validateYield(YieldClause* yield) { } auto colName = deduceColName(col); colNames_.emplace_back(colName); - + // check input var expression auto typeStatus = deduceExprType(col->expr()); NG_RETURN_IF_ERROR(typeStatus); auto type = typeStatus.value(); @@ -142,14 +142,13 @@ Status GoValidator::toPlan() { tail_ = passThrough; root_ = tail_; return Status::OK(); - } else if (steps_.steps == 1) { + } + if (steps_.steps == 1) { return buildOneStepPlan(); - } else { - return buildNStepsPlan(); } - } else { - return buildMToNPlan(); + return buildNStepsPlan(); } + return buildMToNPlan(); } Status GoValidator::oneStep(PlanNode* dependencyForGn, @@ -802,8 +801,7 @@ Status GoValidator::buildColumns() { ? nullptr : new std::string(*(yield->alias())); if (rewriteCol != nullptr) { - newYieldCols_->addColumn( - new YieldColumn(rewriteCol.release(), alias)); + newYieldCols_->addColumn(new YieldColumn(rewriteCol.release(), alias)); } else { newYieldCols_->addColumn(new YieldColumn(newCol.release(), alias)); } diff --git a/src/validator/LookupValidator.cpp b/src/validator/LookupValidator.cpp index 19e1f865b40569f519f3eea17e0e7500fe580851..6bb036383da2bdb0a767cb8a14bc909484a5403b 100644 --- a/src/validator/LookupValidator.cpp +++ b/src/validator/LookupValidator.cpp @@ -172,7 +172,7 @@ Status LookupValidator::prepareFilter() { if (needTextSearch(filter)) { NG_RETURN_IF_ERROR(checkTSService()); if (!textSearchReady_) { - return Status::Error("Text search service not ready"); + return Status::SemanticError("Text search service not ready"); } auto retFilter = rewriteTSFilter(filter); if (!retFilter.ok()) { @@ -198,7 +198,7 @@ StatusOr<std::string> LookupValidator::rewriteTSFilter(Expression* expr) { auto tsExpr = static_cast<TextSearchExpression*>(expr); auto vRet = textSearch(tsExpr); if (!vRet.ok()) { - return Status::Error("Text search error."); + return Status::SemanticError("Text search error."); } if (vRet.value().empty()) { isEmptyResultSet_ = true; @@ -270,18 +270,18 @@ StatusOr<std::vector<std::string>> LookupValidator::textSearch(TextSearchExpress break; } default: - return Status::Error("text search expression error"); + return Status::SemanticError("text search expression error"); } if (!ret.ok()) { continue; - } else if (ret.value()) { + } + if (ret.value()) { return result; - } else { - return Status::Error("External index error. " - "please check the status of fulltext cluster"); } + return Status::SemanticError("External index error. " + "please check the status of fulltext cluster"); } - return Status::Error("scan external index failed"); + return Status::SemanticError("scan external index failed"); } bool LookupValidator::needTextSearch(Expression* expr) { @@ -405,7 +405,7 @@ Status LookupValidator::checkTSService() { return tcs.status(); } if (tcs.value().empty()) { - return Status::Error("No full text client found"); + return Status::SemanticError("No full text client found"); } textSearchReady_ = true; for (const auto& c : tcs.value()) { @@ -428,11 +428,11 @@ Status LookupValidator::checkTSIndex() { ret = nebula::plugin::ESGraphAdapter::kAdapter->indexExists(randomFTClient(), ftIndex); if (!ret.ok()) { continue; - } else if (ret.value()) { + } + if (ret.value()) { return Status::OK(); - } else { - return Status::Error("fulltext index not found : %s", ftIndex.c_str()); } + return Status::SemanticError("fulltext index not found : %s", ftIndex.c_str()); } return ret.status(); } diff --git a/src/validator/MutateValidator.cpp b/src/validator/MutateValidator.cpp index 713e4e8b6ba3103431dad88c9d2085b27184dac5..e0911096fd20248dc1274a9eb9d79dbade70c61f 100644 --- a/src/validator/MutateValidator.cpp +++ b/src/validator/MutateValidator.cpp @@ -98,7 +98,7 @@ Status InsertVerticesValidator::prepareVertices() { return Status::SemanticError("Wrong vid expression `%s'", row->id()->toString().c_str()); } - auto idStatus = SchemaUtil::toVertexID(row->id()); + auto idStatus = SchemaUtil::toVertexID(row->id(), vidType_); NG_RETURN_IF_ERROR(idStatus); auto vertexId = std::move(idStatus).value(); @@ -188,7 +188,7 @@ Status InsertEdgesValidator::check() { return Status::OK(); } -Status InsertEdgesValidator::prepareEdges() {; +Status InsertEdgesValidator::prepareEdges() { edges_.reserve(rows_.size()*2); for (auto i = 0u; i < rows_.size(); i++) { auto *row = rows_[i]; @@ -207,10 +207,10 @@ Status InsertEdgesValidator::prepareEdges() {; row->dstid()->toString().c_str()); } - auto idStatus = SchemaUtil::toVertexID(row->srcid()); + auto idStatus = SchemaUtil::toVertexID(row->srcid(), vidType_); NG_RETURN_IF_ERROR(idStatus); auto srcId = std::move(idStatus).value(); - idStatus = SchemaUtil::toVertexID(row->dstid()); + idStatus = SchemaUtil::toVertexID(row->dstid(), vidType_); NG_RETURN_IF_ERROR(idStatus); auto dstId = std::move(idStatus).value(); @@ -273,7 +273,7 @@ Status DeleteVerticesValidator::validateImpl() { } else { auto vIds = sentence->vidList()->vidList(); for (auto vId : vIds) { - auto idStatus = SchemaUtil::toVertexID(vId); + auto idStatus = SchemaUtil::toVertexID(vId, vidType_); NG_RETURN_IF_ERROR(idStatus); vertices_.emplace_back(std::move(idStatus).value()); } @@ -405,9 +405,9 @@ Status DeleteEdgesValidator::buildEdgeKeyRef(const std::vector<EdgeKey*> &edgeKe for (auto &edgeKey : edgeKeys) { Row row; storage::cpp2::EdgeKey key; - auto srcIdStatus = SchemaUtil::toVertexID(edgeKey->srcid()); + auto srcIdStatus = SchemaUtil::toVertexID(edgeKey->srcid(), vidType_); NG_RETURN_IF_ERROR(srcIdStatus); - auto dstIdStatus = SchemaUtil::toVertexID(edgeKey->dstid()); + auto dstIdStatus = SchemaUtil::toVertexID(edgeKey->dstid(), vidType_); NG_RETURN_IF_ERROR(dstIdStatus); auto srcId = std::move(srcIdStatus).value(); @@ -603,7 +603,7 @@ std::unique_ptr<Expression> UpdateValidator::rewriteSymExpr(Expression *expr, Status UpdateVertexValidator::validateImpl() { auto sentence = static_cast<UpdateVertexSentence*>(sentence_); - auto idRet = SchemaUtil::toVertexID(sentence->getVid()); + auto idRet = SchemaUtil::toVertexID(sentence->getVid(), vidType_); if (!idRet.ok()) { LOG(ERROR) << idRet.status(); return idRet.status(); @@ -638,13 +638,13 @@ Status UpdateVertexValidator::toPlan() { Status UpdateEdgeValidator::validateImpl() { auto sentence = static_cast<UpdateEdgeSentence*>(sentence_); - auto srcIdRet = SchemaUtil::toVertexID(sentence->getSrcId()); + auto srcIdRet = SchemaUtil::toVertexID(sentence->getSrcId(), vidType_); if (!srcIdRet.ok()) { LOG(ERROR) << srcIdRet.status(); return srcIdRet.status(); } srcId_ = std::move(srcIdRet).value(); - auto dstIdRet = SchemaUtil::toVertexID(sentence->getDstId()); + auto dstIdRet = SchemaUtil::toVertexID(sentence->getDstId(), vidType_); if (!dstIdRet.ok()) { LOG(ERROR) << dstIdRet.status(); return dstIdRet.status(); diff --git a/src/validator/MutateValidator.h b/src/validator/MutateValidator.h index 9cf915deb813511c22b4e8ac8c8d99507bdf190a..82929ca5b39c1648ed194159651903a41f27bf91 100644 --- a/src/validator/MutateValidator.h +++ b/src/validator/MutateValidator.h @@ -82,7 +82,7 @@ private: private: GraphSpaceID spaceId_{-1}; // From ConstantExpression - std::vector<VertexID> vertices_; + std::vector<Value> vertices_; // From InputPropertyExpression or InputPropertyExpression Expression* vidRef_{nullptr}; std::vector<EdgeType> edgeTypes_; @@ -168,7 +168,7 @@ private: Status toPlan() override; private: - std::string vId_; + Value vId_; TagID tagId_{-1}; }; @@ -184,8 +184,8 @@ private: Status toPlan() override; private: - std::string srcId_; - std::string dstId_; + Value srcId_; + Value dstId_; EdgeRanking rank_{0}; EdgeType edgeType_{-1}; }; diff --git a/src/validator/Validator.cpp b/src/validator/Validator.cpp index 6976f1be1cf28fdf6ddba42a3daf12e2a7c6c927..40fa2bc97b7e105f40433a182f1348f53357b53e 100644 --- a/src/validator/Validator.cpp +++ b/src/validator/Validator.cpp @@ -306,6 +306,9 @@ Status Validator::validate() { VLOG(1) << "Space chosen, name: " << space_.spaceDesc.space_name << " id: " << space_.id; } + auto vidType = space_.spaceDesc.vid_type.get_type(); + vidType_ = SchemaUtil::propTypeToValueType(vidType); + NG_RETURN_IF_ERROR(validateImpl()); // Check for duplicate reference column names in pipe or var statement diff --git a/src/validator/Validator.h b/src/validator/Validator.h index 1a815aaf60fdda777d5a2f2a88a19910c9a23562..c14a759cabb5b8dadef3a40c2d49ba153a122032 100644 --- a/src/validator/Validator.h +++ b/src/validator/Validator.h @@ -156,6 +156,8 @@ protected: ExpressionProps exprProps_; // user define Variable name list std::set<std::string> userDefinedVarNameList_; + // vid's Type + Value::Type vidType_; }; } // namespace graph diff --git a/src/visitor/DeduceTypeVisitor.cpp b/src/visitor/DeduceTypeVisitor.cpp index 4c3f407f7f2688c5a2c05fe4098d1118b2e987fd..55de8a64a6a18d5915eb159c7149806edef8f053 100644 --- a/src/visitor/DeduceTypeVisitor.cpp +++ b/src/visitor/DeduceTypeVisitor.cpp @@ -101,6 +101,8 @@ 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); } void DeduceTypeVisitor::visit(ConstantExpression *expr) { @@ -372,7 +374,12 @@ void DeduceTypeVisitor::visit(FunctionCallExpression *expr) { if (!ok()) return; argsTypeList.push_back(type_); } - auto result = FunctionManager::getReturnType(*expr->name(), argsTypeList); + auto funName = *expr->name(); + if (funName == "id" || funName == "src" || funName == "dst") { + type_ = vidType_; + return; + } + auto result = FunctionManager::getReturnType(funName, argsTypeList); if (!result.ok()) { status_ = Status::SemanticError("`%s` is not a valid expression : %s", expr->toString().c_str(), @@ -476,7 +483,7 @@ void DeduceTypeVisitor::visit(SourcePropertyExpression *expr) { } void DeduceTypeVisitor::visit(EdgeSrcIdExpression *) { - type_ = Value::Type::STRING; + type_ = vidType_; } void DeduceTypeVisitor::visit(EdgeTypeExpression *) { @@ -488,7 +495,7 @@ void DeduceTypeVisitor::visit(EdgeRankExpression *) { } void DeduceTypeVisitor::visit(EdgeDstIdExpression *) { - type_ = Value::Type::STRING; + type_ = vidType_; } void DeduceTypeVisitor::visit(VertexExpression *) { diff --git a/src/visitor/DeduceTypeVisitor.h b/src/visitor/DeduceTypeVisitor.h index a92ddd5e6bf09d0783b43743e6ec401f4354d01a..bf47c059b6fdbd2bdeb43b5ba5f1500f52206770 100644 --- a/src/visitor/DeduceTypeVisitor.h +++ b/src/visitor/DeduceTypeVisitor.h @@ -97,6 +97,7 @@ private: GraphSpaceID space_; Status status_; Value::Type type_; + Value::Type vidType_; }; } // namespace graph diff --git a/tests/common/comparator.py b/tests/common/comparator.py index fcb994a26782fc9e1213912d3b7efd647a1bec98..b86b0214c7f31d4c5f925f9fd69d208d3913fc75 100644 --- a/tests/common/comparator.py +++ b/tests/common/comparator.py @@ -232,7 +232,7 @@ class DataSetComparator: def bstr(self, vid) -> bytes: return self.b(vid) if type(vid) == str else vid - def compare_vid( + def _compare_vid( self, lid: Union[int, bytes], rid: Union[int, bytes, str], @@ -247,6 +247,19 @@ class DataSetComparator: return lid == self._vid_fn(rid) return False + def compare_vid(self, lid: Value, rid: Value) -> bool: + if lid.getType() == Value.IVAL: + if rid.getType() == Value.IVAL: + return self._compare_vid(lid.get_iVal(), rid.get_iVal()) + if rid.getType() == Value.SVAL: + return self._compare_vid(lid.get_iVal(), rid.get_sVal()) + return False + if lid.getType() == Value.SVAL: + if rid.getType() == Value.SVAL: + return self._compare_vid(lid.get_sVal(), rid.get_sVal()) + return False + return False + def compare_node(self, lhs: Vertex, rhs: Vertex): rtags = [] if self._strict: diff --git a/tests/common/utils.py b/tests/common/utils.py index 39c3bbd55f68c9091f3020dba4d9cb0b5bf5d842..fb218bb521aca9d13948dc24b4b079dc62f48a31 100644 --- a/tests/common/utils.py +++ b/tests/common/utils.py @@ -225,7 +225,7 @@ def edge_to_string(edge): def vertex_to_string(vertex): - vid = vertex.vid.decode('utf-8') + vid = vertex.vid.get_sVal().decode('utf-8') tags = list_to_string(vertex.tags) return f'({vid} {tags})' diff --git a/tests/conftest.py b/tests/conftest.py index 4a12e7b005084324445bbca919d596a34dd6724e..b73e4b86934d00cd107cd37b5733fdea1518cb79 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -194,20 +194,20 @@ def load_nba_data(conn_pool, pytestconfig, tmp_path_factory, worker_id): ) -# @pytest.fixture(scope="session") -# def load_nba_int_vid_data( -# conn_pool, -# pytestconfig, -# tmp_path_factory, -# worker_id, -# ): -# yield from load_csv_data_once( -# tmp_path_factory, -# pytestconfig, -# worker_id, -# conn_pool, -# "nba_int_vid", -# ) +@pytest.fixture(scope="session") +def load_nba_int_vid_data( + conn_pool, + pytestconfig, + tmp_path_factory, + worker_id, +): + yield from load_csv_data_once( + tmp_path_factory, + pytestconfig, + worker_id, + conn_pool, + "nba_int_vid", + ) @pytest.fixture(scope="session") diff --git a/tests/query/v1/test_set.py b/tests/query/v1/test_set.py deleted file mode 100644 index 79863b42d6f58ef8d0d493b1c507fce3a430d73a..0000000000000000000000000000000000000000 --- a/tests/query/v1/test_set.py +++ /dev/null @@ -1,332 +0,0 @@ -# --coding:utf-8-- -# -# 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. - -from nebula2.graph import ttypes - -from tests.common.nebula_test_suite import NebulaTestSuite - - -class TestSetQuery(NebulaTestSuite): - @classmethod - def prepare(self): - self.use_nba() - - def test_union_all(self): - stmt = '''GO FROM "Tim Duncan" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ - UNION ALL GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$^.player.name", "serve.start_year", "$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Tim Duncan", 1997, "Spurs"], - ["Tony Parker", 1999, "Spurs"], - ["Tony Parker", 2018, "Hornets"]] - self.check_out_of_order_result(resp, expected_data) - - stmt = '''GO FROM "Tim Duncan" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ - UNION ALL GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ - UNION ALL GO FROM "Manu Ginobili" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - colums = ["$^.player.name", "serve.start_year", "$$.team.name"] - self.check_column_names(resp, colums) - expected_data = [["Tim Duncan", 1997, "Spurs"], - ["Tony Parker", 1999, "Spurs"], - ["Tony Parker", 2018, "Hornets"], - ["Manu Ginobili", 2002, "Spurs"]] - self.check_out_of_order_result(resp, expected_data) - - stmt = '''(GO FROM "Tim Duncan" OVER like YIELD like._dst AS id | \ - GO FROM $-.id OVER serve YIELD $^.player.name, serve.start_year, $$.team.name) \ - UNION ALL GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$^.player.name", "serve.start_year", "$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Manu Ginobili", 2002, "Spurs"], - ["Tony Parker", 1999, "Spurs"], - ["Tony Parker", 2018, "Hornets"], - ["Tony Parker", 1999, "Spurs"], - ["Tony Parker", 2018, "Hornets"]] - self.check_out_of_order_result(resp, expected_data) - - stmt = '''GO FROM "Tim Duncan" OVER like YIELD like._dst AS id | \ - GO FROM $-.id OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ - UNION ALL GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$^.player.name", "serve.start_year", "$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Manu Ginobili", 2002, "Spurs"], - ["Tony Parker", 1999, "Spurs"], - ["Tony Parker", 2018, "Hornets"], - ["Tony Parker", 1999, "Spurs"], - ["Tony Parker", 2018, "Hornets"]] - self.check_out_of_order_result(resp, expected_data) - - stmt = '''GO FROM "Tim Duncan" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ - UNION ALL (GO FROM "Tony Parker" OVER like YIELD like._dst AS id | \ - GO FROM $-.id OVER serve YIELD $^.player.name, serve.start_year, $$.team.name)''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$^.player.name", "serve.start_year", "$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Tim Duncan", 1997, "Spurs"], - ["LaMarcus Aldridge", 2015, "Spurs"], - ["LaMarcus Aldridge", 2006, "Trail Blazers"], - ["Manu Ginobili", 2002, "Spurs"], - ["Tim Duncan", 1997, "Spurs"]] - self.check_out_of_order_result(resp, expected_data) - - stmt = '''GO FROM "Tim Duncan" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ - UNION ALL GO FROM "Tony Parker" OVER like YIELD like._dst AS id | \ - GO FROM $-.id OVER serve YIELD $^.player.name, serve.start_year, $$.team.name''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$^.player.name", "serve.start_year", "$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Tim Duncan", 1997, "Spurs"], - ["LaMarcus Aldridge", 2015, "Spurs"], - ["LaMarcus Aldridge", 2006, "Trail Blazers"], - ["Manu Ginobili", 2002, "Spurs"], - ["Tim Duncan", 1997, "Spurs"]] - self.check_out_of_order_result(resp, expected_data) - - stmt = '''(GO FROM "Tim Duncan" OVER like YIELD like._dst AS id \ - UNION ALL GO FROM "Tony Parker" OVER like YIELD like._dst AS id) \ - | GO FROM $-.id OVER serve YIELD $^.player.name, serve.start_year, $$.team.name''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$^.player.name", "serve.start_year", "$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Manu Ginobili", 2002, "Spurs"], - ["Manu Ginobili", 2002, "Spurs"], - ["Tony Parker", 1999, "Spurs"], - ["Tony Parker", 2018, "Hornets"], - ["LaMarcus Aldridge", 2015, "Spurs"], - ["LaMarcus Aldridge", 2006, "Trail Blazers"], - ["Tim Duncan", 1997, "Spurs"]] - self.check_out_of_order_result(resp, expected_data) - - stmt = '''GO FROM "Tim Duncan" OVER serve YIELD $^.player.name as name, $$.team.name as player \ - UNION ALL \ - GO FROM "Tony Parker" OVER serve \ - YIELD $^.player.name as name, serve.start_year as player''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["name", "player"] - self.check_column_names(resp, column_names) - expected_data = [["Tim Duncan", "Spurs"], ["Tony Parker", 1999], - ["Tony Parker", 2018]] - self.check_out_of_order_result(resp, expected_data) - - # diffrent column names - stmt = '''GO FROM "Tim Duncan" OVER serve YIELD $^.player.name as name, $$.team.name as player \ - UNION ALL \ - GO FROM "Tony Parker" OVER serve \ - YIELD $^.player.name as name, serve.start_year''' - resp = self.execute(stmt) - self.check_resp_failed(resp) - # column_names = ["name", "player"] - # self.check_column_names(resp, column_names) - # expected_data = [["Tim Duncan", "Spurs"], ["Tony Parker", "1999"], - # ["Tony Parker", "2018"]] - # self.check_out_of_order_result(resp, expected_data) - - stmt = '''GO FROM "Nobody" OVER serve YIELD $^.player.name AS player, serve.start_year AS start \ - UNION ALL \ - GO FROM "Tony Parker" OVER serve YIELD $^.player.name AS player, serve.start_year AS start''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["player", "start"] - self.check_column_names(resp, column_names) - expected_data = [["Tony Parker", 1999], ["Tony Parker", 2018]] - self.check_out_of_order_result(resp, expected_data) - - # diffrent column names - stmt = '''GO FROM "Nobody" OVER serve YIELD $^.player.name AS player, serve.start_year AS start \ - UNION ALL \ - GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year''' - resp = self.execute(stmt) - self.check_resp_failed(resp) - # column_names = ["player", "start"] - # self.check_column_names(resp, column_names) - # expected_data = [["Tony Parker", 1999], ["Tony Parker", 2018]] - # self.check_out_of_order_result(resp, expected_data) - - def test_union_distinct(self): - stmt = '''(GO FROM "Tim Duncan" OVER like YIELD like._dst as id | \ - GO FROM $-.id OVER serve YIELD $^.player.name, serve.start_year, $$.team.name) \ - UNION \ - GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ - UNION \ - GO FROM "Manu Ginobili" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$^.player.name", "serve.start_year", "$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Manu Ginobili", 2002, "Spurs"], - ["Tony Parker", 1999, "Spurs"], - ["Tony Parker", 2018, "Hornets"]] - self.check_out_of_order_result(resp, expected_data) - - stmt = '''(GO FROM "Tim Duncan" OVER like YIELD like._dst as id | \ - GO FROM $-.id OVER serve YIELD $^.player.name, serve.start_year, $$.team.name) \ - UNION DISTINCT \ - GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$^.player.name", "serve.start_year", "$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Manu Ginobili", 2002, "Spurs"], - ["Tony Parker", 1999, "Spurs"], - ["Tony Parker", 2018, "Hornets"]] - self.check_out_of_order_result(resp, expected_data) - - def test_minus(self): - stmt = '''(GO FROM "Tim Duncan" OVER like YIELD like._dst as id | \ - GO FROM $-.id OVER serve YIELD $^.player.name, serve.start_year, $$.team.name) \ - MINUS \ - GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$^.player.name", "serve.start_year", "$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Manu Ginobili", 2002, "Spurs"]] - self.check_result(resp, expected_data) - - def test_intersect(self): - stmt = '''(GO FROM "Tim Duncan" OVER like YIELD like._dst as id | \ - GO FROM $-.id OVER serve YIELD $^.player.name, serve.start_year, $$.team.name) \ - INTERSECT \ - GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$^.player.name", "serve.start_year", "$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Tony Parker", 1999, "Spurs"], - ["Tony Parker", 2018, "Hornets"]] - self.check_out_of_order_result(resp, expected_data) - - def test_mix(self): - stmt = '''(GO FROM "Tim Duncan" OVER like YIELD like._dst as id | \ - GO FROM $-.id OVER serve YIELD $^.player.name, serve.start_year, $$.team.name) \ - MINUS \ - GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ - UNION \ - GO FROM "Tim Duncan" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ - INTERSECT \ - GO FROM "Manu Ginobili" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$^.player.name", "serve.start_year", "$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Manu Ginobili", 2002, "Spurs"]] - self.check_result(resp, expected_data) - - def test_assign(self): - stmt = '''$var = GO FROM "Tim Duncan" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ - UNION ALL \ - GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name; \ - YIELD $var.*''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$var.$^.player.name", "$var.serve.start_year", "$var.$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Tim Duncan", 1997, "Spurs"], - ["Tony Parker", 1999, "Spurs"], - ["Tony Parker", 2018, "Hornets"]] - self.check_out_of_order_result(resp, expected_data) - - stmt = '''$var = (GO FROM "Tim Duncan" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ - UNION ALL \ - GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name); \ - YIELD $var.*''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$var.$^.player.name", "$var.serve.start_year", "$var.$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Tim Duncan", 1997, "Spurs"], - ["Tony Parker", 1999, "Spurs"], - ["Tony Parker", 2018, "Hornets"]] - self.check_out_of_order_result(resp, expected_data) - - stmt = '''$var = (GO FROM "Tim Duncan" OVER like YIELD like._dst as id | \ - GO FROM $-.id OVER serve YIELD $^.player.name, serve.start_year, $$.team.name) \ - MINUS \ - GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name; \ - YIELD $var.*''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$var.$^.player.name", "$var.serve.start_year", "$var.$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Manu Ginobili", 2002, "Spurs"]] - self.check_result(resp, expected_data) - - stmt = '''$var = (GO FROM "Tim Duncan" OVER like YIELD like._dst as id | \ - GO FROM $-.id OVER serve YIELD $^.player.name, serve.start_year, $$.team.name) \ - INTERSECT \ - GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name; \ - YIELD $var.*''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$var.$^.player.name", "$var.serve.start_year", "$var.$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [["Tony Parker", 1999, "Spurs"], - ["Tony Parker", 2018, "Hornets"]] - self.check_out_of_order_result(resp, expected_data) - - def test_empty_input(self): - stmt = '''GO FROM "NON EXIST VERTEX ID" OVER serve YIELD serve.start_year, $$.team.name \ - UNION \ - GO FROM "NON EXIST VERTEX ID" OVER serve YIELD serve.start_year, $$.team.name \ - MINUS \ - GO FROM "NON EXIST VERTEX ID" OVER serve YIELD serve.start_year, $$.team.name \ - INTERSECT \ - GO FROM "NON EXIST VERTEX ID" OVER serve YIELD serve.start_year, $$.team.name''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["serve.start_year", "$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [] - self.check_result(resp, expected_data) - - stmt = '''$var = GO FROM "NON EXIST VERTEX ID" OVER serve YIELD serve.start_year, $$.team.name \ - UNION \ - GO FROM "NON EXIST VERTEX ID" OVER serve YIELD serve.start_year, $$.team.name \ - MINUS \ - GO FROM "NON EXIST VERTEX ID" OVER serve YIELD serve.start_year, $$.team.name \ - INTERSECT \ - GO FROM "NON EXIST VERTEX ID" OVER serve YIELD serve.start_year, $$.team.name; \ - YIELD $var.*''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - column_names = ["$var.serve.start_year", "$var.$$.team.name"] - self.check_column_names(resp, column_names) - expected_data = [] - self.check_result(resp, expected_data) - - def test_syntax_error(self): - stmt = '''GO FROM "123" OVER like \ - YIELD like._src as src, like._dst as dst \ - | (GO FROM $-.src OVER serve \ - UNION GO FROM $-.dst OVER serve)''' - resp = self.execute(stmt) - self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) - - def test_execution_error(self): - stmt = '''GO FROM "Tim Duncan" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name \ - UNION \ - GO FROM "Tony Parker" OVER serve YIELD $^.player.name1, serve.start_year, $$.team.name''' - resp = self.execute(stmt) - self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) - - stmt = '''GO FROM "Tim Duncan" OVER serve YIELD $^.player.name, serve.start_year \ - UNION \ - GO FROM "Tony Parker" OVER serve YIELD $^.player.name, serve.start_year, $$.team.name''' - resp = self.execute(stmt) - self.check_resp_failed(resp, ttypes.ErrorCode.E_SEMANTIC_ERROR) diff --git a/tests/query/v2/conftest.py b/tests/query/v2/conftest.py index de3c89c159f6a99cdacdc8e15f26c1349cc327f0..f2da1b738d350614eec37f0b626719ab5e213e47 100644 --- a/tests/query/v2/conftest.py +++ b/tests/query/v2/conftest.py @@ -15,14 +15,16 @@ from tests.query.v2.utils import check_subgraph def edgekey(edge): - return utf8s(edge.src) + utf8s(edge.dst) + utf8s(edge.name) \ + return utf8s(edge.src.get_sVal()) + utf8s(edge.dst.get_sVal()) + utf8s(edge.name) \ + str(edge.ranking) def create_vertex_team(line): assert len(line) == 2 vertex = ttypes.Vertex() - vertex.vid = utf8b(line[0]) + vid = ttypes.Value() + vid.set_sVal(utf8b(line[0])) + vertex.vid = vid tags = [] tag = ttypes.Tag() tag.name = utf8b('team') @@ -40,7 +42,9 @@ def create_vertex_team(line): def create_vertex_player(line): assert len(line) == 3 vertex = ttypes.Vertex() - vertex.vid = utf8b(line[0]) + vid = ttypes.Value() + vid.set_sVal(utf8b(line[0])) + vertex.vid = vid tags = [] tag = ttypes.Tag() tag.name = utf8b('player') @@ -61,7 +65,9 @@ def create_vertex_player(line): def create_vertex_bachelor(line): assert len(line) == 3 vertex = ttypes.Vertex() - vertex.vid = utf8b(line[0]) + vid = ttypes.Value() + vid.set_sVal(utf8b(line[0])) + vertex.vid = vid tags = [] tag = ttypes.Tag() tag.name = utf8b('bachelor') @@ -82,13 +88,18 @@ def create_vertex_bachelor(line): def create_edge_serve(line): assert len(line) == 4 edge = ttypes.Edge() - edge.src = utf8b(line[0]) + src = ttypes.Value() + src.set_sVal(utf8b(line[0])) + edge.src = src + dst = ttypes.Value() if '@' in line[1]: temp = list(map(lambda i: i.strip('"'), re.split('@', line[1]))) - edge.dst = utf8b(temp[0]) + dst.set_sVal(utf8b(temp[0])) + edge.dst = dst edge.ranking = int(temp[1]) else: - edge.dst = utf8b(line[1]) + dst.set_sVal(utf8b(line[1])) + edge.dst = dst edge.ranking = 0 edge.type = 1 edge.name = utf8b('serve') @@ -106,9 +117,12 @@ def create_edge_serve(line): def create_edge_like(line): assert len(line) == 3 edge = ttypes.Edge() - - edge.src = utf8b(line[0]) - edge.dst = utf8b(line[1]) + src = ttypes.Value() + src.set_sVal(utf8b(line[0])) + dst = ttypes.Value() + dst.set_sVal(utf8b(line[1])) + edge.src = src + edge.dst = dst edge.type = 1 edge.ranking = 0 edge.name = utf8b('like') @@ -123,8 +137,12 @@ def create_edge_like(line): def create_edge_teammate(line): assert len(line) == 4 edge = ttypes.Edge() - edge.src = utf8b(line[0]) - edge.dst = utf8b(line[1]) + src = ttypes.Value() + src.set_sVal(utf8b(line[0])) + dst = ttypes.Value() + dst.set_sVal(utf8b(line[1])) + edge.src = src + edge.dst = dst edge.type = 1 edge.ranking = 0 edge.name = utf8b('teammate') @@ -162,7 +180,7 @@ def fill_vertices_and_edges(line, datatype: str, VERTEXS, EDGES): assert datatype != 'none' if datatype == 'player': vertex = create_vertex_player(line) - key = utf8s(vertex.vid) + key = utf8s(vertex.vid.get_sVal()) if key in VERTEXS: temp = VERTEXS[key].get_vVal() temp.tags.append(vertex.tags[0]) @@ -175,11 +193,11 @@ def fill_vertices_and_edges(line, datatype: str, VERTEXS, EDGES): elif datatype == 'team': vertex = create_vertex_team(line) value.set_vVal(vertex) - key = utf8s(vertex.vid) + key = utf8s(vertex.vid.get_sVal()) VERTEXS[key] = value elif datatype == 'bachelor': vertex = create_vertex_bachelor(line) - key = utf8s(vertex.vid) + key = utf8s(vertex.vid.get_sVal()) if key in VERTEXS: temp = VERTEXS[key].get_vVal() temp.tags.append(vertex.tags[0]) diff --git a/tests/query/v2/test_get_subgraph.py b/tests/query/v2/test_get_subgraph.py deleted file mode 100644 index 37b64c72800209a4b1e14dc66933b432daf25750..0000000000000000000000000000000000000000 --- a/tests/query/v2/test_get_subgraph.py +++ /dev/null @@ -1,1063 +0,0 @@ -# --coding:utf-8-- -# -# 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. - -import pytest - -from tests.common.nebula_test_suite import NebulaTestSuite - - -@pytest.mark.usefixtures('set_vertices_and_edges') -class TestSubGraph(NebulaTestSuite): - @classmethod - def prepare(cls): - cls.use_nba() - - def test_invalid_input(self): - stmt = 'GET SUBGRAPH FROM $-.id' - resp = self.execute(stmt) - self.check_resp_failed(resp) - - stmt = 'GET SUBGRAPH FROM $a.id' - resp = self.execute(stmt) - self.check_resp_failed(resp) - - stmt = 'GO FROM "Tim Duncan" OVER like YIELD $$.player.age AS id | GET SUBGRAPH FROM $-.id' - resp = self.execute(stmt) - self.check_resp_failed(resp) - - stmt = '$a = GO FROM "Tim Duncan" OVER like YIELD $$.player.age AS ID; GET SUBGRAPH FROM $a.ID' - resp = self.execute(stmt) - self.check_resp_failed(resp) - - stmt = '$a = GO FROM "Tim Duncan" OVER like YIELD like._src AS src; GET SUBGRAPH FROM $b.src' - resp = self.execute(stmt) - self.check_resp_failed(resp) - - stmt = 'GO FROM "Tim Duncan" OVER like YIELD like._dst AS id, like._src AS id | GET SUBGRAPH FROM $-.id' - resp = self.execute(stmt) - self.check_resp_failed(resp) - - stmt = '$a = GO FROM "Tim Duncan" OVER like YIELD like._dst AS id, like._src AS id; GET SUBGRAPH FROM $a.id' - resp = self.execute(stmt) - self.check_resp_failed(resp) - - def test_zero_step(self, check_subgraph_result): - VERTEXS = self.VERTEXS - - stmt = 'GET SUBGRAPH 0 STEPS FROM "Tim Duncan"' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - vertices = [ - VERTEXS['Tim Duncan'] - ] - - expected_data = { - "column_names": ['_vertices'], - "rows": [ - [vertices] - ] - } - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - stmt = 'GET SUBGRAPH 0 STEPS FROM "Tim Duncan", "Spurs"' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - vertices = [ - VERTEXS['Tim Duncan'], - VERTEXS['Spurs'], - ] - expected_data = { - "column_names": ['_vertices'], - "rows": [ - [vertices] - ] - } - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - stmt = 'GET SUBGRAPH 0 STEPS FROM "Tim Duncan", "Tony Parker", "Spurs"' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - vertices = [ - VERTEXS['Tony Parker'], - VERTEXS['Spurs'], - VERTEXS['Tim Duncan'], - ] - expected_data = { - "column_names": ['_vertices'], - "rows": [ - [vertices] - ] - } - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - stmt = "GO FROM 'Tim Duncan' over serve YIELD serve._dst AS id | GET SUBGRAPH 0 STEPS FROM $-.id" - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - vertices = [ - VERTEXS['Spurs'] - ] - - expected_data = { - "column_names": ['_vertices'], - "rows": [ - [vertices] - ] - } - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - stmt = "GO FROM 'Tim Duncan' over like YIELD like._dst AS id | GET SUBGRAPH 0 STEPS FROM $-.id" - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - vertices = [ - VERTEXS['Tony Parker'], - VERTEXS['Manu Ginobili'], - ] - - expected_data = { - "column_names": ['_vertices'], - "rows": [ - [vertices] - ] - } - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - stmt = '''$a = GO FROM 'Tim Duncan' over serve YIELD serve._dst AS id; - GET SUBGRAPH 0 STEPS FROM $a.id''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - vertices = [ - VERTEXS['Spurs'] - ] - - expected_data = { - "column_names": ['_vertices'], - "rows": [ - [vertices] - ] - } - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - stmt = '''$a = GO FROM 'Tim Duncan' over like YIELD like._dst AS id; - GET SUBGRAPH 0 STEPS FROM $a.id''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - vertices = [ - VERTEXS['Tony Parker'], - VERTEXS['Manu Ginobili'], - ] - - expected_data = { - "column_names": ['_vertices'], - "rows": [ - [vertices] - ] - } - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - def test_subgraph(self, check_subgraph_result): - VERTEXS, EDGES = self.VERTEXS, self.EDGES - - stmt = "GET SUBGRAPH FROM 'Tim Duncan'" - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - - vertex1 = [VERTEXS['Tim Duncan']] - - edge1 = [ - EDGES['Manu Ginobili'+'Tim Duncan'+'teammate'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'teammate'+'0'], - EDGES['Aron Baynes'+'Tim Duncan'+'like'+'0'], - EDGES['Boris Diaw'+'Tim Duncan'+'like'+'0'], - EDGES['Danny Green'+'Tim Duncan'+'like'+'0'], - EDGES['Dejounte Murray'+'Tim Duncan'+'like'+'0'], - EDGES['LaMarcus Aldridge'+'Tim Duncan'+'like'+'0'], - EDGES['Manu Ginobili'+'Tim Duncan'+'like'+'0'], - EDGES['Marco Belinelli'+'Tim Duncan'+'like'+'0'], - EDGES['Shaquile O\'Neal'+'Tim Duncan'+'like'+'0'], - EDGES['Tiago Splitter'+'Tim Duncan'+'like'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'like'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'like'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'like'+'0'], - EDGES['Tim Duncan'+'Spurs'+'serve'+'0'], - EDGES['Tim Duncan'+'Danny Green'+'teammate'+'0'], - EDGES['Tim Duncan'+'LaMarcus Aldridge'+'teammate'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'teammate'+'0'] - ] - - vertex2 = [ - VERTEXS['Danny Green'], - VERTEXS['Manu Ginobili'], - VERTEXS['Aron Baynes'], - VERTEXS['Boris Diaw'], - VERTEXS['Shaquile O\'Neal'], - VERTEXS['Tony Parker'], - VERTEXS['Spurs'], - VERTEXS['Dejounte Murray'], - VERTEXS['LaMarcus Aldridge'], - VERTEXS['Marco Belinelli'], - VERTEXS['Tiago Splitter'] - ] - - edge2 = [ - EDGES['Tony Parker'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Dejounte Murray'+'Manu Ginobili'+'like'+'0'], - EDGES['Tiago Splitter'+'Manu Ginobili'+'like'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'like'+'0'], - EDGES['Manu Ginobili'+'Spurs'+'serve'+'0'], - EDGES['Manu Ginobili'+'Tony Parker'+'teammate'+'0'], - EDGES['Aron Baynes'+'Spurs'+'serve'+'0'], - EDGES['Boris Diaw'+'Tony Parker'+'like'+'0'], - EDGES['Boris Diaw'+'Spurs'+'serve'+'0'], - EDGES['Dejounte Murray'+'Tony Parker'+'like'+'0'], - EDGES['LaMarcus Aldridge'+'Tony Parker'+'like'+'0'], - EDGES['Marco Belinelli'+'Tony Parker'+'like'+'0'], - EDGES['Tony Parker'+'LaMarcus Aldridge'+'like'+'0'], - EDGES['Tony Parker'+'Spurs'+'serve'+'0'], - EDGES['Tony Parker'+'LaMarcus Aldridge'+'teammate'+'0'], - EDGES['Dejounte Murray'+'Spurs'+'serve'+'0'], - EDGES['LaMarcus Aldridge'+'Spurs'+'serve'+'0'], - EDGES['Marco Belinelli'+'Spurs'+'serve'+'0'], - EDGES['Tiago Splitter'+'Spurs'+'serve'+'0'], - EDGES['Marco Belinelli'+'Spurs'+'serve'+'1'], - EDGES['Dejounte Murray'+'Marco Belinelli'+'like'+'0'], - EDGES['Dejounte Murray'+'Danny Green'+'like'+'0'], - EDGES['Marco Belinelli'+'Danny Green'+'like'+'0'], - EDGES['Danny Green'+'Marco Belinelli'+'like'+'0'], - EDGES['Danny Green'+'Spurs'+'serve'+'0'], - ] - - expected_data = { - "column_names": ["_vertices", "_edges"], - "rows": [ - [vertex1, edge1], - [vertex2, edge2] - ] - } - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - stmt = "GET SUBGRAPH 2 STEPS FROM 'Tim Duncan'" - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - - vertex1 = [VERTEXS["Tim Duncan"]] - - edge1 = [ - EDGES['Manu Ginobili'+'Tim Duncan'+'teammate'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'teammate'+'0'], - EDGES['Aron Baynes'+'Tim Duncan'+'like'+'0'], - EDGES['Boris Diaw'+'Tim Duncan'+'like'+'0'], - EDGES['Danny Green'+'Tim Duncan'+'like'+'0'], - EDGES['Dejounte Murray'+'Tim Duncan'+'like'+'0'], - EDGES['LaMarcus Aldridge'+'Tim Duncan'+'like'+'0'], - EDGES['Manu Ginobili'+'Tim Duncan'+'like'+'0'], - EDGES['Marco Belinelli'+'Tim Duncan'+'like'+'0'], - EDGES['Shaquile O\'Neal'+'Tim Duncan'+'like'+'0'], - EDGES['Tiago Splitter'+'Tim Duncan'+'like'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'like'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'like'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'like'+'0'], - EDGES['Tim Duncan'+'Spurs'+'serve'+'0'], - EDGES['Tim Duncan'+'Danny Green'+'teammate'+'0'], - EDGES['Tim Duncan'+'LaMarcus Aldridge'+'teammate'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'teammate'+'0'] - ] - - vertex2 = [ - VERTEXS['Danny Green'], - VERTEXS['Manu Ginobili'], - VERTEXS['Aron Baynes'], - VERTEXS['Boris Diaw'], - VERTEXS['Shaquile O\'Neal'], - VERTEXS['Tony Parker'], - VERTEXS['Spurs'], - VERTEXS['Dejounte Murray'], - VERTEXS['LaMarcus Aldridge'], - VERTEXS['Marco Belinelli'], - VERTEXS['Tiago Splitter'] - ] - - edge2 = [ - EDGES['Dejounte Murray'+'Danny Green'+'like'+'0'], - EDGES['Marco Belinelli'+'Danny Green'+'like'+'0'], - EDGES['Danny Green'+'LeBron James'+'like'+'0'], - EDGES['Danny Green'+'Marco Belinelli'+'like'+'0'], - EDGES['Danny Green'+'Cavaliers'+'serve'+'0'], - EDGES['Danny Green'+'Raptors'+'serve'+'0'], - EDGES['Danny Green'+'Spurs'+'serve'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Dejounte Murray'+'Manu Ginobili'+'like'+'0'], - EDGES['Tiago Splitter'+'Manu Ginobili'+'like'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'like'+'0'], - EDGES['Manu Ginobili'+'Spurs'+'serve'+'0'], - EDGES['Manu Ginobili'+'Tony Parker'+'teammate'+'0'], - EDGES['Aron Baynes'+'Celtics'+'serve'+'0'], - EDGES['Aron Baynes'+'Pistons'+'serve'+'0'], - EDGES['Aron Baynes'+'Spurs'+'serve'+'0'], - EDGES['Boris Diaw'+'Tony Parker'+'like'+'0'], - EDGES['Boris Diaw'+'Hawks'+'serve'+'0'], - EDGES['Boris Diaw'+'Hornets'+'serve'+'0'], - EDGES['Boris Diaw'+'Jazz'+'serve'+'0'], - EDGES['Boris Diaw'+'Spurs'+'serve'+'0'], - EDGES['Boris Diaw'+'Suns'+'serve'+'0'], - - EDGES['Yao Ming'+'Shaquile O\'Neal'+'like'+'0'], - EDGES['Shaquile O\'Neal'+'JaVale McGee'+'like'+'0'], - EDGES['Shaquile O\'Neal'+'Cavaliers'+'serve'+'0'], - EDGES['Shaquile O\'Neal'+'Celtics'+'serve'+'0'], - EDGES['Shaquile O\'Neal'+'Heat'+'serve'+'0'], - EDGES['Shaquile O\'Neal'+'Lakers'+'serve'+'0'], - EDGES['Shaquile O\'Neal'+'Magic'+'serve'+'0'], - EDGES['Shaquile O\'Neal'+'Suns'+'serve'+'0'], - - EDGES['Dejounte Murray'+'Tony Parker'+'like'+'0'], - EDGES['LaMarcus Aldridge'+'Tony Parker'+'like'+'0'], - EDGES['Marco Belinelli'+'Tony Parker'+'like'+'0'], - EDGES['Tony Parker'+'LaMarcus Aldridge'+'like'+'0'], - EDGES['Tony Parker'+'Hornets'+'serve'+'0'], - EDGES['Tony Parker'+'Spurs'+'serve'+'0'], - EDGES['Tony Parker'+'Kyle Anderson'+'teammate'+'0'], - EDGES['Tony Parker'+'LaMarcus Aldridge'+'teammate'+'0'], - - EDGES['Cory Joseph'+'Spurs'+'serve'+'0'], - EDGES['David West'+'Spurs'+'serve'+'0'], - EDGES['Dejounte Murray'+'Spurs'+'serve'+'0'], - EDGES['Jonathon Simmons'+'Spurs'+'serve'+'0'], - EDGES['Kyle Anderson'+'Spurs'+'serve'+'0'], - EDGES['LaMarcus Aldridge'+'Spurs'+'serve'+'0'], - EDGES['Marco Belinelli'+'Spurs'+'serve'+'0'], - EDGES['Paul Gasol'+'Spurs'+'serve'+'0'], - EDGES['Rudy Gay'+'Spurs'+'serve'+'0'], - EDGES['Tiago Splitter'+'Spurs'+'serve'+'0'], - EDGES['Tracy McGrady'+'Spurs'+'serve'+'0'], - EDGES['Marco Belinelli'+'Spurs'+'serve'+'1'], - - EDGES['Dejounte Murray'+'Chris Paul'+'like'+'0'], - EDGES['Dejounte Murray'+'James Harden'+'like'+'0'], - EDGES['Dejounte Murray'+'Kevin Durant'+'like'+'0'], - EDGES['Dejounte Murray'+'Kyle Anderson'+'like'+'0'], - EDGES['Dejounte Murray'+'LeBron James'+'like'+'0'], - EDGES['Dejounte Murray'+'Marco Belinelli'+'like'+'0'], - EDGES['Dejounte Murray'+'Russell Westbrook'+'like'+'0'], - - EDGES['Damian Lillard'+'LaMarcus Aldridge'+'like'+'0'], - EDGES['Rudy Gay'+'LaMarcus Aldridge'+'like'+'0'], - - EDGES['LaMarcus Aldridge'+'Trail Blazers'+'serve'+'0'], - EDGES['Marco Belinelli'+'76ers'+'serve'+'0'], - EDGES['Marco Belinelli'+'Bulls'+'serve'+'0'], - EDGES['Marco Belinelli'+'Hawks'+'serve'+'0'], - EDGES['Marco Belinelli'+'Hornets'+'serve'+'0'], - EDGES['Marco Belinelli'+'Kings'+'serve'+'0'], - EDGES['Marco Belinelli'+'Raptors'+'serve'+'0'], - EDGES['Marco Belinelli'+'Warriors'+'serve'+'0'], - EDGES['Marco Belinelli'+'Hornets'+'serve'+'1'], - - EDGES['Tiago Splitter'+'76ers'+'serve'+'0'], - EDGES['Tiago Splitter'+'Hawks'+'serve'+'0'] - ] - - vertex3 = [ - VERTEXS['Cavaliers'], - VERTEXS['Pistons'], - VERTEXS['Damian Lillard'], - VERTEXS['Kings'], - VERTEXS['Raptors'], - VERTEXS['Jazz'], - VERTEXS['LeBron James'], - VERTEXS['Paul Gasol'], - VERTEXS['Kyle Anderson'], - VERTEXS['Rudy Gay'], - VERTEXS['Kevin Durant'], - VERTEXS['Yao Ming'], - VERTEXS['James Harden'], - VERTEXS['Hornets'], - VERTEXS['David West'], - VERTEXS['Chris Paul'], - VERTEXS['Celtics'], - VERTEXS['Jonathon Simmons'], - VERTEXS['Hawks'], - VERTEXS['Heat'], - VERTEXS['Lakers'], - VERTEXS['Suns'], - VERTEXS['Magic'], - VERTEXS['Trail Blazers'], - VERTEXS['76ers'], - VERTEXS['JaVale McGee'], - VERTEXS['Cory Joseph'], - VERTEXS['Tracy McGrady'], - VERTEXS['Russell Westbrook'], - VERTEXS['Bulls'], - VERTEXS['Warriors'] - ] - - edge3 = [ - EDGES['LeBron James'+'Cavaliers'+'serve'+'0'], - EDGES['LeBron James'+'Cavaliers'+'serve'+'1'], - EDGES['Damian Lillard'+'Trail Blazers'+'serve'+'0'], - - EDGES['Rudy Gay'+'Kings'+'serve'+'0'], - EDGES['Cory Joseph'+'Raptors'+'serve'+'0'], - EDGES['Rudy Gay'+'Raptors'+'serve'+'0'], - EDGES['Tracy McGrady'+'Raptors'+'serve'+'0'], - - EDGES['Chris Paul'+'LeBron James'+'like'+'0'], - EDGES['LeBron James'+'Heat'+'serve'+'0'], - EDGES['LeBron James'+'Lakers'+'serve'+'0'], - - EDGES['Paul Gasol'+'Bulls'+'serve'+'0'], - EDGES['Paul Gasol'+'Lakers'+'serve'+'0'], - - EDGES['Tracy McGrady'+'Rudy Gay'+'like'+'0'], - EDGES['Kevin Durant'+'Warriors'+'serve'+'0'], - EDGES['Yao Ming'+'Tracy McGrady'+'like'+'0'], - EDGES['Russell Westbrook'+'James Harden'+'like'+'0'], - EDGES['James Harden'+'Russell Westbrook'+'like'+'0'], - - EDGES['Chris Paul'+'Hornets'+'serve'+'0'], - EDGES['David West'+'Hornets'+'serve'+'0'], - EDGES['David West'+'Warriors'+'serve'+'0'], - - EDGES['Jonathon Simmons'+'76ers'+'serve'+'0'], - EDGES['Jonathon Simmons'+'Magic'+'serve'+'0'], - EDGES['JaVale McGee'+'Lakers'+'serve'+'0'], - EDGES['Tracy McGrady'+'Magic'+'serve'+'0'], - - EDGES['JaVale McGee'+'Warriors'+'serve'+'0'] - ] - - expected_data = { - "column_names": ["_vertices", "_edges"], - "rows": [ - [vertex1, edge1], - [vertex2, edge2], - [vertex3, edge3] - ] - } - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - stmt = "GET SUBGRAPH 2 STEPS FROM 'Tim Duncan' IN like, serve" - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - vertex1 = [VERTEXS["Tim Duncan"]] - - edge1 = [ - EDGES['Aron Baynes'+'Tim Duncan'+'like'+'0'], - EDGES['Boris Diaw'+'Tim Duncan'+'like'+'0'], - EDGES['Danny Green'+'Tim Duncan'+'like'+'0'], - EDGES['Dejounte Murray'+'Tim Duncan'+'like'+'0'], - EDGES['LaMarcus Aldridge'+'Tim Duncan'+'like'+'0'], - EDGES['Manu Ginobili'+'Tim Duncan'+'like'+'0'], - EDGES['Marco Belinelli'+'Tim Duncan'+'like'+'0'], - EDGES['Shaquile O\'Neal'+'Tim Duncan'+'like'+'0'], - EDGES['Tiago Splitter'+'Tim Duncan'+'like'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'like'+'0'], - ] - - vertex2 = [ - VERTEXS['Manu Ginobili'], - VERTEXS['Shaquile O\'Neal'], - VERTEXS['LaMarcus Aldridge'], - VERTEXS['Marco Belinelli'], - VERTEXS['Danny Green'], - VERTEXS['Tony Parker'] - ] - - edge2 = [ - EDGES['Dejounte Murray'+'Manu Ginobili'+'like'+'0'], - EDGES['Tiago Splitter'+'Manu Ginobili'+'like'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'like'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'like'+'0'], - EDGES['Yao Ming'+'Shaquile O\'Neal'+'like'+'0'], - EDGES['Damian Lillard'+'LaMarcus Aldridge'+'like'+'0'], - EDGES['Rudy Gay'+'LaMarcus Aldridge'+'like'+'0'], - EDGES['Tony Parker'+'LaMarcus Aldridge'+'like'+'0'], - EDGES['Danny Green'+'Marco Belinelli'+'like'+'0'], - EDGES['Dejounte Murray'+'Marco Belinelli'+'like'+'0'], - EDGES['Dejounte Murray'+'Danny Green'+'like'+'0'], - EDGES['Marco Belinelli'+'Danny Green'+'like'+'0'], - - EDGES['Boris Diaw'+'Tony Parker'+'like'+'0'], - EDGES['Dejounte Murray'+'Tony Parker'+'like'+'0'], - EDGES['LaMarcus Aldridge'+'Tony Parker'+'like'+'0'], - EDGES['Marco Belinelli'+'Tony Parker'+'like'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'like'+'0'] - ] - - vertex3 = [ - VERTEXS['Damian Lillard'], - VERTEXS['Rudy Gay'], - VERTEXS['Dejounte Murray'], - VERTEXS['Yao Ming'], - VERTEXS['Tiago Splitter'], - VERTEXS['Boris Diaw'] - ] - - edge3 = [ - EDGES['Manu Ginobili'+'Tim Duncan'+'teammate'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'teammate'+'0'], - EDGES['Tim Duncan'+'Danny Green'+'teammate'+'0'], - EDGES['Tim Duncan'+'LaMarcus Aldridge'+'teammate'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'teammate'+'0'], - EDGES['Manu Ginobili'+'Tony Parker'+'teammate'+'0'], - EDGES['Tony Parker'+'LaMarcus Aldridge'+'teammate'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'teammate'+'0'] - ] - - expected_data = { - "column_names": ["_vertices", "_edges"], - "rows": [ - [vertex1, edge1], - [vertex2, edge2], - [vertex3, edge3] - ] - } - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - stmt = "GET SUBGRAPH 2 STEPS FROM 'Tim Duncan' IN like OUT serve" - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - - vertex1 = [VERTEXS["Tim Duncan"]] - - edge1 = [ - EDGES['Tim Duncan'+'Spurs'+'serve'+'0'], - EDGES['Aron Baynes'+'Tim Duncan'+'like'+'0'], - EDGES['Boris Diaw'+'Tim Duncan'+'like'+'0'], - EDGES['Danny Green'+'Tim Duncan'+'like'+'0'], - EDGES['Dejounte Murray'+'Tim Duncan'+'like'+'0'], - EDGES['LaMarcus Aldridge'+'Tim Duncan'+'like'+'0'], - EDGES['Manu Ginobili'+'Tim Duncan'+'like'+'0'], - EDGES['Marco Belinelli'+'Tim Duncan'+'like'+'0'], - EDGES['Shaquile O\'Neal'+'Tim Duncan'+'like'+'0'], - EDGES['Tiago Splitter'+'Tim Duncan'+'like'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'like'+'0'] - ] - - vertex2 = [ - VERTEXS['Manu Ginobili'], - VERTEXS['Danny Green'], - VERTEXS['Tony Parker'], - VERTEXS['Aron Baynes'], - VERTEXS['Boris Diaw'], - VERTEXS['Shaquile O\'Neal'], - VERTEXS['Dejounte Murray'], - VERTEXS['LaMarcus Aldridge'], - VERTEXS['Marco Belinelli'], - VERTEXS['Tiago Splitter'] - ] - - edge2 = [ - EDGES['Manu Ginobili'+'Spurs'+'serve'+'0'], - EDGES['Dejounte Murray'+'Manu Ginobili'+'like'+'0'], - EDGES['Tiago Splitter'+'Manu Ginobili'+'like'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'like'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'like'+'0'], - - EDGES['Danny Green'+'Cavaliers'+'serve'+'0'], - EDGES['Danny Green'+'Raptors'+'serve'+'0'], - EDGES['Danny Green'+'Spurs'+'serve'+'0'], - - EDGES['Dejounte Murray'+'Danny Green'+'like'+'0'], - EDGES['Marco Belinelli'+'Danny Green'+'like'+'0'], - - EDGES['Tony Parker'+'Hornets'+'serve'+'0'], - EDGES['Tony Parker'+'Spurs'+'serve'+'0'], - - EDGES['Boris Diaw'+'Tony Parker'+'like'+'0'], - EDGES['Dejounte Murray'+'Tony Parker'+'like'+'0'], - EDGES['LaMarcus Aldridge'+'Tony Parker'+'like'+'0'], - EDGES['Marco Belinelli'+'Tony Parker'+'like'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'like'+'0'], - - - EDGES['Aron Baynes'+'Celtics'+'serve'+'0'], - EDGES['Aron Baynes'+'Pistons'+'serve'+'0'], - EDGES['Aron Baynes'+'Spurs'+'serve'+'0'], - - EDGES['Boris Diaw'+'Hawks'+'serve'+'0'], - EDGES['Boris Diaw'+'Hornets'+'serve'+'0'], - EDGES['Boris Diaw'+'Jazz'+'serve'+'0'], - EDGES['Boris Diaw'+'Spurs'+'serve'+'0'], - EDGES['Boris Diaw'+'Suns'+'serve'+'0'], - - EDGES['Shaquile O\'Neal'+'Cavaliers'+'serve'+'0'], - EDGES['Shaquile O\'Neal'+'Celtics'+'serve'+'0'], - EDGES['Shaquile O\'Neal'+'Heat'+'serve'+'0'], - EDGES['Shaquile O\'Neal'+'Lakers'+'serve'+'0'], - EDGES['Shaquile O\'Neal'+'Magic'+'serve'+'0'], - EDGES['Shaquile O\'Neal'+'Suns'+'serve'+'0'], - - EDGES['Yao Ming'+'Shaquile O\'Neal'+'like'+'0'], - EDGES['Dejounte Murray'+'Spurs'+'serve'+'0'], - EDGES['LaMarcus Aldridge'+'Spurs'+'serve'+'0'], - EDGES['LaMarcus Aldridge'+'Trail Blazers'+'serve'+'0'], - - EDGES['Damian Lillard'+'LaMarcus Aldridge'+'like'+'0'], - EDGES['Rudy Gay'+'LaMarcus Aldridge'+'like'+'0'], - EDGES['Tony Parker'+'LaMarcus Aldridge'+'like'+'0'], - - EDGES['Marco Belinelli'+'76ers'+'serve'+'0'], - EDGES['Marco Belinelli'+'Bulls'+'serve'+'0'], - EDGES['Marco Belinelli'+'Hawks'+'serve'+'0'], - EDGES['Marco Belinelli'+'Hornets'+'serve'+'0'], - EDGES['Marco Belinelli'+'Kings'+'serve'+'0'], - EDGES['Marco Belinelli'+'Raptors'+'serve'+'0'], - EDGES['Marco Belinelli'+'Spurs'+'serve'+'0'], - EDGES['Marco Belinelli'+'Warriors'+'serve'+'0'], - EDGES['Marco Belinelli'+'Hornets'+'serve'+'1'], - EDGES['Marco Belinelli'+'Spurs'+'serve'+'1'], - - EDGES['Danny Green'+'Marco Belinelli'+'like'+'0'], - EDGES['Dejounte Murray'+'Marco Belinelli'+'like'+'0'], - - EDGES['Tiago Splitter'+'76ers'+'serve'+'0'], - EDGES['Tiago Splitter'+'Hawks'+'serve'+'0'], - EDGES['Tiago Splitter'+'Spurs'+'serve'+'0'] - ] - - vertex3 = [ - VERTEXS['Raptors'], - VERTEXS['Jazz'], - VERTEXS['Cavaliers'], - VERTEXS['Pistons'], - VERTEXS['Damian Lillard'], - VERTEXS['Kings'], - VERTEXS['Hornets'], - VERTEXS['Spurs'], - VERTEXS['Rudy Gay'], - VERTEXS['Yao Ming'], - VERTEXS['Hawks'], - VERTEXS['Heat'], - VERTEXS['Lakers'], - VERTEXS['Celtics'], - VERTEXS['Suns'], - VERTEXS['Magic'], - VERTEXS['Trail Blazers'], - VERTEXS['76ers'], - VERTEXS['Bulls'], - VERTEXS['Warriors'] - ] - - edge3 = [ - EDGES['Rudy Gay'+'Raptors'+'serve'+'0'], - EDGES['Damian Lillard'+'Trail Blazers'+'serve'+'0'], - EDGES['Rudy Gay'+'Kings'+'serve'+'0'], - EDGES['Rudy Gay'+'Spurs'+'serve'+'0'], - - EDGES['Manu Ginobili'+'Tim Duncan'+'teammate'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'teammate'+'0'], - EDGES['Tim Duncan'+'Danny Green'+'teammate'+'0'], - EDGES['Tim Duncan'+'LaMarcus Aldridge'+'teammate'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'teammate'+'0'], - EDGES['Manu Ginobili'+'Tony Parker'+'teammate'+'0'], - EDGES['Tony Parker'+'LaMarcus Aldridge'+'teammate'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'teammate'+'0'] - ] - - expected_data = { - "column_names": ["_vertices", "_edges"], - "rows": [ - [vertex1, edge1], - [vertex2, edge2], - [vertex3, edge3] - ] - } - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - stmt = "GET SUBGRAPH 2 STEPS FROM 'Tim Duncan', 'James Harden' IN teammate OUT serve" - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - - vertex1 = [ - VERTEXS["Tim Duncan"], - VERTEXS["James Harden"] - ] - - edge1 = [ - EDGES['Tim Duncan'+'Spurs'+'serve'+'0'], - EDGES['Manu Ginobili'+'Tim Duncan'+'teammate'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'teammate'+'0'], - EDGES['James Harden'+'Rockets'+'serve'+'0'], - EDGES['James Harden'+'Thunders'+'serve'+'0'], - ] - vertex2 = [ - VERTEXS['Manu Ginobili'], - VERTEXS['Tony Parker'], - ] - - edge2 = [ - EDGES['Manu Ginobili'+'Spurs'+'serve'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Tony Parker'+'Hornets'+'serve'+'0'], - EDGES['Tony Parker'+'Spurs'+'serve'+'0'], - EDGES['Manu Ginobili'+'Tony Parker'+'teammate'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'teammate'+'0'] - ] - - vertex3 = [ - VERTEXS['Hornets'], - VERTEXS['Spurs'] - ] - - edge3 = [ - EDGES['Manu Ginobili'+'Tim Duncan'+'like'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'like'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'like'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'like'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'like'+'0'] - ] - - expected_data = { - "column_names": ["_vertices", "_edges"], - "rows": [ - [vertex1, edge1], - [vertex2, edge2], - [vertex3, edge3] - ] - } - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - stmt = "GET SUBGRAPH 3 STEPS FROM 'Paul George' OUT serve BOTH like" - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - - vertex1 = [VERTEXS["Paul George"]] - - edge1 = [ - EDGES['Russell Westbrook'+'Paul George'+'like'+'0'], - EDGES['Paul George'+'Pacers'+'serve'+'0'], - EDGES['Paul George'+'Thunders'+'serve'+'0'], - EDGES['Paul George'+'Russell Westbrook'+'like'+'0'] - ] - vertex2 = [ - VERTEXS["Russell Westbrook"], - ] - edge2 = [ - EDGES['Dejounte Murray'+'Russell Westbrook'+'like'+'0'], - EDGES['James Harden'+'Russell Westbrook'+'like'+'0'], - EDGES['Russell Westbrook'+'Thunders'+'serve'+'0'], - EDGES['Russell Westbrook'+'James Harden'+'like'+'0'] - ] - vertex3 = [ - VERTEXS["Dejounte Murray"], - VERTEXS["James Harden"] - ] - edge3 = [ - EDGES['Dejounte Murray'+'Spurs'+'serve'+'0'], - EDGES['Dejounte Murray'+'Chris Paul'+'like'+'0'], - EDGES['Dejounte Murray'+'Danny Green'+'like'+'0'], - EDGES['Dejounte Murray'+'James Harden'+'like'+'0'], - EDGES['Dejounte Murray'+'Kevin Durant'+'like'+'0'], - EDGES['Dejounte Murray'+'Kyle Anderson'+'like'+'0'], - EDGES['Dejounte Murray'+'LeBron James'+'like'+'0'], - EDGES['Dejounte Murray'+'Manu Ginobili'+'like'+'0'], - EDGES['Dejounte Murray'+'Marco Belinelli'+'like'+'0'], - EDGES['Dejounte Murray'+'Tim Duncan'+'like'+'0'], - EDGES['Dejounte Murray'+'Tony Parker'+'like'+'0'], - - EDGES['Luka Doncic'+'James Harden'+'like'+'0'], - EDGES['James Harden'+'Rockets'+'serve'+'0'], - EDGES['James Harden'+'Thunders'+'serve'+'0'] - ] - vertex4 = [ - VERTEXS["LeBron James"], - VERTEXS["Marco Belinelli"], - VERTEXS["Danny Green"], - VERTEXS["Rockets"], - VERTEXS["Spurs"], - VERTEXS["Kevin Durant"], - VERTEXS["Kyle Anderson"], - VERTEXS["Tim Duncan"], - VERTEXS["Tony Parker"], - VERTEXS["Chris Paul"], - VERTEXS["Luka Doncic"], - VERTEXS["Manu Ginobili"], - VERTEXS["Pacers"], - VERTEXS["Thunders"] - ] - edge4 = [ - EDGES['Chris Paul'+'LeBron James'+'like'+'0'], - EDGES['Danny Green'+'LeBron James'+'like'+'0'], - EDGES['Danny Green'+'Marco Belinelli'+'like'+'0'], - EDGES['Marco Belinelli'+'Danny Green'+'like'+'0'], - EDGES['Marco Belinelli'+'Tim Duncan'+'like'+'0'], - EDGES['Marco Belinelli'+'Tony Parker'+'like'+'0'], - EDGES['Marco Belinelli'+'Spurs'+'serve'+'0'], - EDGES['Marco Belinelli'+'Spurs'+'serve'+'1'], - - EDGES['Tim Duncan'+'Danny Green'+'teammate'+'0'], - EDGES['Danny Green'+'Tim Duncan'+'like'+'0'], - EDGES['Danny Green'+'Spurs'+'serve'+'0'], - EDGES['Chris Paul'+'Rockets'+'serve'+'0'], - EDGES['Kyle Anderson'+'Spurs'+'serve'+'0'], - EDGES['Manu Ginobili'+'Spurs'+'serve'+'0'], - EDGES['Tim Duncan'+'Spurs'+'serve'+'0'], - EDGES['Tony Parker'+'Spurs'+'serve'+'0'], - - EDGES['Kevin Durant'+'Thunders'+'serve'+'0'], - EDGES['Tony Parker'+'Kyle Anderson'+'teammate'+'0'], - EDGES['Manu Ginobili'+'Tim Duncan'+'teammate'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'teammate'+'0'], - EDGES['Manu Ginobili'+'Tim Duncan'+'like'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'like'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'like'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'like'+'0'], - - EDGES['Tim Duncan'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'teammate'+'0'], - EDGES['Manu Ginobili'+'Tony Parker'+'teammate'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'like'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'teammate'+'0'] - ] - - expected_data = { - "column_names": ["_vertices", "_edges"], - "rows": [ - [vertex1, edge1], - [vertex2, edge2], - [vertex3, edge3], - [vertex4, edge4], - ] - } - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - stmt = "GET SUBGRAPH FROM 'Tony Parker' BOTH like" - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - - vertex1 = [VERTEXS["Tony Parker"]] - - edge1 = [ - EDGES['Boris Diaw'+'Tony Parker'+'like'+'0'], - EDGES['Dejounte Murray'+'Tony Parker'+'like'+'0'], - EDGES['LaMarcus Aldridge'+'Tony Parker'+'like'+'0'], - EDGES['Marco Belinelli'+'Tony Parker'+'like'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'like'+'0'], - EDGES['Tony Parker'+'LaMarcus Aldridge'+'like'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'like'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'like'+'0'] - ] - vertex2 = [ - VERTEXS["Dejounte Murray"], - VERTEXS["LaMarcus Aldridge"], - VERTEXS["Marco Belinelli"], - VERTEXS["Boris Diaw"], - VERTEXS["Tim Duncan"], - VERTEXS["Manu Ginobili"] - ] - edge2 = [ - EDGES['Dejounte Murray'+'Manu Ginobili'+'like'+'0'], - EDGES['Dejounte Murray'+'Marco Belinelli'+'like'+'0'], - EDGES['Dejounte Murray'+'Tim Duncan'+'like'+'0'], - - EDGES['Tim Duncan'+'LaMarcus Aldridge'+'teammate'+'0'], - EDGES['Tony Parker'+'LaMarcus Aldridge'+'teammate'+'0'], - - EDGES['LaMarcus Aldridge'+'Tim Duncan'+'like'+'0'], - EDGES['Marco Belinelli'+'Tim Duncan'+'like'+'0'], - EDGES['Boris Diaw'+'Tim Duncan'+'like'+'0'], - EDGES['Manu Ginobili'+'Tim Duncan'+'teammate'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'teammate'+'0'], - EDGES['Manu Ginobili'+'Tim Duncan'+'like'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'like'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'teammate'+'0'], - - EDGES['Tony Parker'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Manu Ginobili'+'Tony Parker'+'teammate'+'0'] - ] - - expected_data = { - "column_names": ["_vertices", "_edges"], - "rows": [ - [vertex1, edge1], - [vertex2, edge2] - ] - } - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - stmt = "GO FROM 'Tim Duncan' over serve YIELD serve._src AS id | GET SUBGRAPH FROM $-.id" - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - - vertex1 = [VERTEXS['Tim Duncan']] - - edge1 = [ - EDGES['Manu Ginobili'+'Tim Duncan'+'teammate'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'teammate'+'0'], - EDGES['Aron Baynes'+'Tim Duncan'+'like'+'0'], - EDGES['Boris Diaw'+'Tim Duncan'+'like'+'0'], - EDGES['Danny Green'+'Tim Duncan'+'like'+'0'], - EDGES['Dejounte Murray'+'Tim Duncan'+'like'+'0'], - EDGES['LaMarcus Aldridge'+'Tim Duncan'+'like'+'0'], - EDGES['Manu Ginobili'+'Tim Duncan'+'like'+'0'], - EDGES['Marco Belinelli'+'Tim Duncan'+'like'+'0'], - EDGES['Shaquile O\'Neal'+'Tim Duncan'+'like'+'0'], - EDGES['Tiago Splitter'+'Tim Duncan'+'like'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'like'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'like'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'like'+'0'], - EDGES['Tim Duncan'+'Spurs'+'serve'+'0'], - EDGES['Tim Duncan'+'Danny Green'+'teammate'+'0'], - EDGES['Tim Duncan'+'LaMarcus Aldridge'+'teammate'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'teammate'+'0'] - ] - - vertex2 = [ - VERTEXS['Danny Green'], - VERTEXS['Manu Ginobili'], - VERTEXS['Aron Baynes'], - VERTEXS['Boris Diaw'], - VERTEXS['Shaquile O\'Neal'], - VERTEXS['Tony Parker'], - VERTEXS['Spurs'], - VERTEXS['Dejounte Murray'], - VERTEXS['LaMarcus Aldridge'], - VERTEXS['Marco Belinelli'], - VERTEXS['Tiago Splitter'] - ] - - edge2 = [ - EDGES['Dejounte Murray'+'Danny Green'+'like'+'0'], - EDGES['Marco Belinelli'+'Danny Green'+'like'+'0'], - EDGES['Danny Green'+'Marco Belinelli'+'like'+'0'], - EDGES['Danny Green'+'Spurs'+'serve'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Dejounte Murray'+'Manu Ginobili'+'like'+'0'], - EDGES['Tiago Splitter'+'Manu Ginobili'+'like'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'like'+'0'], - EDGES['Manu Ginobili'+'Spurs'+'serve'+'0'], - EDGES['Manu Ginobili'+'Tony Parker'+'teammate'+'0'], - EDGES['Aron Baynes'+'Spurs'+'serve'+'0'], - EDGES['Boris Diaw'+'Tony Parker'+'like'+'0'], - EDGES['Boris Diaw'+'Spurs'+'serve'+'0'], - EDGES['Dejounte Murray'+'Tony Parker'+'like'+'0'], - EDGES['LaMarcus Aldridge'+'Tony Parker'+'like'+'0'], - EDGES['Marco Belinelli'+'Tony Parker'+'like'+'0'], - EDGES['Tony Parker'+'LaMarcus Aldridge'+'like'+'0'], - EDGES['Tony Parker'+'Spurs'+'serve'+'0'], - EDGES['Tony Parker'+'LaMarcus Aldridge'+'teammate'+'0'], - EDGES['Dejounte Murray'+'Spurs'+'serve'+'0'], - EDGES['LaMarcus Aldridge'+'Spurs'+'serve'+'0'], - EDGES['Marco Belinelli'+'Spurs'+'serve'+'0'], - EDGES['Tiago Splitter'+'Spurs'+'serve'+'0'], - EDGES['Marco Belinelli'+'Spurs'+'serve'+'1'], - EDGES['Dejounte Murray'+'Marco Belinelli'+'like'+'0'] - ] - - expected_data = { - "column_names": ["_vertices", "_edges"], - "rows": [ - [vertex1, edge1], - [vertex2, edge2] - ] - } - - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) - - stmt = '''$a = GO FROM 'Tim Duncan' over serve YIELD serve._src AS id; - GET SUBGRAPH FROM $a.id''' - resp = self.execute(stmt) - self.check_resp_succeeded(resp) - - vertex1 = [VERTEXS['Tim Duncan']] - - edge1 = [ - EDGES['Manu Ginobili'+'Tim Duncan'+'teammate'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'teammate'+'0'], - EDGES['Aron Baynes'+'Tim Duncan'+'like'+'0'], - EDGES['Boris Diaw'+'Tim Duncan'+'like'+'0'], - EDGES['Danny Green'+'Tim Duncan'+'like'+'0'], - EDGES['Dejounte Murray'+'Tim Duncan'+'like'+'0'], - EDGES['LaMarcus Aldridge'+'Tim Duncan'+'like'+'0'], - EDGES['Manu Ginobili'+'Tim Duncan'+'like'+'0'], - EDGES['Marco Belinelli'+'Tim Duncan'+'like'+'0'], - EDGES['Shaquile O\'Neal'+'Tim Duncan'+'like'+'0'], - EDGES['Tiago Splitter'+'Tim Duncan'+'like'+'0'], - EDGES['Tony Parker'+'Tim Duncan'+'like'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'like'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'like'+'0'], - EDGES['Tim Duncan'+'Spurs'+'serve'+'0'], - EDGES['Tim Duncan'+'Danny Green'+'teammate'+'0'], - EDGES['Tim Duncan'+'LaMarcus Aldridge'+'teammate'+'0'], - EDGES['Tim Duncan'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Tim Duncan'+'Tony Parker'+'teammate'+'0'] - ] - - vertex2 = [ - VERTEXS['Danny Green'], - VERTEXS['Manu Ginobili'], - VERTEXS['Aron Baynes'], - VERTEXS['Boris Diaw'], - VERTEXS['Shaquile O\'Neal'], - VERTEXS['Tony Parker'], - VERTEXS['Spurs'], - VERTEXS['Dejounte Murray'], - VERTEXS['LaMarcus Aldridge'], - VERTEXS['Marco Belinelli'], - VERTEXS['Tiago Splitter'] - ] - - edge2 = [ - EDGES['Dejounte Murray'+'Danny Green'+'like'+'0'], - EDGES['Marco Belinelli'+'Danny Green'+'like'+'0'], - EDGES['Danny Green'+'Marco Belinelli'+'like'+'0'], - EDGES['Danny Green'+'Spurs'+'serve'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'teammate'+'0'], - EDGES['Dejounte Murray'+'Manu Ginobili'+'like'+'0'], - EDGES['Tiago Splitter'+'Manu Ginobili'+'like'+'0'], - EDGES['Tony Parker'+'Manu Ginobili'+'like'+'0'], - EDGES['Manu Ginobili'+'Spurs'+'serve'+'0'], - EDGES['Manu Ginobili'+'Tony Parker'+'teammate'+'0'], - EDGES['Aron Baynes'+'Spurs'+'serve'+'0'], - EDGES['Boris Diaw'+'Tony Parker'+'like'+'0'], - EDGES['Boris Diaw'+'Spurs'+'serve'+'0'], - EDGES['Dejounte Murray'+'Tony Parker'+'like'+'0'], - EDGES['LaMarcus Aldridge'+'Tony Parker'+'like'+'0'], - EDGES['Marco Belinelli'+'Tony Parker'+'like'+'0'], - EDGES['Tony Parker'+'LaMarcus Aldridge'+'like'+'0'], - EDGES['Tony Parker'+'Spurs'+'serve'+'0'], - EDGES['Tony Parker'+'LaMarcus Aldridge'+'teammate'+'0'], - EDGES['Dejounte Murray'+'Spurs'+'serve'+'0'], - EDGES['LaMarcus Aldridge'+'Spurs'+'serve'+'0'], - EDGES['Marco Belinelli'+'Spurs'+'serve'+'0'], - EDGES['Tiago Splitter'+'Spurs'+'serve'+'0'], - EDGES['Marco Belinelli'+'Spurs'+'serve'+'1'], - EDGES['Dejounte Murray'+'Marco Belinelli'+'like'+'0'] - ] - - expected_data = { - "column_names": ["_vertices", "_edges"], - "rows": [ - [vertex1, edge1], - [vertex2, edge2] - ] - } - - self.check_column_names(resp, expected_data["column_names"]) - check_subgraph_result(resp, expected_data["rows"]) diff --git a/tests/tck/conftest.py b/tests/tck/conftest.py index d0d533f8a89779fa81af41f5d476d29e3202032f..1a565b46f9e914cbe20e9466b80f6c5897e8175b 100644 --- a/tests/tck/conftest.py +++ b/tests/tck/conftest.py @@ -41,15 +41,15 @@ def graph_spaces(): def preload_space( space, load_nba_data, - # load_nba_int_vid_data, + load_nba_int_vid_data, load_student_data, session, graph_spaces, ): if space == "nba": graph_spaces["space_desc"] = load_nba_data - # elif space == "nba_int_vid": - # graph_spaces["space_desc"] = load_nba_int_vid_data + elif space == "nba_int_vid": + graph_spaces["space_desc"] = load_nba_int_vid_data elif space == "student": graph_spaces["space_desc"] = load_student_data else: @@ -205,17 +205,18 @@ def execution_should_be_succ(graph_spaces): @then(rparse(r"a (?P<err_type>\w+) should be raised at (?P<time>runtime|compile time)(?P<sym>:|.)(?P<msg>.*)")) def raised_type_error(err_type, time, sym, msg, graph_spaces): res = graph_spaces["result_set"] + ngql = graph_spaces['ngql'] assert not res.is_succeeded(), "Response should be failed" err_type = err_type.strip() - msg = msg.strip().replace('$', r'\$').replace('^', r"\^") + msg = msg.strip() res_msg = res.error_msg() if res.error_code() == ErrorCode.E_EXECUTION_ERROR: assert err_type == "ExecutionError" - expect_msg = r"{}".format(msg) + expect_msg = "{}".format(msg) else: - expect_msg = r"{}: {}".format(err_type, msg) - m = re.search(expect_msg, res_msg) - assert m, f'Could not find "{expect_msg}" in "{res_msg}"' + expect_msg = "{}: {}".format(err_type, msg) + m = res_msg.startswith(expect_msg) + assert m, f'Could not find "{expect_msg}" in "{res_msg}, ngql:{ngql}"' @then("drop the used space") diff --git a/tests/tck/features/fetch/FetchEdges.intVid.feature b/tests/tck/features/fetch/FetchEdges.intVid.feature index e18c581198aa7e4f6b9c60300f04e34298316107..0d1ed115f5da32008979ec62d4506a556fcb69a0 100644 --- a/tests/tck/features/fetch/FetchEdges.intVid.feature +++ b/tests/tck/features/fetch/FetchEdges.intVid.feature @@ -1,4 +1,3 @@ -@skip Feature: Fetch Int Vid Edges Background: Prepare space @@ -76,6 +75,7 @@ Feature: Fetch Int Vid Edges | serve._src | serve._dst | serve._rank | serve.start_year | serve.end_year | | hash("Boris Diaw") | hash("Hawks") | 0 | 2003 | 2005 | + @skip Scenario: [8] Fetch prop works with uuid When executing query: """ @@ -112,6 +112,7 @@ Feature: Fetch Int Vid Edges | serve._src | serve._dst | serve._rank | serve.start_year | serve.end_year | | hash("Boris Diaw") | hash("Hawks") | 0 | 2003 | 2005 | + @skip Scenario: [12] Fetch prop works with uuid, but without YIELD When executing query: """ @@ -212,6 +213,7 @@ Feature: Fetch Int Vid Edges Then the result should be, in any order: | serve._src | serve._dst | serve._rank | serve.start_year | + @skip Scenario: [23] Fetch prop Semantic Error When executing query: """ diff --git a/tests/tck/features/fetch/FetchVertices.intVid.feature b/tests/tck/features/fetch/FetchVertices.intVid.feature index b7ceebfe00d4cb71843abb73c2afeb326c1a34a2..da0caac2d592d404c6957314703ed5217b79022d 100644 --- a/tests/tck/features/fetch/FetchVertices.intVid.feature +++ b/tests/tck/features/fetch/FetchVertices.intVid.feature @@ -1,4 +1,3 @@ -@skip Feature: Fetch Int Vid Vertices Background: Prepare space @@ -44,7 +43,7 @@ Feature: Fetch Int Vid Vertices """ $var = GO FROM hash('Boris Diaw') over like YIELD like._dst as id; FETCH PROP ON player $var.id YIELD player.name, player.age """ - Then the result should be, in any order, with relax comparision: + Then the result should be, in any order, with relax comparison: | VertexID | player.name | player.age | | hash("Tony Parker") | "Tony Parker" | 36 | | hash("Tim Duncan") | "Tim Duncan" | 42 | @@ -54,7 +53,7 @@ Feature: Fetch Int Vid Vertices """ $var = GO FROM hash('Boris Diaw') over like YIELD like._dst as id; FETCH PROP ON player $var.id YIELD player.name as name, player.age | ORDER BY name """ - Then the result should be, in any order, with relax comparision: + Then the result should be, in any order, with relax comparison: | VertexID | name | player.age | | hash("Tim Duncan") | "Tim Duncan" | 42 | | hash("Tony Parker") | "Tony Parker" | 36 | @@ -64,16 +63,17 @@ Feature: Fetch Int Vid Vertices """ FETCH PROP ON player hash('Boris Diaw') YIELD player.name, player.age """ - Then the result should be, in any order, with relax comparision: + Then the result should be, in any order, with relax comparison: | VertexID | player.name | player.age | | hash("Boris Diaw") | "Boris Diaw" | 36 | + @skip Scenario: [8] Fetch Vertices works with uuid() and YIELD When executing query: """ FETCH PROP ON player uuid('Boris Diaw') YIELD player.name, player.age """ - Then the result should be, in any order, with relax comparision: + Then the result should be, in any order, with relax comparison: | VertexID | player.name | player.age | | -7391649757168799460 | "Boris Diaw" | 36 | @@ -82,16 +82,17 @@ Feature: Fetch Int Vid Vertices """ FETCH PROP ON player hash('Boris Diaw') """ - Then the result should be, in any order, with relax comparision: + Then the result should be, in any order, with relax comparison: | VertexID | player.name | player.age | | hash("Boris Diaw") | "Boris Diaw" | 36 | + @skip Scenario: [10] Fetch Vertices works with uuid(), without YIELD When executing query: """ FETCH PROP ON player uuid('Boris Diaw') """ - Then the result should be, in any order, with relax comparision: + Then the result should be, in any order, with relax comparison: | VertexID | player.name | player.age | | -7391649757168799460 | "Boris Diaw" | 36 | @@ -100,7 +101,7 @@ Feature: Fetch Int Vid Vertices """ FETCH PROP ON player hash('Boris Diaw'), hash('Boris Diaw') YIELD DISTINCT player.name, player.age """ - Then the result should be, in any order, with relax comparision: + Then the result should be, in any order, with relax comparison: | VertexID | player.name | player.age | | hash("Boris Diaw") | "Boris Diaw" | 36 | @@ -109,7 +110,7 @@ Feature: Fetch Int Vid Vertices """ FETCH PROP ON player hash('Boris Diaw'), hash('Boris Diaw') YIELD DISTINCT player.age """ - Then the result should be, in any order, with relax comparision: + Then the result should be, in any order, with relax comparison: | VertexID | player.age | | hash("Boris Diaw") | 36 | diff --git a/tests/tck/features/go/go.IntVid.feature b/tests/tck/features/go/go.IntVid.feature index 852c19561d03a18eb9f761c552767d6e001baf32..c5c6fe24004920d6495b10f70c0eb16d3825749b 100644 --- a/tests/tck/features/go/go.IntVid.feature +++ b/tests/tck/features/go/go.IntVid.feature @@ -2,7 +2,6 @@ # # This source code is licensed under Apache 2.0 License, # attached with Common Clause Condition 1.0, found in the LICENSES directory. -@skip Feature: IntegerVid Go Sentence Background: Prepare space @@ -758,7 +757,7 @@ Feature: IntegerVid Go Sentence | hash("Danny Green") | | hash("Aron Baynes") | | hash("Boris Diaw") | - | hash(("Tiago Splitter") | + | hash("Tiago Splitter") | | hash("Dejounte Murray") | | hash("Shaquile O'Neal") | | EMPTY | @@ -1584,3 +1583,13 @@ Feature: IntegerVid Go Sentence | hash("Tony Parker") | hash("LaMarcus Aldridge" ) | hash("LaMarcus Aldridge" ) | hash("Tony Parker") | | hash("Tony Parker") | hash("LaMarcus Aldridge" ) | hash("Manu Ginobili" ) | hash("Tim Duncan" ) | | hash("Tony Parker") | hash("LaMarcus Aldridge" ) | hash("LaMarcus Aldridge" ) | hash("Tim Duncan" ) | + + Scenario: Integer Vid GroupBy and Count + When executing query: + """ + GO 1 TO 2 STEPS FROM hash("Tim Duncan") OVER like WHERE like._dst != hash("YAO MING") YIELD like._dst AS vid + | GROUP BY $-.vid YIELD 1 AS id | GROUP BY $-.id YIELD COUNT($-.id); + """ + Then the result should be, in any order, with relax comparison: + | COUNT($-.id) | + | 4 | diff --git a/tests/tck/features/go/go.feature b/tests/tck/features/go/go.feature index daa4f53910320817f6a0ece1b4bef16fcf1e2cc5..5556140271789f723ed79a39db4e0c3ed6b33990 100644 --- a/tests/tck/features/go/go.feature +++ b/tests/tck/features/go/go.feature @@ -1583,3 +1583,13 @@ Feature: Go Sentence | "Tony Parker" | "LaMarcus Aldridge" | "LaMarcus Aldridge" | "Tony Parker" | | "Tony Parker" | "LaMarcus Aldridge" | "Manu Ginobili" | "Tim Duncan" | | "Tony Parker" | "LaMarcus Aldridge" | "LaMarcus Aldridge" | "Tim Duncan" | + + Scenario: GroupBy and Count + When executing query: + """ + GO 1 TO 2 STEPS FROM "Tim Duncan" OVER like WHERE like._dst != "YAO MING" YIELD like._dst AS vid + | GROUP BY $-.vid YIELD 1 AS id | GROUP BY $-.id YIELD COUNT($-.id); + """ + Then the result should be, in any order, with relax comparison: + | COUNT($-.id) | + | 4 | diff --git a/tests/tck/features/loopup/LookUp.feature b/tests/tck/features/lookup/LookUp.feature similarity index 100% rename from tests/tck/features/loopup/LookUp.feature rename to tests/tck/features/lookup/LookUp.feature diff --git a/tests/tck/features/lookup/Output.feature b/tests/tck/features/lookup/Output.feature index 838209ea80eaebe0404f342d25abb42207d5bf50..3f4d0ba9810ae09cf7ae0f1644ba6cf72d70b63c 100644 --- a/tests/tck/features/lookup/Output.feature +++ b/tests/tck/features/lookup/Output.feature @@ -1,3 +1,4 @@ +@abc Feature: Lookup with output Background: Prepare space diff --git a/tests/tck/features/match/VariableLengthPattern.intVid.feature b/tests/tck/features/match/VariableLengthPattern.intVid.feature new file mode 100644 index 0000000000000000000000000000000000000000..5feb7f345af95deb61765e7481348d8cbeb2dd20 --- /dev/null +++ b/tests/tck/features/match/VariableLengthPattern.intVid.feature @@ -0,0 +1,319 @@ +# 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: Integer Vid Variable length Pattern match (m to n) + + Background: + Given a graph with space named "nba_int_vid" + + Scenario: Integer Vid single both direction edge with properties + When executing query: + """ + MATCH (:player{name:"Tim Duncan"})-[e:serve*2..3{start_year: 2000}]-(v) + RETURN e, v + """ + Then the result should be, in any order: + | e | v | + When executing query: + """ + MATCH (:player{name:"Tim Duncan"})-[e:like*2..3{likeness: 90}]-(v) + RETURN e, v + """ + Then the result should be, in any order, with relax comparison: + | e | v | + | [[:like "Tim Duncan"<-"Manu Ginobili"], [:like "Manu Ginobili"<-"Tiago Splitter"]] | ("Tiago Splitter") | + + Scenario: Integer Vid single direction edge with properties + When executing query: + """ + MATCH (:player{name:"Tim Duncan"})-[e:serve*2..3{start_year: 2000}]->(v) + RETURN e, v + """ + Then the result should be, in any order: + | e | v | + When executing query: + """ + MATCH (:player{name:"Tim Duncan"})-[e:like*2..3{likeness: 90}]->(v) + RETURN e, v + """ + Then the result should be, in any order: + | e | v | + When executing query: + """ + MATCH (:player{name:"Tim Duncan"})<-[e:like*2..3{likeness: 90}]-(v) + RETURN e, v + """ + Then the result should be, in any order, with relax comparison: + | e | v | + | [[:like "Tim Duncan"<-"Manu Ginobili"], [:like "Manu Ginobili"<-"Tiago Splitter"]] | ("Tiago Splitter") | + + Scenario: Integer Vid single both direction edge without properties + When executing query: + """ + MATCH (:player{name:"Tim Duncan"})-[e:serve*2..3]-(v) + RETURN e, v + """ + Then the result should be, in any order, with relax comparison: + | e | v | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Dejounte Murray"]] | ("Dejounte Murray") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"]] | ("Marco Belinelli") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"], [:serve "Marco Belinelli"->"Bulls"]] | ("Bulls") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"], [:serve "Marco Belinelli"->"Hornets"]] | ("Hornets") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"], [:serve "Marco Belinelli"->"Hawks"]] | ("Hawks") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"], [:serve "Marco Belinelli"->"76ers"]] | ("76ers") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"], [:serve "Marco Belinelli"->"Spurs"@1]] | ("Spurs") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"], [:serve "Marco Belinelli"->"Hornets"@1]] | ("Hornets") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"], [:serve "Marco Belinelli"->"Raptors"]] | ("Raptors") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"], [:serve "Marco Belinelli"->"Warriors"]] | ("Warriors") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"], [:serve "Marco Belinelli"->"Kings"]] | ("Kings") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Danny Green"]] | ("Danny Green") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Danny Green"], [:serve "Danny Green"->"Cavaliers"]] | ("Cavaliers") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Danny Green"], [:serve "Danny Green"->"Raptors"]] | ("Raptors") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Aron Baynes"]] | ("Aron Baynes") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Aron Baynes"], [:serve "Aron Baynes"->"Pistons"]] | ("Pistons") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Aron Baynes"], [:serve "Aron Baynes"->"Celtics"]] | ("Celtics") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Jonathon Simmons"]] | ("Jonathon Simmons") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Jonathon Simmons"], [:serve "Jonathon Simmons"->"76ers"]] | ("76ers") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Jonathon Simmons"], [:serve "Jonathon Simmons"->"Magic"]] | ("Magic") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Rudy Gay"]] | ("Rudy Gay") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Rudy Gay"], [:serve "Rudy Gay"->"Raptors"]] | ("Raptors") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Rudy Gay"], [:serve "Rudy Gay"->"Kings"]] | ("Kings") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Rudy Gay"], [:serve "Rudy Gay"->"Grizzlies"]] | ("Grizzlies") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Tony Parker"]] | ("Tony Parker") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Tony Parker"], [:serve "Tony Parker"->"Hornets"]] | ("Hornets") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Manu Ginobili"]] | ("Manu Ginobili") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"David West"]] | ("David West") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"David West"], [:serve "David West"->"Pacers"]] | ("Pacers") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"David West"], [:serve "David West"->"Warriors"]] | ("Warriors") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"David West"], [:serve "David West"->"Hornets"]] | ("Hornets") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Tracy McGrady"]] | ("Tracy McGrady") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Tracy McGrady"], [:serve "Tracy McGrady"->"Raptors"]] | ("Raptors") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Tracy McGrady"], [:serve "Tracy McGrady"->"Magic"]] | ("Magic") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Tracy McGrady"], [:serve "Tracy McGrady"->"Rockets"]] | ("Rockets") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"@1]] | ("Marco Belinelli") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"@1], [:serve "Marco Belinelli"->"Bulls"]] | ("Bulls") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"@1], [:serve "Marco Belinelli"->"Spurs"]] | ("Spurs") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"@1], [:serve "Marco Belinelli"->"Hornets"]] | ("Hornets") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"@1], [:serve "Marco Belinelli"->"Hawks"]] | ("Hawks") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"@1], [:serve "Marco Belinelli"->"76ers"]] | ("76ers") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"@1], [:serve "Marco Belinelli"->"Hornets"]] | ("Hornets") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"@1], [:serve "Marco Belinelli"->"Raptors"]] | ("Raptors") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"@1], [:serve "Marco Belinelli"->"Warriors"]] | ("Warriors") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Marco Belinelli"@1], [:serve "Marco Belinelli"->"Kings"]] | ("Kings") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Paul Gasol"]] | ("Paul Gasol") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Paul Gasol"], [:serve "Paul Gasol"->"Lakers"]] | ("Lakers") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Paul Gasol"], [:serve "Paul Gasol"->"Bulls"]] | ("Bulls") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Paul Gasol"], [:serve "Paul Gasol"->"Grizzlies"]] | ("Grizzlies") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Paul Gasol"], [:serve "Paul Gasol"->"Bucks"]] | ("Bucks") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"LaMarcus Aldridge"]] | ("LaMarcus Aldridge") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"LaMarcus Aldridge"], [:serve "LaMarcus Aldridge"->"Trail Blazers"]] | ("Trail Blazers") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Tiago Splitter"]] | ("Tiago Splitter") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Tiago Splitter"], [:serve "Tiago Splitter"->"Hawks"]] | ("Hawks") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Tiago Splitter"], [:serve "Tiago Splitter"->"76ers"]] | ("76ers") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Cory Joseph"]] | ("Cory Joseph") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Cory Joseph"], [:serve "Cory Joseph"->"Pacers"]] | ("Pacers") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Cory Joseph"], [:serve "Cory Joseph"->"Raptors"]] | ("Raptors") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Kyle Anderson"]] | ("Kyle Anderson") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Kyle Anderson"], [:serve "Kyle Anderson"->"Grizzlies"]] | ("Grizzlies") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Boris Diaw"]] | ("Boris Diaw") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Boris Diaw"], [:serve "Boris Diaw"->"Suns"]] | ("Suns") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Boris Diaw"], [:serve "Boris Diaw"->"Jazz"]] | ("Jazz") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Boris Diaw"], [:serve "Boris Diaw"->"Hawks"]] | ("Hawks") | + | [[:serve "Tim Duncan"->"Spurs"], [:serve "Spurs"<-"Boris Diaw"], [:serve "Boris Diaw"->"Hornets"]] | ("Hornets") | + + Scenario: Integer Vid single both direction edge without properties + When executing query: + """ + MATCH (:player{name: "Tim Duncan"})-[e:like*2..3]-(v) + RETURN e | + YIELD COUNT(*) + """ + Then the result should be, in any order: + | COUNT(*) | + | 292 | + + Scenario: Integer Vid single direction edge without properties + When executing query: + """ + MATCH (:player{name:"Tim Duncan"})-[e:serve*2..3]->(v) + RETURN e, v + """ + Then the result should be, in any order: + | e | v | + When executing query: + """ + MATCH (:player{name: "Tim Duncan"})-[e:like*2..3]->(v) + RETURN e, v + """ + Then the result should be, in any order, with relax comparison: + | e | v | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"Tim Duncan"]] | ("Tim Duncan") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"Tim Duncan"], [:like "Tim Duncan"->"Manu Ginobili"]] | ("Manu Ginobili") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"Manu Ginobili"]] | ("Manu Ginobili") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"Manu Ginobili"], [:like "Manu Ginobili"->"Tim Duncan"]] | ("Tim Duncan") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"LaMarcus Aldridge"]] | ("LaMarcus Aldridge") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"LaMarcus Aldridge"], [:like "LaMarcus Aldridge"->"Tony Parker"]] | ("Tony Parker") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"LaMarcus Aldridge"], [:like "LaMarcus Aldridge"->"Tim Duncan"]] | ("Tim Duncan") | + | [[:like "Tim Duncan"->"Manu Ginobili"], [:like "Manu Ginobili"->"Tim Duncan"]] | ("Tim Duncan") | + | [[:like "Tim Duncan"->"Manu Ginobili"], [:like "Manu Ginobili"->"Tim Duncan"], [:like "Tim Duncan"->"Tony Parker"]] | ("Tony Parker") | + + Scenario: Integer Vid multiple both direction edge with properties + When executing query: + """ + MATCH (:player{name: "Tim Duncan"})-[e:serve|like*2..3{likeness: 90}]-(v) + RETURN e, v + """ + Then the result should be, in any order, with relax comparison: + | e | v | + | [[:like "Tim Duncan"<-"Manu Ginobili"], [:like "Manu Ginobili"<-"Tiago Splitter"]] | ("Tiago Splitter") | + When executing query: + """ + MATCH (:player{name:"Tim Duncan"})-[e:serve|like*2..3{start_year: 2000}]-(v) + RETURN e, v + """ + Then the result should be, in any order: + | e | v | + + Scenario: Integer Vid multiple direction edge with properties + When executing query: + """ + MATCH (:player{name:"Tim Duncan"})-[e:serve|like*2..3{likeness: 90}]->(v) + RETURN e, v + """ + Then the result should be, in any order: + | e | v | + When executing query: + """ + MATCH (:player{name:"Tim Duncan"})<-[e:serve|like*2..3{likeness: 90}]-(v) + RETURN e, v + """ + Then the result should be, in any order, with relax comparison: + | e | v | + | [[:like "Tim Duncan"<-"Manu Ginobili"], [:like "Manu Ginobili"<-"Tiago Splitter"]] | ("Tiago Splitter") | + + Scenario: Integer Vid multiple both direction edge without properties + When executing query: + """ + MATCH (:player{name:"Tim Duncan"})-[e:serve|like*2..3]-(v) + RETURN e | + YIELD COUNT(*) + """ + Then the result should be, in any order: + | COUNT(*) | + | 927 | + + Scenario: Integer Vid multiple direction edge without properties + When executing query: + """ + MATCH (:player{name: "Tim Duncan"})-[e:serve|like*2..3]->(v) + RETURN e, v + """ + Then the result should be, in any order, with relax comparison: + | e | v | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"Tim Duncan"]] | ("Tim Duncan") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"Tim Duncan"], [:like "Tim Duncan"->"Manu Ginobili"]] | ("Manu Ginobili") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"Tim Duncan"], [:serve "Tim Duncan"->"Spurs"]] | ("Spurs") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"Manu Ginobili"]] | ("Manu Ginobili") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"Manu Ginobili"], [:like "Manu Ginobili"->"Tim Duncan"]] | ("Tim Duncan") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"Manu Ginobili"], [:serve "Manu Ginobili"->"Spurs"]] | ("Spurs") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"LaMarcus Aldridge"]] | ("LaMarcus Aldridge") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"LaMarcus Aldridge"], [:like "LaMarcus Aldridge"->"Tony Parker"]] | ("Tony Parker") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"LaMarcus Aldridge"], [:like "LaMarcus Aldridge"->"Tim Duncan"]] | ("Tim Duncan") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"LaMarcus Aldridge"], [:serve "LaMarcus Aldridge"->"Trail Blazers"]] | ("Trail Blazers") | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"LaMarcus Aldridge"], [:serve "LaMarcus Aldridge"->"Spurs"]] | ("Spurs") | + | [[:like "Tim Duncan"->"Tony Parker"], [:serve "Tony Parker"->"Hornets"]] | ("Hornets") | + | [[:like "Tim Duncan"->"Tony Parker"], [:serve "Tony Parker"->"Spurs"]] | ("Spurs") | + | [[:like "Tim Duncan"->"Manu Ginobili"], [:like "Manu Ginobili"->"Tim Duncan"]] | ("Tim Duncan") | + | [[:like "Tim Duncan"->"Manu Ginobili"], [:like "Manu Ginobili"->"Tim Duncan"], [:like "Tim Duncan"->"Tony Parker"]] | ("Tony Parker") | + | [[:like "Tim Duncan"->"Manu Ginobili"], [:like "Manu Ginobili"->"Tim Duncan"], [:serve "Tim Duncan"->"Spurs"]] | ("Spurs") | + | [[:like "Tim Duncan"->"Manu Ginobili"], [:serve "Manu Ginobili"->"Spurs"]] | ("Spurs") | + + Scenario: Integer Vid return all + When executing query: + """ + MATCH (:player{name:"Tim Duncan"})-[e:like*2..3]->() + RETURN * + """ + Then the result should be, in any order, with relax comparison: + | e | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"Tim Duncan"]] | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"Tim Duncan"], [:like "Tim Duncan"->"Manu Ginobili"]] | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"Manu Ginobili"]] | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"Manu Ginobili"], [:like "Manu Ginobili"->"Tim Duncan"]] | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"LaMarcus Aldridge"]] | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"LaMarcus Aldridge"], [:like "LaMarcus Aldridge"->"Tony Parker"]] | + | [[:like "Tim Duncan"->"Tony Parker"], [:like "Tony Parker"->"LaMarcus Aldridge"], [:like "LaMarcus Aldridge"->"Tim Duncan"]] | + | [[:like "Tim Duncan"->"Manu Ginobili"], [:like "Manu Ginobili"->"Tim Duncan"]] | + | [[:like "Tim Duncan"->"Manu Ginobili"], [:like "Manu Ginobili"->"Tim Duncan"], [:like "Tim Duncan"->"Tony Parker"]] | + + Scenario: Integer Vid from one step + When executing query: + """ + MATCH (v:player{name: 'Tim Duncan'})-[e:like*1]-() + RETURN e + """ + Then the result should be, in any order, with relax comparison: + | e | + | [[:like "Tim Duncan"->"Manu Ginobili"]] | + | [[:like "Tim Duncan"->"Tony Parker"]] | + | [[:like "Tim Duncan"<-"Dejounte Murray"]] | + | [[:like "Tim Duncan"<-"Shaquile O'Neal"]] | + | [[:like "Tim Duncan"<-"Marco Belinelli"]] | + | [[:like "Tim Duncan"<-"Boris Diaw"]] | + | [[:like "Tim Duncan"<-"Manu Ginobili"]] | + | [[:like "Tim Duncan"<-"Danny Green"]] | + | [[:like "Tim Duncan"<-"Tiago Splitter"]] | + | [[:like "Tim Duncan"<-"Aron Baynes"]] | + | [[:like "Tim Duncan"<-"Tony Parker"]] | + | [[:like "Tim Duncan"<-"LaMarcus Aldridge"]] | + + Scenario: Integer Vid from one step to one step + When executing query: + """ + MATCH (v:player{name: 'Tim Duncan'})-[e:like*1..1]-() + RETURN e + """ + Then the result should be, in any order, with relax comparison: + | e | + | [[:like "Tim Duncan"->"Manu Ginobili"]] | + | [[:like "Tim Duncan"->"Tony Parker"]] | + | [[:like "Tim Duncan"<-"Dejounte Murray"]] | + | [[:like "Tim Duncan"<-"Shaquile O'Neal"]] | + | [[:like "Tim Duncan"<-"Marco Belinelli"]] | + | [[:like "Tim Duncan"<-"Boris Diaw"]] | + | [[:like "Tim Duncan"<-"Manu Ginobili"]] | + | [[:like "Tim Duncan"<-"Danny Green"]] | + | [[:like "Tim Duncan"<-"Tiago Splitter"]] | + | [[:like "Tim Duncan"<-"Aron Baynes"]] | + | [[:like "Tim Duncan"<-"Tony Parker"]] | + | [[:like "Tim Duncan"<-"LaMarcus Aldridge"]] | + + Scenario: Integer Vid filter by edges + When executing query: + """ + MATCH (v:player{name: 'Tim Duncan'})-[e:like*2..3]-() + WHERE e[1].likeness>95 AND e[2].likeness==100 + RETURN e + """ + Then the result should be, in any order, with relax comparison: + | e | + | [[:like "Tim Duncan"<-"Dejounte Murray"], [:like "Dejounte Murray"->"LeBron James"], [:like "LeBron James"->"Ray Allen"]] | + + Scenario: Integer Vid multi-steps and filter by node properties + When executing query: + """ + MATCH (v:player{name: 'Tim Duncan'})-[e1:like*1..2]-(v2{name: 'Tony Parker'})-[e2:serve]-(v3{name: 'Spurs'}) + RETURN e1, e2 + """ + Then the result should be, in any order, with relax comparison: + | e1 | e2 | + | [[:like "Tim Duncan"<-"Dejounte Murray"], [:like "Dejounte Murray"->"Tony Parker"]] | [:serve "Tony Parker"->"Spurs"] | + | [[:like "Tim Duncan"->"Manu Ginobili"], [:like "Manu Ginobili"<-"Tony Parker"]] | [:serve "Tony Parker"->"Spurs"] | + | [[:like "Tim Duncan"<-"Marco Belinelli"], [:like "Marco Belinelli"->"Tony Parker"]] | [:serve "Tony Parker"->"Spurs"] | + | [[:like "Tim Duncan"<-"Boris Diaw"], [:like "Boris Diaw"->"Tony Parker"]] | [:serve "Tony Parker"->"Spurs"] | + | [[:like "Tim Duncan"<-"Manu Ginobili"], [:like "Manu Ginobili"<-"Tony Parker"]] | [:serve "Tony Parker"->"Spurs"] | + | [[:like "Tim Duncan"<-"LaMarcus Aldridge"], [:like "LaMarcus Aldridge"->"Tony Parker"]] | [:serve "Tony Parker"->"Spurs"] | + | [[:like "Tim Duncan"<-"LaMarcus Aldridge"], [:like "LaMarcus Aldridge"<-"Tony Parker"]] | [:serve "Tony Parker"->"Spurs"] | + | [[:like "Tim Duncan"->"Tony Parker"]] | [:serve "Tony Parker"->"Spurs"] | + | [[:like "Tim Duncan"<-"Tony Parker"]] | [:serve "Tony Parker"->"Spurs"] | diff --git a/tests/tck/features/path/AllPath.IntVid.feature b/tests/tck/features/path/AllPath.IntVid.feature index c7f4bbcfc7359bdb898ce0cd6fa9e62ba33ea3bb..2fd3cc4b2803fd2e9e47d71ca9aae8823d17537c 100644 --- a/tests/tck/features/path/AllPath.IntVid.feature +++ b/tests/tck/features/path/AllPath.IntVid.feature @@ -2,7 +2,6 @@ # # This source code is licensed under Apache 2.0 License, # attached with Common Clause Condition 1.0, found in the LICENSES directory. -@skip Feature: Integer Vid All Path Background: Prepare space @@ -102,10 +101,10 @@ Feature: Integer Vid All Path | ORDER BY $-.path | LIMIT 3 """ Then the result should be, in any order, with relax comparison: - | path | - | <("Tim Duncan")-[:like]->("Manu Ginobili")-[:serve]->("Spurs")> | - | <("Tim Duncan")-[:like]->("Manu Ginobili")-[:like]->("Tim Duncan")-[:serve]->("Spurs")> | - | <("Tim Duncan")-[:like]->("Manu Ginobili")-[:like]->("Tim Duncan")-[:like]->("Tony Parker")> | + | path | + | <("Tim Duncan")-[:like]->("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:like]->("Tony Parker")> | + | <("Tim Duncan")-[:like]->("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:serve]->("Spurs")> | Scenario: Integer Vid [2] ALL Path With Limit When executing query: @@ -115,12 +114,12 @@ Feature: Integer Vid All Path | ORDER BY $-.path | LIMIT 5 """ Then the result should be, in any order, with relax comparison: - | path | - | <("Manu Ginobili")-[:like]->("Tim Duncan")> | - | <("Manu Ginobili")-[:like]->("Tim Duncan")-[:like]->("Tony Parker")-[:like]->("Tim Duncan")> | - | <("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:like]->("Tim Duncan")> | - | <("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:like]->("Tony Parker")-[:like]->("Tim Duncan")> | - | <("Tony Parker")-[:like]->("Manu Ginobili")-[:like]->("Tim Duncan")> | + | path | + | <("Tony Parker")-[:like@0]->("LaMarcus Aldridge")-[:like@0]->("Tim Duncan")> | + | <("Tony Parker")-[:like@0]->("LaMarcus Aldridge")-[:like@0]->("Tony Parker")-[:like@0]->("Tim Duncan")> | + | <("Tony Parker")-[:like@0]->("Manu Ginobili")-[:like@0]->("Tim Duncan")> | + | <("Tony Parker")-[:like@0]->("Tim Duncan")> | + | <("Tony Parker")-[:like@0]->("Tim Duncan")-[:like@0]->("Manu Ginobili")-[:like@0]->("Tim Duncan")> | Scenario: Integer Vid [1] ALL PATH REVERSELY When executing query: diff --git a/tests/tck/features/path/NoLoop.IntVid.feature b/tests/tck/features/path/NoLoop.IntVid.feature index fec5999f69992d789058e89d70b3082ad4867690..0c2b874dae6ce122b6fe3f1c35d573de49cf30f9 100644 --- a/tests/tck/features/path/NoLoop.IntVid.feature +++ b/tests/tck/features/path/NoLoop.IntVid.feature @@ -2,7 +2,6 @@ # # This source code is licensed under Apache 2.0 License, # attached with Common Clause Condition 1.0, found in the LICENSES directory. -@skip Feature: Integer Vid NoLoop Path Background: Prepare space @@ -85,10 +84,10 @@ Feature: Integer Vid NoLoop Path | ORDER BY $-.path | LIMIT 3 """ Then the result should be, in any order, with relax comparison: - | path | - | <("Tim Duncan")-[:like]->("Manu Ginobili")-[:serve]->("Spurs")> | - | <("Tim Duncan")-[:serve]->("Spurs")> | - | <("Tim Duncan")-[:like]->("Tony Parker")> | + | path | + | <("Tim Duncan")-[:like]->("Tony Parker")> | + | < ("Tim Duncan")-[:like]->("Tony Parker")-[:like]->("Manu Ginobili")-[:serve]->("Spurs")> | + | <("Tim Duncan")-[:like]->("Tony Parker")-[:like]->("LaMarcus Aldridge")-[:serve]->("Spurs")> | Scenario: Integer Vid [2] NOLOOP Path With Limit When executing query: diff --git a/tests/tck/features/path/ShortestPath.IntVid.feature b/tests/tck/features/path/ShortestPath.IntVid.feature index 4ab4531a3cfbdf7c28f4ee37d9e522ea7385448c..3c5bee6c3d1da039ba00ab23b22057dd6048b3ac 100644 --- a/tests/tck/features/path/ShortestPath.IntVid.feature +++ b/tests/tck/features/path/ShortestPath.IntVid.feature @@ -2,7 +2,6 @@ # # This source code is licensed under Apache 2.0 License, # attached with Common Clause Condition 1.0, found in the LICENSES directory. -@skip Feature: Integer Vid Shortest Path Background: Prepare space @@ -319,7 +318,7 @@ Feature: Integer Vid Shortest Path """ Then the result should be, in any order, with relax comparison: | path | - | <("Manu Ginobili")-[:like]->("Tim Duncan")> | + | <("Tony Parker")-[:like@0]->("Tim Duncan")> | Scenario: Integer Vid [4] Shortest Path With Limit When executing query: diff --git a/tests/tck/features/set/Set.IntVid.feature b/tests/tck/features/set/Set.IntVid.feature index a4b7b6c7821614f60e7697dbb348341172ef426e..30e1911a832f4e0ac4aecb9c55b4001eb580722f 100644 --- a/tests/tck/features/set/Set.IntVid.feature +++ b/tests/tck/features/set/Set.IntVid.feature @@ -2,11 +2,12 @@ # # This source code is licensed under Apache 2.0 License, # attached with Common Clause Condition 1.0, found in the LICENSES directory. -@skip -Feature: Set Test +Feature: Integer Vid Set Test - Scenario: Union All - Given a graph with space named "nba" + Background: Prepare space + Given a graph with space named "nba_int_vid" + + Scenario: Integer Vid Union All When executing query: """ GO FROM hash("Tim Duncan") OVER serve YIELD $^.player.name, serve.start_year, $$.team.name @@ -126,8 +127,7 @@ Feature: Set Test | "Tony Parker" | 1999 | | "Tony Parker" | 2018 | - Scenario: Union Distinct - Given a graph with space named "nba" + Scenario: Integer Vid Union Distinct When executing query: """ (GO FROM hash("Tim Duncan") OVER like YIELD like._dst as id | @@ -155,8 +155,7 @@ Feature: Set Test | "Tony Parker" | 1999 | "Spurs" | | "Tony Parker" | 2018 | "Hornets" | - Scenario: Minus - Given a graph with space named "nba" + Scenario: Integer Vid Minus When executing query: """ (GO FROM hash("Tim Duncan") OVER like YIELD like._dst as id | @@ -168,8 +167,7 @@ Feature: Set Test | $^.player.name | serve.start_year | $$.team.name | | "Manu Ginobili" | 2002 | "Spurs" | - Scenario: Intersect - Given a graph with space named "nba" + Scenario: Integer Vid Intersect When executing query: """ (GO FROM hash("Tim Duncan") OVER like YIELD like._dst as id | @@ -182,8 +180,7 @@ Feature: Set Test | "Tony Parker" | 1999 | "Spurs" | | "Tony Parker" | 2018 | "Hornets" | - Scenario: Mix - Given a graph with space named "nba" + Scenario: Integer Vid Mix When executing query: """ (GO FROM hash("Tim Duncan") OVER like YIELD like._dst as id | @@ -199,8 +196,7 @@ Feature: Set Test | $^.player.name | serve.start_year | $$.team.name | | "Manu Ginobili" | 2002 | "Spurs" | - Scenario: Assign - Given a graph with space named "nba" + Scenario: Integer Vid Assign When executing query: """ $var = GO FROM hash("Tim Duncan") OVER serve YIELD $^.player.name, serve.start_year, $$.team.name @@ -249,8 +245,7 @@ Feature: Set Test | "Tony Parker" | 1999 | "Spurs" | | "Tony Parker" | 2018 | "Hornets" | - Scenario: Empty Input - Given a graph with space named "nba" + Scenario: Integer Vid Empty Input When executing query: """ GO FROM hash("NON EXIST VERTEX ID") OVER serve YIELD serve.start_year, $$.team.name @@ -277,8 +272,7 @@ Feature: Set Test Then the result should be, in any order: | $var.serve.start_year | $var.$$.team.name | - Scenario: Diffrent column - Given a graph with space named "nba" + Scenario: Integer Vid Diffrent column When executing query: """ GO FROM hash("Tim Duncan") OVER serve YIELD $^.player.name as name, $$.team.name as player @@ -288,8 +282,7 @@ Feature: Set Test """ Then a SemanticError should be raised at runtime: different column names to UNION/INTERSECT/MINUS are not supported - Scenario: Pipe to a set op - Given a graph with space named "nba" + Scenario: Integer Vid Pipe to a set op When executing query: """ GO FROM 123 OVER like YIELD like._src as src, like._dst as dst @@ -297,8 +290,7 @@ Feature: Set Test """ Then a SemanticError should be raised at runtime: `$-.src', not exist prop `src' - Scenario: Non-existent props - Given a graph with space named "nba" + Scenario: Integer Vid Non-existent props When executing query: """ GO FROM hash("Tim Duncan") OVER serve YIELD $^.player.name, serve.start_year, $$.team.name diff --git a/tests/tck/features/subgraph/subgraph.IntVid.feature b/tests/tck/features/subgraph/subgraph.IntVid.feature index f670b847d14a3586b9ac68a9c36a648e8c68d15c..1dedc073abd3dbf1bc701506bfebef33dffc9424 100644 --- a/tests/tck/features/subgraph/subgraph.IntVid.feature +++ b/tests/tck/features/subgraph/subgraph.IntVid.feature @@ -2,7 +2,6 @@ # # This source code is licensed under Apache 2.0 License, # attached with Common Clause Condition 1.0, found in the LICENSES directory. -@skip Feature: Integer Vid subgraph Background: Prepare space @@ -21,27 +20,27 @@ Feature: Integer Vid subgraph Then a SemanticError should be raised at runtime: `$a.id', not exist variable `a' When executing query: """ - GO FROM "Tim Duncan" OVER like YIELD $$.player.age AS id | GET SUBGRAPH FROM $-.id + GO FROM hash("Tim Duncan") OVER like YIELD $$.player.name AS id | GET SUBGRAPH FROM $-.id """ - Then a SemanticError should be raised at runtime: `$-.id', the srcs should be type of FIXED_STRING, but was`INT' + Then a SemanticError should be raised at runtime: `$-.id', the srcs should be type of INT64, but was`STRING' When executing query: """ - $a = GO FROM "Tim Duncan" OVER like YIELD $$.player.age AS ID; GET SUBGRAPH FROM $a.ID + $a = GO FROM hash("Tim Duncan") OVER like YIELD $$.player.name AS ID; GET SUBGRAPH FROM $a.ID """ - Then a SemanticError should be raised at runtime: `$a.ID', the srcs should be type of FIXED_STRING, but was`INT' + Then a SemanticError should be raised at runtime: `$a.ID', the srcs should be type of INT64, but was`STRING' When executing query: """ - $a = GO FROM "Tim Duncan" OVER like YIELD like._src AS src; GET SUBGRAPH FROM $b.src + $a = GO FROM hash("Tim Duncan") OVER like YIELD like._src AS src; GET SUBGRAPH FROM $b.src """ Then a SemanticError should be raised at runtime: `$b.src', not exist variable `b' When executing query: """ - GO FROM "Tim Duncan" OVER like YIELD like._dst AS id, like._src AS id | GET SUBGRAPH FROM $-.id + GO FROM hash("Tim Duncan") OVER like YIELD like._dst AS id, like._src AS id | GET SUBGRAPH FROM $-.id """ Then a SemanticError should be raised at runtime: Duplicate Column Name : `id' When executing query: """ - $a = GO FROM "Tim Duncan" OVER like YIELD like._dst AS id, like._src AS id; GET SUBGRAPH FROM $a.id + $a = GO FROM hash("Tim Duncan") OVER like YIELD like._dst AS id, like._src AS id; GET SUBGRAPH FROM $a.id """ Then a SemanticError should be raised at runtime: Duplicate Column Name : `id' diff --git a/tests/tck/utils/nbv.py b/tests/tck/utils/nbv.py index cafe47a94a599b29f4d9d98ebee7effff4dd7fa7..5907e182c7e3ccb9870c9cca0c6b5f1d0d51c11d 100644 --- a/tests/tck/utils/nbv.py +++ b/tests/tck/utils/nbv.py @@ -27,6 +27,7 @@ from nebula2.common.ttypes import ( ) Value.__hash__ = lambda self: self.value.__hash__() +Pattern = type(re.compile(r"^")) states = ( ('sstr', 'exclusive'), @@ -250,7 +251,18 @@ def p_expr(p): | path | function ''' - p[0] = p[1] + if isinstance(p[1], Value) or isinstance(p[1], Pattern): + p[0] = p[1] + elif type(p[1]) in [str, bytes]: + p[0] = Value(sVal=p[1]) + elif type(p[1]) is int: + p[0] = Value(iVal=p[1]) + elif type(p[1]) is bool: + p[0] = Value(bVal=p[1]) + elif type(p[1]) is float: + p[0] = Value(fVal=p[1]) + else: + raise ValueError(f"Invalid value type: {type(p[1])}") def p_list(p): @@ -327,11 +339,13 @@ def p_vid(p): | function ''' p[0] = p[1] - if isinstance(p[0], Value): - if p[0].getType() == Value.SVAL: - p[0] = p[0].get_sVal() + if not isinstance(p[0], Value): + if type(p[0]) in [str, bytes]: + p[0] = Value(sVal=p[0]) + elif type(p[0]) is int: + p[0] = Value(iVal=p[0]) else: - p[0] = p[0].get_iVal() + raise ValueError(f"Invalid vid type: {type(p[0])}") def p_vertex(p):