You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2021/09/30 03:12:05 UTC

[iotdb] branch master updated: [ISSUE-4059]: IoTDBSqlVisitor#visitTopClause add top range restriction (#4060)

This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 4b34a9c  [ISSUE-4059]: IoTDBSqlVisitor#visitTopClause add top range restriction (#4060)
4b34a9c is described below

commit 4b34a9cd298217917711a28bac038ebd894d4dee
Author: Wenjun Ruan <we...@apache.org>
AuthorDate: Thu Sep 30 11:11:34 2021 +0800

    [ISSUE-4059]: IoTDBSqlVisitor#visitTopClause add top range restriction (#4060)
---
 .../src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java   | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
index 6a687ff..1d4fc6d 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
@@ -1101,8 +1101,10 @@ public class IoTDBSqlVisitor extends SqlBaseBaseVisitor<Operator> {
   public Operator visitTopClause(TopClauseContext ctx) {
     Map<String, Object> props = new HashMap<>();
     int top = Integer.parseInt(ctx.INT().getText());
-    if (top < 0) {
-      throw new SQLParserException("TOP <N>: N should be greater than 0.");
+    if (top <= 0 || top > 1000) {
+      throw new SQLParserException(
+          String.format(
+              "TOP <N>: N should be greater than 0 and less than 1000, current N is %d", top));
     }
     props.put(TOP_K, top);
     queryOp.setProps(props);