aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/s-expressions/suites/Lib/Agg_Avg_If_Opt.yqls
blob: 830f163e5f5109d78d722ececc1df632c56486fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# program
(
(let config (DataSource 'config))
(let world (Configure! world config 'PureDataSource 'yt))

(import agg_module '"/lib/yql/aggregate.yql")
(let list (AsList
(AsStruct '('key (Uint32 '2)) '('pred (Bool '1)) '('value (Just (Uint32 '5))))
(AsStruct '('key (Uint32 '1)) '('pred (Bool '1)) '('value (Nothing (OptionalType (DataType 'Uint32)))))
(AsStruct '('key (Uint32 '2)) '('pred (Bool '0)) '('value (Nothing (OptionalType (DataType 'Uint32)))))
(AsStruct '('key (Uint32 '1)) '('pred (Bool '1)) '('value (Just (Uint32 '4))))
(AsStruct '('key (Uint32 '3)) '('pred (Bool '0)) '('value (Nothing (OptionalType (DataType 'Uint32)))))
(AsStruct '('key (Uint32 '2)) '('pred (Bool '0)) '('value (Just (Uint32 '3))))
(AsStruct '('key (Uint32 '2)) '('pred (Bool '1)) '('value (Just (Uint32 '9))))
))
(let avg_traits (Apply (bind agg_module 'avg_if_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (lambda '(row) (Member row 'pred))))
(let res_sink (DataSink 'result))
(let resKey (Aggregate list '('key) '('('avg_value avg_traits))))
(let world (Write! world res_sink (Key) resKey '('('type))))
(let world (Commit! world res_sink))
(return world)
)