kasakrisz commented on code in PR #3229:
URL: https://github.com/apache/hive/pull/3229#discussion_r858465153
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java:
##########
@@ -2347,22 +2348,49 @@ private RelNode applyPostJoinOrderingTransform(RelNode
basePlan, RelMetadataProv
return basePlan;
}
+ /**
+ * Traverse the plan and collect table names from {@link TableScan}
operators
+ * Use this method if plan does not have any sub query.
+ * Use {@link CalcitePlannerAction#getAllTablesUsed(RelNode)} to include
sub-query expressions.
+ * @see HiveSubQueryRemoveRule
+ */
protected Set<TableName> getTablesUsed(RelNode plan) {
Set<TableName> tablesUsed = new HashSet<>();
new RelVisitor() {
@Override
public void visit(RelNode node, int ordinal, RelNode parent) {
- if (node instanceof TableScan) {
- TableScan ts = (TableScan) node;
- Table hiveTableMD = ((RelOptHiveTable)
ts.getTable()).getHiveTableMD();
- tablesUsed.add(hiveTableMD.getFullTableName());
- }
+ addUsedTable(node, tablesUsed);
super.visit(node, ordinal, parent);
}
}.go(plan);
return tablesUsed;
}
+ /**
+ * Traverse the plan including sub-query expressions and collect table
names from {@link TableScan} operators.
+ */
+ protected Set<TableName> getAllTablesUsed(RelNode plan) {
+ Set<TableName> tablesUsed = new HashSet<>();
+ new HiveSubQueryVisitor() {
Review Comment:
This seems to be a good idea. Let's see how it works: #3246
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]