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
{
"name": "select_expr_groupby_agg_orderby",
"pyspark_version": "3.5",
"input": {
"schema": [
{
"name": "id",
"type": "bigint"
},
{
"name": "name",
"type": "string"
},
{
"name": "age",
"type": "bigint"
},
{
"name": "salary",
"type": "double"
},
{
"name": "department",
"type": "string"
},
{
"name": "hire_date",
"type": "string"
}
],
"rows": [
[
1,
"Alice",
25,
50000.0,
"IT",
"2020-01-15"
],
[
2,
"Bob",
30,
60000.0,
"HR",
"2019-03-10"
],
[
3,
"Charlie",
35,
70000.0,
"IT",
"2021-07-22"
],
[
4,
"David",
40,
80000.0,
"Finance",
"2018-11-05"
],
[
5,
"Eve",
28,
55000.0,
"IT",
"2022-02-14"
]
]
},
"operations": [
{
"op": "withColumn",
"column": "level",
"expr": "coalesce(when(col('age') >= 35, lit('Senior')), lit('Junior'))"
},
{
"op": "groupBy",
"columns": [
"level"
]
},
{
"op": "agg",
"aggregations": [
{
"func": "count",
"alias": "count"
},
{
"func": "avg",
"alias": "avg_salary",
"column": "salary"
}
]
},
{
"op": "orderBy",
"columns": [
"level"
],
"ascending": [
true
]
}
],
"expected": {
"schema": [
{
"name": "level",
"type": "string"
},
{
"name": "count",
"type": "bigint"
},
{
"name": "avg_salary",
"type": "double"
}
],
"rows": [
[
"Junior",
3,
55000.0
],
[
"Senior",
2,
75000.0
]
]
}
}