strongduanmu commented on code in PR #29655:
URL: https://github.com/apache/shardingsphere/pull/29655#discussion_r1442436511


##########
parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementVisitor.java:
##########
@@ -1338,4 +1350,99 @@ public ASTNode visitCreateTableAsSelectClause(final 
CreateTableAsSelectClauseCon
         }
         return result;
     }
+    
+    @Override
+    public ASTNode visitUpdateStatistics(final UpdateStatisticsContext ctx) {
+        SQLServerUpdateStatisticsStatement result = new 
SQLServerUpdateStatisticsStatement();
+        if (null != ctx.tableName()) {
+            result.setTable((SimpleTableSegment) visit(ctx.tableName()));
+        }
+        if (null != ctx.indexName() && ctx.indexName().size() > 0) {
+            List<IndexSegment> indexSegments = new LinkedList<>();
+            for (IndexNameContext indexNameContext : ctx.indexName()) {
+                indexSegments.add((IndexSegment) visit(indexNameContext));
+            }
+            result.setIndexes(indexSegments);
+        }
+        if (null != ctx.statisticsWithClause()) {
+            result.setStrategy((StatisticsStrategySegment) 
visit(ctx.statisticsWithClause()));
+        }
+        return result;
+    }
+    
+    @Override
+    public ASTNode visitStatisticsWithClause(final StatisticsWithClauseContext 
ctx) {
+        StatisticsStrategySegment segment = new 
StatisticsStrategySegment(ctx.getStart().getStartIndex(), 
ctx.getStop().getStopIndex());
+        if (null != ctx.sampleOption()) {
+            segment.setSampleOption((SampleOptionSegment) 
visit(ctx.sampleOption()));
+        }
+        if (null != ctx.statisticsOptions()) {
+            segment.setStatisticsOptions((StatisticsOptionSegment) 
visit(ctx.statisticsOptions()));
+        }
+        return segment;

Review Comment:
   Please rename segment to result.



##########
parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementVisitor.java:
##########
@@ -1338,4 +1350,99 @@ public ASTNode visitCreateTableAsSelectClause(final 
CreateTableAsSelectClauseCon
         }
         return result;
     }
+    
+    @Override
+    public ASTNode visitUpdateStatistics(final UpdateStatisticsContext ctx) {
+        SQLServerUpdateStatisticsStatement result = new 
SQLServerUpdateStatisticsStatement();
+        if (null != ctx.tableName()) {
+            result.setTable((SimpleTableSegment) visit(ctx.tableName()));
+        }
+        if (null != ctx.indexName() && ctx.indexName().size() > 0) {
+            List<IndexSegment> indexSegments = new LinkedList<>();
+            for (IndexNameContext indexNameContext : ctx.indexName()) {
+                indexSegments.add((IndexSegment) visit(indexNameContext));
+            }
+            result.setIndexes(indexSegments);
+        }
+        if (null != ctx.statisticsWithClause()) {
+            result.setStrategy((StatisticsStrategySegment) 
visit(ctx.statisticsWithClause()));
+        }
+        return result;
+    }
+    
+    @Override
+    public ASTNode visitStatisticsWithClause(final StatisticsWithClauseContext 
ctx) {
+        StatisticsStrategySegment segment = new 
StatisticsStrategySegment(ctx.getStart().getStartIndex(), 
ctx.getStop().getStopIndex());
+        if (null != ctx.sampleOption()) {
+            segment.setSampleOption((SampleOptionSegment) 
visit(ctx.sampleOption()));
+        }
+        if (null != ctx.statisticsOptions()) {
+            segment.setStatisticsOptions((StatisticsOptionSegment) 
visit(ctx.statisticsOptions()));
+        }
+        return segment;
+    }
+    
+    @Override
+    public ASTNode visitStatisticsOption(final StatisticsOptionContext ctx) {
+        return super.visitStatisticsOption(ctx);
+    }
+    
+    @Override
+    public ASTNode visitSampleOption(final SampleOptionContext ctx) {
+        SampleOptionSegment segment = new 
SampleOptionSegment(ctx.getStart().getStartIndex(), 
ctx.getStop().getStopIndex());
+        if (null != ctx.FULLSCAN()) {
+            segment.setStrategy(SampleStrategy.FULLSCAN);
+        } else if (null != ctx.SAMPLE()) {
+            segment.setStrategy(SampleStrategy.SAMPLE);
+            if (null != ctx.NUMBER_()) {
+                List<TerminalNode> number = ctx.NUMBER_();
+                segment.setSampleNumber(number.get(0).getText());
+            }
+            if (null != ctx.PERCENT()) {
+                segment.setScanUnit(ScanUnit.PERCENT);
+            } else if (null != ctx.ROWS()) {
+                segment.setScanUnit(ScanUnit.ROWS);
+            }
+        } else if (null != ctx.RESAMPLE()) {
+            segment.setStrategy(SampleStrategy.RESAMPLE);
+            if (null != ctx.NUMBER_()) {
+                List<String> partitions = new LinkedList<>();
+                for (TerminalNode terminalNode : ctx.NUMBER_()) {
+                    partitions.add(terminalNode.getText());
+                }
+                segment.setPartitions(partitions);
+            }
+        }
+        if (null != ctx.PERSIST_SAMPLE_PERCENT()) {
+            segment.setPersistSamplePercent(null != ctx.ON());
+        }
+        return segment;
+    }
+    
+    @Override
+    public ASTNode visitStatisticsOptions(final StatisticsOptionsContext ctx) {
+        StatisticsOptionSegment optionSegment = new 
StatisticsOptionSegment(ctx.getStart().getStartIndex(), 
ctx.getStop().getStopIndex());
+        for (StatisticsOptionContext option : ctx.statisticsOption()) {
+            if (null != option.ALL()) {
+                optionSegment.setStatisticsDimension(StatisticsDimension.ALL);
+            } else if (null != option.COLUMNS()) {
+                
optionSegment.setStatisticsDimension(StatisticsDimension.COLUMNS);
+            } else if (null != option.INDEX()) {
+                
optionSegment.setStatisticsDimension(StatisticsDimension.INDEX);
+            }
+            if (null != option.NORECOMPUTE()) {
+                optionSegment.setNoRecompute(true);
+            }
+            if (null != option.INCREMENTAL()) {
+                optionSegment.setIncremental(null != option.ON());
+            }
+            if (null != option.MAXDOP()) {
+                
optionSegment.setMaxDegreeOfParallelism(option.NUMBER_().getText());
+            }
+            if (null != option.AUTO_DROP()) {
+                optionSegment.setAutoDrop(null != option.ON());
+            }
+        }
+        return optionSegment;

Review Comment:
   Please rename segment to result.



##########
parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/segment/SampleOptionSegment.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.segment;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.SQLSegment;
+
+import java.util.List;
+
+@Getter
+@Setter
+@NoArgsConstructor
+public final class SampleOptionSegment implements SQLSegment {

Review Comment:
   Please add javadoc for this class.



##########
parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/segment/StatisticsDimension.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.segment;
+
+public enum StatisticsDimension {

Review Comment:
   Please add javadoc for this class.



##########
parser/sql/dialect/sqlserver/src/main/java/org/apache/shardingsphere/sql/parser/sqlserver/visitor/statement/SQLServerStatementVisitor.java:
##########
@@ -1338,4 +1350,99 @@ public ASTNode visitCreateTableAsSelectClause(final 
CreateTableAsSelectClauseCon
         }
         return result;
     }
+    
+    @Override
+    public ASTNode visitUpdateStatistics(final UpdateStatisticsContext ctx) {
+        SQLServerUpdateStatisticsStatement result = new 
SQLServerUpdateStatisticsStatement();
+        if (null != ctx.tableName()) {
+            result.setTable((SimpleTableSegment) visit(ctx.tableName()));
+        }
+        if (null != ctx.indexName() && ctx.indexName().size() > 0) {
+            List<IndexSegment> indexSegments = new LinkedList<>();
+            for (IndexNameContext indexNameContext : ctx.indexName()) {
+                indexSegments.add((IndexSegment) visit(indexNameContext));
+            }
+            result.setIndexes(indexSegments);
+        }
+        if (null != ctx.statisticsWithClause()) {
+            result.setStrategy((StatisticsStrategySegment) 
visit(ctx.statisticsWithClause()));
+        }
+        return result;
+    }
+    
+    @Override
+    public ASTNode visitStatisticsWithClause(final StatisticsWithClauseContext 
ctx) {
+        StatisticsStrategySegment segment = new 
StatisticsStrategySegment(ctx.getStart().getStartIndex(), 
ctx.getStop().getStopIndex());
+        if (null != ctx.sampleOption()) {
+            segment.setSampleOption((SampleOptionSegment) 
visit(ctx.sampleOption()));
+        }
+        if (null != ctx.statisticsOptions()) {
+            segment.setStatisticsOptions((StatisticsOptionSegment) 
visit(ctx.statisticsOptions()));
+        }
+        return segment;
+    }
+    
+    @Override
+    public ASTNode visitStatisticsOption(final StatisticsOptionContext ctx) {
+        return super.visitStatisticsOption(ctx);
+    }
+    
+    @Override
+    public ASTNode visitSampleOption(final SampleOptionContext ctx) {
+        SampleOptionSegment segment = new 
SampleOptionSegment(ctx.getStart().getStartIndex(), 
ctx.getStop().getStopIndex());
+        if (null != ctx.FULLSCAN()) {
+            segment.setStrategy(SampleStrategy.FULLSCAN);
+        } else if (null != ctx.SAMPLE()) {
+            segment.setStrategy(SampleStrategy.SAMPLE);
+            if (null != ctx.NUMBER_()) {
+                List<TerminalNode> number = ctx.NUMBER_();
+                segment.setSampleNumber(number.get(0).getText());
+            }
+            if (null != ctx.PERCENT()) {
+                segment.setScanUnit(ScanUnit.PERCENT);
+            } else if (null != ctx.ROWS()) {
+                segment.setScanUnit(ScanUnit.ROWS);
+            }
+        } else if (null != ctx.RESAMPLE()) {
+            segment.setStrategy(SampleStrategy.RESAMPLE);
+            if (null != ctx.NUMBER_()) {
+                List<String> partitions = new LinkedList<>();
+                for (TerminalNode terminalNode : ctx.NUMBER_()) {
+                    partitions.add(terminalNode.getText());
+                }
+                segment.setPartitions(partitions);
+            }
+        }
+        if (null != ctx.PERSIST_SAMPLE_PERCENT()) {
+            segment.setPersistSamplePercent(null != ctx.ON());
+        }
+        return segment;

Review Comment:
   Please rename segment to result.



##########
parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/segment/StatisticsStrategySegment.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.segment;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.SQLSegment;
+
+@Getter
+@Setter
+@NoArgsConstructor
+public final class StatisticsStrategySegment implements SQLSegment {

Review Comment:
   Please add javadoc for this class.



##########
parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/segment/ScanUnit.java:
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.segment;
+
+public enum ScanUnit {

Review Comment:
   Please add javadoc for ScanUnit.



##########
parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/segment/StatisticsOptionSegment.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.segment;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.SQLSegment;
+
+@Getter
+@Setter
+@NoArgsConstructor
+public final class StatisticsOptionSegment implements SQLSegment {

Review Comment:
   Please add javadoc for this class.



##########
parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/sqlserver/segment/SampleStrategy.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.segment;
+
+public enum SampleStrategy {

Review Comment:
   Please add javadoc for SampleStrategy.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to