-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlua_e2e_conditional_sort.json
More file actions
142 lines (142 loc) · 4.75 KB
/
Copy pathlua_e2e_conditional_sort.json
File metadata and controls
142 lines (142 loc) · 4.75 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
{
"name": "Lua E2E: recall → discount → stats → conditional sort",
"config": {
"_PINEAPPLE_VERSION": "0.10.15",
"pipeline_config": {
"operators": {
"recall_items": {
"type_name": "recall_static",
"recall": true,
"items": [
{"item_id": "a", "item_price": 100.0, "item_category": "electronics"},
{"item_id": "b", "item_price": 200.0, "item_category": "clothing"},
{"item_id": "c", "item_price": 50.0, "item_category": "electronics"},
{"item_id": "d", "item_price": 300.0, "item_category": "clothing"}
],
"$metadata": {
"common_input": [],
"common_output": [],
"item_input": [],
"item_output": ["item_id", "item_price", "item_category"]
}
},
"lua_discount": {
"type_name": "transform_by_lua",
"lua_script": "function apply_discount()\n if user_age < 18 then\n return item_price * 0.8\n elseif user_age > 60 then\n return item_price * 0.9\n else\n return item_price\n end\nend",
"function_for_item": "apply_discount",
"function_for_common": "",
"$metadata": {
"common_input": ["user_age"],
"common_output": [],
"item_input": ["item_price"],
"item_output": ["item_final_price"]
}
},
"lua_stats": {
"type_name": "transform_by_lua",
"lua_script": "function compute_stats()\n local sum = 0\n local count = #item_final_price\n for i = 1, count do\n sum = sum + (item_final_price[i] or 0)\n end\n return sum / count, count\nend",
"function_for_item": "",
"function_for_common": "compute_stats",
"$metadata": {
"common_input": [],
"common_output": ["avg_price", "item_count"],
"item_input": ["item_final_price"],
"item_output": []
}
},
"lua_skip_cheap": {
"type_name": "transform_by_lua",
"lua_script": "function should_skip()\n if avg_price > 200 then\n return true\n else\n return false\n end\nend",
"function_for_item": "",
"function_for_common": "should_skip",
"$metadata": {
"common_input": ["avg_price"],
"common_output": ["_skip_sort"],
"item_input": [],
"item_output": []
}
},
"sort_by_price": {
"type_name": "reorder_sort",
"order": "desc",
"skip": ["_skip_sort"],
"$metadata": {
"common_input": ["_skip_sort"],
"common_output": [],
"item_input": ["item_final_price"],
"item_output": []
}
}
},
"pipeline_map": {
"recall_stage": {
"pipeline": ["recall_items"]
},
"feature_stage": {
"pipeline": ["lua_discount", "lua_stats", "lua_skip_cheap", "sort_by_price"]
}
}
},
"pipeline_group": {
"main": {
"pipeline": ["recall_stage", "feature_stage"]
}
},
"flow_contract": {
"common_input": ["user_age"],
"item_input": [],
"common_output": ["avg_price", "item_count"],
"item_output": ["item_id", "item_final_price"]
}
},
"cases": [
{
"name": "young user (age<18): 20% discount, avg=130, sort executes",
"request": {
"common": {"user_age": 15.0},
"items": []
},
"expected": {
"common": {"avg_price": 130, "item_count": 4},
"items": [
{"item_id": "d", "item_final_price": 240},
{"item_id": "b", "item_final_price": 160},
{"item_id": "a", "item_final_price": 80},
{"item_id": "c", "item_final_price": 40}
]
}
},
{
"name": "adult user (30): no discount, avg=162.5, sort executes",
"request": {
"common": {"user_age": 30.0},
"items": []
},
"expected": {
"common": {"avg_price": 162.5, "item_count": 4},
"items": [
{"item_id": "d", "item_final_price": 300},
{"item_id": "b", "item_final_price": 200},
{"item_id": "a", "item_final_price": 100},
{"item_id": "c", "item_final_price": 50}
]
}
},
{
"name": "senior user (age>60): 10% discount, avg=146.25, sort executes",
"request": {
"common": {"user_age": 65.0},
"items": []
},
"expected": {
"common": {"avg_price": 146.25, "item_count": 4},
"items": [
{"item_id": "d", "item_final_price": 270},
{"item_id": "b", "item_final_price": 180},
{"item_id": "a", "item_final_price": 90},
{"item_id": "c", "item_final_price": 45}
]
}
}
]
}