Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add APPLY operator representation #363

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions proto/substrait/algebra.proto
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,29 @@ message JoinRel {
substrait.extensions.AdvancedExtension advanced_extension = 10;
}

// Represents APPLY relational operator, implemented as APPLY in SQL Server and LATERAL in Calcite. It resembles a
// JOIN operator, but has different semantics. To use a JOIN, there must be no dependency between the two input
// relations to be joined. Whereas APPLY depends on a correlation predicate, and to perform APPLY, the table
// source on the right is evaluated against every row of the table source on the left, and not just once.
// APPLY is frequently used when the expression on the right is a Table-Valued-Function.
// See: https://www.mssqltips.com/sqlservertip/1958/sql-server-cross-apply-and-outer-apply/
// e.g. select * from store_sales CROSS APPLY (select * from item where item.i_item_sk = store_sales.ss_item_sk);
message ApplyRel {
RelCommon common = 1;
Rel left = 2;
Expression right = 3;

ApplyType type = 4;

enum ApplyType {
Apply_TYPE_UNSPECIFIED = 0;
Copy link

Choose a reason for hiding this comment

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

Why lower case Apply here and APPLY for the next two?

APPLY_TYPE_CROSS = 1;
APPLY_TYPE_OUTER = 2;
}

substrait.extensions.AdvancedExtension advanced_extension = 10;
}

// Cartesian product relational operator of two tables (left and right)
message CrossRel {
RelCommon common = 1;
Expand Down