diff --git a/src/parser/parser.yy b/src/parser/parser.yy
index 2cfa46582c6a4bb72a7c8085d595a0d8bb75652c..718b536344665b267ff1221534e759c140f6cf1b 100644
--- a/src/parser/parser.yy
+++ b/src/parser/parser.yy
@@ -30,6 +30,7 @@
 
 #include "common/expression/ReduceExpression.h"
 #include "util/ParserUtil.h"
+#include "util/ExpressionUtils.h"
 #include "context/QueryContext.h"
 #include "util/SchemaUtil.h"
 
@@ -1292,10 +1293,22 @@ with_clause
 
 match_clause
     : KW_MATCH match_path where_clause {
-        $$ = new MatchClause($2, $3, false/*optinal*/);
+        if ($3 && graph::ExpressionUtils::findAny($3->filter(),{Expression::Kind::kAggregate})) {
+            delete($2);
+            delete($3);
+            throw nebula::GraphParser::syntax_error(@3, "Invalid use of aggregating function in this context.");
+        } else {
+            $$ = new MatchClause($2, $3, false/*optinal*/);
+        }
     }
     | KW_OPTIONAL KW_MATCH match_path where_clause {
-        $$ = new MatchClause($3, $4, true);
+        if ($4 && graph::ExpressionUtils::findAny($4->filter(),{Expression::Kind::kAggregate})) {
+            delete($3);
+            delete($4);
+            throw nebula::GraphParser::syntax_error(@4, "Invalid use of aggregating function in this context.");
+        } else {
+            $$ = new MatchClause($3, $4, true);
+        }
     }
     ;
 
diff --git a/src/parser/test/ParserTest.cpp b/src/parser/test/ParserTest.cpp
index c7204e8143edc4d76d0ec13ff6e83851a38e61c7..91eb882029b4c7daa1c903cd789e86b51442ea51 100644
--- a/src/parser/test/ParserTest.cpp
+++ b/src/parser/test/ParserTest.cpp
@@ -2444,6 +2444,17 @@ TEST(Parser, Match) {
     }
 }
 
+TEST(Parser, MatchErrorCheck) {
+    {
+        std::string query = "MATCH (v:player) WHERE count(v)>1 RETURN v";
+        auto result = parse(query);
+        ASSERT_FALSE(result.ok());
+        auto error = "SyntaxError: Invalid use of aggregating "
+            "function in this context. near `WHERE count(v)>1'";
+        ASSERT_EQ(error, result.status().toString());
+    }
+}
+
 TEST(Parser, MatchMultipleTags) {
     {
         std::string query = "MATCH (a:person:player) --> (b) RETURN *";
diff --git a/tests/tck/features/aggregate/Agg.feature b/tests/tck/features/aggregate/Agg.feature
index 7bb2f02f70fa2f731471fd42dbc00e90692f76d4..c1fa3a5f097c466d3b4923223a95b5b24b4907eb 100644
--- a/tests/tck/features/aggregate/Agg.feature
+++ b/tests/tck/features/aggregate/Agg.feature
@@ -611,6 +611,13 @@ Feature: Basic Aggregate and GroupBy
                COUNT(serve._dst) AS id
       """
     Then a SemanticError should be raised at runtime: `COUNT(serve._dst) AS id', not support aggregate function in go sentence.
+    When executing query:
+      """
+      MATCH (v:player)
+      WHERE avg(v.age) > 1
+      RETURN v.age
+      """
+    Then a SyntaxError should be raised at runtime: Invalid use of aggregating function in this context. near `WHERE avg(v.age) > 1'
 
 # When executing query:
 # """