yql-10297.sql 768 B

123456789101112131415161718192021222324252627282930
  1. /* syntax version 1 */
  2. /* postgres can not */
  3. DEFINE SUBQUERY $t() AS
  4. select * from as_table([<|key:"0"|>, <|key:"1"|>]);
  5. END DEFINE;
  6. DEFINE SUBQUERY $split_formula_log($in) AS
  7. $parition = ($row) -> {
  8. $recordType = TypeOf($row);
  9. $varType = VariantType(TupleType($recordType,
  10. $recordType));
  11. RETURN case
  12. when $row.key = "0" then
  13. Variant($row, "0", $varType)
  14. when $row.key = "1" then
  15. Variant($row, "1", $varType)
  16. else null
  17. end
  18. ;
  19. };
  20. PROCESS $in() USING $parition(TableRow());
  21. END DEFINE;
  22. $a, $b = (PROCESS $split_formula_log($t));
  23. select * from $a;
  24. select * from $b;