diff --git a/include/substrait-mlir/Dialect/Substrait/IR/SubstraitOps.td b/include/substrait-mlir/Dialect/Substrait/IR/SubstraitOps.td index 6093da8..059c956 100644 --- a/include/substrait-mlir/Dialect/Substrait/IR/SubstraitOps.td +++ b/include/substrait-mlir/Dialect/Substrait/IR/SubstraitOps.td @@ -537,7 +537,7 @@ def SetOpKind : I32EnumAttr<"SetOpKind", I32EnumAttrCase<"union_all", 6>] >; def Substrait_SetOp : Substrait_RelOp<"set", [ - DeclareOpInterfaceMethods + SameOperandsAndResultType ]> { let summary = "set operation"; let description = [{ @@ -554,7 +554,7 @@ def Substrait_SetOp : Substrait_RelOp<"set", [ let results = (outs Substrait_Relation:$result); let assemblyFormat = [{ - $kind `,` $inputs attr-dict `:` type($inputs) `->` type($result) + $kind `,` $inputs attr-dict `:` type($result) }]; } diff --git a/lib/Dialect/Substrait/IR/Substrait.cpp b/lib/Dialect/Substrait/IR/Substrait.cpp index 2207462..8b1b429 100644 --- a/lib/Dialect/Substrait/IR/Substrait.cpp +++ b/lib/Dialect/Substrait/IR/Substrait.cpp @@ -256,33 +256,6 @@ LiteralOp::inferReturnTypes(MLIRContext *context, std::optional loc, return success(); } -LogicalResult -SetOp::inferReturnTypes(MLIRContext *context, std::optional loc, - ValueRange operands, DictionaryAttr attributes, - OpaqueProperties properties, RegionRange regions, - llvm::SmallVectorImpl &inferredReturnTypes) { - - ValueRange inputs = operands; - - if (inputs.size() < 2) - return ::emitError(loc.value()) << "expected at least 2 inputs"; - - TypeRange fieldType = cast(inputs[0].getType()).getTypes(); - - for (Value input : inputs) { - TypeRange inputFieldTypes = cast(input.getType()).getTypes(); - if (fieldType != inputFieldTypes) - return ::emitError(loc.value()) - << "all inputs must have the same field types"; - } - - TypeRange fieldTypes = cast(inputs[0].getType()).getTypes(); - auto resultType = TupleType::get(context, fieldTypes); - inferredReturnTypes = SmallVector{resultType}; - - return success(); -} - /// Verifies that the provided field names match the provided field types. While /// the field types are potentially nested, the names are given in a single, /// flat list and correspond to the field types in depth first order (where each diff --git a/test/Dialect/Substrait/set-invalid.mlir b/test/Dialect/Substrait/set-invalid.mlir deleted file mode 100644 index 1b60d1b..0000000 --- a/test/Dialect/Substrait/set-invalid.mlir +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: substrait-opt -verify-diagnostics %s - -substrait.plan version 0 : 42 : 1 { - relation { - %0 = named_table @t1 as ["a"] : tuple - %1 = named_table @t2 as ["b"] : tuple - // expected-error@+2 {{'substrait.set' op failed to infer returned types}} - // expected-error@+1 {{all inputs must have the same field types}} - %2 = set unspecified, %0, %1 : tuple, tuple -> tuple - yield %2 : tuple - } -} diff --git a/test/Dialect/Substrait/set.mlir b/test/Dialect/Substrait/set.mlir index 21163bc..4fc7692 100644 --- a/test/Dialect/Substrait/set.mlir +++ b/test/Dialect/Substrait/set.mlir @@ -7,7 +7,7 @@ // CHECK: %[[V1:.*]] = named_table // CHECK: %[[V2:.*]] = named_table // CHECK-NEXT: %[[V3:.*]] = set unspecified, %[[V0]], %[[V1]], %[[V2]] -// CHECK-SAME: : tuple, tuple, tuple -> tuple +// CHECK-SAME: : tuple // CHECK-NEXT: yield %[[V3]] : tuple substrait.plan version 0 : 42 : 1 { @@ -15,7 +15,7 @@ substrait.plan version 0 : 42 : 1 { %0 = named_table @t1 as ["a"] : tuple %1 = named_table @t2 as ["b"] : tuple %2 = named_table @t2 as ["c"] : tuple - %3 = set unspecified, %0, %1, %2: tuple, tuple, tuple -> tuple + %3 = set unspecified, %0, %1, %2: tuple yield %3 : tuple } } @@ -27,14 +27,14 @@ substrait.plan version 0 : 42 : 1 { // CHECK: %[[V0:.*]] = named_table // CHECK: %[[V1:.*]] = named_table // CHECK-NEXT: %[[V2:.*]] = set minus_primary, %[[V0]], %[[V1]] -// CHECK-SAME: : tuple, tuple -> tuple +// CHECK-SAME: : tuple // CHECK-NEXT: yield %[[V2]] : tuple substrait.plan version 0 : 42 : 1 { relation { %0 = named_table @t1 as ["a"] : tuple %1 = named_table @t2 as ["b"] : tuple - %2 = set minus_primary, %0, %1 : tuple, tuple -> tuple + %2 = set minus_primary, %0, %1 : tuple yield %2 : tuple } } @@ -46,14 +46,14 @@ substrait.plan version 0 : 42 : 1 { // CHECK: %[[V0:.*]] = named_table // CHECK: %[[V1:.*]] = named_table // CHECK-NEXT: %[[V2:.*]] = set minus_multiset, %[[V0]], %[[V1]] -// CHECK-SAME: : tuple, tuple -> tuple +// CHECK-SAME: : tuple // CHECK-NEXT: yield %[[V2]] : tuple substrait.plan version 0 : 42 : 1 { relation { %0 = named_table @t1 as ["a"] : tuple %1 = named_table @t2 as ["b"] : tuple - %2 = set minus_multiset, %0, %1 : tuple, tuple -> tuple + %2 = set minus_multiset, %0, %1 : tuple yield %2 : tuple } } @@ -64,14 +64,14 @@ substrait.plan version 0 : 42 : 1 { // CHECK: %[[V0:.*]] = named_table // CHECK: %[[V1:.*]] = named_table // CHECK-NEXT: %[[V2:.*]] = set intersection_primary, %[[V0]], %[[V1]] -// CHECK-SAME: : tuple, tuple -> tuple +// CHECK-SAME: : tuple // CHECK-NEXT: yield %[[V2]] : tuple substrait.plan version 0 : 42 : 1 { relation { %0 = named_table @t1 as ["a"] : tuple %1 = named_table @t2 as ["b"] : tuple - %2 = set intersection_primary, %0, %1 : tuple, tuple -> tuple + %2 = set intersection_primary, %0, %1 : tuple yield %2 : tuple } } @@ -82,14 +82,14 @@ substrait.plan version 0 : 42 : 1 { // CHECK: %[[V0:.*]] = named_table // CHECK: %[[V1:.*]] = named_table // CHECK-NEXT: %[[V2:.*]] = set intersection_multiset, %[[V0]], %[[V1]] -// CHECK-SAME: : tuple, tuple -> tuple +// CHECK-SAME: : tuple // CHECK-NEXT: yield %[[V2]] : tuple substrait.plan version 0 : 42 : 1 { relation { %0 = named_table @t1 as ["a"] : tuple %1 = named_table @t2 as ["b"] : tuple - %2 = set intersection_multiset, %0, %1 : tuple, tuple -> tuple + %2 = set intersection_multiset, %0, %1 : tuple yield %2 : tuple } } @@ -100,14 +100,14 @@ substrait.plan version 0 : 42 : 1 { // CHECK: %[[V0:.*]] = named_table // CHECK: %[[V1:.*]] = named_table // CHECK-NEXT: %[[V2:.*]] = set union_distinct, %[[V0]], %[[V1]] -// CHECK-SAME: : tuple, tuple -> tuple +// CHECK-SAME: : tuple // CHECK-NEXT: yield %[[V2]] : tuple substrait.plan version 0 : 42 : 1 { relation { %0 = named_table @t1 as ["a"] : tuple %1 = named_table @t2 as ["b"] : tuple - %2 = set union_distinct, %0, %1 : tuple, tuple -> tuple + %2 = set union_distinct, %0, %1 : tuple yield %2 : tuple } } @@ -118,14 +118,14 @@ substrait.plan version 0 : 42 : 1 { // CHECK: %[[V0:.*]] = named_table // CHECK: %[[V1:.*]] = named_table // CHECK-NEXT: %[[V2:.*]] = set union_all, %[[V0]], %[[V1]] -// CHECK-SAME: : tuple, tuple -> tuple +// CHECK-SAME: : tuple // CHECK-NEXT: yield %[[V2]] : tuple substrait.plan version 0 : 42 : 1 { relation { %0 = named_table @t1 as ["a"] : tuple %1 = named_table @t2 as ["b"] : tuple - %2 = set union_all, %0, %1 : tuple, tuple -> tuple + %2 = set union_all, %0, %1 : tuple yield %2 : tuple } } diff --git a/test/Target/SubstraitPB/Export/set.mlir b/test/Target/SubstraitPB/Export/set.mlir index c5912fa..2a3920b 100644 --- a/test/Target/SubstraitPB/Export/set.mlir +++ b/test/Target/SubstraitPB/Export/set.mlir @@ -27,7 +27,7 @@ substrait.plan version 0 : 42 : 1 { relation { %0 = named_table @t1 as ["a"] : tuple %1 = named_table @t2 as ["b"] : tuple - %2 = set unspecified, %0, %1 : tuple, tuple -> tuple + %2 = set unspecified, %0, %1 : tuple yield %2 : tuple } } @@ -51,7 +51,7 @@ substrait.plan version 0 : 42 : 1 { relation { %0 = named_table @t1 as ["a"] : tuple %1 = named_table @t2 as ["b"] : tuple - %2 = set minus_primary, %0, %1 : tuple, tuple -> tuple + %2 = set minus_primary, %0, %1 : tuple yield %2 : tuple } } @@ -75,7 +75,7 @@ substrait.plan version 0 : 42 : 1 { relation { %0 = named_table @t1 as ["a"] : tuple %1 = named_table @t2 as ["b"] : tuple - %2 = set minus_multiset, %0, %1 : tuple, tuple -> tuple + %2 = set minus_multiset, %0, %1 : tuple yield %2 : tuple } } @@ -99,7 +99,7 @@ substrait.plan version 0 : 42 : 1 { relation { %0 = named_table @t1 as ["a"] : tuple %1 = named_table @t2 as ["b"] : tuple - %2 = set intersection_primary, %0, %1 : tuple, tuple -> tuple + %2 = set intersection_primary, %0, %1 : tuple yield %2 : tuple } } @@ -123,7 +123,7 @@ substrait.plan version 0 : 42 : 1 { relation { %0 = named_table @t1 as ["a"] : tuple %1 = named_table @t2 as ["b"] : tuple - %2 = set intersection_multiset, %0, %1 : tuple, tuple -> tuple + %2 = set intersection_multiset, %0, %1 : tuple yield %2 : tuple } } @@ -147,7 +147,7 @@ substrait.plan version 0 : 42 : 1 { relation { %0 = named_table @t1 as ["a"] : tuple %1 = named_table @t2 as ["b"] : tuple - %2 = set union_distinct, %0, %1 : tuple, tuple -> tuple + %2 = set union_distinct, %0, %1 : tuple yield %2 : tuple } } @@ -171,7 +171,7 @@ substrait.plan version 0 : 42 : 1 { relation { %0 = named_table @t1 as ["a"] : tuple %1 = named_table @t2 as ["b"] : tuple - %2 = set union_all, %0, %1 : tuple, tuple -> tuple + %2 = set union_all, %0, %1 : tuple yield %2 : tuple } } \ No newline at end of file diff --git a/test/Target/SubstraitPB/Import/set.textpb b/test/Target/SubstraitPB/Import/set.textpb index 008470a..03aa1be 100644 --- a/test/Target/SubstraitPB/Import/set.textpb +++ b/test/Target/SubstraitPB/Import/set.textpb @@ -14,7 +14,7 @@ # CHECK-NEXT: relation { # CHECK-NEXT: %[[V0:.*]] = named_table # CHECK-NEXT: %[[V1:.*]] = named_table -# CHECK-NEXT: %[[V2:.*]] = set unspecified, %[[V0]], %[[V1]] : tuple, tuple -> tuple +# CHECK-NEXT: %[[V2:.*]] = set unspecified, %[[V0]], %[[V1]] : tuple # CHECK-NEXT: yield %[[V2]] : tuple relations { @@ -82,7 +82,7 @@ version { # CHECK-NEXT: relation { # CHECK-NEXT: %[[V0:.*]] = named_table # CHECK-NEXT: %[[V1:.*]] = named_table -# CHECK-NEXT: %[[V2:.*]] = set minus_primary, %[[V0]], %[[V1]] : tuple, tuple -> tuple +# CHECK-NEXT: %[[V2:.*]] = set minus_primary, %[[V0]], %[[V1]] : tuple # CHECK-NEXT: yield %[[V2]] : tuple relations { @@ -151,7 +151,7 @@ version { # CHECK-NEXT: relation { # CHECK-NEXT: %[[V0:.*]] = named_table # CHECK-NEXT: %[[V1:.*]] = named_table -# CHECK-NEXT: %[[V2:.*]] = set minus_multiset, %[[V0]], %[[V1]] : tuple, tuple -> tuple +# CHECK-NEXT: %[[V2:.*]] = set minus_multiset, %[[V0]], %[[V1]] : tuple # CHECK-NEXT: yield %[[V2]] : tuple relations { @@ -220,7 +220,7 @@ version { # CHECK-NEXT: relation { # CHECK-NEXT: %[[V0:.*]] = named_table # CHECK-NEXT: %[[V1:.*]] = named_table -# CHECK-NEXT: %[[V2:.*]] = set intersection_primary, %[[V0]], %[[V1]] : tuple, tuple -> tuple +# CHECK-NEXT: %[[V2:.*]] = set intersection_primary, %[[V0]], %[[V1]] : tuple # CHECK-NEXT: yield %[[V2]] : tuple relations { @@ -289,7 +289,7 @@ version { # CHECK-NEXT: relation { # CHECK-NEXT: %[[V0:.*]] = named_table # CHECK-NEXT: %[[V1:.*]] = named_table -# CHECK-NEXT: %[[V2:.*]] = set intersection_multiset, %[[V0]], %[[V1]] : tuple, tuple -> tuple +# CHECK-NEXT: %[[V2:.*]] = set intersection_multiset, %[[V0]], %[[V1]] : tuple # CHECK-NEXT: yield %[[V2]] : tuple relations { @@ -358,7 +358,7 @@ version { # CHECK-NEXT: relation { # CHECK-NEXT: %[[V0:.*]] = named_table # CHECK-NEXT: %[[V1:.*]] = named_table -# CHECK-NEXT: %[[V2:.*]] = set union_distinct, %[[V0]], %[[V1]] : tuple, tuple -> tuple +# CHECK-NEXT: %[[V2:.*]] = set union_distinct, %[[V0]], %[[V1]] : tuple # CHECK-NEXT: yield %[[V2]] : tuple relations { @@ -427,7 +427,7 @@ version { # CHECK-NEXT: relation { # CHECK-NEXT: %[[V0:.*]] = named_table # CHECK-NEXT: %[[V1:.*]] = named_table -# CHECK-NEXT: %[[V2:.*]] = set union_all, %[[V0]], %[[V1]] : tuple, tuple -> tuple +# CHECK-NEXT: %[[V2:.*]] = set union_all, %[[V0]], %[[V1]] : tuple # CHECK-NEXT: yield %[[V2]] : tuple relations {