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/01/30 11:17:13 UTC

[GitHub] [incubator-shardingsphere] jingshanglu opened a new pull request #4117: add visitor for dal

jingshanglu opened a new pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117
 
 
   
   
   Changes proposed in this pull request:
   - add visitor for desc
   - add visitor for ShowDatabases
   - add visitor for ShowTables
   - add visitor for ShowColumns
   - add visitor for ShowIndex
   - add visitor for ShowCreateTable
   

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

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

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r375051182
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -227,27 +241,120 @@
     @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();
+        FromTableContext fromTableContext = ctx.fromTable();
+        FromSchemaContext fromSchemaContext = ctx.fromSchema();
+        ShowLikeContext showLikeContext = ctx.showLike();
+        if (null != fromTableContext) {
+            FromTableSegment fromTableSegment = (FromTableSegment) visit(fromTableContext);
+            result.setTable(fromTableSegment.getPattern());
+            result.getAllSQLSegments().add(fromTableSegment);
+        }
+        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();
+        FromSchemaContext fromSchemaContext = ctx.fromSchema();
+        FromTableContext fromTableContext = ctx.fromTable();
+        if (null != fromSchemaContext) {
+            SchemaNameContext schemaNameContext = fromSchemaContext.schemaName();
+            LiteralValue schema = (LiteralValue) visit(schemaNameContext);
+            SchemaSegment schemaSegment = new SchemaSegment(schemaNameContext.start.getStartIndex(), schemaNameContext.stop.getStopIndex(), schema.getLiteral());
+            result.getAllSQLSegments().add(schemaSegment);
+        }
+        if (null != fromTableContext) {
+            FromTableSegment fromTableSegment = (FromTableSegment) visitFromTable(fromTableContext);
 
 Review comment:
   Same with the above one.

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

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

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373859892
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -237,7 +284,42 @@ public ASTNode visitShowTableStatus(final ShowTableStatusContext ctx) {
         }
         return showTableStatusStatement;
     }
-    
+
+    @Override
+    public ASTNode visitShowColumns(final ShowColumnsContext ctx) {
+        ShowColumnsStatement showColumnsStatement = new ShowColumnsStatement();
+        FromSchemaContext fromSchemaContext = ctx.fromSchema();
+        ShowLikeContext showLikeContext = ctx.showLike();
+        if (null != fromSchemaContext) {
+            FromSchemaSegment fromSchemaSegment = (FromSchemaSegment) visit(ctx.fromSchema());
+            showColumnsStatement.getAllSQLSegments().add(fromSchemaSegment);
+        }
+        if (null != showLikeContext) {
+            ShowLikeSegment showLikeSegment = (ShowLikeSegment) visit(ctx.showLike());
+            showColumnsStatement.getAllSQLSegments().add(showLikeSegment);
+        }
+        return showColumnsStatement;
+    }
+
+    @Override
+    public ASTNode visitShowIndex(final ShowIndexContext ctx) {
+        ShowIndexStatement showIndexStatement = new ShowIndexStatement();
+        FromSchemaContext fromSchemaContext = ctx.fromSchema();
+        if (null != fromSchemaContext) {
+            FromSchemaSegment fromSchemaSegment = (FromSchemaSegment) visit(ctx.fromSchema());
+            showIndexStatement.getAllSQLSegments().add(fromSchemaSegment);
+        }
+        return showIndexStatement;
+    }
+
+    @Override
+    public ASTNode visitShowCreateTable(final ShowCreateTableContext ctx) {
+        ShowCreateTableStatement showCreateTableStatement = new ShowCreateTableStatement();
 
 Review comment:
   Variable name of `showCreateTableStatement` should be `result`.

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

[GitHub] [incubator-shardingsphere] coveralls commented on issue #4117: add visitor for dal

Posted by GitBox <gi...@apache.org>.
coveralls commented on issue #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#issuecomment-582220628
 
 
   ## Pull Request Test Coverage Report for [Build 9319](https://coveralls.io/builds/28534533)
   
   * **0** of **66**   **(0.0%)**  changed or added relevant lines in **2** files are covered.
   * **9** unchanged lines in **6** files lost coverage.
   * Overall coverage decreased (**-0.2%**) to **64.903%**
   
   ---
   
   |  Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
   | :-----|--------------|--------|---: |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/sql/segment/dal/FromTableSegment.java](https://coveralls.io/builds/28534533/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-mysql%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fsegment%2Fdal%2FFromTableSegment.java#L39) | 0 | 2 | 0.0%
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java](https://coveralls.io/builds/28534533/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-mysql%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2FMySQLVisitor.java#L244) | 0 | 64 | 0.0%
   <!-- | **Total:** | **0** | **66** | **0.0%** | -->
   
   |  Files with Coverage Reduction | New Missed Lines | % |
   | :-----|--------------|--: |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/DescribeStatement.java](https://coveralls.io/builds/28534533/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-engine%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fstatement%2Fdal%2Fdialect%2Fmysql%2FDescribeStatement.java#L32) | 1 | 0% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowColumnsStatement.java](https://coveralls.io/builds/28534533/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-engine%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fstatement%2Fdal%2Fdialect%2Fmysql%2FShowColumnsStatement.java#L32) | 1 | 0% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowCreateTableStatement.java](https://coveralls.io/builds/28534533/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-engine%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fstatement%2Fdal%2Fdialect%2Fmysql%2FShowCreateTableStatement.java#L32) | 1 | 0% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowIndexStatement.java](https://coveralls.io/builds/28534533/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-engine%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fstatement%2Fdal%2Fdialect%2Fmysql%2FShowIndexStatement.java#L32) | 1 | 0% |
   | [sharding-sql-test/src/main/java/org/apache/shardingsphere/test/sql/loader/SQLCasesLoader.java](https://coveralls.io/builds/28534533/source?filename=sharding-sql-test%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Ftest%2Fsql%2Floader%2FSQLCasesLoader.java#L138) | 2 | 79.76% |
   | [sharding-orchestration/sharding-orchestration-core/src/main/java/org/apache/shardingsphere/orchestration/internal/util/IpUtils.java](https://coveralls.io/builds/28534533/source?filename=sharding-orchestration%2Fsharding-orchestration-core%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Forchestration%2Finternal%2Futil%2FIpUtils.java#L65) | 3 | 76.0% |
   <!-- | **Total:** | **9** |  | -->
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/28534533/badge)](https://coveralls.io/builds/28534533) |
   | :-- | --: |
   | Change from base [Build 773](https://coveralls.io/builds/28518281): |  -0.2% |
   | Covered Lines: | 10920 |
   | Relevant Lines: | 16825 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   

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

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

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373342377
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -169,7 +216,42 @@ public ASTNode visitShowTableStatus(final ShowTableStatusContext ctx) {
         }
         return showTableStatusStatement;
     }
-    
 
 Review comment:
   Recover to origin style.

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

[GitHub] [incubator-shardingsphere] tristaZero commented on issue #4117: add visitor for dal

Posted by GitBox <gi...@apache.org>.
tristaZero commented on issue #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#issuecomment-581228161
 
 
   Hi, @jingshanglu After reviewing your PR, i thought you are familiar with Sharding parser. Not only you consider to add some members for `some SQLStatement`, but make each `visitXX()` clear and in line with ss code standard. Good job!
   Some of my suggestions are attached, welcome your feedback.

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

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

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373914215
 
 

 ##########
 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:
   It seems the remainding rules of `DALStatement` are just showOther` and `setVariable`, 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

[GitHub] [incubator-shardingsphere] coveralls edited a comment on issue #4117: add visitor for dal

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on issue #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#issuecomment-582220628
 
 
   ## Pull Request Test Coverage Report for [Build 9323](https://coveralls.io/builds/28535129)
   
   * **0** of **66**   **(0.0%)**  changed or added relevant lines in **2** files are covered.
   * **4** unchanged lines in **4** files lost coverage.
   * Overall coverage decreased (**-0.2%**) to **64.903%**
   
   ---
   
   |  Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
   | :-----|--------------|--------|---: |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/sql/segment/dal/FromTableSegment.java](https://coveralls.io/builds/28535129/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-mysql%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fsegment%2Fdal%2FFromTableSegment.java#L39) | 0 | 2 | 0.0%
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java](https://coveralls.io/builds/28535129/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-mysql%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2FMySQLVisitor.java#L244) | 0 | 64 | 0.0%
   <!-- | **Total:** | **0** | **66** | **0.0%** | -->
   
   |  Files with Coverage Reduction | New Missed Lines | % |
   | :-----|--------------|--: |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/DescribeStatement.java](https://coveralls.io/builds/28535129/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-engine%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fstatement%2Fdal%2Fdialect%2Fmysql%2FDescribeStatement.java#L32) | 1 | 0% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowColumnsStatement.java](https://coveralls.io/builds/28535129/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-engine%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fstatement%2Fdal%2Fdialect%2Fmysql%2FShowColumnsStatement.java#L32) | 1 | 0% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowCreateTableStatement.java](https://coveralls.io/builds/28535129/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-engine%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fstatement%2Fdal%2Fdialect%2Fmysql%2FShowCreateTableStatement.java#L32) | 1 | 0% |
   | [shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowIndexStatement.java](https://coveralls.io/builds/28535129/source?filename=shardingsphere-sql-parser%2Fshardingsphere-sql-parser-engine%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fshardingsphere%2Fsql%2Fparser%2Fsql%2Fstatement%2Fdal%2Fdialect%2Fmysql%2FShowIndexStatement.java#L32) | 1 | 0% |
   <!-- | **Total:** | **4** |  | -->
   
   |  Totals | [![Coverage Status](https://coveralls.io/builds/28535129/badge)](https://coveralls.io/builds/28535129) |
   | :-- | --: |
   | Change from base [Build 9322](https://coveralls.io/builds/28534779): |  -0.2% |
   | Covered Lines: | 10920 |
   | Relevant Lines: | 16825 |
   
   ---
   ##### 💛  - [Coveralls](https://coveralls.io)
   

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

[GitHub] [incubator-shardingsphere] jingshanglu commented on issue #4117: add visitor for dal

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on issue #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#issuecomment-582235157
 
 
   @tristaZero next pr,this comment will be fix
   

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

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

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373860081
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -221,6 +233,41 @@ public ASTNode visitUse(final UseContext ctx) {
         useStatement.setSchema(schema.getLiteral());
         return useStatement;
     }
+
+    @Override
+    public ASTNode visitDesc(final DescContext ctx) {
+        TableSegment tablename = (TableSegment) visit(ctx.tableName());
+        DescribeStatement describeStatement = new DescribeStatement();
+        describeStatement.setTableName(tablename);
+        return describeStatement;
+    }
+
+    @Override
+    public ASTNode visitShowDatabases(final ShowDatabasesContext ctx) {
+        ShowDatabasesStatement showDatabasesStatement = new ShowDatabasesStatement();
+        ShowLikeContext showLikeContext = ctx.showLike();
+        if (null != showLikeContext) {
+            ShowLikeSegment showLikeSegment = (ShowLikeSegment) visit(ctx.showLike());
+            showDatabasesStatement.getAllSQLSegments().add(showLikeSegment);
+        }
+        return showDatabasesStatement;
+    }
+
+    @Override
+    public ASTNode visitShowTables(final ShowTablesContext ctx) {
+        ShowTablesStatement showTablesStatement = new ShowTablesStatement();
 
 Review comment:
   Variable name of `showTablesStatement` should be `result`.

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

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

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373341634
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -153,6 +165,41 @@ public ASTNode visitUse(final UseContext ctx) {
         useStatement.setSchema(schema.getLiteral());
         return useStatement;
     }
+
+    @Override
+    public ASTNode visitDesc(final DescContext ctx) {
+        LiteralValue tablename = (LiteralValue) visit(ctx.tableName());
 
 Review comment:
   `visit(ctx.tableName())` should return `TableSegment` not `LiteralValue `.

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

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

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373341944
 
 

 ##########
 File path: sharding-sql-test/src/main/resources/sql/visitor/dal/show.xml
 ##########
 @@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<sql-cases>
+    <sql-case id="show_table_status" value="SHOW TABLE STATUS" db-types="MySQL" />
+    <sql-case id="show_index_with_index_with_table" value="SHOW INDEX FROM t_order" db-types="MySQL" />
+    <sql-case id="show_index_with_indexes_with_table_and_database" value="SHOW INDEXES FROM t_order FROM sharding_db" db-types="MySQL" />
+    <sql-case id="show_index_with_keys_with_database_and_table" value="SHOW KEYS FROM sharding_db.t_order" db-types="MySQL" />
+    <sql-case id="show_index_with_table_back_quotes" value="SHOW INDEXES FROM `t_order` FROM sharding_db" db-types="MySQL" />
+    <sql-case id="show_index_with_database_back_quotes" value="SHOW INDEXES FROM t_order FROM `sharding_db`" db-types="MySQL" />
+    <sql-case id="show_index_with_back_quotes" value="SHOW KEYS FROM `sharding_db`.`t_order`" db-types="MySQL" />
+    <sql-case id="show_all" value="SHOW ALL" db-types="PostgreSQL" />
+    <sql-case id="show_server_version" value="SHOW SERVER_VERSION" db-types="PostgreSQL" />
 
 Review comment:
   sql-case of db-types="PostgreSQL" should be removed, test for visitor is based on MySQL.

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

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

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r375052087
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -227,27 +241,120 @@
     @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();
+        FromTableContext fromTableContext = ctx.fromTable();
+        FromSchemaContext fromSchemaContext = ctx.fromSchema();
+        ShowLikeContext showLikeContext = ctx.showLike();
+        if (null != fromTableContext) {
+            FromTableSegment fromTableSegment = (FromTableSegment) visit(fromTableContext);
+            result.setTable(fromTableSegment.getPattern());
+            result.getAllSQLSegments().add(fromTableSegment);
+        }
+        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();
+        FromSchemaContext fromSchemaContext = ctx.fromSchema();
+        FromTableContext fromTableContext = ctx.fromTable();
+        if (null != fromSchemaContext) {
+            SchemaNameContext schemaNameContext = fromSchemaContext.schemaName();
+            LiteralValue schema = (LiteralValue) visit(schemaNameContext);
+            SchemaSegment schemaSegment = new SchemaSegment(schemaNameContext.start.getStartIndex(), schemaNameContext.stop.getStopIndex(), schema.getLiteral());
+            result.getAllSQLSegments().add(schemaSegment);
+        }
+        if (null != fromTableContext) {
+            FromTableSegment fromTableSegment = (FromTableSegment) visitFromTable(fromTableContext);
+            TableSegment tableSegment = fromTableSegment.getPattern();
+            result.setTable(tableSegment);
+            result.getAllSQLSegments().add(tableSegment);
+        }
+        return result;
+    }
+
+    @Override
+    public ASTNode visitShowCreateTable(final ShowCreateTableContext ctx) {
+        ShowCreateTableStatement result = new ShowCreateTableStatement();
+        TableSegment table = (TableSegment) visit(ctx.tableName());
+        result.setTable(table);
+        return result;
+    }
+
+    @Override
+    public ASTNode visitFromTable(final FromTableContext ctx) {
+        FromTableSegment fromTableSegment = new FromTableSegment();
 
 Review comment:
   The name of this variable should be `result`.

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

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

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r375051375
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/sql/segment/dal/FromTableSegment.java
 ##########
 @@ -0,0 +1,47 @@
+/*
+ * 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.segment.dal;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.sql.parser.core.constant.QuoteCharacter;
+import org.apache.shardingsphere.sql.parser.sql.segment.SQLSegment;
+import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableAvailable;
+import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
+
+@Setter
+@Getter
+public class FromTableSegment implements SQLSegment, TableAvailable {
+
+    private int startIndex;
+
+    private int stopIndex;
+
+    private TableSegment pattern;
+
+    @Override
+    public String getTableName() {
+        return pattern.getTableName();
+    }
+
+    @Override
+    public QuoteCharacter getTableQuoteCharacter() {
+        return QuoteCharacter.NONE;
+    }
+
 
 Review comment:
   Invalid blank line. Please delete it.

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

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

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373860023
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -221,6 +233,41 @@ public ASTNode visitUse(final UseContext ctx) {
         useStatement.setSchema(schema.getLiteral());
         return useStatement;
     }
+
+    @Override
+    public ASTNode visitDesc(final DescContext ctx) {
+        TableSegment tablename = (TableSegment) visit(ctx.tableName());
+        DescribeStatement describeStatement = new DescribeStatement();
 
 Review comment:
   Variable name of `describeStatement` should be `result`.

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

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

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r375050565
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/sql/segment/dal/FromTableSegment.java
 ##########
 @@ -0,0 +1,47 @@
+/*
+ * 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.segment.dal;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.sql.parser.core.constant.QuoteCharacter;
+import org.apache.shardingsphere.sql.parser.sql.segment.SQLSegment;
+import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableAvailable;
+import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
+
+@Setter
+@Getter
+public class FromTableSegment implements SQLSegment, TableAvailable {
+
+    private int startIndex;
+
+    private int stopIndex;
+
+    private TableSegment pattern;
 
 Review comment:
   It is better to rename it to `table`.

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

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

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373342714
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -169,7 +216,42 @@ public ASTNode visitShowTableStatus(final ShowTableStatusContext ctx) {
         }
         return showTableStatusStatement;
     }
-    
+
+    @Override
+    public ASTNode visitShowColumns(final ShowColumnsContext ctx) {
+        ShowColumnsStatement showColumnsStatement = new ShowColumnsStatement();
+        FromSchemaContext fromSchemaContext = ctx.fromSchema();
+        ShowLikeContext showLikeContext = ctx.showLike();
+        if (null != fromSchemaContext) {
+            FromSchemaSegment fromSchemaSegment = (FromSchemaSegment) visit(ctx.fromSchema());
+            showColumnsStatement.getAllSQLSegments().add(fromSchemaSegment);
+        }
+        if (null != showLikeContext) {
+            ShowLikeSegment showLikeSegment = (ShowLikeSegment) visit(ctx.showLike());
+            showColumnsStatement.getAllSQLSegments().add(showLikeSegment);
+        }
+        return showColumnsStatement;
+    }
+
+    @Override
+    public ASTNode visitShowIndex(final ShowIndexContext ctx) {
+        ShowIndexStatement showIndexStatement = new ShowIndexStatement();
+        FromSchemaContext fromSchemaContext = ctx.fromSchema();
+        if (null != fromSchemaContext) {
+            FromSchemaSegment fromSchemaSegment = (FromSchemaSegment) visit(ctx.fromSchema());
+            showIndexStatement.getAllSQLSegments().add(fromSchemaSegment);
+        }
+        return showIndexStatement;
+    }
+
+    @Override
+    public ASTNode visitShowCreateTable(final ShowCreateTableContext ctx) {
+        ShowCreateTableStatement showCreateTableStatement = new ShowCreateTableStatement();
+        LiteralValue tablename = (LiteralValue) visit(ctx.tableName());
 
 Review comment:
   Same to above.

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

[GitHub] [incubator-shardingsphere] tristaZero merged pull request #4117: add visitor for dal

Posted by GitBox <gi...@apache.org>.
tristaZero merged pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117
 
 
   

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

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

Posted by GitBox <gi...@apache.org>.
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

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

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r375052215
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -227,27 +241,120 @@
     @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();
+        FromTableContext fromTableContext = ctx.fromTable();
+        FromSchemaContext fromSchemaContext = ctx.fromSchema();
+        ShowLikeContext showLikeContext = ctx.showLike();
+        if (null != fromTableContext) {
+            FromTableSegment fromTableSegment = (FromTableSegment) visit(fromTableContext);
 
 Review comment:
   Please check whether there is simiar issue here. Thx.

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

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

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r375051573
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/ShowColumnsStatement.java
 ##########
 @@ -17,12 +17,18 @@
 
 package org.apache.shardingsphere.sql.parser.sql.statement.dal.dialect.mysql;
 
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.dal.DALStatement;
 
 /**
  * Show columns statement.
  *
  * @author zhangliang
  */
+@Setter
+@Getter
 public final class ShowColumnsStatement extends DALStatement {
+    private TableSegment table;
 
 Review comment:
   A blank line should be added above this line.

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

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

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r375051050
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -227,27 +241,120 @@
     @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();
+        FromTableContext fromTableContext = ctx.fromTable();
+        FromSchemaContext fromSchemaContext = ctx.fromSchema();
+        ShowLikeContext showLikeContext = ctx.showLike();
+        if (null != fromTableContext) {
+            FromTableSegment fromTableSegment = (FromTableSegment) visit(fromTableContext);
 
 Review comment:
   Since `FromTableSegment` is not handled in `rewriteEngine`, `Show columns from t_order` could not be rewriten to correct sql. You can have a try.

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

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

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r375052909
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/sql/segment/dal/FromTableSegment.java
 ##########
 @@ -0,0 +1,47 @@
+/*
+ * 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.segment.dal;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.sql.parser.core.constant.QuoteCharacter;
+import org.apache.shardingsphere.sql.parser.sql.segment.SQLSegment;
+import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableAvailable;
+import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
+
+@Setter
+@Getter
+public class FromTableSegment implements SQLSegment, TableAvailable {
+
+    private int startIndex;
+
+    private int stopIndex;
+
+    private TableSegment pattern;
 
 Review comment:
   next pr, I'll fix it

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

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

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373860047
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -221,6 +233,41 @@ public ASTNode visitUse(final UseContext ctx) {
         useStatement.setSchema(schema.getLiteral());
         return useStatement;
     }
+
+    @Override
+    public ASTNode visitDesc(final DescContext ctx) {
+        TableSegment tablename = (TableSegment) visit(ctx.tableName());
+        DescribeStatement describeStatement = new DescribeStatement();
+        describeStatement.setTableName(tablename);
+        return describeStatement;
+    }
+
+    @Override
+    public ASTNode visitShowDatabases(final ShowDatabasesContext ctx) {
+        ShowDatabasesStatement showDatabasesStatement = new ShowDatabasesStatement();
 
 Review comment:
   Variable name of `showDatabasesStatement` should be `result`.

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

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

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373860104
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -237,7 +284,42 @@ public ASTNode visitShowTableStatus(final ShowTableStatusContext ctx) {
         }
         return showTableStatusStatement;
     }
-    
+
+    @Override
+    public ASTNode visitShowColumns(final ShowColumnsContext ctx) {
+        ShowColumnsStatement showColumnsStatement = new ShowColumnsStatement();
 
 Review comment:
   Similar to above.

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

[GitHub] [incubator-shardingsphere] tristaZero edited a comment on issue #4117: add visitor for dal

Posted by GitBox <gi...@apache.org>.
tristaZero edited a comment on issue #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#issuecomment-581228161
 
 
   Hi, @jingshanglu After reviewing your PR, i thought you are familiar with Sharding parser. 
   
   Not only you considered to add some members for `some SQLStatement`, but made each `visitXX()` clear and in line with ss code standard. Good job!
   
   Some of my suggestions are attached, welcome your feedback.

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

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

Posted by GitBox <gi...@apache.org>.
tristaZero commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373913553
 
 

 ##########
 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();
 
 Review comment:
   How to handle the rule `fromTable_` of `showColumns` in `DALStatement.g4`? Please notice change the name of `fromTable_` once visit it.

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

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

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373859961
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/sql/statement/dal/dialect/mysql/DescribeStatement.java
 ##########
 @@ -17,12 +17,19 @@
 
 package org.apache.shardingsphere.sql.parser.sql.statement.dal.dialect.mysql;
 
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.shardingsphere.sql.parser.sql.segment.generic.TableSegment;
 import org.apache.shardingsphere.sql.parser.sql.statement.dal.DALStatement;
 
 /**
  * Describe statement.
  *
  * @author zhangliang
  */
+@Getter
+@Setter
 public final class DescribeStatement extends DALStatement {
+
+    private TableSegment tableName;
 
 Review comment:
   Variable of `tableName` is recommended to named `table`.

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

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

Posted by GitBox <gi...@apache.org>.
jingshanglu commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373917721
 
 

 ##########
 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();
 
 Review comment:
   I will think the hander or sub rule.

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

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

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on a change in pull request #4117: add visitor for dal
URL: https://github.com/apache/incubator-shardingsphere/pull/4117#discussion_r373860099
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/MySQLVisitor.java
 ##########
 @@ -237,7 +284,42 @@ public ASTNode visitShowTableStatus(final ShowTableStatusContext ctx) {
         }
         return showTableStatusStatement;
     }
-    
+
+    @Override
+    public ASTNode visitShowColumns(final ShowColumnsContext ctx) {
+        ShowColumnsStatement showColumnsStatement = new ShowColumnsStatement();
+        FromSchemaContext fromSchemaContext = ctx.fromSchema();
+        ShowLikeContext showLikeContext = ctx.showLike();
+        if (null != fromSchemaContext) {
+            FromSchemaSegment fromSchemaSegment = (FromSchemaSegment) visit(ctx.fromSchema());
+            showColumnsStatement.getAllSQLSegments().add(fromSchemaSegment);
+        }
+        if (null != showLikeContext) {
+            ShowLikeSegment showLikeSegment = (ShowLikeSegment) visit(ctx.showLike());
+            showColumnsStatement.getAllSQLSegments().add(showLikeSegment);
+        }
+        return showColumnsStatement;
+    }
+
+    @Override
+    public ASTNode visitShowIndex(final ShowIndexContext ctx) {
+        ShowIndexStatement showIndexStatement = new ShowIndexStatement();
 
 Review comment:
   Similar to above.

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