tristaZero commented on a change in pull request #4123: Add MySQL DDLStatement 
antlr visitor
URL: 
https://github.com/apache/incubator-shardingsphere/pull/4123#discussion_r373778970
 
 

 ##########
 File path: 
shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -871,6 +1051,53 @@ private ASTNode createExpressionSegment(final ASTNode 
astNode, final ParserRuleC
         return astNode;
     }
     
+    private ColumnDefinitionSegment createColumnDefinitionSegment(final 
ColumnDefinitionContext columnDefinition, final DDLStatement statement) {
+        ColumnSegment column = (ColumnSegment) 
visit(columnDefinition.columnName());
+        LiteralValue dataType = (LiteralValue) 
visit(columnDefinition.dataType().dataTypeName_());
+        boolean isPrimaryKey = false;
+        for (InlineDataType_Context inlineDataType : 
columnDefinition.inlineDataType_()) {
+            CommonDataTypeOption_Context commonDataTypeOption = 
inlineDataType.commonDataTypeOption_();
+            if (null != commonDataTypeOption) {
+                if (null != commonDataTypeOption.primaryKey()) {
+                    isPrimaryKey = true;
+                }
+                if (null != commonDataTypeOption.referenceDefinition_()) {
+                    statement.getAllSQLSegments().add((TableSegment) 
visit(commonDataTypeOption.referenceDefinition_().tableName()));
+                }
+            }
+        }
+        for (GeneratedDataType_Context generatedDataType: 
columnDefinition.generatedDataType_()) {
+            CommonDataTypeOption_Context commonDataTypeOption = 
generatedDataType.commonDataTypeOption_();
+            if (null != commonDataTypeOption) {
+                if (null != commonDataTypeOption.primaryKey()) {
+                    isPrimaryKey = true;
+                }
+                if (null != commonDataTypeOption.referenceDefinition_()) {
+                    statement.getAllSQLSegments().add((TableSegment) 
visit(commonDataTypeOption.referenceDefinition_().tableName()));
 
 Review comment:
   Could give more review on other long funcions?

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


With regards,
Apache Git Services

Reply via email to