Skip to content

Commit 6a52d82

Browse files
authored
feat: make plan body ops an interface (#126)
Partly motivated by not having a long list of legal ops, mostly motivated by increasing the interoperability of the dialect, allowing other dialects to mark ops with `PlanBodyOpInterface`, making them legal to nest within a `Substrait_PlanOp`.
1 parent 2ef48f6 commit 6a52d82

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

include/substrait-mlir/Dialect/Substrait/IR/SubstraitInterfaces.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,11 @@ def Substrait_RelOpInterface : OpInterface<"RelOpInterface"> {
7171
let cppNamespace = "::mlir::substrait";
7272
}
7373

74+
def Substrait_PlanBodyOpInterface : OpInterface<"PlanBodyOpInterface"> {
75+
let description = [{
76+
Interface for any operation that can be used in a plan body.
77+
}];
78+
let cppNamespace = "::mlir::substrait";
79+
}
80+
7481
#endif // SUBSTRAIT_DIALECT_SUBSTRAIT_IR_SUBSTRAITINTERFACES

include/substrait-mlir/Dialect/Substrait/IR/SubstraitOps.td

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def StringArrayAttr :
6363
//===----------------------------------------------------------------------===//
6464

6565
def Substrait_ExtensionUriOp : Substrait_Op<"extension_uri", [
66-
Symbol
66+
Symbol,
67+
Substrait_PlanBodyOpInterface
6768
]> {
6869
let summary = "Declares a simple extension URI";
6970
let description = [{
@@ -91,7 +92,8 @@ def Substrait_ExtensionUriOp : Substrait_Op<"extension_uri", [
9192
class Substrait_ExtensionOp<string mnemonic, list<Trait> traits = []> :
9293
Substrait_Op<"extension_" # mnemonic, traits # [
9394
DeclareOpInterfaceMethods<SymbolUserOpInterface>,
94-
DeclareOpInterfaceMethods<Symbol>
95+
DeclareOpInterfaceMethods<Symbol>,
96+
Substrait_PlanBodyOpInterface
9597
]> {
9698
let description = [{
9799
This op represents the `SimpleExtensionDeclaration` message type of
@@ -142,13 +144,7 @@ def Substrait_ExtensionTypeVariationOp :
142144
// https://github.com/substrait-io/substrait/blob/main/proto/substrait/plan.proto.
143145
//===----------------------------------------------------------------------===//
144146

145-
def PlanBodyOp : AnyOf<[
146-
IsOp<"::mlir::substrait::PlanRelOp">,
147-
IsOp<"::mlir::substrait::ExtensionUriOp">,
148-
IsOp<"::mlir::substrait::ExtensionFunctionOp">,
149-
IsOp<"::mlir::substrait::ExtensionTypeOp">,
150-
IsOp<"::mlir::substrait::ExtensionTypeVariationOp">,
151-
]>;
147+
def PlanBodyOp : IsOp<"::mlir::substrait::PlanBodyOpInterface">;
152148

153149
def Substrait_PlanVersionOp : Substrait_Op<"plan_version"> {
154150
let summary = "Represents a stand-alone plan version";
@@ -228,7 +224,8 @@ def Substrait_PlanRelOp : Substrait_Op<"relation", [
228224
DeclareOpInterfaceMethods<OpAsmOpInterface, ["getDefaultDialect"]>,
229225
HasParent<"::mlir::substrait::PlanOp">,
230226
SingleBlockImplicitTerminator<"::mlir::substrait::YieldOp">,
231-
NoRegionArguments
227+
NoRegionArguments,
228+
Substrait_PlanBodyOpInterface
232229
]> {
233230
let summary = "Represents a query tree in a Substrait plan";
234231
let description = [{

0 commit comments

Comments
 (0)