Skip to content

Commit ed93081

Browse files
test: use valid URLs and values for extension test cases (#118)
Substrait represents several types of extensions as `google.protobuf.any` messages, which consist of a value, which a byte sequence of a binary Protobuf message, and a URL. Turns out that `some protobuf message` is not a valid binary Protobuf message and `some url` is not a valid Protobuf schema URL. This wans't a problem for round-tripping between our dialect and Protobufs in either text or binary format but the JSON format requires both to be valid (and known, in the case of the URL). This PR, thus, changes the URL and value fields of all `any` messages and the corresponding type and detail fields of the extension attributes in the test cases in order to allow for round-tripping them through JSON.
1 parent d3d8b0a commit ed93081

File tree

10 files changed

+46
-43
lines changed

10 files changed

+46
-43
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ def Substrait_ExtensionTableOp : Substrait_RelOp<"extension_table"> {
609609

610610
```mlir
611611
%0 = extension_table
612-
"some detail" : !substrait.any<"some url">
612+
"\08*" : !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
613613
as ["a"] : tuple<si32>
614614
```
615615
}];

test/Dialect/Substrait/extension-table.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
// CHECK-LABEL: substrait.plan
55
// CHECK: relation
66
// CHECK: %[[V0:.*]] = extension_table
7-
// CHECK-SAME: "some detail" : !substrait.any<"some url">
7+
// CHECK-SAME: "\08*" : !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
88
// CHECK-SAME: as ["a"] : tuple<si32>
99
// CHECK-NEXT: yield %[[V0]] : tuple<si32>
1010

1111
substrait.plan version 0 : 42 : 1 {
1212
relation {
1313
%0 = extension_table
14-
"some detail" : !substrait.any<"some url">
14+
"\08*" : !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
1515
as ["a"] : tuple<si32>
1616
yield %0 : tuple<si32>
1717
}

test/Dialect/Substrait/plan.mlir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ substrait.plan version 0 : 42 : 1 {
9191

9292
// CHECK: substrait.plan
9393
// CHECK-SAME: advanced_extension
94-
// CHECK-SAME: optimization = "protobuf message" : !substrait.any<"http://some.url/with/type.proto">
95-
// CHECK-SAME: enhancement = "other protobuf message" : !substrait.any<"http://other.url/with/type.proto">
94+
// CHECK-SAME: optimization = "\08*" : !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
95+
// CHECK-SAME: enhancement = "\08\01" : !substrait.any<"type.googleapis.com/google.protobuf.BoolValue">
9696
// CHECK-NEXT: }
9797

9898
substrait.plan version 0 : 42 : 1
9999
advanced_extension
100-
optimization = "protobuf message" : !substrait.any<"http://some.url/with/type.proto">
101-
enhancement = "other protobuf message" : !substrait.any<"http://other.url/with/type.proto">
100+
optimization = "\08*" : !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
101+
enhancement = "\08\01" : !substrait.any<"type.googleapis.com/google.protobuf.BoolValue">
102102
{}
103103

104104
// -----

test/Dialect/Substrait/project.mlir

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,16 @@ substrait.plan version 0 : 42 : 1 {
5151
// CHECK-NEXT: relation
5252
// CHECK: %[[V0:.*]] = named_table
5353
// CHECK-NEXT: %[[V1:.*]] = project %[[V0]]
54-
// CHECK-SAME: advanced_extension optimization = "foo" : !substrait.any<"bar">
54+
// CHECK-SAME: advanced_extension optimization = "\08*" :
55+
// CHECK-SAME: !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
5556
// CHECK-SAME: tuple<si32> -> tuple<si32> {
5657

5758
substrait.plan version 0 : 42 : 1 {
5859
relation {
5960
%0 = named_table @t1 as ["a"] : tuple<si32>
6061
%1 = project %0
61-
advanced_extension optimization = "foo" : !substrait.any<"bar">
62+
advanced_extension optimization = "\08*"
63+
: !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
6264
: tuple<si32> -> tuple<si32> {
6365
^bb0(%arg0: tuple<si32>):
6466
yield

test/Target/SubstraitPB/Export/extension-table.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
// CHECK-NEXT: }
3030
// CHECK-NEXT: extension_table {
3131
// CHECK-NEXT: detail {
32-
// CHECK-NEXT: type_url: "some url"
33-
// CHECK-NEXT: value: "some detail"
32+
// CHECK-NEXT: type_url: "type.googleapis.com/google.protobuf.Int32Value"
33+
// CHECK-NEXT: value: "\010*"
3434
// CHECK-NEXT: }
3535
// CHECK-NEXT: }
3636
// CHECK-NEXT: }
@@ -41,7 +41,7 @@
4141
substrait.plan version 0 : 42 : 1 {
4242
relation {
4343
%0 = extension_table
44-
"some detail" : !substrait.any<"some url">
44+
"\08*" : !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
4545
as ["a"] : tuple<si32>
4646
yield %0 : tuple<si32>
4747
}

test/Target/SubstraitPB/Export/plan.mlir

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,20 @@ substrait.plan version 0 : 42 : 1 {
143143

144144
// CHECK: advanced_extensions {
145145
// CHECK-NEXT: optimization {
146-
// CHECK-NEXT: type_url: "http://some.url/with/type.proto"
147-
// CHECK-NEXT: value: "protobuf message"
146+
// CHECK-NEXT: type_url: "type.googleapis.com/google.protobuf.Int32Value"
147+
// CHECK-NEXT: value: "\010*"
148148
// CHECK-NEXT: }
149149
// CHECK-NEXT: enhancement {
150-
// CHECK-NEXT: type_url: "http://other.url/with/type.proto"
151-
// CHECK-NEXT: value: "other protobuf message"
150+
// CHECK-NEXT: type_url: "type.googleapis.com/google.protobuf.BoolValue"
151+
// CHECK-NEXT: value: "\010\001"
152152
// CHECK-NEXT: }
153153
// CHECK-NEXT: }
154154
// CHECK-NEXT: version
155155

156156
substrait.plan version 0 : 42 : 1
157157
advanced_extension
158-
optimization = "protobuf message" : !substrait.any<"http://some.url/with/type.proto">
159-
enhancement = "other protobuf message" : !substrait.any<"http://other.url/with/type.proto">
158+
optimization = "\08*" : !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
159+
enhancement = "\08\01" : !substrait.any<"type.googleapis.com/google.protobuf.BoolValue">
160160
{}
161161

162162
// -----
@@ -168,7 +168,7 @@ substrait.plan version 0 : 42 : 1
168168

169169
substrait.plan version 0 : 42 : 1
170170
advanced_extension
171-
optimization = "protobuf message" : !substrait.any<"http://some.url/with/type.proto">
171+
optimization = "\08*" : !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
172172
{}
173173

174174
// -----
@@ -180,7 +180,7 @@ substrait.plan version 0 : 42 : 1
180180

181181
substrait.plan version 0 : 42 : 1
182182
advanced_extension
183-
enhancement = "other protobuf message" : !substrait.any<"http://other.url/with/type.proto">
183+
enhancement = "\08\01" : !substrait.any<"type.googleapis.com/google.protobuf.BoolValue">
184184
{}
185185

186186
// -----

test/Target/SubstraitPB/Export/project.mlir

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,17 @@ substrait.plan version 0 : 42 : 1 {
4949
// CHECK: input {
5050
// CHECK: advanced_extension {
5151
// CHECK-NEXT: optimization {
52-
// CHECK-NEXT: type_url: "bar"
53-
// CHECK-NEXT: value: "foo"
52+
// CHECK-NEXT: type_url: "type.googleapis.com/google.protobuf.Int32Value"
53+
// CHECK-NEXT: value: "\010*"
5454
// CHECK-NEXT: }
5555
// CHECK-NEXT: }
5656

5757
substrait.plan version 0 : 42 : 1 {
5858
relation {
5959
%0 = named_table @t1 as ["a"] : tuple<si32>
6060
%1 = project %0
61-
advanced_extension optimization = "foo" : !substrait.any<"bar">
61+
advanced_extension optimization = "\08*"
62+
: !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
6263
: tuple<si32> -> tuple<si32> {
6364
^bb0(%arg0: tuple<si32>):
6465
yield

test/Target/SubstraitPB/Import/extension-table.textpb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# CHECK-LABEL: substrait.plan
1010
# CHECK-NEXT: relation {
1111
# CHECK-NEXT: %[[V0:.*]] = extension_table
12-
# CHECK-SAME: "some detail" : !substrait.any<"some url">
12+
# CHECK-SAME: "\08*" : !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
1313
# CHECK-SAME: as ["a"] : tuple<si32>
1414
# CHECK-NEXT: yield %[[V0]] : tuple<si32>
1515

@@ -33,8 +33,8 @@ relations {
3333
}
3434
extension_table {
3535
detail {
36-
type_url: "some url"
37-
value: "some detail"
36+
type_url: "type.googleapis.com/google.protobuf.Int32Value"
37+
value: "\010*"
3838
}
3939
}
4040
}

test/Target/SubstraitPB/Import/plan.textpb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,18 @@ version {
192192

193193
# CHECK-LABEL: substrait.plan
194194
# CHECK-SAME: advanced_extension
195-
# CHECK-SAME: optimization = "protobuf message" : !substrait.any<"http://some.url/with/type.proto">
196-
# CHECK-SAME: enhancement = "other protobuf message" : !substrait.any<"http://other.url/with/type.proto">
195+
# CHECK-SAME: optimization = "\08*" : !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
196+
# CHECK-SAME: enhancement = "\08\01" : !substrait.any<"type.googleapis.com/google.protobuf.BoolValue">
197197
# CHECK-NEXT: }
198198

199199
advanced_extensions {
200200
optimization {
201-
type_url: "http://some.url/with/type.proto"
202-
value: "protobuf message"
201+
type_url: "type.googleapis.com/google.protobuf.Int32Value"
202+
value: "\010*"
203203
}
204204
enhancement {
205-
type_url: "http://other.url/with/type.proto"
206-
value: "other protobuf message"
205+
type_url: "type.googleapis.com/google.protobuf.BoolValue"
206+
value: "\010\01"
207207
}
208208
}
209209
version {
@@ -214,14 +214,14 @@ version {
214214
# -----
215215

216216
# CHECK-LABEL: substrait.plan
217-
# CHECK-SAME: advanced_extension
218-
# CHECK-SAME: optimization = "protobuf message" : !substrait.any<"http://some.url/with/type.proto">
217+
# CHECK-SAME: advanced_extension optimization
218+
# CHECK-SAME: "\08*" : !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
219219
# CHECK-NEXT: }
220220

221221
advanced_extensions {
222222
optimization {
223-
type_url: "http://some.url/with/type.proto"
224-
value: "protobuf message"
223+
type_url: "type.googleapis.com/google.protobuf.Int32Value"
224+
value: "\010*"
225225
}
226226
}
227227
version {
@@ -232,14 +232,14 @@ version {
232232
# -----
233233

234234
# CHECK-LABEL: substrait.plan
235-
# CHECK-SAME: advanced_extension
236-
# CHECK-SAME: enhancement = "other protobuf message" : !substrait.any<"http://other.url/with/type.proto">
235+
# CHECK-SAME: advanced_extension enhancement
236+
# CHECK-SAME: "\08\01" : !substrait.any<"type.googleapis.com/google.protobuf.BoolValue">
237237
# CHECK-NEXT: }
238238

239239
advanced_extensions {
240240
enhancement {
241-
type_url: "http://other.url/with/type.proto"
242-
value: "other protobuf message"
241+
type_url: "type.googleapis.com/google.protobuf.BoolValue"
242+
value: "\010\01"
243243
}
244244
}
245245
version {

test/Target/SubstraitPB/Import/project.textpb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ version {
7474
# CHECK-NEXT: relation
7575
# CHECK: %[[V0:.*]] = named_table
7676
# CHECK-NEXT: %[[V1:.*]] = project %[[V0]]
77-
# CHECK-SAME: advanced_extension optimization = "foo" : !substrait.any<"bar">
77+
# CHECK-SAME: "\08*" : !substrait.any<"type.googleapis.com/google.protobuf.Int32Value">
7878

7979
relations {
8080
rel {
@@ -107,8 +107,8 @@ relations {
107107
}
108108
advanced_extension {
109109
optimization {
110-
type_url: "bar"
111-
value: "foo"
110+
type_url: "type.googleapis.com/google.protobuf.Int32Value"
111+
value: "\010*"
112112
}
113113
}
114114
}

0 commit comments

Comments
 (0)