Skip to content

[CALCITE-3400] Implement left/right/semi/anti/full join in Interpreter#1496

Closed
yanlin-Lynn wants to merge 2 commits into
apache:masterfrom
yanlin-Lynn:interpreter
Closed

[CALCITE-3400] Implement left/right/semi/anti/full join in Interpreter#1496
yanlin-Lynn wants to merge 2 commits into
apache:masterfrom
yanlin-Lynn:interpreter

Conversation

@yanlin-Lynn

Copy link
Copy Markdown
Contributor

Currently, we can only interpreter inner join with Interpreter, because JoinNode only support inner join type.

This PR tries to add support more join types for JoinNode

+ rel.getRight().getRowType().getFieldCount();
context.values = new Object[fieldCount];

Source baseSource = leftSource;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call it outer/inner source.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hsyuan Thanks for reviewing, just a little question.
Might it a little misleading by calling it outer/inner source?
It seems do not match well with semi/anti/full join.
Any more detail explanation for outer/inner?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is misleading. It is for outer relation or inner relation, not for the outer join or inner join. Look at the nested loop, the outer relation is used for outer loop, the inner relation is used for the inner loop.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, got your point.
Updated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "outer" and "inner" are a bit misleading. Since outer is always left and inner is always right, how about we keep the names left and right? You could add a comment about left being the outer side of the nested loop.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But for right outer join, the right relation is outer, left relation is inner.

/** Implementation of {@code MIN} function to calculate the minimum of
* {@code boolean} values as a user-defined aggregate.
*/
public static class MinBoolean {

@yanlin-Lynn yanlin-Lynn Oct 12, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For anti join, right input of the join may like this,

LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
    LogicalProject(X=[$0], $f1=[true])
        LogicalValues(tuples=[[{ 1, 'd' }]])

so need to calculate the minimum of boolean values, use MinBoolean as a user-defined aggregate.

joinRows = new ArrayList<Row>();
Row joinRow = null;
while ((joinRow = innerSource.receive()) != null) {
joinRows.add(joinRow);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here. baseRow, joinRow to outerRow, innerRow...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I miss that.
And the parameter of doJoin and doSend should also be updated, right?
I'll update them together.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I unify all of them to outerRow and innerRow.

@julianhyde

Copy link
Copy Markdown
Contributor

In method javadoc, you must use the 3rd person declarative (e.g. "Gets ...".)

…r (Wang Yanlin)

For anti join, right input of the join may like this,
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
   LogicalProject(X=[$0], $f1=[true])
      LogicalValues(tuples=[[{ 1, 'd' }]])
so need to calculate the minimum of boolean values, use MinBoolean as a user-defined aggregate.
@yanlin-Lynn yanlin-Lynn changed the title [CALCITE-3400] Add support for interpretering left/right/semi/anti/full join [CALCITE-3400] Implement left/right/semi/anti/full join in Interpreter Oct 17, 2019
}
}
doSend(outerRow, matchInnerRows, joinRelType);
return ImmutableList.copyOf(matchInnerRows);

@hsyuan hsyuan Nov 4, 2019

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need ImmutableList copy? matchRowSet.addAll() will copy them again, right?

@yanlin-Lynn yanlin-Lynn Nov 4, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we do not need.
Updated

@hsyuan hsyuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@hsyuan hsyuan closed this in 01043b1 Nov 5, 2019
@yanlin-Lynn
yanlin-Lynn deleted the interpreter branch November 5, 2019 05:47
XuQianJin-Stars pushed a commit to XuQianJin-Stars/calcite that referenced this pull request Nov 17, 2019
…r (Wang Yanlin)

For anti join, right input of the join may like this,
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
   LogicalProject(X=[$0], $f1=[true])
      LogicalValues(tuples=[[{ 1, 'd' }]])
so need to calculate the minimum of boolean values, use MinBoolean as a
user-defined aggregate.

Close apache#1496
XuQianJin-Stars pushed a commit to XuQianJin-Stars/calcite that referenced this pull request Nov 20, 2019
…r (Wang Yanlin)

For anti join, right input of the join may like this,
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
   LogicalProject(X=[$0], $f1=[true])
      LogicalValues(tuples=[[{ 1, 'd' }]])
so need to calculate the minimum of boolean values, use MinBoolean as a
user-defined aggregate.

Close apache#1496
XuQianJin-Stars pushed a commit to XuQianJin-Stars/calcite that referenced this pull request Nov 20, 2019
…r (Wang Yanlin)

For anti join, right input of the join may like this,
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
   LogicalProject(X=[$0], $f1=[true])
      LogicalValues(tuples=[[{ 1, 'd' }]])
so need to calculate the minimum of boolean values, use MinBoolean as a
user-defined aggregate.

Close apache#1496
wangxlong pushed a commit to wangxlong/calcite that referenced this pull request Feb 13, 2020
…r (Wang Yanlin)

For anti join, right input of the join may like this,
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
   LogicalProject(X=[$0], $f1=[true])
      LogicalValues(tuples=[[{ 1, 'd' }]])
so need to calculate the minimum of boolean values, use MinBoolean as a
user-defined aggregate.

Close apache#1496
jamesstarr pushed a commit to jamesstarr/calcite that referenced this pull request Aug 28, 2025
…r (Wang Yanlin)

For anti join, right input of the join may like this,
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
   LogicalProject(X=[$0], $f1=[true])
      LogicalValues(tuples=[[{ 1, 'd' }]])
so need to calculate the minimum of boolean values, use MinBoolean as a
user-defined aggregate.

Close apache#1496

Change-Id: I5aa61f0e341e5e45174e8867ffaf26ee26ec9f19
jamesstarr pushed a commit to jamesstarr/calcite that referenced this pull request Mar 16, 2026
…r (Wang Yanlin)

For anti join, right input of the join may like this,
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
   LogicalProject(X=[$0], $f1=[true])
      LogicalValues(tuples=[[{ 1, 'd' }]])
so need to calculate the minimum of boolean values, use MinBoolean as a
user-defined aggregate.

Close apache#1496

Change-Id: I5aa61f0e341e5e45174e8867ffaf26ee26ec9f19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants