Agg_Distinct_Max_Opt.yqls 892 B

1234567891011121314151617181920
  1. # program
  2. (
  3. (let config (DataSource 'config))
  4. (import agg_module '"/lib/yql/aggregate.yqls")
  5. (let list (AsList
  6. (AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '2))))
  7. (AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '3))))
  8. (AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Uint32)))))
  9. (AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32)))))
  10. (AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5))))
  11. (AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5))))
  12. ))
  13. (let max_traits (Apply (bind agg_module 'max_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v)))
  14. (let res_sink (DataSink 'result))
  15. (let resKey (Aggregate list '('key) '('('max_value max_traits 'value))))
  16. (let world (Write! world res_sink (Key) resKey '('('type))))
  17. (let world (Commit! world res_sink))
  18. (return world)
  19. )