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:
[email protected]
With regards,
Apache Git Services