[ 
https://issues.apache.org/jira/browse/CALCITE-5787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18053708#comment-18053708
 ] 

Julian Hyde edited comment on CALCITE-5787 at 1/22/26 9:25 PM:
---------------------------------------------------------------

[~jensen], In the following code, I can't find any rationale for the 
{{{}assert{}}}, nor do I understand why it is delegating to its inputs.
{code:java}
  public ImmutableList<ImmutableBitSet> getInputFieldsUsed(SetOp setOp,
      RelMetadataQuery mq) {
    final ImmutableList.Builder<ImmutableBitSet> builder = 
ImmutableList.builder();
    for (RelNode input : setOp.getInputs()) {
      ImmutableList<ImmutableBitSet> inputFieldsBits = 
mq.getInputFieldsUsed(input);
      assert inputFieldsBits.size() == 1;
      builder.add(inputFieldsBits.get(0));
    }
    return builder.build();
  } {code}
 

The use of {{ImmutableBitSet.union}} to merge bit sets in {{SemiJoinRule}} is 
so bizarre that I don't trust the fix to this case or to CALCITE-5740.


was (Author: julianhyde):
[~jensen], In the following code, I can't find any rationale for the 
{{{}assert{}}}, nor do I understand why it is delegating to its inputs.
{code:java}
  public ImmutableList<ImmutableBitSet> getInputFieldsUsed(SetOp setOp,
      RelMetadataQuery mq) {
    final ImmutableList.Builder<ImmutableBitSet> builder = 
ImmutableList.builder();
    for (RelNode input : setOp.getInputs()) {
      ImmutableList<ImmutableBitSet> inputFieldsBits = 
mq.getInputFieldsUsed(input);
      assert inputFieldsBits.size() == 1;
      builder.add(inputFieldsBits.get(0));
    }
    return builder.build();
  } {code}
 

The use of {{ImmutableBitSet.union}} to merge bit sets is so bizarre that I 
don't trust the fix to this case or to CALCITE-5740.

> The RelMdInputFieldsUsed is introduced to track the usage of input fields
> -------------------------------------------------------------------------
>
>                 Key: CALCITE-5787
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5787
>             Project: Calcite
>          Issue Type: New Feature
>            Reporter: Rong Rong
>            Assignee: Zhen Chen
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.42.0
>
>
> It would be super useful to detect all the input fields used in a {{RelNode}} 
> to indicate what's being used from the inputs. 
> We have a similar utility to find all input fields referenced for a 
> {{RexNode}} via {{RelOptUtil.InputFinder}}. For a relation we can do one step 
> further to automatically keep track of all the relevant relations.
> For example,
>  - {{Aggregate}} relations: {{RelNode.getInputFieldsUsed}} should return a 
> union of the input fields used by {{groupSet}} and all {{aggregateCall}}  
>  - for each {{aggregateCall}}, we should include all fields used in 
> {{{}argList{}}}, {{{}filterArg{}}}, {{{}distinctKeys{}}}, and 
> {{{}collation{}}}.
> see relative discussion in CALCITE-5740



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to