tristaZero commented on a change in pull request #7704:
URL: https://github.com/apache/shardingsphere/pull/7704#discussion_r501432718



##########
File path: 
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/ddl/routine/ValidStatementSegment.java
##########
@@ -0,0 +1,145 @@
+/*
+ * 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.common.segment.ddl.routine;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.SQLSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterTableStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateTableStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropTableStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.TruncateStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DeleteStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.UpdateStatement;
+
+import java.util.Optional;
+
+/**
+ * Valid statement segment.
+ */
+@RequiredArgsConstructor
+@Getter
+@Setter
+public class ValidStatementSegment implements SQLSegment {
+    
+    private final int startIndex;
+    
+    private final int stopIndex;
+    
+    private CreateTableStatement createTable;
+    
+    private AlterTableStatement alterTable;
+    
+    private DropTableStatement dropTable;
+    
+    private TruncateStatement truncate;
+    
+    private InsertStatement insert;
+    
+    private InsertStatement replace;
+    
+    private UpdateStatement update;
+    
+    private DeleteStatement delete;
+    
+    private SelectStatement select;

Review comment:
       >  we need to extract the tables contained in the various statements 
during parsing. 
   
   I think the visitor handling could retain the same, even though here its 
member is `SQLStatement`. 
   We should visit out the concrete SQLStatement, IMO, since that is in line 
with its g4 definition. However, I wonder whether a generic SQLStatment instead 
of a list of possible types is adequate to reflect its composition. What's 
more, the following functions like `getCreateTable()` seem to help give more 
descriptions of a `SQLStatement` to the outer calls. 
   It seems these public functions rather than its members are more likely to 
be called,  doesn't it?  That way, do you think this list of member options 
seems a lit bloated (as you said before:-))?




----------------------------------------------------------------
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.

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


Reply via email to