-
Notifications
You must be signed in to change notification settings - Fork 2
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: implement join
operation
#32
base: main
Are you sure you want to change the base?
Changes from 2 commits
095af9b
959c396
fa7646e
0172bcc
f60e77d
f77df3d
396a9d7
afc3b8e
ff2b1e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -474,6 +474,36 @@ def Substrait_FilterOp : Substrait_RelOp<"filter", [ | |
}]; | ||
} | ||
|
||
def JoinTypeKind : I32EnumAttr<"JoinTypeKind", | ||
"The enum values correspond to those in the JoinRel.JoinType message.", [ | ||
I32EnumAttrCase<"unspecified", 0>, | ||
I32EnumAttrCase<"inner", 1>, | ||
I32EnumAttrCase<"outer", 2>, | ||
I32EnumAttrCase<"left", 3>, | ||
I32EnumAttrCase<"right", 4>, | ||
I32EnumAttrCase<"semi", 5>, | ||
I32EnumAttrCase<"anti", 6>, | ||
I32EnumAttrCase<"single", 7>] >; | ||
|
||
def Substrait_JoinOp : Substrait_RelOp<"join", [DeclareOpInterfaceMethods<InferTypeOpInterface>]> { | ||
let summary = "join operation"; | ||
let description = [{ | ||
Represents a `JoinRel` message together with the `RelCommon`, left and | ||
right `Rel` messages and `JoinType` enumeration it contains. The current | ||
implementation assumes the join expression to be True. | ||
}]; | ||
//TODO(daliashaaban): Add support for join expressions. | ||
let arguments = (ins | ||
Substrait_Relation:$left, | ||
Substrait_Relation:$right, | ||
JoinTypeKind:$join_type | ||
); | ||
let results = (outs Substrait_Relation:$result); | ||
let assemblyFormat = [{ | ||
$join_type $left `j` $right attr-dict `:` type($left) `j` type($right) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I am not a fan of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fun fact: I actually initially tried to do this symbol in the assembly format There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pitty! Nice idea, though! |
||
}]; | ||
} | ||
|
||
def Substrait_NamedTableOp : Substrait_RelOp<"named_table", [ | ||
]> { | ||
let summary = "Read operation of a named table"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
// RUN: substrait-opt -split-input-file %s \ | ||
// RUN: | FileCheck %s | ||
|
||
// CHECK-LABEL: substrait.plan | ||
// CHECK: relation | ||
// CHECK: %[[V0:.*]] = named_table | ||
// CHECK: %[[V1:.*]] = named_table | ||
// CHECK-NEXT: %[[V2:.*]] = join unspecified %[[V0]] j %[[V1]] | ||
// CHECK-SAME: : tuple<si32> j tuple<si32> | ||
// CHECK-NEXT: yield %[[V2]] : tuple<si32, si32> | ||
|
||
substrait.plan version 0 : 42 : 1 { | ||
relation { | ||
%0 = named_table @t1 as ["a"] : tuple<si32> | ||
%1 = named_table @t2 as ["b"] : tuple<si32> | ||
%2 = join unspecified %0 j %1 : tuple<si32> j tuple<si32> | ||
yield %2 : tuple<si32, si32> | ||
} | ||
} | ||
|
||
// CHECK-LABEL: substrait.plan | ||
// CHECK: relation | ||
// CHECK: %[[V0:.*]] = named_table | ||
// CHECK: %[[V1:.*]] = named_table | ||
// CHECK-NEXT: %[[V2:.*]] = join inner %[[V0]] j %[[V1]] | ||
// CHECK-SAME: : tuple<si32> j tuple<si1> | ||
// CHECK-NEXT: yield %[[V2]] : tuple<si32, si1> | ||
|
||
substrait.plan version 0 : 42 : 1 { | ||
relation { | ||
%0 = named_table @t1 as ["a"] : tuple<si32> | ||
%1 = named_table @t2 as ["b"] : tuple<si1> | ||
%2 = join inner %0 j %1 : tuple<si32> j tuple<si1> | ||
yield %2 : tuple<si32, si1> | ||
} | ||
} | ||
|
||
// CHECK-LABEL: substrait.plan | ||
// CHECK: relation | ||
// CHECK: %[[V0:.*]] = named_table | ||
// CHECK: %[[V1:.*]] = named_table | ||
// CHECK-NEXT: %[[V2:.*]] = join outer %[[V0]] j %[[V1]] | ||
// CHECK-SAME: : tuple<si32> j tuple<si32> | ||
// CHECK-NEXT: yield %[[V2]] : tuple<si32, si32> | ||
|
||
substrait.plan version 0 : 42 : 1 { | ||
relation { | ||
%0 = named_table @t1 as ["a"] : tuple<si32> | ||
%1 = named_table @t2 as ["b"] : tuple<si32> | ||
%2 = join outer %0 j %1 : tuple<si32> j tuple<si32> | ||
yield %2 : tuple<si32, si32> | ||
} | ||
} | ||
|
||
// CHECK-LABEL: substrait.plan | ||
// CHECK: relation | ||
// CHECK: %[[V0:.*]] = named_table | ||
// CHECK: %[[V1:.*]] = named_table | ||
// CHECK-NEXT: %[[V2:.*]] = join left %[[V0]] j %[[V1]] | ||
// CHECK-SAME: : tuple<si32> j tuple<si32> | ||
// CHECK-NEXT: yield %[[V2]] : tuple<si32, si32> | ||
|
||
substrait.plan version 0 : 42 : 1 { | ||
relation { | ||
%0 = named_table @t1 as ["a"] : tuple<si32> | ||
%1 = named_table @t2 as ["b"] : tuple<si32> | ||
%2 = join left %0 j %1 : tuple<si32> j tuple<si32> | ||
yield %2 : tuple<si32, si32> | ||
} | ||
} | ||
|
||
// CHECK-LABEL: substrait.plan | ||
// CHECK: relation | ||
// CHECK: %[[V0:.*]] = named_table | ||
// CHECK: %[[V1:.*]] = named_table | ||
// CHECK-NEXT: %[[V2:.*]] = join right %[[V0]] j %[[V1]] | ||
// CHECK-SAME: : tuple<si32> j tuple<si32> | ||
// CHECK-NEXT: yield %[[V2]] : tuple<si32, si32> | ||
|
||
substrait.plan version 0 : 42 : 1 { | ||
relation { | ||
%0 = named_table @t1 as ["a"] : tuple<si32> | ||
%1 = named_table @t2 as ["b"] : tuple<si32> | ||
%2 = join right %0 j %1 : tuple<si32> j tuple<si32> | ||
yield %2 : tuple<si32, si32> | ||
} | ||
} | ||
|
||
// CHECK-LABEL: substrait.plan | ||
// CHECK: relation | ||
// CHECK: %[[V0:.*]] = named_table | ||
// CHECK: %[[V1:.*]] = named_table | ||
// CHECK-NEXT: %[[V2:.*]] = join semi %[[V0]] j %[[V1]] | ||
// CHECK-SAME: : tuple<si32> j tuple<si32> | ||
// CHECK-NEXT: yield %[[V2]] : tuple<si32, si32> | ||
|
||
substrait.plan version 0 : 42 : 1 { | ||
relation { | ||
%0 = named_table @t1 as ["a"] : tuple<si32> | ||
%1 = named_table @t2 as ["b"] : tuple<si32> | ||
%2 = join semi %0 j %1 : tuple<si32> j tuple<si32> | ||
yield %2 : tuple<si32, si32> | ||
} | ||
} | ||
|
||
// CHECK-LABEL: substrait.plan | ||
// CHECK: relation | ||
// CHECK: %[[V0:.*]] = named_table | ||
// CHECK: %[[V1:.*]] = named_table | ||
// CHECK-NEXT: %[[V2:.*]] = join anti %[[V0]] j %[[V1]] | ||
// CHECK-SAME: : tuple<si32> j tuple<si32> | ||
// CHECK-NEXT: yield %[[V2]] : tuple<si32, si32> | ||
|
||
substrait.plan version 0 : 42 : 1 { | ||
relation { | ||
%0 = named_table @t1 as ["a"] : tuple<si32> | ||
%1 = named_table @t2 as ["b"] : tuple<si32> | ||
%2 = join anti %0 j %1 : tuple<si32> j tuple<si32> | ||
yield %2 : tuple<si32, si32> | ||
} | ||
} | ||
|
||
// CHECK-LABEL: substrait.plan | ||
// CHECK: relation | ||
// CHECK: %[[V0:.*]] = named_table | ||
// CHECK: %[[V1:.*]] = named_table | ||
// CHECK-NEXT: %[[V2:.*]] = join single %[[V0]] j %[[V1]] | ||
// CHECK-SAME: : tuple<si32> j tuple<si32> | ||
// CHECK-NEXT: yield %[[V2]] : tuple<si32, si32> | ||
|
||
substrait.plan version 0 : 42 : 1 { | ||
relation { | ||
%0 = named_table @t1 as ["a"] : tuple<si32> | ||
%1 = named_table @t2 as ["b"] : tuple<si32> | ||
%2 = join single %0 j %1 : tuple<si32> j tuple<si32> | ||
yield %2 : tuple<si32, si32> | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: add a blank line at the end. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: move to enums file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually don't have an enums file. the SetOpKind Enum is also defined in this file. Should I do a PR that creates a SubstraitEnums.td file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, OK! My long-pending PR for
aggregate
creates one. Let's move the other enums once that is merged?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets do that 👍