xuzifu666 commented on code in PR #5253:
URL: https://github.com/apache/calcite/pull/5253#discussion_r3968999463
##########
core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java:
##########
@@ -1303,6 +1308,11 @@ public TrimResult trimFields(
// because zero-column records are illegal. Give them the last field,
// which is unlikely to be a system field.
if (fieldsUsed.isEmpty()) {
+ if (fieldCount == 0) {
Review Comment:
You're right that it looks contradictory. I've reworded the comment to
explain the edge case: the "keep the last field" rule only applies when there
is a last field. If the input already has zero columns, we can't manufacture
one, so we return it unchanged. This matches the fix for SetOp as well.
--
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]