You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2022/05/16 02:19:56 UTC
[GitHub] [calcite] chunweilei commented on a diff in pull request #2806: [CALCITE-5061] Improve recursive application of the field trimming
chunweilei commented on code in PR #2806:
URL: https://github.com/apache/calcite/pull/2806#discussion_r873279078
##########
core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java:
##########
@@ -352,11 +352,24 @@ public TrimResult trimFields(
RelNode rel,
ImmutableBitSet fieldsUsed,
Set<RelDataTypeField> extraFields) {
- // We don't know how to trim this kind of relational expression, so give
- // it back intact.
+ // We don't know how to trim this kind of relational expression
Util.discard(fieldsUsed);
- return result(rel,
- Mappings.createIdentity(rel.getRowType().getFieldCount()));
+ if (rel.getInputs().isEmpty()) {
+ return result(rel, Mappings.createIdentity(rel.getRowType().getFieldCount()));
+ }
+
+ // We don't know how to trim this RelNode, but we can try to trim inside its inputs
+ List<RelNode> newInputs = new ArrayList<>(rel.getInputs().size());
+ for (RelNode input : rel.getInputs()) {
+ ImmutableBitSet inputFieldsUsed = ImmutableBitSet.range(input.getRowType().getFieldCount());
+ TrimResult trimResult = dispatchTrimFields(input, inputFieldsUsed, extraFields);
+ if (!trimResult.right.isIdentity()) {
+ throw new IllegalArgumentException();
+ }
Review Comment:
> throw new IllegalArgumentException();
Should we add some clear exception messages instead?
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org