Skip to content

Commit 07f8cb3

Browse files
Merge pull request #29447 from nrainer-materialize/output-consistency/list-agg-with-order
output consistency: fix list_agg and change it to use order
2 parents ca3ab9e + e9fb5e2 commit 07f8cb3

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

misc/python/materialize/output_consistency/input_data/operations/aggregate_operations_provider.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@
151151
{3: "string_agg($, $ ORDER BY row_index, $)"},
152152
[
153153
StringOperationParam(),
154+
# separator value
154155
StringOperationParam(),
155-
SameOperationParam(index_of_previous_param=1),
156+
SameOperationParam(index_of_previous_param=0),
156157
],
157158
StringReturnTypeSpec(),
158159
is_aggregation=True,

misc/python/materialize/output_consistency/input_data/operations/jsonb_operations_provider.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,14 @@
209209
JSONB_OPERATION_TYPES.append(
210210
DbFunctionWithCustomPattern(
211211
"jsonb_object_agg",
212-
{3: "jsonb_object_agg($, $ ORDER BY row_index, $)"},
212+
{4: "jsonb_object_agg($, $ ORDER BY row_index, $, $)"},
213213
[
214+
# key
214215
AnyOperationParam(),
216+
# value
215217
AnyOperationParam(include_record_type=False),
216218
SameOperationParam(index_of_previous_param=0),
219+
SameOperationParam(index_of_previous_param=1),
217220
],
218221
JsonbReturnTypeSpec(),
219222
is_aggregation=True,
@@ -228,7 +231,9 @@
228231
"jsonb_object_agg",
229232
{3: "jsonb_object_agg($, $ ORDER BY row_index, $)"},
230233
[
234+
# key
231235
AnyOperationParam(),
236+
# value
232237
RecordOperationParam(),
233238
SameOperationParam(index_of_previous_param=0),
234239
],

misc/python/materialize/output_consistency/input_data/operations/list_operations_provider.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
# by the Apache License, Version 2.0.
99

1010
from materialize.output_consistency.input_data.params.any_operation_param import (
11-
AnyLikeOtherOperationParam,
1211
AnyOperationParam,
1312
)
1413
from materialize.output_consistency.input_data.params.collection_operation_param import (
@@ -23,6 +22,9 @@
2322
ListOfOtherElementOperationParam,
2423
ListOperationParam,
2524
)
25+
from materialize.output_consistency.input_data.params.same_operation_param import (
26+
SameOperationParam,
27+
)
2628
from materialize.output_consistency.input_data.return_specs.boolean_return_spec import (
2729
BooleanReturnTypeSpec,
2830
)
@@ -37,6 +39,7 @@
3739
)
3840
from materialize.output_consistency.operation.operation import (
3941
DbFunction,
42+
DbFunctionWithCustomPattern,
4043
DbOperation,
4144
DbOperationOrFunction,
4245
)
@@ -93,13 +96,14 @@
9396
)
9497

9598
LIST_OPERATION_TYPES.append(
96-
DbFunction(
99+
DbFunctionWithCustomPattern(
97100
"list_agg",
101+
{
102+
2: "list_agg($ ORDER BY row_index, $)",
103+
},
98104
[
99-
AnyOperationParam(include_record_type=False),
100-
AnyLikeOtherOperationParam(index_of_previous_param=0, optional=True),
101-
AnyLikeOtherOperationParam(index_of_previous_param=0, optional=True),
102-
AnyLikeOtherOperationParam(index_of_previous_param=0, optional=True),
105+
AnyOperationParam(include_record_type=True),
106+
SameOperationParam(index_of_previous_param=0),
103107
],
104108
ListReturnTypeSpec(),
105109
)

misc/python/materialize/output_consistency/input_data/operations/map_operations_provider.py

+3
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@
114114
"map_agg",
115115
{3: "map_agg($, $ ORDER BY row_index, $)"},
116116
[
117+
# key
117118
StringOperationParam(only_type_text=True),
119+
# value
118120
AnyOperationParam(),
121+
# order within aggregated values
119122
SameOperationParam(index_of_previous_param=1),
120123
],
121124
MapReturnTypeSpec(),

0 commit comments

Comments
 (0)