danny0405 commented on a change in pull request #2125:
URL: https://github.com/apache/calcite/pull/2125#discussion_r481950279
##########
File path: core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java
##########
@@ -885,14 +886,22 @@ public TrimResult trimFields(
/**
* Variant of {@link #trimFields(RelNode, ImmutableBitSet, Set)} for
- * {@link org.apache.calcite.rel.core.SetOp} (including UNION and UNION ALL).
+ * {@link org.apache.calcite.rel.core.SetOp} (Only UNION ALL is supported).
*/
public TrimResult trimFields(
SetOp setOp,
ImmutableBitSet fieldsUsed,
Set<RelDataTypeField> extraFields) {
final RelDataType rowType = setOp.getRowType();
final int fieldCount = rowType.getFieldCount();
+
+ // Trim fields only for UNION ALL.
+ // Operator UNION/INTERSECT/INTERSECT ALL/EXCEPT/EXCEPT ALL
+ // will check duplication. We can not trim fields on them.
+ if (!(setOp.kind == SqlKind.UNION && setOp.all)) {
+ return result(setOp, Mappings.createIdentity(fieldCount));
Review comment:
And what is your conclusion there ?
----------------------------------------------------------------
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]