Skip to content

Commit

Permalink
Minor refactor for SelectStatementContext#containsTableSubquery (#32278)
Browse files Browse the repository at this point in the history
  • Loading branch information
strongduanmu authored Jul 26, 2024
1 parent c7d5e37 commit bc673ba
Showing 1 changed file with 1 addition and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,18 +403,7 @@ private void appendInheritedSimpleTables(final Collection<TableSegment> inherite
* @return whether sql statement contains table subquery segment or not
*/
public boolean containsTableSubquery() {
return getSqlStatement().getFrom().isPresent() && isAllSubqueryTable(getSqlStatement().getFrom().get()) || getSqlStatement().getWithSegment().isPresent();
}

private boolean isAllSubqueryTable(final TableSegment tableSegment) {
return tableSegment instanceof SubqueryTableSegment || isAllSubqueryTableInJoinTable(tableSegment);
}

private boolean isAllSubqueryTableInJoinTable(final TableSegment tableSegment) {
if (tableSegment instanceof JoinTableSegment) {
return isAllSubqueryTable(((JoinTableSegment) tableSegment).getLeft()) && isAllSubqueryTable(((JoinTableSegment) tableSegment).getRight());
}
return false;
return getSqlStatement().getFrom().isPresent() && getSqlStatement().getFrom().get() instanceof SubqueryTableSegment || getSqlStatement().getWithSegment().isPresent();
}

/**
Expand Down

0 comments on commit bc673ba

Please sign in to comment.