1111
1212include "substrait-mlir/Dialect/Substrait/IR/SubstraitDialect.td"
1313include "mlir/IR/CommonTypeConstraints.td"
14- include "mlir/IR/OpBase.td"
15- include "mlir/IR/BuiltinAttributeInterfaces.td"
1614
1715// Base class for Substrait dialect types.
1816class Substrait_Type<string name, string typeMnemonic, list<Trait> traits = []>
1917 : TypeDef<Substrait_Dialect, name, traits> {
2018 let mnemonic = typeMnemonic;
2119}
2220
23- // Base class for Substrait dialect attribute types.
24- class Substrait_Attr<string name, string typeMnemonic, list<Trait> traits = []>
25- : AttrDef<Substrait_Dialect, name, traits> {
26- let mnemonic = typeMnemonic;
27- }
28-
2921def Substrait_BinaryType : Substrait_Type<"Binary", "binary"> {
3022 let summary = "Substrait binary type";
3123 let description = [{
@@ -36,22 +28,7 @@ def Substrait_BinaryType : Substrait_Type<"Binary", "binary"> {
3628def Substrait_DateType : Substrait_Type<"Date", "date"> {
3729 let summary = "Substrait date type";
3830 let description = [{
39- This type represents a substrait date type.
40- }];
41- }
42-
43- def Substrait_DateAttr : Substrait_Attr<"Date", "date",
44- [TypedAttrInterface]> {
45- let summary = "Substrait date type";
46- let description = [{
47- This type represents a substrait date attribute type.
48- }];
49- let parameters = (ins "int32_t":$value);
50- let assemblyFormat = [{ `<` $value `>` }];
51- let extraClassDeclaration = [{
52- ::mlir::Type getType() const {
53- return DateType::get(getContext());
54- }
31+ This type represents a substrait date type.
5532 }];
5633}
5734
@@ -65,73 +42,27 @@ def Substrait_StringType : Substrait_Type<"String", "string"> {
6542def Substrait_TimeType : Substrait_Type<"Time", "time"> {
6643 let summary = "Substrait time type";
6744 let description = [{
68- This type represents a substrait time type.
69- }];
70- }
71-
72- def Substrait_TimeAttr : Substrait_Attr<"Time", "time",
73- [TypedAttrInterface]> {
74- let summary = "Substrait time type";
75- let description = [{
76- This type represents a substrait time attribute type.
77- }];
78- let parameters = (ins "int64_t":$value);
79- let assemblyFormat = [{ `<` $value `` `us` `>` }];
80- let extraClassDeclaration = [{
81- ::mlir::Type getType() const {
82- return TimeType::get(getContext());
83- }
45+ This type represents a substrait time type.
8446 }];
8547}
8648
8749def Substrait_TimestampType : Substrait_Type<"Timestamp", "timestamp"> {
8850 let summary = "Substrait timezone-unaware timestamp type";
8951 let description = [{
90- This type represents a substrait timezone-unaware timestamp type.
91- }];
92- }
93-
94- def Substrait_TimestampAttr : Substrait_Attr<"Timestamp", "timestamp",
95- [TypedAttrInterface]> {
96- let summary = "Substrait timezone-unaware timestamp type";
97- let description = [{
98- This type represents a substrait timezone-unaware timestamp attribute type.
99- }];
100- let parameters = (ins "int64_t":$value);
101- let assemblyFormat = [{ `<` $value `` `us` `>` }];
102- let extraClassDeclaration = [{
103- ::mlir::Type getType() const {
104- return TimestampType::get(getContext());
105- }
52+ This type represents a substrait timezone-unaware timestamp type.
10653 }];
10754}
10855
10956def Substrait_TimestampTzType : Substrait_Type<"TimestampTz", "timestamp_tz"> {
11057 let summary = "Substrait timezone-aware timestamp type";
11158 let description = [{
112- This type represents a substrait timezone-aware timestamp type.
113- }];
114- }
115-
116- def Substrait_TimestampTzAttr : Substrait_Attr<"TimestampTz", "timestamp_tz",
117- [TypedAttrInterface]> {
118- let summary = "Substrait timezone-aware timestamp type";
119- let description = [{
120- This type represents a substrait timezone-aware timestamp attribute type.
121- }];
122- let parameters = (ins "int64_t":$value);
123- let assemblyFormat = [{ `<` $value `` `us` `>` }];
124- let extraClassDeclaration = [{
125- ::mlir::Type getType() const {
126- return TimestampTzType::get(getContext());
127- }
59+ This type represents a substrait timezone-aware timestamp type.
12860 }];
12961}
13062
131- /// Currently supported atomic types, listed in order of substrait specification.
63+ /// Currently supported atomic types, listed in order of substrait specification.
13264/// These correspond directly to the types in
13365/// https://github.com/substrait-io/substrait/blob/main/proto/substrait/type.proto.
134- // TODO(ingomueller): Add the other low-hanging fruits here.
13566def Substrait_AtomicTypes {
13667 list<Type> types = [
13768 SI1, // Boolean
@@ -150,26 +81,6 @@ def Substrait_AtomicTypes {
15081 ];
15182}
15283
153- /// Attributes of currently supported atomic types, listed in order of substrait
154- /// specification.
155- def Substrait_AtomicAttributes {
156- list<Attr> attrs = [
157- SI1Attr, // Boolean
158- SI8Attr, // I8
159- SI16Attr, // I16
160- SI32Attr, // I32
161- SI64Attr, // I64
162- F32Attr, // FP32
163- F64Attr, // FP64
164- TypedStrAttr<Substrait_StringType>, // String
165- TypedStrAttr<Substrait_BinaryType>, // Binary
166- Substrait_TimestampAttr, // Timestamp
167- Substrait_TimestampTzAttr, // TimestampTZ
168- Substrait_DateAttr, // Date
169- Substrait_TimeAttr, // Time
170- ];
171- }
172-
17384def Substrait_AnyType : Substrait_Type<"Any", "any"> {
17485 let summary = "Represents the `type_url` of a `google.protobuf.Any` message";
17586 let description = [{
@@ -182,23 +93,6 @@ def Substrait_AnyType : Substrait_Type<"Any", "any"> {
18293
18394}
18495
185- def Substrait_AdvancedExtensionAttr
186- : Substrait_Attr<"AdvancedExtension", "advanced_extension"> {
187- let summary = "Represents the `AdvancedExtenssion` message of Substrait";
188- let parameters = (ins
189- OptionalParameter<"StringAttr">:$optimization, // XXX: verify type
190- OptionalParameter<"StringAttr">:$enhancement
191- );
192- let assemblyFormat = [{
193- ( `optimization` `=` $optimization^ )?
194- ( `enhancement` `=` $enhancement^ )?
195- }];
196- let genVerifyDecl = 1;
197- }
198-
199- /// Attribute of one of the currently supported atomic types.
200- def Substrait_AtomicAttribute : AnyAttrOf<Substrait_AtomicAttributes.attrs>;
201-
20296/// One of the currently supported atomic types.
20397def Substrait_AtomicType : AnyTypeOf<Substrait_AtomicTypes.types>;
20498
0 commit comments