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/03/25 04:02:46 UTC

[GitHub] [incubator-shardingsphere] tristaZero commented on a change in pull request #4916: add tableReferences in selectStatement

tristaZero commented on a change in pull request #4916: add tableReferences in selectStatement
URL: https://github.com/apache/incubator-shardingsphere/pull/4916#discussion_r397594875
 
 

 ##########
 File path: shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/impl/MySQLDMLVisitor.java
 ##########
 @@ -479,78 +495,67 @@ public ASTNode visitEscapedTableReference(final EscapedTableReferenceContext ctx
     
     @Override
     public ASTNode visitTableReference(final TableReferenceContext ctx) {
-        CollectionValue<SimpleTableSegment> result = new CollectionValue<>();
+        TableReferenceSegment result = new TableReferenceSegment();
         if (null != ctx.tableFactor()) {
-            // TODO :Ignore subquery table segment
             ASTNode tableFactor = visit(ctx.tableFactor());
-            if (tableFactor instanceof SimpleTableSegment) {
-                result.getValue().add((SimpleTableSegment) tableFactor);
+            if (null != tableFactor) {
+                result.setTable((TableSegment) tableFactor);
             }
         }
-        if (null != ctx.joinedTable()) {
-            for (JoinedTableContext each : ctx.joinedTable()) {
-                result.getValue().addAll(getTableSegments(result.getValue(), each));
+        if (!ctx.joinedTable().isEmpty()) {
+            for (JoinedTableContext jc : ctx.joinedTable()) {
+                JoinedTableSegment joinedTableSegment = (JoinedTableSegment) visit(jc);
+                result.getJoinedTables().add(joinedTableSegment);
             }
         }
         return result;
     }
     
     @Override
     public ASTNode visitTableFactor(final TableFactorContext ctx) {
+        if (null != ctx.subquery()) {
+            visit(ctx.subquery());
+        }
         if (null != ctx.tableName()) {
             SimpleTableSegment result = (SimpleTableSegment) visit(ctx.tableName());
             if (null != ctx.alias()) {
                 result.setAlias((AliasSegment) visit(ctx.alias()));
             }
             return result;
         }
-        if (null != ctx.tableReferences()) {
-            return visit(ctx.tableReferences());
-        }
-        SubqueryTableSegment result = new SubqueryTableSegment(new SubquerySegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), (SelectStatement) visit(ctx.subquery())));
 
 Review comment:
   How to handle the `alias` for `subquery`?

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