You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2022/04/26 08:59:18 UTC
[GitHub] [hive] kasakrisz commented on a diff in pull request #3229: HIVE-26160: Materialized View rewrite does not check tables scanned in sub-query expressions
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: gitbox-unsubscribe@hive.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org