diff --git a/src/validator/GoValidator.cpp b/src/validator/GoValidator.cpp index 1c689f68ac4906ff0f1eeb35a0ed02fcfbca1120..eb4ae6b1052a32149305e741e3f7171d02bff7b8 100644 --- a/src/validator/GoValidator.cpp +++ b/src/validator/GoValidator.cpp @@ -36,11 +36,6 @@ Status GoValidator::validateImpl() { NG_RETURN_IF_ERROR(buildColumns()); - if (isOverAll_) { - // TODO: implement over all. - return Status::Error("Not support over all yet."); - } - return Status::OK(); } @@ -112,7 +107,7 @@ Status GoValidator::validateOver(const OverClause* over) { direction_ = over->direction(); if (over->isOverAll()) { isOverAll_ = true; - return Status::OK(); + return Status::Error("Not support over all yet."); } auto edges = over->edges(); auto* schemaMng = qctx_->schemaMng(); @@ -163,6 +158,11 @@ Status GoValidator::validateYield(const YieldClause* yield) { distinct_ = yield->isDistinct(); auto cols = yield->columns(); for (auto col : cols) { + if (!col->getAggFunName().empty()) { + return Status::Error( + "`%s', not support aggregate function in go sentence.", + col->toString().c_str()); + } auto colName = deduceColName(col); colNames_.emplace_back(colName); @@ -767,6 +767,11 @@ void GoValidator::extractPropExprs(const Expression* expr) { extractPropExprs(unaryExpr->operand()); break; } + case Expression::Kind::kTypeCasting: { + auto typeCastingExpr = static_cast<const TypeCastingExpression*>(expr); + extractPropExprs(typeCastingExpr->operand()); + break; + } case Expression::Kind::kFunctionCall: { auto funcExpr = static_cast<const FunctionCallExpression*>(expr); auto& args = funcExpr->args()->args(); @@ -823,7 +828,6 @@ void GoValidator::extractPropExprs(const Expression* expr) { case Expression::Kind::kVar: case Expression::Kind::kVersionedVar: case Expression::Kind::kSymProperty: - case Expression::Kind::kTypeCasting: case Expression::Kind::kUnaryIncr: case Expression::Kind::kUnaryDecr: case Expression::Kind::kRelIn: { @@ -873,6 +877,16 @@ std::unique_ptr<Expression> GoValidator::rewriteToInputProp(Expression* expr) { } break; } + case Expression::Kind::kTypeCasting: { + auto typeCastingExpr = + static_cast<TypeCastingExpression*>(expr); + auto rewrite = rewriteToInputProp( + const_cast<Expression*>(typeCastingExpr->operand())); + if (rewrite != nullptr) { + typeCastingExpr->setOperand(rewrite.release()); + } + break; + } case Expression::Kind::kFunctionCall: { auto funcExpr = static_cast<FunctionCallExpression*>(expr); auto* argList = const_cast<ArgumentList*>(funcExpr->args()); @@ -907,7 +921,6 @@ std::unique_ptr<Expression> GoValidator::rewriteToInputProp(Expression* expr) { case Expression::Kind::kVar: case Expression::Kind::kVersionedVar: case Expression::Kind::kSymProperty: - case Expression::Kind::kTypeCasting: case Expression::Kind::kUnaryIncr: case Expression::Kind::kUnaryDecr: case Expression::Kind::kRelIn: { diff --git a/src/validator/test/QueryValidatorTest.cpp b/src/validator/test/QueryValidatorTest.cpp index 548a8966a743ef987bc11d8a2d6b53fd9aa656c6..886908fe2f95905e51cc78db0ca0317c53d136f3 100644 --- a/src/validator/test/QueryValidatorTest.cpp +++ b/src/validator/test/QueryValidatorTest.cpp @@ -714,6 +714,10 @@ TEST_F(QueryValidatorTest, GoInvalid) { "| GO FROM $-.id OVER like WHERE $var.id == \"\""; EXPECT_FALSE(checkResult(query)); } + { + std::string query = "GO FROM \"2\" OVER like YIELD COUNT(123);"; + EXPECT_FALSE(checkResult(query)); + } } TEST_F(QueryValidatorTest, Limit) {