-
Notifications
You must be signed in to change notification settings - Fork 217
Expand file tree
/
Copy pathexpressions.proto
More file actions
251 lines (213 loc) · 7.03 KB
/
Copy pathexpressions.proto
File metadata and controls
251 lines (213 loc) · 7.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
// Proto mirror of `kernel/src/expressions/mod.rs` + `scalars.rs` (the Rust IR is the source
// of truth for these shapes).
//
// Opaque{Expression,Predicate} and Unknown are escape hatches: kernel-rs can't serialise the
// opaque trait objects, and Unknown is the "do not silently interpret" marker. They appear
// here so the grammar is total, but engines MUST error on them, not produce NULL.
syntax = "proto3";
package delta.kernel.expressions;
// Java package for generated bindings. Ignored by prost (Rust codegen).
option java_package = "io.delta.kernel.proto.expressions";
import "schema.proto";
// ============================================================================
// Operator enums
// ============================================================================
enum UnaryPredicateOp {
UNARY_PREDICATE_OP_UNSPECIFIED = 0;
UNARY_PREDICATE_OP_IS_NULL = 1;
}
enum BinaryPredicateOp {
BINARY_PREDICATE_OP_UNSPECIFIED = 0;
BINARY_PREDICATE_OP_LESS_THAN = 1;
BINARY_PREDICATE_OP_GREATER_THAN = 2;
BINARY_PREDICATE_OP_EQUAL = 3;
BINARY_PREDICATE_OP_DISTINCT = 4;
BINARY_PREDICATE_OP_IN = 5;
}
enum UnaryExpressionOp {
UNARY_EXPRESSION_OP_UNSPECIFIED = 0;
UNARY_EXPRESSION_OP_TO_JSON = 1;
}
enum BinaryExpressionOp {
BINARY_EXPRESSION_OP_UNSPECIFIED = 0;
BINARY_EXPRESSION_OP_PLUS = 1;
BINARY_EXPRESSION_OP_MINUS = 2;
BINARY_EXPRESSION_OP_MULTIPLY = 3;
BINARY_EXPRESSION_OP_DIVIDE = 4;
}
enum VariadicExpressionOp {
VARIADIC_EXPRESSION_OP_UNSPECIFIED = 0;
VARIADIC_EXPRESSION_OP_COALESCE = 1;
VARIADIC_EXPRESSION_OP_ARRAY = 2;
}
enum JunctionPredicateOp {
JUNCTION_PREDICATE_OP_UNSPECIFIED = 0;
JUNCTION_PREDICATE_OP_AND = 1;
JUNCTION_PREDICATE_OP_OR = 2;
}
// ============================================================================
// Scalar payloads
// ============================================================================
// `bits` is the unscaled integer, big-endian two's-complement; pair with `decimal_type` to
// materialise a language-native decimal.
message DecimalData {
bytes bits = 1;
delta.kernel.schema.DecimalType decimal_type = 2;
}
message ArrayData {
delta.kernel.schema.ArrayType array_type = 1;
repeated Scalar elements = 2;
}
// Modeled as repeated key/value pairs because proto map keys must be scalar, but Delta map
// keys can be any `Scalar` (including structs).
message MapEntry {
Scalar key = 1;
Scalar value = 2;
}
message MapData {
delta.kernel.schema.MapType map_type = 1;
repeated MapEntry pairs = 2;
}
// `fields` and `values` are pairwise indexed: `values[i]` is the value for `fields[i]`.
message StructData {
repeated delta.kernel.schema.StructField fields = 1;
repeated Scalar values = 2;
}
// `Null` carries a `DataType` so the evaluator can produce a NULL of the right type.
message Scalar {
oneof value {
int32 integer = 1;
int64 long = 2;
int32 short = 3; // i16 narrowed at decode (proto has no i16)
int32 byte = 4; // i8 narrowed at decode (proto has no i8)
float float = 5;
double double = 6;
string string = 7;
bool boolean = 8;
int64 timestamp = 9; // micros since epoch, UTC
int64 timestamp_ntz = 10; // micros since epoch, no tz
int32 date = 11; // days since epoch
bytes binary = 12;
DecimalData decimal = 13;
delta.kernel.schema.DataType null = 14;
StructData struct = 15;
ArrayData array = 16;
MapData map = 17;
int32 interval_year_month = 18; // year-month interval: signed month count
int64 interval_day_time = 19; // day-time interval: signed microsecond count
}
}
message ColumnName {
repeated string path = 1;
}
// ============================================================================
// Composite expression bodies
// ============================================================================
message UnaryExpression {
UnaryExpressionOp op = 1;
Expression expr = 2;
}
message BinaryExpression {
BinaryExpressionOp op = 1;
Expression left = 2;
Expression right = 3;
}
message VariadicExpression {
VariadicExpressionOp op = 1;
repeated Expression exprs = 2;
}
message IfExpression {
Predicate condition = 1;
Expression then_expr = 2;
Expression else_expr = 3;
}
message ParseJsonExpression {
Expression json_expr = 1;
delta.kernel.schema.StructType output_schema = 2;
}
message MapToStructOptions {
// Optional connector-supplied IANA timezone or normalized fixed offset (`+HH:MM` or `-HH:MM`)
// for offset-less TIMESTAMP values. Kernel never infers this from the host or table metadata. A
// timezone or offset in a value takes precedence; absence means UTC.
optional string timestamp_timezone = 1;
}
message MapToStructExpression {
Expression map_expr = 1;
MapToStructOptions options = 2;
}
// `nullability_predicate` is optional: when set and it evaluates to false/null, the whole
// struct is null.
message StructExpression {
repeated Expression exprs = 1;
Expression nullability_predicate = 2;
}
message FieldTransform {
repeated Expression exprs = 1;
bool is_replace = 2;
bool optional = 3;
}
message Transform {
// `input_path` is optional: absent means a top-level transform (no input path).
ColumnName input_path = 1;
map<string, FieldTransform> field_transforms = 2;
repeated Expression prepended_fields = 3;
repeated Expression appended_fields = 4;
}
// The opaque op carries only its `name()` because the Rust trait object can't be serialised;
// engines resolve `name` against a local op registry or hard-error (never NULL).
message OpaqueExpression {
string name = 1;
repeated Expression exprs = 2;
}
message OpaquePredicate {
string name = 1;
repeated Expression exprs = 2;
}
// ============================================================================
// Predicate
// ============================================================================
message UnaryPredicate {
UnaryPredicateOp op = 1;
Expression expr = 2;
}
message BinaryPredicate {
BinaryPredicateOp op = 1;
Expression left = 2;
Expression right = 3;
}
message JunctionPredicate {
JunctionPredicateOp op = 1;
repeated Predicate preds = 2;
}
message Predicate {
oneof kind {
Expression boolean_expression = 1;
Predicate not = 2;
UnaryPredicate unary = 3;
BinaryPredicate binary = 4;
JunctionPredicate junction = 5;
OpaquePredicate opaque = 6;
string unknown = 7;
}
}
// ============================================================================
// Expression
// ============================================================================
message Expression {
oneof kind {
Scalar literal = 1;
ColumnName column = 2;
Predicate predicate = 3;
StructExpression struct_expr = 4;
Transform transform = 5;
UnaryExpression unary = 6;
BinaryExpression binary = 7;
VariadicExpression variadic = 8;
// TODO: IfExpression is not yet available in Kernel but will be needed in the future.
IfExpression if_expr = 9;
OpaqueExpression opaque = 10;
ParseJsonExpression parse_json = 11;
MapToStructExpression map_to_struct = 12;
string unknown = 13;
}
}