soumyakanti3578 commented on code in PR #6103:
URL: https://github.com/apache/hive/pull/6103#discussion_r2475372515
##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelFieldTrimmer.java:
##########
@@ -203,6 +202,26 @@ protected RexNode handle(RexFieldAccess fieldAccess) {
return dispatchTrimFields(input, fieldsUsedBuilder.build(), extraFields);
}
+ @Override
+ protected void setColumnAccessInfoForViews(RelNode rel, ImmutableBitSet
fieldsUsed) {
+ final ColumnAccessInfo columnAccessInfo = COLUMN_ACCESS_INFO.get();
+ final Map<RelNode, Table> relNodeToTableAndProjects =
VIEW_RELNODE_TO_TABLE.get();
+
+ // HiveTableScans are handled separately in HiveTableScan's trimFields
method.
+ if (!(rel instanceof HiveTableScan) &&
+ columnAccessInfo != null &&
+ relNodeToTableAndProjects != null &&
+ relNodeToTableAndProjects.containsKey(rel)) {
+ Table table = relNodeToTableAndProjects.get(rel);
+ List<FieldSchema> tableAllCols = table.getAllCols();
+
+ rel.getRowType().getFieldList().stream()
+ .map(RelDataTypeField::getIndex)
+ .filter(fieldsUsed::get)
+ .forEach(i -> columnAccessInfo.add(table.getCompleteName(),
tableAllCols.get(i).getName()));
Review Comment:
Agreed!
Replaced with
```
for (int i = fieldsUsed.nextSetBit(0); i >= 0; i = fieldsUsed.nextSetBit(i +
1)) {
columnAccessInfo.add(table.getCompleteName(),
tableAllCols.get(i).getName());
}
```
which is slightly cleaner and more readable in my opinion.
--
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]