You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/02/03 04:01:25 UTC

[GitHub] [incubator-shardingsphere] tristaZero commented on a change in pull request #4117: add visitor for dal

tristaZero commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373913251
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -217,27 +229,97 @@
     @Override
     public ASTNode visitUse(final UseContext ctx) {
         LiteralValue schema = (LiteralValue) visit(ctx.schemaName());
-        UseStatement useStatement = new UseStatement();
-        useStatement.setSchema(schema.getLiteral());
-        return useStatement;
+        UseStatement result = new UseStatement();
+        result.setSchema(schema.getLiteral());
+        return result;
+    }
+
+    @Override
+    public ASTNode visitDesc(final DescContext ctx) {
+        TableSegment table = (TableSegment) visit(ctx.tableName());
+        DescribeStatement result = new DescribeStatement();
+        result.setTable(table);
+        return result;
+    }
+
+    @Override
+    public ASTNode visitShowDatabases(final ShowDatabasesContext ctx) {
+        ShowDatabasesStatement result = new ShowDatabasesStatement();
+        ShowLikeContext showLikeContext = ctx.showLike();
+        if (null != showLikeContext) {
+            ShowLikeSegment showLikeSegment = (ShowLikeSegment) visit(ctx.showLike());
+            result.getAllSQLSegments().add(showLikeSegment);
+        }
+        return result;
+    }
+
+    @Override
+    public ASTNode visitShowTables(final ShowTablesContext ctx) {
+        ShowTablesStatement result = new ShowTablesStatement();
+        FromSchemaContext fromSchemaContext = ctx.fromSchema();
+        ShowLikeContext showLikeContext = ctx.showLike();
+        if (null != fromSchemaContext) {
+            FromSchemaSegment fromSchemaSegment = (FromSchemaSegment) visit(ctx.fromSchema());
+            result.getAllSQLSegments().add(fromSchemaSegment);
+        }
+        if (null != showLikeContext) {
+            ShowLikeSegment showLikeSegment = (ShowLikeSegment) visit(ctx.showLike());
+            result.getAllSQLSegments().add(showLikeSegment);
+        }
+        return result;
     }
     
     @Override
     public ASTNode visitShowTableStatus(final ShowTableStatusContext ctx) {
-        ShowTableStatusStatement showTableStatusStatement = new ShowTableStatusStatement();
+        ShowTableStatusStatement result = new ShowTableStatusStatement();
         FromSchemaContext fromSchemaContext = ctx.fromSchema();
         ShowLikeContext showLikeContext = ctx.showLike();
         if (null != fromSchemaContext) {
             FromSchemaSegment fromSchemaSegment = (FromSchemaSegment) visit(ctx.fromSchema());
-            showTableStatusStatement.getAllSQLSegments().add(fromSchemaSegment);
+            result.getAllSQLSegments().add(fromSchemaSegment);
         }
         if (null != showLikeContext) {
             ShowLikeSegment showLikeSegment = (ShowLikeSegment) visit(ctx.showLike());
-            showTableStatusStatement.getAllSQLSegments().add(showLikeSegment);
+            result.getAllSQLSegments().add(showLikeSegment);
         }
-        return showTableStatusStatement;
+        return result;
     }
-    
+
+    @Override
+    public ASTNode visitShowColumns(final ShowColumnsContext ctx) {
+        ShowColumnsStatement result = new ShowColumnsStatement();
+        FromSchemaContext fromSchemaContext = ctx.fromSchema();
+        ShowLikeContext showLikeContext = ctx.showLike();
+        if (null != fromSchemaContext) {
+            FromSchemaSegment fromSchemaSegment = (FromSchemaSegment) visit(ctx.fromSchema());
+            result.getAllSQLSegments().add(fromSchemaSegment);
+        }
+        if (null != showLikeContext) {
+            ShowLikeSegment showLikeSegment = (ShowLikeSegment) visit(ctx.showLike());
+            result.getAllSQLSegments().add(showLikeSegment);
+        }
+        return result;
+    }
+
+    @Override
+    public ASTNode visitShowIndex(final ShowIndexContext ctx) {
+        ShowIndexStatement result = new ShowIndexStatement();
 
 Review comment:
   `visitTable()` is necessary, right?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services