AlterToOverStruct.yqls 674 B

123456789101112131415161718192021
  1. (
  2. (library "alterto.yql")
  3. (import alterto_module '"alterto.yql")
  4. (let config (DataSource 'config))
  5. (let targetType (StructType '('"a" (DataType 'Uint8)) '('"b" (DataType 'Utf8))))
  6. (let failValue (AsStruct '('a (Uint8 '0)) '('b (Utf8 '"not converted"))))
  7. # Struct<Int32, String> -> Struct<Uint8, Utf8>
  8. (let value (AsStruct '('a (Int32 '1)) '('b (String 'one))))
  9. (let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue))
  10. # Struct<Int32, String> -> Struct<Uint8, Utf8> (fail)
  11. (let value (AsStruct '('a (Int32 '"-1")) '('b (String 'one))))
  12. (let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue))
  13. (return world)
  14. )