weizhengte commented on code in PR #10170:
URL: https://github.com/apache/doris/pull/10170#discussion_r990726564


##########
fe/fe-core/src/main/java/org/apache/doris/analysis/TableSample.java:
##########
@@ -0,0 +1,101 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.analysis;
+
+import org.apache.doris.common.AnalysisException;
+
+/*
+ * To represent following stmt:
+ *      TABLESAMPLE (10 PERCENT)
+ *      TABLESAMPLE (100 ROWS)
+ *      TABLESAMPLE (10 PERCENT) REPEATABLE (123)
+ *      TABLESAMPLE (100 ROWS) REPEATABLE (123)R
+ *
+ * references:
+ *      
https://simplebiinsights.com/sql-server-tablesample-retrieving-random-data-from-sql-server/
+ *      https://sqlrambling.net/2018/01/24/tablesample-basic-examples/
+ */
+public class TableSample implements ParseNode {
+
+    private final Long sampleValue;
+    private final boolean isPercent;
+    private final Long seek;
+
+    public TableSample(boolean isPercent, Long sampleValue) {
+        this.sampleValue = sampleValue;
+        this.isPercent = isPercent;
+        this.seek = -1L;
+    }
+
+    public TableSample(boolean isPercent, Long sampleValue, Long seek) {
+        this.sampleValue = sampleValue;
+        this.isPercent = isPercent;
+        this.seek = seek;
+    }
+
+    public TableSample(TableSample other) {
+        this.sampleValue = other.sampleValue;
+        this.isPercent = other.isPercent;
+        this.seek = other.seek;
+    }
+
+    public Long getSampleValue() {
+        return sampleValue;
+    }
+
+    public boolean isPercent() {
+        return isPercent;
+    }
+
+    public Long getSeek() {
+        return seek;
+    }
+
+    @Override
+    public void analyze(Analyzer analyzer) throws AnalysisException {
+        if (sampleValue <= 0 || (isPercent && sampleValue > 100)) {
+            throw new AnalysisException("table sample value must be greater 
than 0");

Review Comment:
   It would be better to clarify the reason for the exception~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to