SafeCastOverStream.yql 979 B

123456789101112131415161718192021222324252627282930
  1. (
  2. (let config (DataSource 'config))
  3. (let world (Configure! world config 'PureDataSource 'yt))
  4. (let res_sink (DataSink 'result))
  5. # Stream<Int32> -> Stream<Uint16> (full)
  6. (let targetType (StreamType (DataType 'Uint16)))
  7. (let src (Iterator (AsList (Int32 '1) (Int32 '2) (Int32 '3))))
  8. (let cast (SafeCast src targetType))
  9. (let world (Write! world res_sink (Key) (Collect cast) '('('type))))
  10. # Stream<Int32> -> Stream<Uint16> (less)
  11. (let targetType (StreamType (DataType 'Uint16)))
  12. (let src (Iterator (AsList (Int32 '1) (Int32 '-2) (Int32 '3))))
  13. (let cast (SafeCast src targetType))
  14. (let world (Write! world res_sink (Key) (Collect cast) '('('type))))
  15. # Stream<Int32?> -> Stream<Uint16> (less)
  16. (let targetType (StreamType (DataType 'Uint16)))
  17. (let src (Iterator (AsList (Just (Int32 '1)) (Null) (Just (Int32 '3)))))
  18. (let cast (SafeCast src targetType))
  19. (let world (Write! world res_sink (Key) (Collect cast) '('('type))))
  20. (let world (Commit! world res_sink))
  21. (return world)
  22. )