Jackie-Jiang commented on code in PR #13666:
URL: https://github.com/apache/pinot/pull/13666#discussion_r1685167251
##########
pinot-query-planner/src/main/java/org/apache/pinot/calcite/rel/rules/PinotRelDistributionTraitRule.java:
##########
@@ -110,10 +117,22 @@ private static RelDistribution deriveDistribution(RelNode
node) {
LogicalProject project = (LogicalProject) node;
try {
if (inputRelDistribution != null) {
- return inputRelDistribution.apply(project.getMapping());
+ Mappings.TargetMapping mapping =
+ Project.getPartialMapping(input.getRowType().getFieldCount(),
project.getProjects());
+ // Note(gonzalo): In Calcite 1.37 mapping.getTargetOpt will fail in
what it looks like a Calcite bug.
+ // Therefore here we apply a workaround and create a new map where
the same elements (extracted with
+ // iterator, which actually work) are added to the new mapping.
+ // See
https://lists.apache.org/thread/qz18qxrfp5bqldnoln2tg4582g402zyv
+ Mapping actualMapping =
Mappings.create(MappingType.PARTIAL_FUNCTION,
input.getRowType().getFieldCount(),
+ project.getRowType().getFieldCount());
+ for (IntPair intPair : mapping) {
+ actualMapping.set(intPair.source, intPair.target);
+ }
+ return inputRelDistribution.apply(actualMapping);
}
} catch (Exception e) {
// ... skip;
+ LOGGER.debug("Failed to derive distribution from input for node: {}",
node, e);
Review Comment:
Do you want to log warning instead if it is not expected to fail?
--
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]