diff options
author | Maxim Yurchuk <maxim-yurchuk@ydb.tech> | 2024-11-20 17:37:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-20 17:37:57 +0000 |
commit | f76323e9b295c15751e51e3443aa47a36bee8023 (patch) | |
tree | 4113c8cad473a33e0f746966e0cf087252fa1d7a /yql/essentials/tests/s-expressions/suites/Builtins | |
parent | 753ecb8d410a4cb459c26f3a0082fb2d1724fe63 (diff) | |
parent | a7b9a6afea2a9d7a7bfac4c5eb4c1a8e60adb9e6 (diff) | |
download | ydb-f76323e9b295c15751e51e3443aa47a36bee8023.tar.gz |
Merge pull request #11788 from ydb-platform/mergelibs-241120-1113
Library import 241120-1113
Diffstat (limited to 'yql/essentials/tests/s-expressions/suites/Builtins')
88 files changed, 2393 insertions, 0 deletions
diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/AndOverOptional.yql b/yql/essentials/tests/s-expressions/suites/Builtins/AndOverOptional.yql new file mode 100644 index 0000000000..4b878ab6d0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/AndOverOptional.yql @@ -0,0 +1,60 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let writer (lambda '(x) (MatchType x 'Optional +(lambda '(x) (Coalesce (Map x (lambda '(y) (ToString y))) (String 'NULL))) +(lambda '(x) (ToString x))))) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let t (Bool 'true)) + (let jt (Just t)) + (let f (Bool 'false)) + (let jf (Just f)) + (let n (Nothing (OptionalType (DataType 'Bool)))) + (let newValue value) + + (let newValue (Concat newValue (String '" => AND true : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And t t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And t jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And t f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And t jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And t n))))) + (let newValue (Concat newValue (String '" => AND false : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And f t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And f jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And f f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And f jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And f n))))) + (let newValue (Concat newValue (String '" => AND just true : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And jt t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And jt jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And jt f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And jt jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And jt n))))) + (let newValue (Concat newValue (String '" => AND just false : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And jf t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And jf jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And jf f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And jf jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And jf n))))) + (let newValue (Concat newValue (String '" => AND nothing : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And n t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And n jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And n f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And n jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (And n n))))) + + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Arithmetic.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Arithmetic.yql new file mode 100644 index 0000000000..ac50a50ada --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Arithmetic.yql @@ -0,0 +1,30 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let x (Uint32 '2)) + (let y (Uint32 '0)) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (+ (Size value) x))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (- (Size value) x))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (* (Size value) x))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (/ (Size value) x) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (/ (Size value) y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (% (Size value) x) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (% (Size value) y) (Uint32 '999)))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/ArithmeticOverEmptyOptionals.yql b/yql/essentials/tests/s-expressions/suites/Builtins/ArithmeticOverEmptyOptionals.yql new file mode 100644 index 0000000000..fa25eff9ff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/ArithmeticOverEmptyOptionals.yql @@ -0,0 +1,80 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let x (Uint32 '7)) + (let y (Uint32 '2)) + (let z (Uint32 '0)) + (let jx (Just x)) + (let jy (Just y)) + (let n (Nothing (OptionalType (DataType 'Uint32)))) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (String '" + "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (+ x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (+ jx y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (+ x jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (+ jx jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (+ jx n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (+ n jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (+ x n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (+ n y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (+ n n) (Uint32 '999)))))) + (let newValue (Concat newValue (String '" - "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (- x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (- jx y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (- x jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (- jx jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (- jx n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (- n jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (- x n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (- n y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (- n n) (Uint32 '999)))))) + (let newValue (Concat newValue (String '" * "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (* x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (* jx y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (* x jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (* jx jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (* jx n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (* n jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (* x n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (* n y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (* n n) (Uint32 '999)))))) + (let newValue (Concat newValue (String '" / "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (/ x y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (/ x z) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (/ jx y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (/ x jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (/ jx jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (/ jx n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (/ n jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (/ x n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (/ n y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (/ n n) (Uint32 '999)))))) + (let newValue (Concat newValue (String '" % "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (% x y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (% x z) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (% jx y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (% x jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (% jx jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (% jx n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (% n jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (% x n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (% n y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (% n n) (Uint32 '999)))))) + + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/ArithmeticUnary.cfg b/yql/essentials/tests/s-expressions/suites/Builtins/ArithmeticUnary.cfg new file mode 100644 index 0000000000..6f99339756 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/ArithmeticUnary.cfg @@ -0,0 +1,2 @@ +in Input input.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/ArithmeticUnary.yql b/yql/essentials/tests/s-expressions/suites/Builtins/ArithmeticUnary.yql new file mode 100644 index 0000000000..2df7e940fe --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/ArithmeticUnary.yql @@ -0,0 +1,53 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let u (Uint32 '2)) + (let u64 (Uint64 '333)) + (let u8 (Uint8 '7)) + (let s (Int32 '-2)) + (let d (Double '3.1415)) + (let ju (Just u)) + (let js (Just s)) + (let jd (Just d)) + (let newValue (Member item 'value)) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (CountBits u))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (CountBits u64))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (CountBits u8))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Inc u))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Dec u))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Plus u))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Minus u))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Inc ju) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Dec ju) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Plus ju) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Minus ju) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Inc s))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Dec s))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Plus s))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Minus s))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Inc js) (Int32 '-999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Dec js) (Int32 '-999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Plus js) (Int32 '-999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Minus js) (Int32 '-999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Abs s))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Abs d))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Plus d))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Minus d))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Plus jd) (Double '0)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Minus jd) (Double '0)))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'result)) +(let world (Write! world mr_sink (Key) table1map '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/AsTagged.cfg b/yql/essentials/tests/s-expressions/suites/Builtins/AsTagged.cfg new file mode 100644 index 0000000000..fe2b19a9ff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/AsTagged.cfg @@ -0,0 +1,3 @@ +in Input input.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/AsTagged.yql b/yql/essentials/tests/s-expressions/suites/Builtins/AsTagged.yql new file mode 100644 index 0000000000..76a39cde33 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/AsTagged.yql @@ -0,0 +1,26 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let newValue (AsTagged (Member item 'value) 'myTag)) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(let x (Read! world mr_source (Key '('table (String 'Output))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table2 '('('type)))) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/BitLogical.yql b/yql/essentials/tests/s-expressions/suites/Builtins/BitLogical.yql new file mode 100644 index 0000000000..801f98c809 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/BitLogical.yql @@ -0,0 +1,26 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let x (Uint32 '2)) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (BitNot (Size value)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (BitAnd (Size value) x))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (BitOr (Size value) x))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (BitXor (Size value) x))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/BitLogicalOverEmptyOptionals.yql b/yql/essentials/tests/s-expressions/suites/Builtins/BitLogicalOverEmptyOptionals.yql new file mode 100644 index 0000000000..bad75321c1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/BitLogicalOverEmptyOptionals.yql @@ -0,0 +1,62 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let x (Uint32 '7)) + (let y (Uint32 '2)) + (let z (Uint32 '0)) + (let jx (Just x)) + (let jy (Just y)) + (let n (Nothing (OptionalType (DataType 'Uint32)))) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (String '" BitNot "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (BitNot x))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitNot jx) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitNot n) (Uint32 '999)))))) + (let newValue (Concat newValue (String '" BitAnd "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (BitAnd x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitAnd jx y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitAnd x jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitAnd jx jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitAnd jx n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitAnd n jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitAnd x n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitAnd n y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitAnd n n) (Uint32 '999)))))) + (let newValue (Concat newValue (String '" BitOr "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (BitOr x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitOr jx y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitOr x jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitOr jx jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitOr jx n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitOr n jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitOr x n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitOr n y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitOr n n) (Uint32 '999)))))) + (let newValue (Concat newValue (String '" BitXor "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (BitXor x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitXor jx y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitXor x jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitXor jx jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitXor jx n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitXor n jy) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitXor x n) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitXor n y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (BitXor n n) (Uint32 '999)))))) + + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/BitShifts.yql b/yql/essentials/tests/s-expressions/suites/Builtins/BitShifts.yql new file mode 100644 index 0000000000..d38c5df0c2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/BitShifts.yql @@ -0,0 +1,31 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let x (Uint8 '1)) + (let y (Uint8 '10)) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (ShiftLeft (Size value) x))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (RotLeft (Size value) x))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (ShiftRight (Size value) x))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (RotRight (Size value) x))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (ShiftLeft (Size value) y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (RotLeft (Size value) y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (ShiftRight (Size value) y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (RotRight (Size value) y))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/BitShiftsOverEmptyOptionals.yql b/yql/essentials/tests/s-expressions/suites/Builtins/BitShiftsOverEmptyOptionals.yql new file mode 100644 index 0000000000..d2dd9c92b4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/BitShiftsOverEmptyOptionals.yql @@ -0,0 +1,42 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let x (Uint32 '7)) + (let y (Uint8 '2)) + (let jx (Just x)) + (let n (Nothing (OptionalType (DataType 'Uint32)))) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (String '" ShiftLeft "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (ShiftLeft x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (ShiftLeft jx y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (ShiftLeft n y) (Uint32 '999)))))) + (let newValue (Concat newValue (String '" RotLeft "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (RotLeft x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (RotLeft jx y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (RotLeft n y) (Uint32 '999)))))) + (let newValue (Concat newValue (String '" ShiftRight "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (ShiftRight x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (ShiftRight jx y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (ShiftRight n y) (Uint32 '999)))))) + (let newValue (Concat newValue (String '" RotRight "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (RotRight x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (RotRight jx y) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (RotRight n y) (Uint32 '999)))))) + + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Cast.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Cast.yql new file mode 100644 index 0000000000..edf5b44792 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Cast.yql @@ -0,0 +1,26 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (SafeCast value (DataType 'Int32)) (Int32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (SafeCast (String '42) (DataType 'Int32)) (Int32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (SafeCast value (DataType 'String)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (SafeCast (Int32 '123) (DataType 'String)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (SafeCast (Int32 '123) (DataType 'Double)))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/CastStruct.yql b/yql/essentials/tests/s-expressions/suites/Builtins/CastStruct.yql new file mode 100644 index 0000000000..ff4a01823d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/CastStruct.yql @@ -0,0 +1,25 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let type (StructType '('key (DataType 'String)))) + (let list (List (ListType type))) + (let castedValue (CastStruct item type)) + (let list (Append list castedValue)) + (let newValue (Member castedValue 'key)) + (let newValue (Concat newValue (ToString (Length list)))) + (let s (Struct)) + (let s (AddMember s 'key (String '.))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Coalesce.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Coalesce.yql new file mode 100644 index 0000000000..b03717e014 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Coalesce.yql @@ -0,0 +1,45 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let x (Uint32 '1)) + (let y (Uint32 '2)) + (let z (Uint32 '3)) + (let n (Nothing (OptionalType (TypeOf x)))) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + # single arg + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce x))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Unwrap (Coalesce (Just x))))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Exists (Coalesce n)))))) + # two arg + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Just x) y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Unwrap (Coalesce (Just x) (Just y))))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce n y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Unwrap (Coalesce n (Just y))))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Exists (Coalesce n n)))))) + # more args + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce x y z))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Just x) (Just y) z))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Unwrap (Coalesce (Just x) (Just y) (Just z))))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce n (Just y) z))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Unwrap (Coalesce n (Just y) (Just z))))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce n n z))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Unwrap (Coalesce n n (Just z))))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Exists (Coalesce n n n)))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/CombineByKey.yql b/yql/essentials/tests/s-expressions/suites/Builtins/CombineByKey.yql new file mode 100644 index 0000000000..5fa1b5c037 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/CombineByKey.yql @@ -0,0 +1,30 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Prepend (String 'abc) newValue)) + (let newValue (Append newValue (String 'q))) + (let preMap (lambda '(item) (Just item))) + (let keyExtractor (lambda '(item) item)) + (let init (lambda '(key item) item)) + (let update (lambda '(key item state) (Concat state item))) + (let finish (lambda '(key state) (AsList '(key state)))) + (let combined (CombineByKey newValue preMap keyExtractor init update finish)) + (let ret (Map combined (lambda '(item2) (block '( + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Concat (Concat (Nth item2 '0) (String '" => ")) (ToString (Nth item2 '1))))) + (return s)))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Compare.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Compare.yql new file mode 100644 index 0000000000..bd5b02bfc8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Compare.yql @@ -0,0 +1,28 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let b (String 'q)) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (< value b))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (<= value b))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (> value b))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (>= value b))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (== value b))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (!= value b))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/CompareWithEmptyOptionals.yql b/yql/essentials/tests/s-expressions/suites/Builtins/CompareWithEmptyOptionals.yql new file mode 100644 index 0000000000..4e7c2ed97f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/CompareWithEmptyOptionals.yql @@ -0,0 +1,69 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let x (Uint32 '700)) + (let y (Uint32 '20)) + (let z (Uint32 '0)) + (let jx (FromString (Member item 'key) 'Uint32)) + (let jy (FromString (Member item 'subkey) 'Uint32)) + (let n (Nothing (OptionalType (DataType 'Uint32)))) + (let test (lambda '(item) (If (Exists item) (ToString (Coalesce item (Bool 'false))) (String 'NULL)))) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (String '" < "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (< x y))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (< jx y))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (< x jy))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (< jx jy))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (< jx n))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (< n jy))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (< x n))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (< n y))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (< n n))))) + (let newValue (Concat newValue (String '" > "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (> x y))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (> jx y))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (> x jy))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (> jx jy))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (> jx n))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (> n jy))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (> x n))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (> n y))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (> n n))))) + (let newValue (Concat newValue (String '" == "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (== x y))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (== jx y))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (== x jy))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (== jx jy))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (== jx n))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (== n jy))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (== x n))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (== n y))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (== n n))))) + (let newValue (Concat newValue (String '" != "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (!= x y))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (!= jx y))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (!= x jy))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (!= jx jy))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (!= jx n))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (!= n jy))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (!= x n))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (!= n y))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply test (!= n n))))) + + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Concat.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Concat.yql new file mode 100644 index 0000000000..d423bbd1a2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Concat.yql @@ -0,0 +1,20 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (Concat value (String 'zzz))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Condense.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Condense.yql new file mode 100644 index 0000000000..d601958e3e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Condense.yql @@ -0,0 +1,25 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Prepend (String 'prepended) newValue)) + (let newValue (Append newValue (String 'appended))) + (let state (Uint32 '0)) + (let state (Condense (Iterator newValue) state (lambda '(item state) (Bool 'False)) (lambda '(item state) (+ state (Size item))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Concat (Concat value (String '" ==> ")) + (ToString (Coalesce (ToOptional (Collect state)) (Uint32 '0)))))) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Condense1.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Condense1.yql new file mode 100644 index 0000000000..1899624162 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Condense1.yql @@ -0,0 +1,24 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Prepend (String 'prepended) newValue)) + (let newValue (Append newValue (String 'appended))) + (let state (Condense1 (Iterator newValue) (lambda '(item) (Size item)) (lambda '(item state) (Bool 'False)) (lambda '(item state) (+ state (Size item))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Concat (Concat value (String '" ==> ")) + (ToString (Coalesce (ToOptional (Collect state)) (Uint32 '0)))))) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Contains.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Contains.yql new file mode 100644 index 0000000000..1dbafaba7d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Contains.yql @@ -0,0 +1,27 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let t1 (DataType 'Uint32)) + (let t2 (DataType 'String)) + (let d1 (DictType t1 t2)) + (let d2 (Dict d1 '((Uint32 '4) (String 'aaa)) '((Uint32 '5) (String 'bbb))) ) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Contains d2 (Uint32 '4)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Contains d2 (Uint32 '6)))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Convert.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Convert.yql new file mode 100644 index 0000000000..74e0bf07e5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Convert.yql @@ -0,0 +1,26 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let x (Int32 '1)) + (let y (Uint32 '20)) + (let z (Double '300)) + (let newValue (ToString (+ (Convert x (DataType 'Uint32)) y))) + (let newValue (Concat (Concat newValue (String '" ")) (ToString (+ (Coalesce (ToIntegral z (DataType 'Int32)) (Int32 '999)) x)))) + (let newValue (Concat (Concat newValue (String '" ")) (ToString (+ (Convert y (DataType 'Double)) z)))) + (let newValue (Concat (Concat newValue (String '" ")) (ToString (Coalesce (ToIntegral z (DataType 'Uint8)) (Uint8 '99))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/DicItems.yql b/yql/essentials/tests/s-expressions/suites/Builtins/DicItems.yql new file mode 100644 index 0000000000..95277fbb51 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/DicItems.yql @@ -0,0 +1,48 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let t1 (DataType 'Uint32)) + (let t2 (DataType 'String)) + (let d1 (DictType t1 t2)) + (let d2 (Dict d1 '((Uint32 '4) (String 'aaa)) '((Uint32 '4) (String 'zzz)) '((Uint32 '5) (String 'bbb))) ) + (let list1 (Sort (DictItems d2) (Bool 'true) (lambda '(x) (Nth x '0)))) + (let list2 (Sort (DictKeys d2) (Bool 'true) (lambda '(x) x))) + (let list3 (Sort (DictPayloads d2) (Bool 'true) (lambda '(x) x))) + (let value1 (Fold list1 (String '"") (lambda '(item state) (block '( + (let newValue state) + (let newValue (Concat newValue (String '" Items => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Nth item '0))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Nth item '1))))) + (return newValue) + ))))) + + (let value2 (Fold list2 (String '"") (lambda '(item state) (block '( + (let newValue state) + (let newValue (Concat newValue (String '" Keys => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString item)))) + (return newValue) + ))))) + + (let value3 (Fold list3 (String '"") (lambda '(item state) (block '( + (let newValue state) + (let newValue (Concat newValue (String '" Payloads => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString item)))) + (return newValue) + ))))) + + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value (Concat (Concat (Concat value value1) value2) value3))) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/DivePrefixMembers.yql b/yql/essentials/tests/s-expressions/suites/Builtins/DivePrefixMembers.yql new file mode 100644 index 0000000000..d7d096c666 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/DivePrefixMembers.yql @@ -0,0 +1,45 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let value (AsStruct '('akey1 (Int8 '1)) '('bkey2 (String 'str)) '('c (Int32 '2)))) +(let prefixes '('a 'b)) +(let result (DivePrefixMembers value prefixes)) +(let world (Write! world res_sink (Key) result '('('type)))) + +(let value (AsStruct '('akey1 (Int8 '1)) '('bkey2 (String 'str)) '('c (Int32 '2)))) +(let prefixes '('b 'a '"")) +(let result (DivePrefixMembers value prefixes)) +(let world (Write! world res_sink (Key) result '('('type)))) + +(let value (AsStruct '('akey1 (Int8 '1)) '('bkey2 (String 'str)) '('c (Int32 '2)))) +(let prefixes '('b 'a 'ak '"")) +(let result (DivePrefixMembers value prefixes)) +(let world (Write! world res_sink (Key) result '('('type)))) + +(let value (AsStruct '('akey1 (Int8 '1)) '('bkey2 (String 'str)) '('c (Int32 '2)))) +(let prefixes '('"")) +(let result (DivePrefixMembers value prefixes)) +(let world (Write! world res_sink (Key) result '('('type)))) + +(let value (AsStruct '('akey1 (Int8 '1)) '('bkey2 (String 'str)) '('c (Int32 '2)))) +(let prefixes '()) +(let result (DivePrefixMembers value prefixes)) +(let world (Write! world res_sink (Key) result '('('type)))) + +(let value (AsStruct)) +(let prefixes '('"")) +(let result (DivePrefixMembers value prefixes)) +(let world (Write! world res_sink (Key) result '('('type)))) + +(let value (AsStruct)) +(let prefixes '()) +(let result (DivePrefixMembers value prefixes)) +(let world (Write! world res_sink (Key) result '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/DivePrefixMembersOpt.yql b/yql/essentials/tests/s-expressions/suites/Builtins/DivePrefixMembersOpt.yql new file mode 100644 index 0000000000..aabfde5009 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/DivePrefixMembersOpt.yql @@ -0,0 +1,20 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let value (Just (AsStruct '('akey1 (Just (Int8 '1))) '('bkey2 (String 'str)) '('c (Nothing (OptionalType (DataType 'Int32))))))) +(let prefixes '('b 'a 'ak '"")) +(let result (DivePrefixMembers value prefixes)) +(let world (Write! world res_sink (Key) result '('('type)))) + +(let value (Nothing (OptionalType (StructType '('akey1 (OptionalType (DataType 'Int8))) '('bkey2 (DataType 'String)) '('c (OptionalType (DataType 'Int32))))))) +(let prefixes '('b 'a 'ak '"")) +(let result (DivePrefixMembers value prefixes)) +(let world (Write! world res_sink (Key) result '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Enumerate.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Enumerate.yql new file mode 100644 index 0000000000..245bccb5a7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Enumerate.yql @@ -0,0 +1,25 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Prepend (String 'p) newValue)) + (let newValue (Append newValue (String 'a))) + (let numList (Enumerate newValue)) + (let ret (Map numList (lambda '(item2) (block '( + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Concat (Concat (ToString (Nth item2 '0)) (String '" => ")) (Nth item2 '1)))) + (return s)))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Exists.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Exists.yql new file mode 100644 index 0000000000..a45adbeeeb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Exists.yql @@ -0,0 +1,24 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList (Exists (FromString (String 'zzz) 'Int32)))) + (let newValue (Append newValue (Exists (FromString (String '3456) 'Int32)))) + (let newValue (Append newValue (Exists (String 'zzz)))) + (let ret (Map newValue (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (String '.))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (ToString item))) + (return s)))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Extract.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Extract.yql new file mode 100644 index 0000000000..97637f6e25 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Extract.yql @@ -0,0 +1,25 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let list1 (AsList item)) + (let list2 (Just '(value (Uint32 '22)))) + (let structExtract (Extract list1 'key)) + (let tupleExtract (Extract list2 '0)) + (let ret (Map (Extend structExtract (ToList tupleExtract)) (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (String '.))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value item)) + (return s)))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/FilterAndSize.yql b/yql/essentials/tests/s-expressions/suites/Builtins/FilterAndSize.yql new file mode 100644 index 0000000000..db9c86ab6d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/FilterAndSize.yql @@ -0,0 +1,24 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let list (AsList value)) + (let list (Append list (String 'x))) + (let filtered (Filter list (lambda '(x) (== (Size x) (Uint32 '1))))) + (let ret (Map filtered (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (String '.))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value item)) + (return s)))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/FlattenMembers.yql b/yql/essentials/tests/s-expressions/suites/Builtins/FlattenMembers.yql new file mode 100644 index 0000000000..7bb2ee9823 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/FlattenMembers.yql @@ -0,0 +1,25 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let myStruct (AsStruct '('a (String 'z)))) + (let flatten (FlattenMembers '('"first_" item) '('"second_" myStruct))) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (Member flatten 'first_key)))) + (let newValue (Concat newValue (Concat (String '" ") (Member flatten 'second_a)))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/FlattenMembersOptional.yql b/yql/essentials/tests/s-expressions/suites/Builtins/FlattenMembersOptional.yql new file mode 100644 index 0000000000..4a2d27f7ce --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/FlattenMembersOptional.yql @@ -0,0 +1,25 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let myStruct (AsStruct '('a (String 'z)))) + (let flatten (FlattenMembers '('"first_" item) '('"second_" (Just myStruct)))) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (Member flatten 'first_key)))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Member flatten 'second_a) (String '""))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/FlattenMembersOptional2.yql b/yql/essentials/tests/s-expressions/suites/Builtins/FlattenMembersOptional2.yql new file mode 100644 index 0000000000..42b30ea242 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/FlattenMembersOptional2.yql @@ -0,0 +1,30 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let value (AsStruct '('a (Int8 '1)) '('b (Just (String 'str))) '('c '((Int32 '2) (Int64 '3))))) +(let flattenMembersResult (FlattenMembers '('"" (Just value)))) +(let world (Write! world res_sink (Key) flattenMembersResult '('('type)))) + +(let value (Nothing (TypeOf (Just value)))) +(let flattenMembersResult (FlattenMembers '('"x" value))) +(let world (Write! world res_sink (Key) flattenMembersResult '('('type)))) + +(let value (AsStruct)) +(let flattenMembersResult (FlattenMembers '('"x" value))) +(let world (Write! world res_sink (Key) flattenMembersResult '('('type)))) + +(let value (Just (AsStruct))) +(let flattenMembersResult (FlattenMembers '('"" value))) +(let world (Write! world res_sink (Key) flattenMembersResult '('('type)))) + +(let value (Nothing (TypeOf value))) +(let flattenMembersResult (FlattenMembers '('"x" value))) +(let world (Write! world res_sink (Key) flattenMembersResult '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Floats.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Floats.yql new file mode 100644 index 0000000000..08f9f64797 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Floats.yql @@ -0,0 +1,35 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let x (Double '1.2)) + (let y (Double '3)) + (let newValue (String '" => ")) + (let newValue (Concat newValue (Concat (String '" ") (ToString (+ x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (- x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (* x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (/ x y))))) + + (let x (Float '0.1)) + (let y (Float '-2.2)) + (let newValue (Concat newValue (Concat (String '" ") (ToString (+ x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (- x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (* x y))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (/ x y))))) + + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (FromString (String '1.23) 'Float) (Float '0.0)))))) + + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Fold.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Fold.yql new file mode 100644 index 0000000000..34544fa51e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Fold.yql @@ -0,0 +1,24 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Prepend (String 'prepended) newValue)) + (let newValue (Append newValue (String 'appended))) + (let state (Uint32 '0)) + (let state (Fold newValue state (lambda '(item state) (+ state (Size item))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Concat (Concat value (String '" ==> ")) (ToString state)))) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Fold1.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Fold1.yql new file mode 100644 index 0000000000..d360f24111 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Fold1.yql @@ -0,0 +1,30 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Prepend (String 'prepended) newValue)) + (let newValue (Append newValue (String 'appended))) + (let state (Fold1 newValue + (lambda '(item) '((Size item) (Uint64 '1))) + (lambda '(item state) '((+ (Nth state '0) (Size item)) (+ (Nth state '1) (Uint64 '1)))))) + (return (FlatMap state (lambda '(state) (block '( + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '.))) + (let x (ToString (Nth state '0))) + (let y (ToString (Nth state '1))) + (let s (AddMember s 'value + (Concat (Concat value (String '" ==> ")) (Concat (Concat x (String '" ")) y)))) + (return (AsList s)) + ))))) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Fold2Lambda.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Fold2Lambda.yql new file mode 100644 index 0000000000..9d15c7ceb8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Fold2Lambda.yql @@ -0,0 +1,29 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Prepend (String 'prepended) newValue)) + (let newValue (Append newValue (String 'appended))) + (let myLambda (lambda '(item state) (+ state item))) + (let state (Uint32 '0)) + (let state (Fold (Map newValue (lambda '(x) (Size x))) state myLambda)) + (let ilist (AsList (Int32 '4))) + (let ilist (Append ilist (Int32 '6))) + (let state2 (Int32 '0)) + (let state2 (Fold ilist state2 myLambda)) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Concat (Concat value (String '" ==> ")) (Concat (ToString state) (ToString state2))))) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/FromString.yql b/yql/essentials/tests/s-expressions/suites/Builtins/FromString.yql new file mode 100644 index 0000000000..ba534b346d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/FromString.yql @@ -0,0 +1,31 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList (Coalesce (FromString (String 'zzz) 'Int32) (Int32 '999)))) + (let newValue (Append newValue (Coalesce (FromString (String '3456) 'Int32) (Int32 '999)))) + (let newValue (Append newValue (Coalesce (FromString (String 'x"2345") 'Int32) (Int32 '999)))) + (let newValue (Append newValue (Coalesce (FromString (String 'x"31") 'Int32) (Int32 '999)))) + (let newValue (Append newValue (If (Coalesce (FromString (String 'true) 'Bool) (Bool 'false)) + (Int32 '100) (Int32 '0)))) + (let ret (Map newValue (lambda '(item) (block '( + (let s (Struct)) + (let k (ToString (Coalesce (FromString (String '"1u,34") 'Yson) (Yson '"999")))) + (let k (Concat k (ToString (Coalesce (FromString (String '"NaN") 'Double) (Double '"999"))))) + (let s (AddMember s 'key k)) + (let sk (ToString (Coalesce (FromString (String '"[1u;34]") 'Yson) (Yson '"999")))) + (let sk (Concat sk (ToString (Coalesce (FromString (String '"-inf") 'Float) (Float '"999"))))) + (let s (AddMember s 'subkey sk)) + (let s (AddMember s 'value (ToString item))) + (return s)))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/GroupByKey.yql b/yql/essentials/tests/s-expressions/suites/Builtins/GroupByKey.yql new file mode 100644 index 0000000000..931c95d7b6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/GroupByKey.yql @@ -0,0 +1,24 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Prepend (String 'q) newValue)) + (let newValue (Append newValue (String 'ddd))) + (let ret (GroupByKey newValue (lambda '(x) x) (lambda '(key list) (block '( + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (ToString (Length list)))) + (return (AsList s))))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/HasItems.yql b/yql/essentials/tests/s-expressions/suites/Builtins/HasItems.yql new file mode 100644 index 0000000000..2500618f6f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/HasItems.yql @@ -0,0 +1,25 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (Member item 'value)) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (HasItems (AsList (String 'zzz))))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (HasItems (List (ListType (DataType 'Int32)))))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (HasItems (AsDict '((Int32 '234) (String 'zzz)))))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (HasItems (Dict (DictType (DataType 'Int32) (DataType 'String)))))))) + (let s (Struct)) + (let s (AddMember s 'key (String '.))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/If.yql b/yql/essentials/tests/s-expressions/suites/Builtins/If.yql new file mode 100644 index 0000000000..f0cd523350 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/If.yql @@ -0,0 +1,20 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (If (< (Member item 'key) (String '100)) value (String 'UUU))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value res)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/IfType.cfg b/yql/essentials/tests/s-expressions/suites/Builtins/IfType.cfg new file mode 100644 index 0000000000..6f99339756 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/IfType.cfg @@ -0,0 +1,2 @@ +in Input input.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/IfType.yql b/yql/essentials/tests/s-expressions/suites/Builtins/IfType.yql new file mode 100644 index 0000000000..9503f0ed59 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/IfType.yql @@ -0,0 +1,20 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let key (Member item 'key)) + (let res (IfType key (DataType 'String) (lambda '(item) (Concat item item)) (lambda '(item) item))) + (let s (Struct)) + (let s (AddMember s 'key (ToString res))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value (Member item 'value))) + (return s) +))))) +(let mr_sink (DataSink 'result)) +(let world (Write! world mr_sink (Key) table1map '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/IntTypes.yql b/yql/essentials/tests/s-expressions/suites/Builtins/IntTypes.yql new file mode 100644 index 0000000000..56b74c715c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/IntTypes.yql @@ -0,0 +1,25 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (Concat (String '"") (ToString (Uint8 '1)))) + (let newValue (Concat newValue (ToString (Int32 '2)))) + (let newValue (Concat newValue (ToString (Uint32 '3)))) + (let newValue (Concat newValue (ToString (Int64 '4)))) + (let newValue (Concat newValue (ToString (Uint64 '5)))) + (let newValue (Concat newValue (ToString (Bool 'true)))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Just.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Just.yql new file mode 100644 index 0000000000..eac651c347 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Just.yql @@ -0,0 +1,23 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList (Not (Exists (Just (Uint32 '111)))))) + (let newValue (Append newValue (== (Coalesce (Just (String 'z)) (String 'y)) (String 'z)))) + (let ret (Map newValue (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (String '.))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (ToString item))) + (return s)))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/LengthInsideMap.yql b/yql/essentials/tests/s-expressions/suites/Builtins/LengthInsideMap.yql new file mode 100644 index 0000000000..f308062a08 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/LengthInsideMap.yql @@ -0,0 +1,20 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (Concat value (ToString (Length table1)))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/LengthInsideReduce.yql b/yql/essentials/tests/s-expressions/suites/Builtins/LengthInsideReduce.yql new file mode 100644 index 0000000000..a28b93a7a7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/LengthInsideReduce.yql @@ -0,0 +1,23 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let keySelector (lambda '(x) (Member x 'key))) +(let listHandler (lambda '(stream) (FlatMap stream (lambda '(pair) (block '( + (let key (Nth pair '0)) + (let list (ForwardList (Nth pair '1))) + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (Concat (ToString (Length table1)) (ToString (HasItems table1))))) + (let s (AddMember s 'value (Concat (ToString (Length list)) (ToString (HasItems list))))) + (let ret (AsList s)) + (return ret) +)))))) +(let reducedTable (PartitionByKey table1 keySelector (Bool 'true) (lambda '(item) (Member item 'subkey)) listHandler)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) reducedTable '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/ListAppendPrependExtend.yql b/yql/essentials/tests/s-expressions/suites/Builtins/ListAppendPrependExtend.yql new file mode 100644 index 0000000000..c58fcc163d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/ListAppendPrependExtend.yql @@ -0,0 +1,26 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Prepend (String 'prepended) newValue)) + (let newValue (Append newValue (String 'appended))) + (let x (AsList (String '"extended twice"))) + (let newValue (Extend newValue (Extend x x))) + (let ret (Map newValue (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (String '.))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value item)) + (return s)))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Logical.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Logical.yql new file mode 100644 index 0000000000..100c3df83b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Logical.yql @@ -0,0 +1,28 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let x (Bool 'true)) + (let y (Bool 'false)) + (let z (== value (String 'q))) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (And x z))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Or x z))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Xor x z))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Not z))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Lookup.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Lookup.yql new file mode 100644 index 0000000000..2eb0e2ff1f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Lookup.yql @@ -0,0 +1,27 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let t1 (DataType 'Uint32)) + (let t2 (DataType 'String)) + (let d1 (DictType t1 t2)) + (let d2 (Dict d1 '((Uint32 '4) (String 'aaa)) '((Uint32 '5) (String 'bbb))) ) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Lookup d2 (Uint32 '4)) (String '?))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Lookup d2 (Uint32 '6)) (String '?))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/MatchType.cfg b/yql/essentials/tests/s-expressions/suites/Builtins/MatchType.cfg new file mode 100644 index 0000000000..6f99339756 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/MatchType.cfg @@ -0,0 +1,2 @@ +in Input input.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/MatchType.yql b/yql/essentials/tests/s-expressions/suites/Builtins/MatchType.yql new file mode 100644 index 0000000000..5eb3cb79d7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/MatchType.yql @@ -0,0 +1,20 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let key (FromString (Member item 'key) 'Uint64)) + (let res (MatchType key 'Optional (lambda '(item) (Coalesce item (Uint64 '0))) (lambda '(item) item))) + (let s (Struct)) + (let s (AddMember s 'key (ToString res))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value (Member item 'value))) + (return s) +))))) +(let mr_sink (DataSink 'result)) +(let world (Write! world mr_sink (Key) table1map '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/MinMax.yql b/yql/essentials/tests/s-expressions/suites/Builtins/MinMax.yql new file mode 100644 index 0000000000..71a972e7e9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/MinMax.yql @@ -0,0 +1,33 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let x (Member item 'value)) + (let y (String 'q)) + (let z (String 'zzzz)) + (let newValue x) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (Min x)))) + (let newValue (Concat newValue (Concat (String '" ") (Max x)))) + (let newValue (Concat newValue (Concat (String '" ") (Min x y)))) + (let newValue (Concat newValue (Concat (String '" ") (Min x x)))) + (let newValue (Concat newValue (Concat (String '" ") (Max x y)))) + (let newValue (Concat newValue (Concat (String '" ") (Max y y)))) + (let newValue (Concat newValue (Concat (String '" ") (Min x y z)))) + (let newValue (Concat newValue (Concat (String '" ") (Min x x z)))) + (let newValue (Concat newValue (Concat (String '" ") (Max x y z)))) + (let newValue (Concat newValue (Concat (String '" ") (Max z z z)))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/MinMaxOverOptional.yql b/yql/essentials/tests/s-expressions/suites/Builtins/MinMaxOverOptional.yql new file mode 100644 index 0000000000..87b210c725 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/MinMaxOverOptional.yql @@ -0,0 +1,45 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let x (Member item 'value)) + (let y (String 'q)) + (let jx (Just x)) + (let jy (Just y)) + (let n (Nothing (OptionalType (DataType 'String)))) + (let newValue x) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (String '" Min "))) + (let newValue (Concat newValue (Concat (String '" ") (Min x y)))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Min jx y) (String '999))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Min x jy) (String '999))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Min jx jy) (String '999))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Min jx n) (String '999))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Min n jy) (String '999))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Min n y) (String '999))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Min x n) (String '999))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Min n n) (String '999))))) + (let newValue (Concat newValue (String '" Max "))) + (let newValue (Concat newValue (Concat (String '" ") (Max x y)))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Max jx y) (String '999))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Max x jy) (String '999))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Max jx jy) (String '999))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Max jx n) (String '999))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Max n jy) (String '999))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Max n y) (String '999))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Max x n) (String '999))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Max n n) (String '999))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Nanvl.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Nanvl.yql new file mode 100644 index 0000000000..899ddf853d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Nanvl.yql @@ -0,0 +1,81 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue value) + (let x (Float '2)) + (let y (Float '0)) + (let nan (/ y y)) + (let jx (Just x)) + (let jy (Just y)) + (let jnan (Just nan)) + (let n (Nothing (TypeOf jx))) + (let v (Null)) + (let newValue (Concat newValue (String '" Float => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl x y) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl y y) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl nan y) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jx y) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jy y) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jnan y) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl n y) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl x jy) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl y jy) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl nan jy) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jx jy) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jy jy) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jnan jy) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl n jy) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl x n) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl y n) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl nan n) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jx n) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jy n) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jnan n) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl n n) (Float '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl x v) (Float '999)))))) + (let x (Double '2)) + (let y (Double '0)) + (let nan (/ y y)) + (let jx (Just x)) + (let jy (Just y)) + (let jnan (Just nan)) + (let n (Nothing (TypeOf jx))) + (let newValue (Concat newValue (String '" Double => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl x y) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl y y) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl nan y) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jx y) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jy y) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jnan y) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl n y) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl x jy) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl y jy) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl nan jy) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jx jy) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jy jy) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jnan jy) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl n jy) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl x n) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl y n) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl nan n) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jx n) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jy n) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl jnan n) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl n n) (Double '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Nanvl x v) (Double '999)))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/NotOverOptional.yql b/yql/essentials/tests/s-expressions/suites/Builtins/NotOverOptional.yql new file mode 100644 index 0000000000..6a4f6f8e19 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/NotOverOptional.yql @@ -0,0 +1,35 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let writer (lambda '(x) (MatchType x 'Optional +(lambda '(x) (Coalesce (Map x (lambda '(y) (ToString y))) (String 'NULL))) +(lambda '(x) (ToString x))))) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let t (Bool 'true)) + (let jt (Just t)) + (let f (Bool 'false)) + (let jf (Just f)) + (let n (Nothing (OptionalType (DataType 'Bool)))) + (let newValue value) + (let newValue (Concat newValue (String '" => NOT : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Not t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Not jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Not f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Not jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Not n))))) + + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Now.cfg b/yql/essentials/tests/s-expressions/suites/Builtins/Now.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Now.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Now.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Now.yql new file mode 100644 index 0000000000..f187eeef74 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Now.yql @@ -0,0 +1,19 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let newValue (ToString (Now (DependsOn (Member item 'value))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (ToString (Now)))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Nth.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Nth.yql new file mode 100644 index 0000000000..0e3fc4acf6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Nth.yql @@ -0,0 +1,20 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let x '((String 'zzz) (Member item 'value))) + (let newValue (Nth x '1)) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/OptionalIf.yql b/yql/essentials/tests/s-expressions/suites/Builtins/OptionalIf.yql new file mode 100644 index 0000000000..08758ca2b4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/OptionalIf.yql @@ -0,0 +1,20 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (Coalesce (OptionalIf (== (Size value) (Uint32 '1)) value) (String '--))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/OptionalReduce.yql b/yql/essentials/tests/s-expressions/suites/Builtins/OptionalReduce.yql new file mode 100644 index 0000000000..f53f027cbe --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/OptionalReduce.yql @@ -0,0 +1,32 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let x (Uint32 '2)) + (let y (Uint32 '3)) + (let jx (Just x)) + (let jy (Just y)) + (let n (Nothing (OptionalType (DataType 'Uint32)))) + (let handler (lambda '(x y) (+ x y))) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (OptionalReduce x y handler))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (OptionalReduce jx jy handler) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (OptionalReduce jx n handler) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (OptionalReduce n jy handler) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (OptionalReduce n n handler) (Uint32 '999)))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/OrOverOptional.yql b/yql/essentials/tests/s-expressions/suites/Builtins/OrOverOptional.yql new file mode 100644 index 0000000000..8a1440b4a0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/OrOverOptional.yql @@ -0,0 +1,60 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let writer (lambda '(x) (MatchType x 'Optional +(lambda '(x) (Coalesce (Map x (lambda '(y) (ToString y))) (String 'NULL))) +(lambda '(x) (ToString x))))) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let t (Bool 'true)) + (let jt (Just t)) + (let f (Bool 'false)) + (let jf (Just f)) + (let n (Nothing (OptionalType (DataType 'Bool)))) + (let newValue value) + + (let newValue (Concat newValue (String '" => OR true : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or t t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or t jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or t f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or t jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or t n))))) + (let newValue (Concat newValue (String '" => OR false : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or f t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or f jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or f f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or f jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or f n))))) + (let newValue (Concat newValue (String '" => OR just true : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or jt t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or jt jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or jt f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or jt jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or jt n))))) + (let newValue (Concat newValue (String '" => OR just false : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or jf t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or jf jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or jf f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or jf jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or jf n))))) + (let newValue (Concat newValue (String '" => OR nothing : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or n t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or n jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or n f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or n jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Or n n))))) + + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Random.cfg b/yql/essentials/tests/s-expressions/suites/Builtins/Random.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Random.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Random.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Random.yql new file mode 100644 index 0000000000..2e6b0f7236 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Random.yql @@ -0,0 +1,23 @@ +# canonize yson here +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let newValue (Member item 'value)) + (let newValue (Concat (Concat newValue (String '" ")) (ToString + (Coalesce (ToIntegral (* (Uint64 '1000) (Random (DependsOn item))) (DataType 'Uint64)) (Uint64 '0))))) + (let newValue (Concat (Concat newValue (String '" ")) (ToString (RandomNumber (DependsOn item))))) + (let newValue (Concat (Concat newValue (String '" ")) (ToString (RandomUuid (DependsOn item))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (ToString (RandomNumber)))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Reverse.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Reverse.yql new file mode 100644 index 0000000000..d9d5058791 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Reverse.yql @@ -0,0 +1,23 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Append newValue (String 'appended))) + (let ret (OrderedMap (Reverse newValue) (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (String '.))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value item)) + (return s)))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Skip.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Skip.yql new file mode 100644 index 0000000000..3691a0bc21 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Skip.yql @@ -0,0 +1,24 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Prepend (String 'p) newValue)) + (let newValue (Append newValue (String 'a))) + (let ret (Map (Skip newValue (Uint64 '1)) (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (String '.))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value item)) + (return s)))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/SkipAfterTake.yql b/yql/essentials/tests/s-expressions/suites/Builtins/SkipAfterTake.yql new file mode 100644 index 0000000000..75ce137d75 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/SkipAfterTake.yql @@ -0,0 +1,13 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table2 (Take table1 (Uint64 '2))) +(let table3 (Skip table2 (Uint64 '1))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table3 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Sort.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Sort.yql new file mode 100644 index 0000000000..7333ac3a14 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Sort.yql @@ -0,0 +1,26 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Prepend (String 'p) newValue)) + (let newValue (Append newValue (String 'a))) + (let sorted (Sort newValue (Bool 'False) (lambda '(x) x))) + (let sorted (Append sorted (String '----))) + (let ret (Map sorted (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (String '.))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value item)) + (return s)))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/SortByOptionalNumbers.cfg b/yql/essentials/tests/s-expressions/suites/Builtins/SortByOptionalNumbers.cfg new file mode 100644 index 0000000000..9979f3f240 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/SortByOptionalNumbers.cfg @@ -0,0 +1,2 @@ +in Input numeric_keys.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/SortByOptionalNumbers.yql b/yql/essentials/tests/s-expressions/suites/Builtins/SortByOptionalNumbers.yql new file mode 100644 index 0000000000..8d61d0d81b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/SortByOptionalNumbers.yql @@ -0,0 +1,12 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let result (Sort table1 (Bool 'true) (lambda '(item) (FromString (Member item 'key) 'Uint64)))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) result '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/SortBySubkeyInsideReduce.yql b/yql/essentials/tests/s-expressions/suites/Builtins/SortBySubkeyInsideReduce.yql new file mode 100644 index 0000000000..db65afbd99 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/SortBySubkeyInsideReduce.yql @@ -0,0 +1,23 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let keySelector (lambda '(x) (Member x 'key))) +(let listHandler (lambda '(stream) (FlatMap stream (lambda '(pair) (block '( + (let key (Nth pair '0)) + (let list (ForwardList (Nth pair '1))) + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (ToString (Length list)))) + (let ret (AsList s)) + (return ret) +)))))) +(let reducedTable (PartitionByKey table1 keySelector (Bool 'true) (lambda '(item) (Member item 'subkey)) listHandler)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) reducedTable '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Substring.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Substring.yql new file mode 100644 index 0000000000..7a43121bdc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Substring.yql @@ -0,0 +1,20 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (Substring value (Uint32 '0) (Uint32 '1))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Take.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Take.yql new file mode 100644 index 0000000000..16e5ff7c87 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Take.yql @@ -0,0 +1,24 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Prepend (String 'p) newValue)) + (let newValue (Append newValue (String 'a))) + (let ret (Map (Take newValue (Uint64 '2)) (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (String '.))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value item)) + (return s)))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/TakeAfterSkip.yql b/yql/essentials/tests/s-expressions/suites/Builtins/TakeAfterSkip.yql new file mode 100644 index 0000000000..8fb8659c08 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/TakeAfterSkip.yql @@ -0,0 +1,13 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table2 (Skip table1 (Uint64 '1))) +(let table3 (Take table2 (Uint64 '2))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table3 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/ToIndexDict.yql b/yql/essentials/tests/s-expressions/suites/Builtins/ToIndexDict.yql new file mode 100644 index 0000000000..866fd55415 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/ToIndexDict.yql @@ -0,0 +1,28 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let list (AsList (Uint32 '7) (Uint32 '16))) + (let dict (ToIndexDict list)) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Length dict))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Contains dict (Uint64 '1)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Contains dict (Uint64 '10)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Lookup dict (Uint64 '1)) (Uint32 '999)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Coalesce (Lookup dict (Uint64 '10)) (Uint32 '999)))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/TryMember.yql b/yql/essentials/tests/s-expressions/suites/Builtins/TryMember.yql new file mode 100644 index 0000000000..2c8d57527e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/TryMember.yql @@ -0,0 +1,21 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let key (Member item 'key)) + (let res (TryMember item 'key (String 'aaa))) + (let res (Concat res (TryMember item 'newValue (String 'bbb)))) + (let s (Struct)) + (let s (AddMember s 'key res)) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value (Member item 'value))) + (return s) +))))) +(let mr_sink (DataSink 'result)) +(let world (Write! world mr_sink (Key) table1map '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/TwoSkip.yql b/yql/essentials/tests/s-expressions/suites/Builtins/TwoSkip.yql new file mode 100644 index 0000000000..453205bc66 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/TwoSkip.yql @@ -0,0 +1,13 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table2 (Skip table1 (Uint64 '1))) +(let table3 (Skip table2 (Uint64 '2))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table3 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/TwoTake.yql b/yql/essentials/tests/s-expressions/suites/Builtins/TwoTake.yql new file mode 100644 index 0000000000..abd4639a4c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/TwoTake.yql @@ -0,0 +1,13 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table2 (Take table1 (Uint64 '1))) +(let table3 (Take table2 (Uint64 '2))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table3 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/TypeConstructors.yql b/yql/essentials/tests/s-expressions/suites/Builtins/TypeConstructors.yql new file mode 100644 index 0000000000..50527bf4fd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/TypeConstructors.yql @@ -0,0 +1,49 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (RemoveSystemMembers (Right! x))) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let x (Uint32 '2)) + (let y (String '!)) + (let newValue value) + (let t1 (DataType 'Uint32)) + (let o1 (OptionalType t1)) + (let u1 (TupleType t1 o1)) + (let str (DataType 'String)) + (let s1 (StructType '('key str) '('subkey str) '('value str))) + (let s2 (Struct s1 '('subkey (String 'a)) '('key y) '('value y))) + (let s3 (AsStruct '('subkey (String 'a)) '('key y) '('value y))) + (let d1 (DictType t1 u1)) + (let d2 (Dict d1)) + (let d3 (Dict d1 '(x '(x (Just x))))) + (let d4 (AsDict '((String 'aaa) (Uint32 '17)) '((String 'aaa) (Uint32 '18)) '((String 'bbb) (Uint32 '5)))) + (let z1 (Nothing (OptionalType (VoidType)))) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (+ (Size value) x))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Length (List (ListType t1) x x)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Length (List (ListType o1))))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Length (List (ListType u1) '(x (Just x)))))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Exists (Nothing o1)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Length (AsList x x)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Length (List (ListType s1) item)))))) + (let newValue (Concat newValue (Concat (String '" ") (Member s2 'key)))) + (let newValue (Concat newValue (Concat (String '" ") (Member s3 'subkey)))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Length d2))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Length d3))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Length d4))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Exists (Optional o1 x)))))) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Exists z1))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/UnionAll.yql b/yql/essentials/tests/s-expressions/suites/Builtins/UnionAll.yql new file mode 100644 index 0000000000..e332263266 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/UnionAll.yql @@ -0,0 +1,26 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let list1 (Map table1 (lambda '(row) (block '( + (let res (AsStruct '('foo (FromString (Member row 'key) 'Int32)) '('bar (FromString (Member row 'subkey) 'Int32)))) + (return res) +) +)))) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let list2 (Map table2 (lambda '(row) (block '( + (let res (AsStruct '('foo (FromString (Member row 'key) 'Double)) '('jar (Member row 'value)))) + (return res) +) +)))) +(let result (UnionAll list1 list2)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf result)) '())) +(let world (Write! world res_sink (Key) result '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Unwrap.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Unwrap.yql new file mode 100644 index 0000000000..2180970236 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Unwrap.yql @@ -0,0 +1,22 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let x (Uint32 '2)) + (let newValue value) + (let newValue (Concat newValue (Concat (String '" ") (ToString (Unwrap (/ (Size value) x)))))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/XorOverOptional.yql b/yql/essentials/tests/s-expressions/suites/Builtins/XorOverOptional.yql new file mode 100644 index 0000000000..3d605c38b6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/XorOverOptional.yql @@ -0,0 +1,60 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let writer (lambda '(x) (MatchType x 'Optional +(lambda '(x) (Coalesce (Map x (lambda '(y) (ToString y))) (String 'NULL))) +(lambda '(x) (ToString x))))) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let t (Bool 'true)) + (let jt (Just t)) + (let f (Bool 'false)) + (let jf (Just f)) + (let n (Nothing (OptionalType (DataType 'Bool)))) + (let newValue value) + + (let newValue (Concat newValue (String '" => XOR true : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor t t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor t jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor t f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor t jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor t n))))) + (let newValue (Concat newValue (String '" => XOR false : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor f t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor f jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor f f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor f jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor f n))))) + (let newValue (Concat newValue (String '" => XOR just true : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor jt t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor jt jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor jt f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor jt jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor jt n))))) + (let newValue (Concat newValue (String '" => XOR just false : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor jf t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor jf jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor jf f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor jf jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor jf n))))) + (let newValue (Concat newValue (String '" => XOR nothing : "))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor n t))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor n jt))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor n f))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor n jf))))) + (let newValue (Concat newValue (Concat (String '" ") (Apply writer (Xor n n))))) + + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let s (AddMember s 'value newValue)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/Zip.yql b/yql/essentials/tests/s-expressions/suites/Builtins/Zip.yql new file mode 100644 index 0000000000..0455714f00 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/Zip.yql @@ -0,0 +1,26 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Prepend (String 'p) newValue)) + (let newValue (Append newValue (String 'a))) + (let smallList (AsList (Int32 '2))) + (let zippedList (Zip newValue smallList)) + (let ret (Map zippedList (lambda '(item2) (block '( + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Concat (Concat (Nth item2 '0) (String '" => ")) (ToString (Nth item2 '1))))) + (return s)))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/ZipAll.yql b/yql/essentials/tests/s-expressions/suites/Builtins/ZipAll.yql new file mode 100644 index 0000000000..554544466a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/ZipAll.yql @@ -0,0 +1,28 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1map (FlatMap table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let newValue (AsList value)) + (let newValue (Prepend (String 'p) newValue)) + (let newValue (Append newValue (String 'a))) + (let smallList (AsList (Int32 '2))) + (let zippedList (ZipAll newValue smallList)) + (let ret (Map zippedList (lambda '(item2) (block '( + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '.))) + (let x (Coalesce (Nth item2 '0) (String '_))) + (let y (Coalesce (Map (Nth item2 '1) (lambda '(x) (ToString x))) (String '_))) + (let s (AddMember s 'value (Concat (Concat x (String '" => ")) y))) + (return s)))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/default.cfg b/yql/essentials/tests/s-expressions/suites/Builtins/default.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/default.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/input.txt b/yql/essentials/tests/s-expressions/suites/Builtins/input.txt new file mode 100644 index 0000000000..65949ea745 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/input.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="800";"subkey"="2";"value"="ddd"}; +{"key"="020";"subkey"="3";"value"="q"}; +{"key"="150";"subkey"="4";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/input.txt.attr b/yql/essentials/tests/s-expressions/suites/Builtins/input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/input.txt.attr @@ -0,0 +1,30 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/numeric_keys.txt b/yql/essentials/tests/s-expressions/suites/Builtins/numeric_keys.txt new file mode 100644 index 0000000000..cebd64e139 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/numeric_keys.txt @@ -0,0 +1,4 @@ +{"key"="1";"subkey"="10";"value"="FOO"}; +{"key"="2";"subkey"="20";"value"="BAR"}; +{"key"="3";"subkey"="30";"value"="BAR"}; +{"key"="WAT";"subkey"="WAT";"value"="FOO"}; diff --git a/yql/essentials/tests/s-expressions/suites/Builtins/numeric_keys.txt.attr b/yql/essentials/tests/s-expressions/suites/Builtins/numeric_keys.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Builtins/numeric_keys.txt.attr @@ -0,0 +1,30 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +}
\ No newline at end of file |