tristaZero commented on a change in pull request #4916: add tableReferences in selectStatement URL: https://github.com/apache/incubator-shardingsphere/pull/4916#discussion_r397733820
########## 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 +493,73 @@ 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); - } + TableFactorSegment tableFactor = (TableFactorSegment) visit(ctx.tableFactor()); + result.setTableFactor(tableFactor); } - if (null != ctx.joinedTable()) { + if (!ctx.joinedTable().isEmpty()) { for (JoinedTableContext each : ctx.joinedTable()) { - result.getValue().addAll(getTableSegments(result.getValue(), each)); + JoinedTableSegment joinedTableSegment = (JoinedTableSegment) visit(each); + result.getJoinedTables().add(joinedTableSegment); } } return result; } @Override public ASTNode visitTableFactor(final TableFactorContext ctx) { + TableFactorSegment result = new TableFactorSegment(); + if (null != ctx.subquery()) { + SelectStatement subquery = (SelectStatement) visit(ctx.subquery()); + result.setSubquery(new SubquerySegment(ctx.subquery().start.getStartIndex(), ctx.subquery().stop.getStopIndex(), subquery)); Review comment: Please use `SubqueryTableSegment` ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services