jinxing64 commented on a change in pull request #1468: [CALCITE-3366]
RelDecorrelator supports Union
URL: https://github.com/apache/calcite/pull/1468#discussion_r327453817
##########
File path: core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
##########
@@ -1242,6 +1244,37 @@ public Frame decorrelateRel(Join rel) {
return register(rel, newJoin, mapOldToNewOutputs, corDefOutputs);
}
+ public Frame decorrelateRel(LogicalUnion rel) {
+ return decorrelateRel((Union) rel);
+ }
+
+ public Frame decorrelateRel(Union rel) {
+ assert !cm.mapRefRelToCorRef.containsKey(rel);
+
+ final List<RelNode> oldInputs = rel.getInputs();
+
+ final Frame frame0 = getInvoke(oldInputs.get(0), rel);
+ if (frame0 == null) {
+ return null;
+ }
+
+ relBuilder.push(frame0.r);
+
+ for (int i = 1; i < oldInputs.size(); i++) {
+ final Frame frame = getInvoke(oldInputs.get(i), rel);
+ if (frame == null) {
+ return null;
+ }
+ if (!frame.oldToNewOutputs.equals(frame0.oldToNewOutputs)
+ || !frame.corDefOutputs.equals(frame0.corDefOutputs)) {
Review comment:
@hsyuan Good question ~
`testDecorrelateUnion1` is testing the second point "2. The input frames
have the same correlation references and corresponding outputs."
But for the first point (" 1. The input frames have the same mapping of old
outputs to new outputs"), I cannot find a way to test.
In current implementation of decorrelation for operators like
Project/Filter/Join/Correlate/Union/Aggregate, I didn't find one which permute
the mapping in `oldToNewOutputs `, i.e. basically the mapping is derived from
parent to child.
For short, in my understanding, Union should always have child frames with
the same `oldToNewOutputs`.
Please correct me if I'm wrong.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services