diff options
author | udovichenko-r <udovichenko-r@yandex-team.com> | 2024-11-18 18:00:20 +0300 |
---|---|---|
committer | udovichenko-r <udovichenko-r@yandex-team.com> | 2024-11-18 18:32:34 +0300 |
commit | 227883e6978c3b90e91b931488e9dd4c56c350bf (patch) | |
tree | 925008663989d95a31a74a4f6e19886ecb47bd47 /yql/essentials/tests/s-expressions/suites | |
parent | 0dc8d9e60034615bb2e67687bfd94a4ea3e7296f (diff) | |
download | ydb-227883e6978c3b90e91b931488e9dd4c56c350bf.tar.gz |
YQL-19206 Move contrib/ydb/library/yql/tests/s-expressions/suites -> yql/essentials/tests/s-expressions/suites
commit_hash:02beb73b0c072658a9f2dc8bd9762791936b4e29
Diffstat (limited to 'yql/essentials/tests/s-expressions/suites')
1813 files changed, 37832 insertions, 0 deletions
diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggrAdd.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggrAdd.yql new file mode 100644 index 0000000000..ae95d15a68 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggrAdd.yql @@ -0,0 +1,21 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let x (Int32 '34)) +(let y (Int32 '56)) +(let jx (Just x)) +(let jy (Just y)) +(let n (Nothing (TypeOf jx))) + +(let world (Write! world res_sink (Key) (AggrAdd x y) '('('type)))) +(let world (Write! world res_sink (Key) (AggrAdd jx jy) '('('type)))) +(let world (Write! world res_sink (Key) (AggrAdd jx n) '('('type)))) +(let world (Write! world res_sink (Key) (AggrAdd n jy) '('('type)))) +(let world (Write! world res_sink (Key) (AggrAdd n n) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggrCount.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggrCount.yql new file mode 100644 index 0000000000..f0a27ab8d5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggrCount.yql @@ -0,0 +1,33 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let x (Int32 '34)) +(let jx (Just x)) +(let n (Nothing (TypeOf jx))) + +(let world (Write! world res_sink (Key) (AggrCountInit x) '('('type)))) +(let world (Write! world res_sink (Key) (AggrCountInit jx) '('('type)))) +(let world (Write! world res_sink (Key) (AggrCountInit n) '('('type)))) + +(let world (Write! world res_sink (Key) (AggrCountUpdate x (Uint64 '10)) '('('type)))) +(let world (Write! world res_sink (Key) (AggrCountUpdate jx (Uint64 '10)) '('('type)))) +(let world (Write! world res_sink (Key) (AggrCountUpdate n (Uint64 '10)) '('('type)))) + +(let cx (Callable (ParseType '"()->Int32") (lambda '() x))) +(let cjx (Callable (ParseType '"()->Int32?") (lambda '() jx))) +(let cn (Callable (ParseType '"()->Int32?") (lambda '() n))) + +(let world (Write! world res_sink (Key) (AggrCountInit (Apply cx)) '('('type)))) +(let world (Write! world res_sink (Key) (AggrCountInit (Apply cjx)) '('('type)))) +(let world (Write! world res_sink (Key) (AggrCountInit (Apply cn)) '('('type)))) + +(let world (Write! world res_sink (Key) (AggrCountUpdate (Apply cx) (Uint64 '10)) '('('type)))) +(let world (Write! world res_sink (Key) (AggrCountUpdate (Apply cjx) (Uint64 '10)) '('('type)))) +(let world (Write! world res_sink (Key) (AggrCountUpdate (Apply cn) (Uint64 '10)) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggrMinMax.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggrMinMax.yql new file mode 100644 index 0000000000..ab948dc649 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggrMinMax.yql @@ -0,0 +1,28 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let x (Int32 '34)) +(let y (Int32 '56)) +(let jx (Just x)) +(let jy (Just y)) +(let n (Nothing (TypeOf jx))) + +(let world (Write! world res_sink (Key) (AggrMin x y) '('('type)))) +(let world (Write! world res_sink (Key) (AggrMin jx jy) '('('type)))) +(let world (Write! world res_sink (Key) (AggrMin jx n) '('('type)))) +(let world (Write! world res_sink (Key) (AggrMin n jy) '('('type)))) +(let world (Write! world res_sink (Key) (AggrMin n n) '('('type)))) + +(let world (Write! world res_sink (Key) (AggrMax x y) '('('type)))) +(let world (Write! world res_sink (Key) (AggrMax jx jy) '('('type)))) +(let world (Write! world res_sink (Key) (AggrMax jx n) '('('type)))) +(let world (Write! world res_sink (Key) (AggrMax n jy) '('('type)))) +(let world (Write! world res_sink (Key) (AggrMax n n) '('('type)))) + + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateGroubByTwoFields.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateGroubByTwoFields.yql new file mode 100644 index 0000000000..e9565555ef --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateGroubByTwoFields.yql @@ -0,0 +1,44 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key" '"subkey" '"value") '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let output (block '( + (let select (block '( + (let core table1) + (let core (block '( + (let Count0_create (lambda '(row) (Convert (Exists row) 'Uint64))) + (let Count0_update (lambda '(row state) (OptionalReduce state (Convert (Exists row) 'Uint64) (lambda '(a b) (+ a b))))) + (let Count0_save (lambda '(state) state)) + (let Count0_load (lambda '(item) item)) + (let Count0_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Count0_finish (lambda '(state) state)) + (return (Aggregate core '('"key" '"subkey") '('('Count0 (AggregationTraits (StructMemberType (ListItemType (TypeOf core)) '"value") Count0_create Count0_update Count0_save Count0_load Count0_merge Count0_finish (Uint64 '0)) '"value")))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"subkey" (Member row '"subkey"))) + (let res (AddMember res '"column2" (Member row 'Count0))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (let select (Sort select '((Bool 'true) (Bool 'true)) (lambda '(row) '((Member row '"key") (Member row '"subkey"))))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"key" '"subkey" '"column2"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateGroubByTwoFieldsUsingTuple.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateGroubByTwoFieldsUsingTuple.yql new file mode 100644 index 0000000000..502366d6d5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateGroubByTwoFieldsUsingTuple.yql @@ -0,0 +1,52 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key" '"subkey" '"value") '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let table1 (FlatMap table1 (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" '((Member row '"key") (Member row '"key")))) + (let res (AddMember res '"subkey" (Member row '"subkey"))) + (let res (AddMember res '"value" (Member row 'value))) + (let res (AsList res)) + (return res) + ))))) + (let output (block '( + (let select (block '( + (let core table1) + (let core (block '( + (let Count0_create (lambda '(row) (Convert (Exists row) 'Uint64))) + (let Count0_update (lambda '(row state) (OptionalReduce state (Convert (Exists row) 'Uint64) (lambda '(a b) (+ a b))))) + (let Count0_save (lambda '(state) state)) + (let Count0_load (lambda '(item) item)) + (let Count0_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Count0_finish (lambda '(state) state)) + (return (Aggregate core '('"key" '"subkey") '('('Count0 (AggregationTraits (StructMemberType (ListItemType (TypeOf core)) '"value") Count0_create Count0_update Count0_save Count0_load Count0_merge Count0_finish (Uint64 '0)) '"value")))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"subkey" (Member row '"subkey"))) + (let res (AddMember res '"column2" (Member row 'Count0))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (let select (Sort select '((Bool 'true) (Bool 'true) (Bool 'true)) (lambda '(row) '((Nth (Member row '"key") '0) (Nth (Member row '"key") '1) (Member row '"subkey"))))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"key" '"subkey" '"column2"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateGroupByOneField.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateGroupByOneField.yql new file mode 100644 index 0000000000..b309a99b1c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateGroupByOneField.yql @@ -0,0 +1,50 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key" '"subkey" '"value") '())) + (let world (Left! x)) + (let table2 (Right! x)) + (let output (block '( + (let select (block '( + (let core table2) + (let core (block '( + (let Sum0_create (lambda '(row) ("Coalesce" (Cast (Member row '"subkey") 'Uint64) (Int64 '"0")))) + (let Sum0_update (lambda '(row state) (OptionalReduce state ("Coalesce" (Cast (Member row '"subkey") 'Uint64) (Int64 '"0")) (lambda '(a b) (+ a b))))) + (let Sum0_save (lambda '(state) state)) + (let Sum0_load (lambda '(item) item)) + (let Sum0_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Sum0_finish (lambda '(state) state)) + (let Count1_create (lambda '(row) (Convert (Exists row) 'Uint64))) + (let Count1_update (lambda '(row state) (OptionalReduce state (Convert (Exists row) 'Uint64) (lambda '(a b) (+ a b))))) + (let Count1_save (lambda '(state) state)) + (let Count1_load (lambda '(item) item)) + (let Count1_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Count1_finish (lambda '(state) state)) + (return (Aggregate core '('"key") '('('Sum0 (AggregationTraits (ListItemType (TypeOf core)) Sum0_create Sum0_update Sum0_save Sum0_load Sum0_merge Sum0_finish (Null))) '('Count1 (AggregationTraits (StructMemberType (ListItemType (TypeOf core)) '"value") Count1_create Count1_update Count1_save Count1_load Count1_merge Count1_finish (Uint64 '0)) '"value")))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"column1" (Member row 'Sum0))) + (let res (AddMember res '"column2" (Member row 'Count1))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (let select (Sort select (Bool 'true) (lambda '(row) (Member row '"key")))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"key" '"column1" '"column2"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateOptState.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateOptState.yql new file mode 100644 index 0000000000..bb96925785 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateOptState.yql @@ -0,0 +1,38 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"value" '"key" '"subkey") '())) + (let world (Left! x)) + (let table2 (Right! x)) + (let output (block '( + (let select (block '( + (let core table2) + (let core (block '( + (let Sum1_create (lambda '(row) (FromString (Member row '"subkey") '"Int64"))) + (let Sum1_update (lambda '(row state) (OptionalReduce state (FromString (Member row '"subkey") '"Int64") (lambda '(a b) (+ a b))))) + (let Sum1_save (lambda '(state) state)) + (let Sum1_load (lambda '(item) item)) + (let Sum1_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Sum1_finish (lambda '(state) state)) + (return (Aggregate core '('"value") '('('"Sum1" (AggregationTraits (ListItemType (TypeOf core)) Sum1_create Sum1_update Sum1_save Sum1_load Sum1_merge Sum1_finish (Null)))))) +) +)) + (return core) +) +)) + (return select) +) +)) + (let world (block '( + (let result_sink (DataSink 'result)) + (let sortedOutput (Sort output (Bool 'false) (lambda '(x) (Member x 'value) ))) + (let world (Write! world result_sink (Key) sortedOutput '('('type) '('autoref)))) + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return (Commit! world result_sink)) +) +)) + (return world) +) +)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateRead.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateRead.yql new file mode 100644 index 0000000000..70d8879fc0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateRead.yql @@ -0,0 +1,22 @@ +( +#comment +(let res_sink (DataSink 'result)) +(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 init (lambda '(x) (StrictFromString (Member x 'value) 'Uint32))) +(let update_min (lambda '(x y) (Min (StrictFromString (Member x 'value) 'Uint32) y))) +(let save (lambda '(x) x)) +(let load (lambda '(x) x)) +(let merge_min (lambda '(x y) (Min x y))) +(let finish (lambda '(x) x)) +(let min (AggregationTraits (ListItemType (TypeOf table1)) init update_min save load merge_min finish (Null))) +(let resAll (Aggregate table1 '() '('('minvalue min)))) +(let world (Write! world res_sink (Key) resAll '('('type)))) +(let resKey (Aggregate table1 '('key) '('('minvalue min)))) +(let sortedOutput (Sort resKey (Bool 'false) (lambda '(x) (Member x 'key) ))) +(let world (Write! world res_sink (Key) sortedOutput '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateReadDistinct.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateReadDistinct.yql new file mode 100644 index 0000000000..94034d32af --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateReadDistinct.yql @@ -0,0 +1,24 @@ +( +#comment +(let res_sink (DataSink 'result)) +(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 init (lambda '(x) (StrictFromString (Member x 'value) 'Uint32))) +(let init_distinct (lambda '(x) (StrictFromString x 'Uint32))) +(let update_sum_distinct (lambda '(x y) (+ (StrictFromString x 'Uint32) y))) +(let save (lambda '(x) x)) +(let load (lambda '(x) x)) +(let merge_sum (lambda '(x y) (+ x y))) +(let finish (lambda '(x) x)) +# distinct process one column and requires data/data? type +(let sum (AggregationTraits (StructMemberType (ListItemType (TypeOf table1)) 'value) init_distinct update_sum_distinct save load merge_sum finish (Null))) +(let resAll (Aggregate table1 '() '('('distsum sum 'value)))) +(let world (Write! world res_sink (Key) resAll '('('type)))) +(let resKey (Aggregate table1 '('key) '('('distsum sum 'value)))) +(let sortedOutput (Sort resKey (Bool 'false) (lambda '(x) (Member x 'key) ))) +(let world (Write! world res_sink (Key) sortedOutput '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateReadDistinctUsingTuple.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateReadDistinctUsingTuple.yql new file mode 100644 index 0000000000..d4f0adca76 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateReadDistinctUsingTuple.yql @@ -0,0 +1,36 @@ +( +#comment +(let res_sink (DataSink 'result)) +(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 table1 (FlatMap table1 (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" '((Member row '"key") (Member row '"key")))) + (let res (AddMember res '"subkey" (Member row '"subkey"))) + (let res (AddMember res '"value" (Member row 'value))) + (let res (AsList res)) + (return res) +))))) + +(let init (lambda '(x) (StrictFromString (Member x 'value) 'Uint32))) +(let init_distinct (lambda '(x) (StrictFromString x 'Uint32))) +(let update_sum_distinct (lambda '(x y) (+ (StrictFromString x 'Uint32) y))) +(let save (lambda '(x) x)) +(let load (lambda '(x) x)) +(let merge_sum (lambda '(x y) (+ x y))) +(let finish (lambda '(x) x)) +# distinct process one column and requires data/data? type +(let sum (AggregationTraits (StructMemberType (ListItemType (TypeOf table1)) 'value) init_distinct update_sum_distinct save load merge_sum finish (Null))) +(let resAll (Aggregate table1 '() '('('distsum sum 'value)))) +(let world (Write! world res_sink (Key) resAll '('('type)))) +(let resKey (Aggregate table1 '('key) '('('distsum sum 'value)))) +(let sortedOutput (Sort resKey '((Bool 'false) (Bool 'false)) (lambda '(x) (Member x 'key) ))) +(let world (Write! world res_sink (Key) sortedOutput '('('type)))) +(let resKey (Aggregate table1 '('key 'subkey) '('('distsum sum 'value)))) +(let sortedOutput (Sort resKey '((Bool 'false) (Bool 'false) (Bool 'false)) (lambda '(x) '((Nth (Member x 'key) '0) (Nth (Member x 'key) '1) (Member x 'subkey)) ))) +(let world (Write! world res_sink (Key) sortedOutput '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateReadDistinctWithParents.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateReadDistinctWithParents.yql new file mode 100644 index 0000000000..27c4faf647 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateReadDistinctWithParents.yql @@ -0,0 +1,24 @@ +( +#comment +(let res_sink (DataSink 'result)) +(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 init (lambda '(x parent) '(parent (StrictFromString (Member x 'value) 'Uint32)))) +(let init_distinct (lambda '(x parent) '(parent (StrictFromString x 'Uint32)))) +(let update_sum_distinct (lambda '(x y parent) '(parent (+ (StrictFromString x 'Uint32) (Nth y '1))))) +(let save (lambda '(x) x)) +(let load (lambda '(x) x)) +(let merge_sum (lambda '(x y) '((Nth x '0) (AggrAdd (Nth x '1) (Nth y '1))))) +(let finish (lambda '(x) (Nth x '1))) +# distinct process one column and requires data/data? type +(let sum (AggregationTraits (StructMemberType (ListItemType (TypeOf table1)) 'value) init_distinct update_sum_distinct save load merge_sum finish (Null))) +(let resAll (Aggregate table1 '() '('('distsum sum 'value)))) +(let world (Write! world res_sink (Key) resAll '('('type)))) +(let resKey (Aggregate table1 '('key) '('('distsum sum 'value)))) +(let sortedOutput (Sort resKey (Bool 'false) (lambda '(x) (Member x 'key) ))) +(let world (Write! world res_sink (Key) sortedOutput '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateReadWithParents.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateReadWithParents.yql new file mode 100644 index 0000000000..b0b2f6a084 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateReadWithParents.yql @@ -0,0 +1,22 @@ +( +#comment +(let res_sink (DataSink 'result)) +(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 init (lambda '(x parent) '(parent (StrictFromString (Member x 'value) 'Uint32)))) +(let update_min (lambda '(x y parent) '(parent (AggrMin (StrictFromString (Member x 'value) 'Uint32) (Nth y '1))))) +(let save (lambda '(x) x)) +(let load (lambda '(x) x)) +(let merge_min (lambda '(x y) (AggrMin x y))) +(let finish (lambda '(x) (Nth x '1))) +(let min (AggregationTraits (ListItemType (TypeOf table1)) init update_min save load merge_min finish (Null))) +(let resAll (Aggregate table1 '() '('('minvalue min)))) +(let world (Write! world res_sink (Key) resAll '('('type)))) +(let resKey (Aggregate table1 '('key) '('('minvalue min)))) +(let sortedOutput (Sort resKey (Bool 'false) (lambda '(x) (Member x 'key) ))) +(let world (Write! world res_sink (Key) sortedOutput '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateSameDistinct.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateSameDistinct.yql new file mode 100644 index 0000000000..9f4fb01757 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateSameDistinct.yql @@ -0,0 +1,107 @@ +( +(let $1 world) +(let $2 (DataSource '"yt" '"plato")) +(let $3 (String '"Input")) +(let $4 '('table $3)) +(let $5 (Key $4)) +(let $6 '('"key")) +(let $7 '()) +(let $8 (Read! $1 $2 $5 $6 $7)) +(let $9 (Left! $8)) +(let $10 (DataSink 'result)) +(let $11 (Key)) +(let $12 (Right! $8)) +(let $13 '()) +(let $14 (TypeOf $12)) +(let $15 (ListItemType $14)) +(let $16 (StructMemberType $15 '"key")) +(let $17 (lambda '($49) (block '( + (let $51 (Exists $49)) + (let $52 (Convert $51 'Uint64)) + (return $52) +)))) +(let $18 (lambda '($53 $54) (block '( + (let $56 (Exists $53)) + (let $57 (Convert $56 'Uint64)) + (let $58 (lambda '($60 $61) (block '( + (let $63 (+ $60 $61)) + (return $63) + )))) + (let $59 (OptionalReduce $54 $57 $58)) + (return $59) +)))) +(let $19 (lambda '($64) (block '( + (return $64) +)))) +(let $20 (lambda '($66) (block '( + (return $66) +)))) +(let $21 (lambda '($68 $69) (block '( + (let $71 (lambda '($73 $74) (block '( + (let $76 (+ $73 $74)) + (return $76) + )))) + (let $72 (OptionalReduce $68 $69 $71)) + (return $72) +)))) +(let $22 (lambda '($77) (block '( + (return $77) +)))) +(let $23 (AggregationTraits $16 $17 $18 $19 $20 $21 $22 (Null))) +(let $24 '('Count0 $23 '"key")) +(let $25 (TypeOf $12)) +(let $26 (ListItemType $25)) +(let $27 (StructMemberType $26 '"key")) +(let $28 (lambda '($79) (block '( + (return $79) +)))) +(let $29 (lambda '($81 $82) (block '( + (let $84 (lambda '($86 $87) (block '( + (let $89 (Min $86 $87)) + (return $89) + )))) + (let $85 (OptionalReduce $82 $81 $84)) + (return $85) +)))) +(let $30 (lambda '($90) (block '( + (return $90) +)))) +(let $31 (lambda '($92) (block '( + (return $92) +)))) +(let $32 (lambda '($94 $95) (block '( + (let $97 (lambda '($99 $100) (block '( + (let $102 (Min $99 $100)) + (return $102) + )))) + (let $98 (OptionalReduce $94 $95 $97)) + (return $98) +)))) +(let $33 (lambda '($103) (block '( + (return $103) +)))) +(let $34 (AggregationTraits $27 $28 $29 $30 $31 $32 $33 (Null))) +(let $35 '('Min1 $34 '"key")) +(let $36 '($24 $35)) +(let $37 (Aggregate $12 $13 $36)) +(let $38 (lambda '($105) (block '( + (let $107 (Struct)) + (let $108 (Member $105 'Count0)) + (let $109 (AddMember $107 '"column0" $108)) + (let $110 (Member $105 'Min1)) + (let $111 (AddMember $109 '"column1" $110)) + (let $112 (AsList $111)) + (return $112) +)))) +(let $39 (FlatMap $37 $38)) +(let $40 '('type)) +(let $41 '('autoref)) +(let $42 '('"column0" '"column1")) +(let $43 '('columns $42)) +(let $44 '($40 $41 $43)) +(let $45 (Write! $9 $10 $11 $39 $44)) +(let $46 (Commit! $45 $10)) +(let $47 (DataSink '"yt" '"plato")) +(let $48 (Commit! $46 $47)) +(return $48) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateWithoutGroup.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateWithoutGroup.yql new file mode 100644 index 0000000000..472d0234d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateWithoutGroup.yql @@ -0,0 +1,55 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key" '"subkey" '"value") '())) + (let world (Left! x)) + (let table3 (Right! x)) + (let output (block '( + (let select (block '( + (let core table3) + (let core (block '( + (let Sum0_create (lambda '(row) ("Coalesce" (Cast (Member row '"key") 'Uint64) (Int64 '"0")))) + (let Sum0_update (lambda '(row state) (OptionalReduce state ("Coalesce" (Cast (Member row '"key") 'Uint64) (Int64 '"0")) (lambda '(a b) (+ a b))))) + (let Sum0_save (lambda '(state) state)) + (let Sum0_load (lambda '(item) item)) + (let Sum0_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Sum0_finish (lambda '(state) state)) + (let Count1_create (lambda '(row) (Convert (Exists row) 'Uint64))) + (let Count1_update (lambda '(row state) (OptionalReduce state (Convert (Exists row) 'Uint64) (lambda '(a b) (+ a b))))) + (let Count1_save (lambda '(state) state)) + (let Count1_load (lambda '(item) item)) + (let Count1_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Count1_finish (lambda '(state) state)) + (let Count2_create (lambda '(row) (Convert (Exists row) 'Uint64))) + (let Count2_update (lambda '(row state) (OptionalReduce state (Convert (Exists row) 'Uint64) (lambda '(a b) (+ a b))))) + (let Count2_save (lambda '(state) state)) + (let Count2_load (lambda '(item) item)) + (let Count2_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Count2_finish (lambda '(state) state)) + (return (Aggregate core '() '('('Sum0 (AggregationTraits (ListItemType (TypeOf core)) Sum0_create Sum0_update Sum0_save Sum0_load Sum0_merge Sum0_finish (Null))) '('Count1 (AggregationTraits (StructMemberType (ListItemType (TypeOf core)) '"subkey") Count1_create Count1_update Count1_save Count1_load Count1_merge Count1_finish (Uint64 '0)) '"subkey") '('Count2 (AggregationTraits (StructMemberType (ListItemType (TypeOf core)) '"value") Count2_create Count2_update Count2_save Count2_load Count2_merge Count2_finish (Uint64 '0)) '"value")))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"column0" (Member row 'Sum0))) + (let res (AddMember res '"column1" (Member row 'Count1))) + (let res (AddMember res '"column2" (Member row 'Count2))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0" '"column1" '"column2"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateWithoutTraits.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateWithoutTraits.yql new file mode 100644 index 0000000000..59dd4cabc3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/AggregateWithoutTraits.yql @@ -0,0 +1,37 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key" '"subkey" '"value") '())) + (let world (Left! x)) + (let input (Right! x)) + (let output (block '( + (let select (block '( + (let core input) + (let core (block '( + (return (Aggregate core '('key 'value) '())) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row 'key))) + (let res (AddMember res '"value" (Member row 'value))) + (let res (AsList res)) + (return res) + ))))) + (let core (Sort core '((Bool 'true) (Bool 'true)) (lambda '(x) '((Member x 'key) (Member x 'value)) ))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/Bug1.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/Bug1.yql new file mode 100644 index 0000000000..0a2a83b345 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/Bug1.yql @@ -0,0 +1,69 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key" '"value") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"value1" (MatchType (Member row '"value") 'Optional (lambda '(item) (Coalesce (Map item (lambda '(val) (IfType val (DataType 'String) (lambda '(item) (FromString item '"Int64")) (lambda '(item) (Just (Convert item '"Int64")))))) (Nothing (OptionalType (DataType '"Int64"))))) (lambda '(item) (IfType item (DataType 'String) (lambda '(item) (FromString item '"Int64")) (lambda '(item) (Convert item '"Int64"))))))) + (let res (AsList res)) + (return res) +) +)))) + (return core) +) +)) + (return select) +) +)) + (let core (block '( + (let Max1_create (lambda '(row) (Member row '"value1"))) + (let Max1_update (lambda '(row state) (OptionalReduce state (Member row '"value1") (lambda '(a b) (Max a b))))) + (let Max1_save (lambda '(state) state)) + (let Max1_load (lambda '(item) item)) + (let Max1_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (Max a b))))) + (let Max1_finish (lambda '(state) state)) + (let Count2_create (lambda '(row) (Convert (Exists row) 'Uint64))) + (let Count2_update (lambda '(row state) (OptionalReduce state (Convert (Exists row) 'Uint64) (lambda '(a b) (+ a b))))) + (let Count2_save (lambda '(state) state)) + (let Count2_load (lambda '(item) item)) + (let Count2_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Count2_finish (lambda '(state) state)) + (return (Aggregate core '('"key") '('('Max1 (AggregationTraits (ListItemType (TypeOf core)) Max1_create Max1_update Max1_save Max1_load Max1_merge Max1_finish (Null))) '('Count2 (AggregationTraits (StructMemberType (ListItemType (TypeOf core)) '"value1") Count2_create Count2_update Count2_save Count2_load Count2_merge Count2_finish (Uint64 '0)) '"value1")))) +) +)) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"column0" (Member row 'Max1))) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"column2" (Member row 'Count2))) + (let res (AsList res)) + (return res) +) +)))) + (return core) +) +)) + (return select) +) +)) + (let world (block '( + (let result_sink (DataSink 'result)) + (let sortedOutput (Sort output (Bool 'false) (lambda '(x) (Member x 'key) ))) + (let world (Write! world result_sink (Key) sortedOutput '('('type) '('autoref) '('columns '('"column0" '"key" '"column2"))))) + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return (Commit! world result_sink)) +) +)) + (return world) +) +)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/Bug2.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/Bug2.yql new file mode 100644 index 0000000000..1558d5a3a9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/Bug2.yql @@ -0,0 +1,53 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key" '"value") '())) + (let world (Left! x)) + (let table2 (Right! x)) + (let output (block '( + (let select (block '( + (let core table2) + (let core (block '( + (let Max0_create (lambda '(row) (Member row '"value"))) + (let Max0_update (lambda '(row state) (OptionalReduce state (Member row '"value") (lambda '(a b) (Max a b))))) + (let Max0_save (lambda '(state) state)) + (let Max0_load (lambda '(item) item)) + (let Max0_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (Max a b))))) + (let Max0_finish (lambda '(state) state)) + (let Count1_create (lambda '(row) (Convert (Exists row) 'Uint64))) + (let Count1_update (lambda '(row state) (OptionalReduce state (Convert (Exists row) 'Uint64) (lambda '(a b) (+ a b))))) + (let Count1_save (lambda '(state) state)) + (let Count1_load (lambda '(item) item)) + (let Count1_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Count1_finish (lambda '(state) state)) + (return (Aggregate core '('"key") '('('Max0 (AggregationTraits (ListItemType (TypeOf core)) Max0_create Max0_update Max0_save Max0_load Max0_merge Max0_finish (Null))) '('Count1 (AggregationTraits (StructMemberType (ListItemType (TypeOf core)) '"value") Count1_create Count1_update Count1_save Count1_load Count1_merge Count1_finish (Uint64 '0)) '"value")))) +) +)) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"column0" (Member row 'Max0))) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"column2" (Member row 'Count1))) + (let res (AsList res)) + (return res) +) +)))) + (return core) +) +)) + (return select) +) +)) + (let world (block '( + (let result_sink (DataSink 'result)) + (let sortedOutput (Sort output (Bool 'false) (lambda '(x) (Member x 'key) ))) + (let world (Write! world result_sink (Key) sortedOutput '('('type) '('autoref) '('columns '('"column0" '"key" '"column2"))))) + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return (Commit! world result_sink)) +) +)) + (return world) +) +)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/Bug3.cfg b/yql/essentials/tests/s-expressions/suites/Aggregation/Bug3.cfg new file mode 100644 index 0000000000..2c8f4d3baa --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/Bug3.cfg @@ -0,0 +1,3 @@ +in Input input3.txt +res result.txt +udf datetime2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/Bug3.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/Bug3.yql new file mode 100644 index 0000000000..61e56c5a0f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/Bug3.yql @@ -0,0 +1,40 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(import core_module '"/lib/yql/core.yql") +(let world (Configure! world (DataSource '"config") 'SQL '0)) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) (Void) '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let output (block '( + (let select (block '( + (let core table1) + (let core (Aggregate core '() '('('Avg0 (Apply (bind aggregate_module '"avg_traits_factory") (TypeOf core) (lambda '(row) (PersistableRepr (Apply (lambda '("$UniqID") (block '( + (let $string_uniqid (Coalesce (SafeCast "$UniqID" (DataType 'String)) (String '""))) + (let $time (Substring "$string_uniqid" ("-" (Size "$string_uniqid") (SafeCast (Int32 '"10") (DataType 'Uint32))) (Int32 '"10"))) + (return ("-" (SafeCast (SqlCall '"DateTime2.ToSeconds" '((PositionalArgs (SafeCast (String '"2017-06-29") (DataType 'Date))))) (DataType 'Int64)) (SafeCast (SqlCall '"DateTime2.FromSeconds" '((PositionalArgs (SafeCast "$time" (DataType 'Uint32))))) (DataType 'Int64)))) + ))) (Member row '"key"))))))) '())) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"avg_timediff" (Cast (/ (Member row 'Avg0) (Uint64 '1000000000000)) 'Int32)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"avg_timediff"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/EmptyOptional.cfg b/yql/essentials/tests/s-expressions/suites/Aggregation/EmptyOptional.cfg new file mode 100644 index 0000000000..c8889a670f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/EmptyOptional.cfg @@ -0,0 +1,2 @@ +in Input input1.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/EmptyOptional.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/EmptyOptional.yql new file mode 100644 index 0000000000..312c757886 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/EmptyOptional.yql @@ -0,0 +1,58 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key" '"subkey" '"value") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"subkey" (Member row '"subkey"))) + (let res (AddMember res '"value" (Cast (Member row '"value") 'Double))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (let Sum1_create (lambda '(row) (Member row '"value"))) + (let Sum1_update (lambda '(row state) (OptionalReduce state (Member row '"value") (lambda '(a b) (+ a b))))) + (let Sum1_save (lambda '(state) state)) + (let Sum1_load (lambda '(item) item)) + (let Sum1_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Sum1_finish (lambda '(state) state)) + (return (Aggregate core '('"key") '('('Sum1 (AggregationTraits (ListItemType (TypeOf core)) Sum1_create Sum1_update Sum1_save Sum1_load Sum1_merge Sum1_finish (Null)))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"subkey" (String '""))) + (let res (AddMember res '"value" (Member row 'Sum1))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (let select (Sort select (Bool 'true) (lambda '(row) (Member row '"key")))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"key" '"subkey" '"value"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregate.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregate.yql new file mode 100644 index 0000000000..b25953f460 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregate.yql @@ -0,0 +1,35 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let init (lambda '(x) (Member x 'value))) +(let init_distinct (lambda '(x) x)) +(let update_min (lambda '(x y) (Min (Member x 'value) y))) +(let update_sum_distinct (lambda '(x y) (+ x y))) +(let save (lambda '(x) x)) +(let load (lambda '(x) x)) +(let merge_min (lambda '(x y) (Min x y))) +(let merge_sum (lambda '(x y) (+ x y))) +(let finish (lambda '(x) x)) +(let finish_min2 (lambda '(x) '(x (* (Uint32 '2) x)))) +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '10))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +# non-distinct processes row +(let min (AggregationTraits (ListItemType (TypeOf list)) init update_min save load merge_min finish_min2 (Null))) +# distinct process one column and requires data/data? type +(let sum (AggregationTraits (StructMemberType (ListItemType (TypeOf list)) 'value) init_distinct update_sum_distinct save load merge_sum finish (Null))) +(let resAll (Aggregate list '() '('('('minvalue 'minvalue2) min) '('distsum sum 'value)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) resAll '('('type)))) +(let resKey (Aggregate list '('key) '('('('minvalue 'minvalue2) min) '('distsum sum 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregateUsingTuple.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregateUsingTuple.yql new file mode 100644 index 0000000000..d3c8358342 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregateUsingTuple.yql @@ -0,0 +1,40 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let init (lambda '(x) (Member x 'value))) +(let init_distinct (lambda '(x) x)) +(let update_min (lambda '(x y) (Min (Member x 'value) y))) +(let update_sum_distinct (lambda '(x y) (+ x y))) +(let save (lambda '(x) x)) +(let load (lambda '(x) x)) +(let merge_min (lambda '(x y) (Min x y))) +(let merge_sum (lambda '(x y) (+ x y))) +(let finish (lambda '(x) x)) +(let finish_min2 (lambda '(x) '(x (* (Uint32 '2) x)))) +(let list (AsList +(AsStruct '('key '((Uint32 '1) (Uint32 '1))) '('subkey (String '.)) '('value (Uint32 '2))) +(AsStruct '('key '((Uint32 '2) (Uint32 '2))) '('subkey (String '.)) '('value (Uint32 '3))) +(AsStruct '('key '((Uint32 '1) (Uint32 '1))) '('subkey (String '.)) '('value (Uint32 '4))) +(AsStruct '('key '((Uint32 '3) (Uint32 '3))) '('subkey (String '.)) '('value (Uint32 '10))) +(AsStruct '('key '((Uint32 '2) (Uint32 '2))) '('subkey (String '.)) '('value (Uint32 '5))) +(AsStruct '('key '((Uint32 '2) (Uint32 '2))) '('subkey (String '.)) '('value (Uint32 '5))) +)) +# non-distinct processes row +(let min (AggregationTraits (ListItemType (TypeOf list)) init update_min save load merge_min finish_min2 (Null))) +# distinct process one column and requires data/data? type +(let sum (AggregationTraits (StructMemberType (ListItemType (TypeOf list)) 'value) init_distinct update_sum_distinct save load merge_sum finish (Null))) +(let resAll (Aggregate list '() '('('('minvalue 'minvalue2) min) '('distsum sum 'value)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) resAll '('('type)))) +(let resKey (Aggregate list '('key) '('('('minvalue 'minvalue2) min) '('distsum sum 'value)))) +(let keyExtractor (lambda '(x) '((Nth (Member x 'key) '0) (Nth (Member x 'key) '1)))) +(let resSort (ListSort resKey '((Bool 'true) (Bool 'false)) keyExtractor)) +(let world (Write! world res_sink (Key) resSort '('('type)))) +(let world (Commit! world res_sink)) +(let resKey (Aggregate list '('key 'subkey) '('('('minvalue 'minvalue2) min) '('distsum sum 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregateWithParents.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregateWithParents.yql new file mode 100644 index 0000000000..4357fcf5c7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregateWithParents.yql @@ -0,0 +1,35 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let init (lambda '(x parent) '(parent (Member x 'value)))) +(let init_distinct (lambda '(x parent) '(parent x))) +(let update_min (lambda '(x y parent) '(parent (Min (Member x 'value) (Nth y '1))))) +(let update_sum_distinct (lambda '(x y parent) '(parent (Add x (Nth y '1))))) +(let save (lambda '(x) x)) +(let load (lambda '(x) x)) +(let merge_min (lambda '(x y) (AggrMin x y))) +(let merge_sum (lambda '(x y) '((Nth x '0) (AggrAdd (Nth y '1) (Nth x '1))))) +(let finish (lambda '(x) (Nth x '1))) +(let finish_min2 (lambda '(x) '((Nth x '1) (* (Uint32 '2) (Nth x '1))))) +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '10))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +# non-distinct processes row +(let min (AggregationTraits (ListItemType (TypeOf list)) init update_min save load merge_min finish_min2 (Null))) +# distinct process one column and requires data/data? type +(let sum (AggregationTraits (StructMemberType (ListItemType (TypeOf list)) 'value) init_distinct update_sum_distinct save load merge_sum finish (Null))) +(let resAll (Aggregate list '() '('('('minvalue 'minvalue2) min) '('distsum sum 'value)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) resAll '('('type)))) +(let resKey (Aggregate list '('key) '('('('minvalue 'minvalue2) min) '('distsum sum 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregateZero.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregateZero.yql new file mode 100644 index 0000000000..73069b7061 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregateZero.yql @@ -0,0 +1,24 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let init_min (lambda '(x) (Member x 'value))) +(let init_count (lambda '(x) (Uint64 '1))) +(let update_min (lambda '(x y) (Min (Member x 'value) y))) +(let update_count (lambda '(x y) (+ y (Uint64 '1)))) +(let id (lambda '(x) x)) +(let merge_min (lambda '(x y) (Min x y))) +(let merge_count (lambda '(x y) (+ x y))) +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +)) +(let list (Take list (Uint64 '0))) +(let min (AggregationTraits (ListItemType (TypeOf list)) init_min update_min id id merge_min id (Null))) +(let count (AggregationTraits (ListItemType (TypeOf list)) init_count update_count id id merge_count id (Uint64 '0))) +(let resAll (Aggregate list '() '('('minvalue min) '('count count)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) resAll '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregateZeroOpt.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregateZeroOpt.yql new file mode 100644 index 0000000000..857859cc2c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/InMemAggregateZeroOpt.yql @@ -0,0 +1,24 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let init_min (lambda '(x) (Member x 'value))) +(let init_count (lambda '(x) (Uint64 '1))) +(let update_min (lambda '(x y) (Min (Member x 'value) y))) +(let update_count (lambda '(x y) (+ y (Uint64 '1)))) +(let id (lambda '(x) x)) +(let merge_min (lambda '(x y) (Min x y))) +(let merge_count (lambda '(x y) (+ x y))) +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '2)))) +)) +(let list (Take list (Uint64 '0))) +(let min (AggregationTraits (ListItemType (TypeOf list)) init_min update_min id id merge_min id (Null))) +(let count (AggregationTraits (ListItemType (TypeOf list)) init_count update_count id id merge_count id (Uint64 '0))) +(let resAll (Aggregate list '() '('('minvalue min) '('count count)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) resAll '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/Level_4.cfg b/yql/essentials/tests/s-expressions/suites/Aggregation/Level_4.cfg new file mode 100644 index 0000000000..e341fb79d2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/Level_4.cfg @@ -0,0 +1,7 @@ +in Input many_columns.txt +out Output output.txt +out Output1 output1.txt +out Output2 output2.txt +res result.txt +mount ..\mounts.txt +udf datetime2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/Level_4.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/Level_4.yql new file mode 100644 index 0000000000..f18d8573a4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/Level_4.yql @@ -0,0 +1,168 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(let world (Configure! world (DataSource '"config") 'SQL '0)) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"assignment_gs_count" '"assignment_assignment_id" '"assignment_last_status_change_time" '"requester_id" '"project_id" '"assignment_gs_weight") '())) + (let world (Left! x)) + (let table5 (Right! x)) + (let values (block '( + (let select (block '( + (let core table5) + (let core (Filter core (lambda '(row) (Coalesce (">" (Member row '"assignment_gs_count") (Int64 '"0")) (Bool 'false))))) + (let core (block '( + (return (Aggregate core '('"assignment_assignment_id") '('('Some0 (Apply (bind aggregate_module '"some_traits_factory") (TypeOf core) (lambda '(row) (Member row '"assignment_last_status_change_time")))) '('Some1 (Apply (bind aggregate_module '"some_traits_factory") (TypeOf core) (lambda '(row) (Member row '"requester_id")))) '('Some2 (Apply (bind aggregate_module '"some_traits_factory") (TypeOf core) (lambda '(row) (Member row '"project_id")))) '('Some3 (Apply (bind aggregate_module '"some_traits_factory") (TypeOf core) (lambda '(row) (Member row '"assignment_gs_count")))) '('Some4 (Apply (bind aggregate_module '"some_traits_factory") (TypeOf core) (lambda '(row) (Member row '"assignment_gs_weight"))))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"assignment_id" (Member row '"assignment_assignment_id"))) + (let res (AddMember res '"date" (SafeCast ("Apply" ("Udf" '"DateTime2.FromSeconds") (Cast (Member row 'Some0) 'Uint32)) (DataType 'Date)))) + (let res (AddMember res '"requester_id" (Member row 'Some1))) + (let res (AddMember res '"project_id" (Member row 'Some2))) + (let res (AddMember res '"gs_count" (Member row 'Some3))) + (let res (AddMember res '"gs_weight" (Cast (Member row 'Some4) 'Double))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"Output"))) values '('('mode 'renew)))) + (return world) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Output"))) (Void) '())) + (let world (Left! x)) + (let table7 (Right! x)) + (let values (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table7) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (return (Aggregate core '('"date" '"project_id" '"requester_id") '('('Sum8 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_count")))) '('Sum9 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_weight"))))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"date" (Member row '"date"))) + (let res (AddMember res '"requester_id" (Member row '"requester_id"))) + (let res (AddMember res '"project_id" (Member row '"project_id"))) + (let res (AddMember res '"gs_count" (Member row 'Sum8))) + (let res (AddMember res '"gs_weight" (Member row 'Sum9))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"Output1"))) values '('('mode 'renew)))) + (return world) + ))) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Output"))) (Void) '())) + (let world (Left! x)) + (let table7 (Right! x)) + (let values (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table7) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (return (Aggregate core '('"date" '"project_id" '"requester_id") '('('Sum8 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_count")))) '('Sum9 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_weight"))))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"date" (Member row '"date"))) + (let res (AddMember res '"requester_id" (Member row '"requester_id"))) + (let res (AddMember res '"project_id" (Member row '"project_id"))) + (let res (AddMember res '"gs_count" (Member row 'Sum8))) + (let res (AddMember res '"gs_weight" (Member row 'Sum9))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (return (Aggregate core '('"date" '"requester_id") '('('Sum11 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_count")))) '('Sum12 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_weight"))))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"date" (Member row '"date"))) + (let res (AddMember res '"requester_id" (Member row '"requester_id"))) + (let res (AddMember res '"gs_count" (Member row 'Sum11))) + (let res (AddMember res '"gs_weight" (Member row 'Sum12))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"Output2"))) values '('('mode 'renew)))) + (return world) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/Level_5.cfg b/yql/essentials/tests/s-expressions/suites/Aggregation/Level_5.cfg new file mode 100644 index 0000000000..f01a3e0180 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/Level_5.cfg @@ -0,0 +1,8 @@ +in Input many_columns.txt +out Output output.txt +out Output1 output1.txt +out Output2 output2.txt +out Output3 output3.txt +res result.txt +mount ..\mounts.txt +udf datetime2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/Level_5.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/Level_5.yql new file mode 100644 index 0000000000..18d89027da --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/Level_5.yql @@ -0,0 +1,254 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(let world (Configure! world (DataSource '"config") 'SQL '0)) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"assignment_gs_count" '"assignment_assignment_id" '"assignment_last_status_change_time" '"requester_id" '"project_id" '"assignment_gs_weight") '())) + (let world (Left! x)) + (let table5 (Right! x)) + (let values (block '( + (let select (block '( + (let core table5) + (let core (Filter core (lambda '(row) (Coalesce (">" (Member row '"assignment_gs_count") (Int64 '"0")) (Bool 'false))))) + (let core (block '( + (return (Aggregate core '('"assignment_assignment_id") '('('Some0 (Apply (bind aggregate_module '"some_traits_factory") (TypeOf core) (lambda '(row) (Member row '"assignment_last_status_change_time")))) '('Some1 (Apply (bind aggregate_module '"some_traits_factory") (TypeOf core) (lambda '(row) (Member row '"requester_id")))) '('Some2 (Apply (bind aggregate_module '"some_traits_factory") (TypeOf core) (lambda '(row) (Member row '"project_id")))) '('Some3 (Apply (bind aggregate_module '"some_traits_factory") (TypeOf core) (lambda '(row) (Member row '"assignment_gs_count")))) '('Some4 (Apply (bind aggregate_module '"some_traits_factory") (TypeOf core) (lambda '(row) (Member row '"assignment_gs_weight"))))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"assignment_id" (Member row '"assignment_assignment_id"))) + (let res (AddMember res '"date" (SafeCast ("Apply" ("Udf" '"DateTime2.FromSeconds") (Cast (Member row 'Some0) 'Uint32)) (DataType 'Date)))) + (let res (AddMember res '"requester_id" (Member row 'Some1))) + (let res (AddMember res '"project_id" (Member row 'Some2))) + (let res (AddMember res '"gs_count" (Member row 'Some3))) + (let res (AddMember res '"gs_weight" (Cast (Member row 'Some4) 'Double))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"Output"))) values '('('mode 'renew)))) + (return world) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Output"))) (Void) '())) + (let world (Left! x)) + (let table7 (Right! x)) + (let values (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table7) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (return (Aggregate core '('"date" '"project_id" '"requester_id") '('('Sum8 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_count")))) '('Sum9 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_weight"))))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"date" (Member row '"date"))) + (let res (AddMember res '"requester_id" (Member row '"requester_id"))) + (let res (AddMember res '"project_id" (Member row '"project_id"))) + (let res (AddMember res '"gs_count" (Member row 'Sum8))) + (let res (AddMember res '"gs_weight" (Member row 'Sum9))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"Output1"))) values '('('mode 'renew)))) + (return world) + ))) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Output"))) (Void) '())) + (let world (Left! x)) + (let table7 (Right! x)) + (let values (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table7) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (return (Aggregate core '('"date" '"project_id" '"requester_id") '('('Sum8 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_count")))) '('Sum9 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_weight"))))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"date" (Member row '"date"))) + (let res (AddMember res '"requester_id" (Member row '"requester_id"))) + (let res (AddMember res '"project_id" (Member row '"project_id"))) + (let res (AddMember res '"gs_count" (Member row 'Sum8))) + (let res (AddMember res '"gs_weight" (Member row 'Sum9))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (return (Aggregate core '('"date" '"requester_id") '('('Sum11 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_count")))) '('Sum12 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_weight"))))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"date" (Member row '"date"))) + (let res (AddMember res '"requester_id" (Member row '"requester_id"))) + (let res (AddMember res '"gs_count" (Member row 'Sum11))) + (let res (AddMember res '"gs_weight" (Member row 'Sum12))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"Output2"))) values '('('mode 'renew)))) + (return world) + ))) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Output"))) (Void) '())) + (let world (Left! x)) + (let table7 (Right! x)) + (let values (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table7) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (return (Aggregate core '('"date" '"project_id" '"requester_id") '('('Sum8 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_count")))) '('Sum9 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_weight"))))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"date" (Member row '"date"))) + (let res (AddMember res '"requester_id" (Member row '"requester_id"))) + (let res (AddMember res '"project_id" (Member row '"project_id"))) + (let res (AddMember res '"gs_count" (Member row 'Sum8))) + (let res (AddMember res '"gs_weight" (Member row 'Sum9))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (return (Aggregate core '('"date" '"requester_id") '('('Sum11 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_count")))) '('Sum12 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_weight"))))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"date" (Member row '"date"))) + (let res (AddMember res '"requester_id" (Member row '"requester_id"))) + (let res (AddMember res '"gs_count" (Member row 'Sum11))) + (let res (AddMember res '"gs_weight" (Member row 'Sum12))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (return (Aggregate core '('"date") '('('Sum14 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_count")))) '('Sum15 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"gs_weight"))))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"date" (Member row '"date"))) + (let res (AddMember res '"gs_count" (Member row 'Sum14))) + (let res (AddMember res '"gs_weight" (Member row 'Sum15))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"Output3"))) values '('('mode 'renew)))) + (return world) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/SameTrait.cfg b/yql/essentials/tests/s-expressions/suites/Aggregation/SameTrait.cfg new file mode 100644 index 0000000000..ed61022bf8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/SameTrait.cfg @@ -0,0 +1,5 @@ +in Input input.txt +out Output output.txt +res result.txt +mount ..\mounts.txt +udf stat_udf diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/SameTrait.sql b/yql/essentials/tests/s-expressions/suites/Aggregation/SameTrait.sql new file mode 100644 index 0000000000..aaa89e48d5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/SameTrait.sql @@ -0,0 +1,17 @@ +USE plato; + +SELECT + key as key, + "a" || min(subkey || "q") as x1, + "b" || min(subkey || "q") as x2, + "c" || max(value) as x3, + "d" || max(value) as x4, + "1" || min(distinct subkey) as y1, + "2" || min(distinct subkey) as y2, + "3" || max(distinct value) as y3, + "4" || max(distinct value) as y4, + percentile(x, 0.5), + percentile(x, 0.9) +FROM (SELECT key, subkey, value, Length(key) as x from Input) +GROUP BY key +ORDER BY key;
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/SameTrait.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/SameTrait.yql new file mode 100644 index 0000000000..64ee248ed9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/SameTrait.yql @@ -0,0 +1,73 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key" '"subkey" '"value") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"subkey" (Member row '"subkey"))) + (let res (AddMember res '"value" (Member row '"value"))) + (let res (AddMember res '"x" ("Size" (Member row '"key")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (let percentile_x_create (lambda '(row) (MatchType (Member row '"x") 'Optional (lambda '(optValue) (FlatMap optValue (lambda '(value) (Just (Apply (Udf 'Stat.TDigest_Create) value))))) (lambda '(value) (Apply (Udf 'Stat.TDigest_Create) value))))) + (let percentile_x_update (lambda '(row state) (MatchType (Member row '"x") 'Optional (lambda '(optValue) (IfPresent state (lambda '(state) (IfPresent optValue (lambda '(value) (Just (Apply (Udf 'Stat.TDigest_AddValue) state value))) (Just state))) (FlatMap optValue (lambda '(value) (Just (Apply (Udf 'Stat.TDigest_Create) value)))))) (lambda '(value) (Apply (Udf 'Stat.TDigest_AddValue) state value))))) + (let percentile_x_save (lambda '(state) (MatchType state 'Optional (lambda '(optState) (Map optState (lambda '(currState) (Apply (Udf 'Stat.TDigest_Serialize) currState)))) (lambda '(currState) (Apply (Udf 'Stat.TDigest_Serialize) currState))))) + (let percentile_x_load (lambda '(item) (MatchType item 'Optional (lambda '(optData) (FlatMap optData (lambda '(data) (Just (Apply (Udf 'Stat.TDigest_Deserialize) data))))) (lambda '(data) (Apply (Udf 'Stat.TDigest_Deserialize) data))))) + (let percentile_x_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (Apply (Udf 'Stat.TDigest_Merge) a b))))) + (let percentile_x_finish (lambda '(state) (block '( + (let res (Struct)) + (let res (AddMember res 'Percentile9 (Apply (lambda '(state) (MatchType state 'Optional (lambda '(optData) (Map optData (lambda '(data) (Apply (Udf 'Stat.TDigest_GetPercentile) data (Double '0.5))))) (lambda '(data) (Apply (Udf 'Stat.TDigest_GetPercentile) data (Double '0.5))))) state))) + (let res (AddMember res 'Percentile10 (Apply (lambda '(state) (MatchType state 'Optional (lambda '(optData) (Map optData (lambda '(data) (Apply (Udf 'Stat.TDigest_GetPercentile) data (Double '0.9))))) (lambda '(data) (Apply (Udf 'Stat.TDigest_GetPercentile) data (Double '0.9))))) state))) + (return res) + )))) + (return (Aggregate core '('"key") '('('Min1 (Apply (bind aggregate_module '"min_traits_factory") (TypeOf core) (lambda '(row) ("Concat" (Member row '"subkey") (String '"q"))))) '('Min2 (Apply (bind aggregate_module '"min_traits_factory") (TypeOf core) (lambda '(row) ("Concat" (Member row '"subkey") (String '"q"))))) '('Max3 (Apply (bind aggregate_module '"max_traits_factory") (TypeOf core) (lambda '(row) (Member row '"value")))) '('Max4 (Apply (bind aggregate_module '"max_traits_factory") (TypeOf core) (lambda '(row) (Member row '"value")))) '('Min5 (Apply (bind aggregate_module '"min_traits_factory") (ListType (StructMemberType (ListItemType (TypeOf core)) '"subkey")) (lambda '(row) row)) '"subkey") '('Min6 (Apply (bind aggregate_module '"min_traits_factory") (ListType (StructMemberType (ListItemType (TypeOf core)) '"subkey")) (lambda '(row) row)) '"subkey") '('Max7 (Apply (bind aggregate_module '"max_traits_factory") (ListType (StructMemberType (ListItemType (TypeOf core)) '"value")) (lambda '(row) row)) '"value") '('Max8 (Apply (bind aggregate_module '"max_traits_factory") (ListType (StructMemberType (ListItemType (TypeOf core)) '"value")) (lambda '(row) row)) '"value") '('percentile_x (AggregationTraits (ListItemType (TypeOf core)) percentile_x_create percentile_x_update percentile_x_save percentile_x_load percentile_x_merge percentile_x_finish (Null)))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"x1" ("Concat" (String '"a") (Member row 'Min1)))) + (let res (AddMember res '"x2" ("Concat" (String '"b") (Member row 'Min2)))) + (let res (AddMember res '"x3" ("Concat" (String '"c") (Member row 'Max3)))) + (let res (AddMember res '"x4" ("Concat" (String '"d") (Member row 'Max4)))) + (let res (AddMember res '"y1" ("Concat" (String '"1") (Member row 'Min5)))) + (let res (AddMember res '"y2" ("Concat" (String '"2") (Member row 'Min6)))) + (let res (AddMember res '"y3" ("Concat" (String '"3") (Member row 'Max7)))) + (let res (AddMember res '"y4" ("Concat" (String '"4") (Member row 'Max8)))) + (let res (AddMember res '"column9" (Member (Member row '"percentile_x") 'Percentile9))) + (let res (AddMember res '"column10" (Member (Member row '"percentile_x") 'Percentile10))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (let select (Sort select (Bool 'true) (lambda '(row) (Member row '"key")))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"key" '"x1" '"x2" '"x3" '"x4" '"y1" '"y2" '"y3" '"y4" '"column9" '"column10"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/Traits.yql b/yql/essentials/tests/s-expressions/suites/Aggregation/Traits.yql new file mode 100644 index 0000000000..7a8c8845dc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/Traits.yql @@ -0,0 +1,17 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let init (lambda '(x) x)) +(let update (lambda '(x y) (+ x y))) +(let save (lambda '(x) x)) +(let load (lambda '(x) x)) +(let merge (lambda '(x y) (+ x y))) +(let finish (lambda '(x) x)) +(let sum (AggregationTraits (DataType 'Uint32) init update save load merge finish (Null))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf sum)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/default.cfg b/yql/essentials/tests/s-expressions/suites/Aggregation/default.cfg new file mode 100644 index 0000000000..fe2b19a9ff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/default.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/Aggregation/input.txt b/yql/essentials/tests/s-expressions/suites/Aggregation/input.txt new file mode 100644 index 0000000000..fc70ee2541 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/input.txt @@ -0,0 +1,7 @@ +{"key"="075";"subkey"="1";"value"="2"}; +{"key"="075";"subkey"="2";"value"="5"}; +{"key"="075";"subkey"="3";"value"="5"}; +{"key"="800";"subkey"="4";"value"="4"}; +{"key"="020";"subkey"="5";"value"="10"}; +{"key"="150";"subkey"="6";"value"="2"}; +{"key"="150";"subkey"="7";"value"="3"}; diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/input.txt.attr b/yql/essentials/tests/s-expressions/suites/Aggregation/input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/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/Aggregation/input1.txt b/yql/essentials/tests/s-expressions/suites/Aggregation/input1.txt new file mode 100644 index 0000000000..d1fa0973d9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/input1.txt @@ -0,0 +1,8 @@ +{"key"="075";"subkey"=".";"value"="abc"}; +{"key"="911";"subkey"=".";"value"="kkk"}; +{"key"="023";"subkey"=".";"value"="aaa"}; +{"key"="527";"subkey"=".";"value"="bbb"}; +{"key"="037";"subkey"=".";"value"="ddd"}; +{"key"="761";"subkey"=".";"value"="ccc"}; +{"key"="200";"subkey"=".";"value"="qqq"}; +{"key"="150";"subkey"=".";"value"="zzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/input1.txt.attr b/yql/essentials/tests/s-expressions/suites/Aggregation/input1.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/input1.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/Aggregation/input3.txt b/yql/essentials/tests/s-expressions/suites/Aggregation/input3.txt new file mode 100644 index 0000000000..6872d1e389 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/input3.txt @@ -0,0 +1,2 @@ +{"key"=1016143471372484394u}; +{"key"=1033900131482000140u}; diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/input3.txt.attr b/yql/essentials/tests/s-expressions/suites/Aggregation/input3.txt.attr new file mode 100644 index 0000000000..bdbbaad78d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/input3.txt.attr @@ -0,0 +1,10 @@ +{"_yql_row_spec"={ + "Type"=["StructType";[ + ["key";["DataType";"Uint64"]]; + ] + ]; + "SortDirections"=[1;]; + "SortedBy"=["key";]; + "SortedByTypes"=[["DataType";"Uint64";];]; + "SortMembers"=["key";]; +}} diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/many_columns.txt b/yql/essentials/tests/s-expressions/suites/Aggregation/many_columns.txt new file mode 100644 index 0000000000..c76c262542 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/many_columns.txt @@ -0,0 +1,10 @@ +{"assignment_assignment_id"=243u;"assignment_gs_count"=98u;"assignment_gs_weight"=89989u;"assignment_last_status_change_time"=43u;"project_id"=67u;"requester_id"=65u}; +{"assignment_assignment_id"=43u;"assignment_gs_count"=9u;"assignment_gs_weight"=8u;"assignment_last_status_change_time"=4563u;"project_id"=6897u;"requester_id"=765u}; +{"assignment_assignment_id"=25u;"assignment_gs_count"=678u;"assignment_gs_weight"=0u;"assignment_last_status_change_time"=45u;"project_id"=62u;"requester_id"=63u}; +{"assignment_assignment_id"=2563u;"assignment_gs_count"=98u;"assignment_gs_weight"=89989u;"assignment_last_status_change_time"=43u;"project_id"=67u;"requester_id"=65u}; +{"assignment_assignment_id"=233453u;"assignment_gs_count"=98u;"assignment_gs_weight"=89989u;"assignment_last_status_change_time"=43u;"project_id"=67u;"requester_id"=65u}; +{"assignment_assignment_id"=2456u;"assignment_gs_count"=978u;"assignment_gs_weight"=89u;"assignment_last_status_change_time"=403u;"project_id"=67u;"requester_id"=67u}; +{"assignment_assignment_id"=27643u;"assignment_gs_count"=9768u;"assignment_gs_weight"=86789u;"assignment_last_status_change_time"=49u;"project_id"=67u;"requester_id"=67u}; +{"assignment_assignment_id"=248u;"assignment_gs_count"=9768u;"assignment_gs_weight"=89989u;"assignment_last_status_change_time"=409u;"project_id"=67u;"requester_id"=625u}; +{"assignment_assignment_id"=248u;"assignment_gs_count"=9768u;"assignment_gs_weight"=89969u;"assignment_last_status_change_time"=4u;"project_id"=6347u;"requester_id"=65u}; +{"assignment_assignment_id"=24893u;"assignment_gs_count"=98u;"assignment_gs_weight"=8963989u;"assignment_last_status_change_time"=40u;"project_id"=6767u;"requester_id"=655u}; diff --git a/yql/essentials/tests/s-expressions/suites/Aggregation/many_columns.txt.attr b/yql/essentials/tests/s-expressions/suites/Aggregation/many_columns.txt.attr new file mode 100644 index 0000000000..54d58bb57d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Aggregation/many_columns.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"Type"=["StructType";[["assignment_assignment_id";["DataType";"Uint64"]];["assignment_last_status_change_time";["DataType";"Uint64"]];["requester_id";["DataType";"Uint64"]];["project_id";["DataType";"Uint64"]];["assignment_gs_count";["DataType";"Uint64"]];["assignment_gs_weight";["DataType";"Uint64"]]]]} +} 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 diff --git a/yql/essentials/tests/s-expressions/suites/Casts/AlterToEnormousList.yql b/yql/essentials/tests/s-expressions/suites/Casts/AlterToEnormousList.yql new file mode 100644 index 0000000000..95a0ec2555 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/AlterToEnormousList.yql @@ -0,0 +1,9 @@ +( +(let w (DataSink 'result)) +(let out '('('type) '('autoref) '('columns '('column0)))) +(let res (Write! world w (Key) (Unordered (EnsurePersistable (OrderedFlatMap (AsList (Uint32 '0)) (lambda '(stub) (block '( + (let $5 (AlterTo (ListFromRange (Minus (Int64 '1)) (Int64 '1000000000000)) (ListType (DataType 'Uint64)) (lambda '(x) x) (AsList (Uint64 '0)))) + (return (AsList (AsStruct '('"column0" $5)))) +)))))) out)) +(return (CommitAll! (Commit! res w))) +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverDataFloatTypes.yql b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverDataFloatTypes.yql new file mode 100644 index 0000000000..157a109a64 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverDataFloatTypes.yql @@ -0,0 +1,39 @@ +( + +(library "alterto.yql") +(import alterto_module '"alterto.yql") + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# Float -> Double (always success) +(let world (Apply (bind alterto_module 'doAlterTo) world (Float '"1.0") (DataType 'Double) (Double '"0.0"))) + +# Double -> Float (success) +(let world (Apply (bind alterto_module 'doAlterTo) world (Double '"2.0") (DataType 'Float) (Float '"123456.0"))) + +# Double -> Float (fail) +(let world (Apply (bind alterto_module 'doAlterTo) world (Double '"3.0000001") (DataType 'Float) (Float '"123456.0"))) + +# Float -> Integer (success) +(let world (Apply (bind alterto_module 'doAlterTo) world (Float '"3.0") (DataType 'Uint32) (Uint32 '123456))) + +# Float -> Integer (success) +(let world (Apply (bind alterto_module 'doAlterTo) world (Float '"-3.0") (DataType 'Int32) (Int32 '123456))) + +# Float -> Integer (fail) +(let world (Apply (bind alterto_module 'doAlterTo) world (Float '"3.3") (DataType 'Uint32) (Uint32 '123456))) + +# Float -> Integer (fail) +(let world (Apply (bind alterto_module 'doAlterTo) world (Float '"1e10") (DataType 'Uint32) (Uint32 '123456))) + +# Float -> Integer (fail) +(let world (Apply (bind alterto_module 'doAlterTo) world (Float '"-3.0") (DataType 'Uint32) (Uint32 '123456))) + +# Float -> Integer (fail) +(let inf (/ (Float '"1.0") (Int8 '0))) +(let world (Apply (bind alterto_module 'doAlterTo) world inf (DataType 'Int64) (Int64 '123456789))) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverDataIntegralTypes.yql b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverDataIntegralTypes.yql new file mode 100644 index 0000000000..746f8f987d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverDataIntegralTypes.yql @@ -0,0 +1,37 @@ +( + +(library "alterto.yql") +(import alterto_module '"alterto.yql") + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# Int32->Int16 +(let world (Apply (bind alterto_module 'doAlterTo) world (Int32 '10) (DataType 'Int16) (Int16 '100))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Int32 '32768) (DataType 'Int16) (Int16 '101))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Int32 '"-32769") (DataType 'Int16) (Int16 '102))) + +# Int64->Uint16 +(let world (Apply (bind alterto_module 'doAlterTo) world (Int64 '11) (DataType 'Uint16) (Uint16 '110))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Int64 '65536) (DataType 'Uint16) (Uint16 '111))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Int64 '"-1") (DataType 'Uint16) (Uint16 '112))) + +# Uint32->Int8 +(let world (Apply (bind alterto_module 'doAlterTo) world (Uint32 '12) (DataType 'Int8) (Int8 '120))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Uint32 '128) (DataType 'Int8) (Int8 '121))) + +# Uint64->Uint32 +(let world (Apply (bind alterto_module 'doAlterTo) world (Uint64 '13) (DataType 'Uint32) (Uint32 '130))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Uint64 '4294967296) (DataType 'Uint32) (Uint32 '131))) + +# Int64->Uint64 +(let world (Apply (bind alterto_module 'doAlterTo) world (Int64 '14) (DataType 'Uint64) (Uint64 '140))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Int64 '"-1") (DataType 'Uint64) (Uint64 '141))) + +# Int32->Uint32 +(let world (Apply (bind alterto_module 'doAlterTo) world (Int32 '15) (DataType 'Uint32) (Uint32 '150))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Int32 '"-1") (DataType 'Uint32) (Uint32 '151))) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverDataTypes.yql b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverDataTypes.yql new file mode 100644 index 0000000000..fd605370d2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverDataTypes.yql @@ -0,0 +1,35 @@ +( + +(library "alterto.yql") +(import alterto_module '"alterto.yql") + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# String->Utf8 +(let world (Apply (bind alterto_module 'doAlterTo) world (String 'OK) (DataType 'Utf8) (Utf8 'FAIL))) +(let world (Apply (bind alterto_module 'doAlterTo) world (String '"\xff\xfe") (DataType 'Utf8) (Utf8 'OK))) + +# TzDatetime->TzDate +# 2019-01-09T00:00:00,Europe/Moscow +(let world (Apply (bind alterto_module 'doAlterTo) world (TzDatetime '"1546981200,Europe/Moscow") (DataType 'TzDate) (TzDate '"1,GMT"))) +(let world (Apply (bind alterto_module 'doAlterTo) world (TzDatetime '"1546981201,Europe/Moscow") (DataType 'TzDate) (TzDate '"2,GMT"))) + +# TzTimestamp->Date +# 2019-01-09T00:00:00,GMT +(let world (Apply (bind alterto_module 'doAlterTo) world (TzTimestamp '"1546992000000000,GMT") (DataType 'Date) (Date '3))) +(let world (Apply (bind alterto_module 'doAlterTo) world (TzTimestamp '"1546992000000001,GMT") (DataType 'Date) (Date '4))) +# 2019-01-09T00:00:00,Europe/Moscow +(let world (Apply (bind alterto_module 'doAlterTo) world (TzTimestamp '"1546981200000000,Europe/Moscow") (DataType 'Date) (Date '5))) +# 2019-01-09T03:00:00,Europe/Moscow +(let world (Apply (bind alterto_module 'doAlterTo) world (TzTimestamp '"1546992000000000,Europe/Moscow") (DataType 'Date) (Date '6))) +(let world (Apply (bind alterto_module 'doAlterTo) world (TzTimestamp '"1546992000000001,Europe/Moscow") (DataType 'Date) (Date '7))) + +# Datetime->Date +# 2019-01-09T00:00:00Z +(let world (Apply (bind alterto_module 'doAlterTo) world (Datetime '"1546992000") (DataType 'Date) (Date '8))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Datetime '"1546992001") (DataType 'Date) (Date '9))) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverDict.yql b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverDict.yql new file mode 100644 index 0000000000..95377162e7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverDict.yql @@ -0,0 +1,21 @@ +( + +(library "alterto.yql") +(import alterto_module '"alterto.yql") + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# Dict<Int32, String> -> Dict<Int32, Utf8> +(let targetType (DictType (DataType 'Int32) (DataType 'Utf8))) +(let emptyTarget (Dict targetType)) +(let src (AsDict '((Int32 '1) (String 'one)) '((Int32 '2) (String 'two)) '((Int32 '3) (String 'three)))) +(let world (Apply (bind alterto_module 'doAlterTo) world src targetType emptyTarget)) + +# Dict<Int32, String> -> Dict<Int32, Utf8> (fail) +(let src (AsDict '((Int32 '1) (String 'one)) '((Int32 '2) (String '"\xff\xfe")) '((Int32 '3) (String 'three)))) +(let world (Apply (bind alterto_module 'doAlterTo) world src targetType emptyTarget)) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverList.yql b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverList.yql new file mode 100644 index 0000000000..6330d3262a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverList.yql @@ -0,0 +1,29 @@ +( + +(library "alterto.yql") +(import alterto_module '"alterto.yql") + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# List<Int32> -> List<Uint16> (success) +(let targetType (ListType (DataType 'Uint16))) +(let emptyTarget (List targetType)) +(let src (AsList (Int32 '1) (Int32 '2) (Int32 '3))) +(let world (Apply (bind alterto_module 'doAlterTo) world src targetType emptyTarget)) + +# List<Int32> -> List<Uint16> (fail) +(let targetType (ListType (DataType 'Uint16))) +(let emptyTarget (List targetType)) +(let src (AsList (Int32 '1) (Int32 '"-2") (Int32 '3))) +(let world (Apply (bind alterto_module 'doAlterTo) world src targetType emptyTarget)) + +# List<Int32?> -> List<Uint16> (fail) +(let targetType (ListType (DataType 'Uint16))) +(let emptyTarget (List targetType)) +(let src (AsList (Just (Int32 '1)) (Null) (Just (Int32 '3)))) +(let world (Apply (bind alterto_module 'doAlterTo) world src targetType emptyTarget)) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverNull.yql b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverNull.yql new file mode 100644 index 0000000000..6039cd0719 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverNull.yql @@ -0,0 +1,36 @@ +( + +(library "alterto.yql") +(import alterto_module '"alterto.yql") + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# Null -> Uint16? +(let targetType (OptionalType (DataType 'Uint16))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Null) targetType (Just (Uint16 '12345)))) + +# Just(Null) -> Null +(let alterToResult (AlterTo (Just (Null)) (NullType) (lambda '(x) (String 'OK)) (String 'FAIL))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) alterToResult '('('type)))) + +# Nothing(Null?) -> Null +(let alterToResult (AlterTo (Nothing (OptionalType (NullType))) (NullType) (lambda '(x) (String 'OK)) (String 'FAIL))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) alterToResult '('('type)))) + +# Nothing(Uint16?) -> Null +(let alterToResult (AlterTo (Nothing (OptionalType (DataType 'Uint16))) (NullType) (lambda '(x) (String 'OK)) (String 'FAIL))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) alterToResult '('('type)))) + +# Null -> Null? +(let alterToResult (AlterTo (Null) (OptionalType (NullType)) (lambda '(x) (String 'OK)) (String 'FAIL))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) alterToResult '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverOptional.yql b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverOptional.yql new file mode 100644 index 0000000000..9141b62154 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverOptional.yql @@ -0,0 +1,52 @@ +( + +(library "alterto.yql") +(import alterto_module '"alterto.yql") + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# Int32? -> Uint16 +(let world (Apply (bind alterto_module 'doAlterTo) world (Just (Int32 '1)) (DataType 'Uint16) (Uint16 '12345))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Just (Int32 '1000000)) (DataType 'Uint16) (Uint16 '12345))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Nothing (OptionalType (DataType 'Int32))) (DataType 'Uint16) (Uint16 '12345))) + +# Int32? -> Uint16? +(let targetType (OptionalType (DataType 'Uint16))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Just (Int32 '1)) targetType (Just (Uint16 '12345)))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Just (Int32 '1000000)) targetType (Just (Uint16 '12345)))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Nothing (OptionalType (DataType 'Int32))) targetType (Just (Uint16 '12345)))) + +# Int32? -> Uint16??? +(let targetType (OptionalType (OptionalType (OptionalType (DataType 'Uint16))))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Just (Int32 '1)) targetType (Just (Just (Just (Uint16 '12345)))))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Just (Int32 '1000000)) targetType (Just (Just (Just (Uint16 '12345)))))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Nothing (OptionalType (DataType 'Int32))) targetType (Just (Just (Just (Uint16 '12345)))))) + +# Int32??? -> Uint16? +(let targetType (OptionalType (DataType 'Uint16))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Just (Just (Just (Int32 '1)))) targetType (Just (Uint16 '12345)))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Just (Just (Just (Int32 '1000000)))) targetType (Just (Uint16 '12345)))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Nothing (OptionalType (OptionalType (OptionalType (DataType 'Int32))))) targetType (Just (Uint16 '12345)))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Just (Nothing (OptionalType (OptionalType (DataType 'Int32))))) targetType (Just (Uint16 '12345)))) +(let world (Apply (bind alterto_module 'doAlterTo) world (Just (Just (Nothing (OptionalType (DataType 'Int32))))) targetType (Just (Uint16 '12345)))) + +# Int32? -> Null +(let targetType (NullType)) +(let alterToResult (AlterTo (Just (Int32 '1)) targetType (lambda '(x) (String '"converted")) (String '"not converted"))) +(let world (Write! world res_sink (Key) alterToResult '('('type)))) +(let alterToResult (AlterTo (Nothing (OptionalType (DataType 'Int32))) targetType (lambda '(x) (String '"converted")) (String '"not converted"))) +(let world (Write! world res_sink (Key) alterToResult '('('type)))) + +# Int64? -> Null? +(let targetType (NullType)) +(let alterToResult (AlterTo (Just (Int64 '1)) targetType (lambda '(x) (String '"converted")) (String '"not converted"))) +(let world (Write! world res_sink (Key) alterToResult '('('type)))) +(let alterToResult (AlterTo (Nothing (OptionalType (DataType 'Int64))) targetType (lambda '(x) (String '"converted")) (String '"not converted"))) +(let world (Write! world res_sink (Key) alterToResult '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverStruct.yql b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverStruct.yql new file mode 100644 index 0000000000..6654166a27 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverStruct.yql @@ -0,0 +1,22 @@ +( + +(library "alterto.yql") +(import alterto_module '"alterto.yql") + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let targetType (StructType '('"a" (DataType 'Uint8)) '('"b" (DataType 'Utf8)))) +(let failValue (AsStruct '('a (Uint8 '0)) '('b (Utf8 '"not converted")))) + +# Struct<Int32, String> -> Struct<Uint8, Utf8> +(let value (AsStruct '('a (Int32 '1)) '('b (String 'one)))) +(let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue)) + +# Struct<Int32, String> -> Struct<Uint8, Utf8> (fail) +(let value (AsStruct '('a (Int32 '"-1")) '('b (String 'one)))) +(let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue)) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverTuple.yql b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverTuple.yql new file mode 100644 index 0000000000..3ad49c4744 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverTuple.yql @@ -0,0 +1,22 @@ +( + +(library "alterto.yql") +(import alterto_module '"alterto.yql") + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let targetType (TupleType (DataType 'Uint8) (DataType 'Utf8))) +(let failValue '((Uint8 '0) (Utf8 '"not converted"))) + +# (Int32, String) -> (Uint8, Utf8) +(let value '((Int32 '1) (String 'one))) +(let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue)) + +# (Int32, String) -> (Uint8, Utf8) (fail) +(let value '((Int32 '1) (String '"garbage\xff"))) +(let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue)) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverVariant.yql b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverVariant.yql new file mode 100644 index 0000000000..020cf59904 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/AlterToOverVariant.yql @@ -0,0 +1,38 @@ +( + +(library "alterto.yql") +(import alterto_module '"alterto.yql") + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +### Tuple + +(let srcType (VariantType (TupleType (DataType 'Int32) (DataType 'String)))) +(let targetType (VariantType (TupleType (DataType 'Uint8) (DataType 'Utf8)))) +(let failValue (Variant (Utf8 '"not converted") '1 targetType)) + +# Variant<Tuple<Int32, String>> -> Variant<Tuple<Uint8, Utf8>> +(let value (Variant (String 'one) '1 srcType)) +(let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue)) + +# Variant<Tuple<Int32, String>> -> Variant<Tuple<Uint8, Utf8>> (fail) +(let value (Variant (String '"garbage\xff") '1 srcType)) +(let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue)) + +### Struct +(let srcType (VariantType (StructType '('a (DataType 'Int32)) '('b (DataType 'String))))) +(let targetType (VariantType (StructType '('a (DataType 'Uint8)) '('b (DataType 'Utf8))))) +(let failValue (Variant (Uint8 '123) 'a targetType)) + +# Variant<Struct<Int32, String>> -> Variant<Struct<Uint8, Utf8>> +(let value (Variant (Int32 '1) 'a srcType)) +(let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue)) + +# Variant<Struct<Int32, String>> -> Variant<Struct<Uint8, Utf8>> (fail) +(let value (Variant (Int32 '"-1") 'a srcType)) +(let world (Apply (bind alterto_module 'doAlterTo) world value targetType failValue)) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/DoAlterTo.yql.txt b/yql/essentials/tests/s-expressions/suites/Casts/DoAlterTo.yql.txt new file mode 100644 index 0000000000..2278581ec9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/DoAlterTo.yql.txt @@ -0,0 +1,14 @@ +( + +(let doAlterTo (lambda '(world src targetType failValue) ( block '( + (let res_sink (DataSink 'result)) + (let identity (lambda '(x) x)) + (let alterToResult (AlterTo src targetType identity failValue)) + (let world (Write! world res_sink (Key) alterToResult '('('type)))) + (let world (Commit! world res_sink)) + (return world) +)))) + +(export doAlterTo) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/HasNullFalse.yql b/yql/essentials/tests/s-expressions/suites/Casts/HasNullFalse.yql new file mode 100644 index 0000000000..8f253ab7a0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/HasNullFalse.yql @@ -0,0 +1,57 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + + +# Data +(let value (String 'test)) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let value (Int32 '1)) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let value (TzDatetime '"1546981200,Europe/Moscow")) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let valye (/ (Float '1) (Float '0))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +# Optional +(let value (Just (Int32 '1))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +# Tuple +(let value '((Int32 '1) (String 'test) (Float '1))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let value '()) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +# Struct +(let value (AsStruct '('a (Int32 '1)) '('b (String 'one)))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let value (Struct)) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +# Variant +(let valueType (VariantType (TupleType (DataType 'Int32) (NullType)))) +(let value (Variant (Int32 '123) '0 valueType)) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let valueType (VariantType (StructType '('a (DataType 'Int32)) '('b (OptionalType (DataType 'String)))))) +(let value (Variant (Int32 '1) 'a valueType)) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +# List +(let value (AsList (Int32 '1) (Int32 '2) (Int32 '3))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let value (List (ListType (NullType)))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/HasNullTrue.yql b/yql/essentials/tests/s-expressions/suites/Casts/HasNullTrue.yql new file mode 100644 index 0000000000..a26295ffad --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/HasNullTrue.yql @@ -0,0 +1,54 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + + +# Optional +(let value (Nothing (OptionalType (DataType 'Int32)))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let value (Just (Nothing (OptionalType (DataType 'Int32))))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +# Null +(let value (Null)) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let value (Just (Null))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let value (Nothing (OptionalType (NullType)))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let value (Just (Nothing (OptionalType (NullType))))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +# Tuple +(let value '((Int32 '1) (String 'test) (Nothing (OptionalType (DataType 'Int32))))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +# Struct +(let value (AsStruct '('a (Int32 '1)) '('b (Just (Nothing (OptionalType (DataType 'Int32))))))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +# Variant +(let valueType (VariantType (TupleType (DataType 'Int32) (NullType)))) +(let value (Variant (Null) '1 valueType)) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let valueType (VariantType (StructType '('a (DataType 'Int32)) '('b (OptionalType (DataType 'String)))))) +(let value (Variant (Nothing (OptionalType (DataType 'String))) 'b valueType)) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +# List +(let value (AsList (Null) (Int32 '1) (Int32 '2))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let value (AsList (Int32 '1) (Int32 '2) (Null))) +(let world (Write! world res_sink (Key) (HasNull value) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverDict.yql b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverDict.yql new file mode 100644 index 0000000000..6dc4b237c5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverDict.yql @@ -0,0 +1,23 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# Dict<Int32, String> -> Dict<Uint8, Utf8> (full) +(let targetType (DictType (DataType 'Uint8) (DataType 'Utf8))) +(let src (AsDict '((Int32 '1) (String 'one)) '((Int32 '2) (String 'two)) '((Int32 '3) (String 'three)))) +(let cast (SafeCast src targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Dict<Int32, String> -> Dict<Int64, Utf8> (less) +(let targetType (DictType (DataType 'Int64) (DataType 'Utf8))) +(let src (AsDict '((Int32 '1) (String 'one)) '((Int32 '2) (String '"\xff\xfe")) '((Int32 '3) (String 'three)))) +(let cast (SafeCast src targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +(let world (Commit! world res_sink)) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverList.yql b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverList.yql new file mode 100644 index 0000000000..8f00b970d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverList.yql @@ -0,0 +1,30 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# List<Int32> -> List<Uint16> (full) +(let targetType (ListType (DataType 'Uint16))) +(let src (AsList (Int32 '1) (Int32 '2) (Int32 '3))) +(let cast (SafeCast src targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# List<Int32> -> List<Uint16> (less) +(let targetType (ListType (DataType 'Uint16))) +(let src (AsList (Int32 '1) (Int32 '-2) (Int32 '3))) +(let cast (SafeCast src targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# List<Int32?> -> List<Uint16> (less) +(let targetType (ListType (DataType 'Uint16))) +(let src (AsList (Just (Int32 '1)) (Null) (Just (Int32 '3)))) +(let cast (SafeCast src targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +(let world (Commit! world res_sink)) + +(return world) + +) + diff --git a/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverNull.yql b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverNull.yql new file mode 100644 index 0000000000..6044a39e4e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverNull.yql @@ -0,0 +1,38 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# Null -> Uint16 +(let cast (SafeCast (Null) (DataType 'Uint16))) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Null -> Uint16? +(let cast (SafeCast (Null) (OptionalType (DataType 'Uint16)))) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Just(Null) -> Null +(let cast (SafeCast (Just (Null)) (NullType))) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Nothing(Null?) -> Null +(let cast (SafeCast (Nothing (OptionalType (NullType))) (NullType))) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Uint16 -> Null +(let cast (SafeCast (Uint16 '0) (NullType))) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Nothing(Uint16?) -> Null +(let cast (SafeCast (Nothing (OptionalType (DataType 'Uint16))) (NullType))) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Null -> Null? +(let cast (SafeCast (Null) (OptionalType (NullType)))) +(let world (Write! world res_sink (Key) cast '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverOptional.yql b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverOptional.yql new file mode 100644 index 0000000000..c10d1243e9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverOptional.yql @@ -0,0 +1,76 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# Int32? -> Uint16 +(let targetType (OptionalType (DataType 'Uint16))) +(let cast (SafeCast (Just (Int32 '1)) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Just (Int32 '1000000)) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Nothing (OptionalType (DataType 'Int32))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Int32? -> Uint16? +(let targetType (OptionalType (DataType 'Uint16))) +(let cast (SafeCast (Just (Int32 '1)) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Just (Int32 '1000000)) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Nothing (OptionalType (DataType 'Int32))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Int32? -> Uint16??? +(let targetType (OptionalType (OptionalType (OptionalType (DataType 'Uint16))))) +(let cast (SafeCast (Just (Int32 '1)) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Just (Int32 '1000000)) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Nothing (OptionalType (DataType 'Int32))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Int32??? -> Uint16? +(let targetType (OptionalType (DataType 'Uint16))) +(let cast (SafeCast (Just (Just (Just (Int32 '1)))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Just (Just (Just (Int32 '1000000)))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Nothing (OptionalType (OptionalType (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Just (Nothing (OptionalType (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Just (Just (Nothing (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Int32??? -> Uint16?? +(let targetType (OptionalType (OptionalType (DataType 'Uint16)))) +(let cast (SafeCast (Just (Just (Just (Int32 '1)))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Just (Just (Just (Int32 '1000000)))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Nothing (OptionalType (OptionalType (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Just (Nothing (OptionalType (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Just (Just (Nothing (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Int32??? -> Uint16???? +(let targetType (OptionalType (OptionalType (OptionalType (OptionalType (DataType 'Uint16)))))) +(let cast (SafeCast (Just (Just (Just (Int32 '1)))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Just (Just (Just (Int32 '1000000)))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Nothing (OptionalType (OptionalType (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Just (Nothing (OptionalType (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (SafeCast (Just (Just (Nothing (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverResource.cfg b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverResource.cfg new file mode 100644 index 0000000000..ec2b802773 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverResource.cfg @@ -0,0 +1,2 @@ +res result.txt +udf yson2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverResource.yql b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverResource.yql new file mode 100644 index 0000000000..11fd9ebc30 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverResource.yql @@ -0,0 +1,22 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + + +(let yson1 (Apply (Udf '"Yson2.Parse") (String '"#") (Just (NamedApply (Udf 'Yson2.Options) '() (AsStruct '('"AutoConvert" (Just (Bool '"false"))) '('"Strict" (Just (Bool '"false")))))))) +(let yson2 (Apply (Udf '"Yson2.Parse") (String '"[]") (Just (NamedApply (Udf 'Yson2.Options) '() (AsStruct '('"AutoConvert" (Just (Bool '"false"))) '('"Strict" (Just (Bool '"false")))))))) + + +(let targetType (ListType (ResourceType 'Yson2.Node))) +(let src (AsList (Just yson1) (Just yson2))) +(let cast (SafeCast src targetType)) +(let world (Write! world res_sink (Key) (Map cast (lambda '(item) (Apply (Udf '"Yson2.Serialize") item))) '('('type)))) + +(let world (Commit! world res_sink)) + +(return world) + +) + diff --git a/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverStream.yql b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverStream.yql new file mode 100644 index 0000000000..1ac4fd613e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverStream.yql @@ -0,0 +1,30 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# Stream<Int32> -> Stream<Uint16> (full) +(let targetType (StreamType (DataType 'Uint16))) +(let src (Iterator (AsList (Int32 '1) (Int32 '2) (Int32 '3)))) +(let cast (SafeCast src targetType)) +(let world (Write! world res_sink (Key) (Collect cast) '('('type)))) + +# Stream<Int32> -> Stream<Uint16> (less) +(let targetType (StreamType (DataType 'Uint16))) +(let src (Iterator (AsList (Int32 '1) (Int32 '-2) (Int32 '3)))) +(let cast (SafeCast src targetType)) +(let world (Write! world res_sink (Key) (Collect cast) '('('type)))) + +# Stream<Int32?> -> Stream<Uint16> (less) +(let targetType (StreamType (DataType 'Uint16))) +(let src (Iterator (AsList (Just (Int32 '1)) (Null) (Just (Int32 '3))))) +(let cast (SafeCast src targetType)) +(let world (Write! world res_sink (Key) (Collect cast) '('('type)))) + +(let world (Commit! world res_sink)) + +(return world) + +) + diff --git a/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverStruct.yql b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverStruct.yql new file mode 100644 index 0000000000..94bc8b7842 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverStruct.yql @@ -0,0 +1,23 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# Struct<Int32, String, Utf8> -> Struct<Uint8?, Utf8?> +(let targetType (StructType '('a (OptionalType (DataType 'Uint8))) '('b (OptionalType (DataType 'Utf8))))) +(let value (AsStruct '('a (Int32 '1)) '('b (String 'one)) '('c (Utf8 'two)))) +(let cast (SafeCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Struct<Int32, String> -> Struct<Int8, Utf8, Float?>? +(let targetType (StructType '('a (DataType 'Int8)) '('b (DataType 'Utf8)) '('c (OptionalType (DataType 'Float))))) +(let value (AsStruct '('a (Int32 '-1)) '('b (String 'one)))) +(let cast (SafeCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +(let world (Commit! world res_sink)) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverTuple.yql b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverTuple.yql new file mode 100644 index 0000000000..33421380cb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverTuple.yql @@ -0,0 +1,39 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let targetType (TupleType (DataType 'Uint8) (DataType 'Utf8))) + +# (Int32, String) -> (Uint8, Utf8) [good] +(let value '((Int32 '1) (String 'one))) +(let cast (SafeCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# (Int32, String) -> (Uint8, Utf8)? [null] +(let value '((Int32 '1) (String '"garbage\xff"))) +(let cast (SafeCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# (Int32?, String???) -> (Uint8??, Utf8?)? [good] +(let targetType (TupleType (OptionalType (OptionalType (DataType 'Uint8))) (OptionalType (DataType 'Utf8)))) +(let value '((Just (Int32 '1)) (Just (Nothing (OptionalType (DataType 'String)))))) +(let cast (SafeCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# (Int32?, String???) -> (Uint8??, Utf8?)? [null] +(let value '((Just (Int32 '1)) (Nothing (OptionalType (OptionalType (DataType 'String)))))) +(let cast (SafeCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# (Int32?, String???) -> (Uint8??, Utf8?)? [null] +(let value '((Just (Int32 '-1)) (Just (Nothing (OptionalType (DataType 'String)))))) +(let cast (SafeCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +(let world (Commit! world res_sink)) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverVariant.yql b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverVariant.yql new file mode 100644 index 0000000000..ea34cbd481 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/SafeCastOverVariant.yql @@ -0,0 +1,39 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +### Tuple +(let srcType (VariantType (TupleType (DataType 'Int32) (DataType 'String)))) +(let targetType (VariantType (TupleType (DataType 'Uint8) (DataType 'Utf8)))) + +# Variant<Tuple<Int32, String>> -> Variant<Tuple<Uint8, Utf8>>? (good) +(let value (Variant (String 'one) '1 srcType)) +(let cast (SafeCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Variant<Tuple<Int32, String>> -> Variant<Tuple<Uint8, Utf8>>? (null) +(let value (Variant (String '"garbage\xff") '1 srcType)) +(let cast (SafeCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +### Struct +(let srcType (VariantType (StructType '('a (DataType 'Int32)) '('b (DataType 'String))))) +(let targetType (VariantType (StructType '('a (DataType 'Uint8)) '('b (DataType 'Utf8))))) + +# Variant<Struct<Int32, String>> -> Variant<Struct<Uint8, Utf8>>? (good) +(let value (Variant (Int32 '1) 'a srcType)) +(let cast (SafeCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Variant<Struct<Int32, String>> -> Variant<Struct<Uint8, Utf8>>? (null) +(let value (Variant (Int32 '"-1") 'a srcType)) +(let cast (SafeCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +(let world (Commit! world res_sink)) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverDict.yql b/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverDict.yql new file mode 100644 index 0000000000..ee7aa8e401 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverDict.yql @@ -0,0 +1,23 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# Dict<Int32, String> -> Dict<Uint8, Utf8> (good) +(let targetType (DictType (DataType 'Uint8) (DataType 'Utf8))) +(let src (AsDict '((Int32 '1) (String 'one)) '((Int32 '2) (String 'two)) '((Int32 '3) (String 'three)))) +(let cast (StrictCast src targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Dict<Int32, String> -> Dict<Int64, Utf8> (fail) +(let targetType (DictType (DataType 'Int64) (DataType 'Utf8))) +(let src (AsDict '((Int32 '1) (String 'one)) '((Int32 '2) (String '"\xff\xfe")) '((Int32 '3) (String 'three)))) +(let cast (StrictCast src targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +(let world (Commit! world res_sink)) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverList.yql b/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverList.yql new file mode 100644 index 0000000000..146ed0dbe9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverList.yql @@ -0,0 +1,30 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# List<Int32> -> List<Uint16> (good) +(let targetType (ListType (DataType 'Uint16))) +(let src (AsList (Int32 '1) (Int32 '2) (Int32 '3))) +(let cast (StrictCast src targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# List<Int32> -> List<Uint16> (fail) +(let targetType (ListType (DataType 'Uint16))) +(let src (AsList (Int32 '1) (Int32 '-2) (Int32 '3))) +(let cast (StrictCast src targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# List<Int32?> -> List<Uint16> (fail) +(let targetType (ListType (DataType 'Uint16))) +(let src (AsList (Just (Int32 '1)) (Null) (Just (Int32 '3)))) +(let cast (StrictCast src targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +(let world (Commit! world res_sink)) + +(return world) + +) + diff --git a/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverNull.yql b/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverNull.yql new file mode 100644 index 0000000000..d7c66842b0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverNull.yql @@ -0,0 +1,30 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# Null -> Uint16? +(let cast (StrictCast (Null) (OptionalType (DataType 'Uint16)))) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Just(Null) -> Null? [good] +(let cast (StrictCast (Just (Null)) (NullType))) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Nothing(Null?) -> Null? [fail] +(let cast (StrictCast (Nothing (OptionalType (NullType))) (NullType))) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Nothing(Uint16?) -> Null +(let cast (StrictCast (Nothing (OptionalType (DataType 'Uint16))) (NullType))) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Null -> Null? +(let cast (StrictCast (Null) (OptionalType (NullType)))) +(let world (Write! world res_sink (Key) cast '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverOptional.yql b/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverOptional.yql new file mode 100644 index 0000000000..28cf793e44 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverOptional.yql @@ -0,0 +1,76 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# Int32? -> Uint16 +(let targetType (OptionalType (DataType 'Uint16))) +(let cast (StrictCast (Just (Int32 '1)) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Just (Int32 '1000000)) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Nothing (OptionalType (DataType 'Int32))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Int32? -> Uint16? +(let targetType (OptionalType (DataType 'Uint16))) +(let cast (StrictCast (Just (Int32 '1)) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Just (Int32 '1000000)) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Nothing (OptionalType (DataType 'Int32))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Int32? -> Uint16??? +(let targetType (OptionalType (OptionalType (OptionalType (DataType 'Uint16))))) +(let cast (StrictCast (Just (Int32 '1)) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Just (Int32 '1000000)) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Nothing (OptionalType (DataType 'Int32))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Int32??? -> Uint16? +(let targetType (OptionalType (DataType 'Uint16))) +(let cast (StrictCast (Just (Just (Just (Int32 '1)))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Just (Just (Just (Int32 '1000000)))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Nothing (OptionalType (OptionalType (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Just (Nothing (OptionalType (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Just (Just (Nothing (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Int32??? -> Uint16?? +(let targetType (OptionalType (OptionalType (DataType 'Uint16)))) +(let cast (StrictCast (Just (Just (Just (Int32 '1)))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Just (Just (Just (Int32 '1000000)))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Nothing (OptionalType (OptionalType (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Just (Nothing (OptionalType (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Just (Just (Nothing (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Int32??? -> Uint16???? +(let targetType (OptionalType (OptionalType (OptionalType (OptionalType (DataType 'Uint16)))))) +(let cast (StrictCast (Just (Just (Just (Int32 '1)))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Just (Just (Just (Int32 '1000000)))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Nothing (OptionalType (OptionalType (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Just (Nothing (OptionalType (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) +(let cast (StrictCast (Just (Just (Nothing (OptionalType (DataType 'Int32))))) targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverStruct.yql b/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverStruct.yql new file mode 100644 index 0000000000..afa021dd11 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverStruct.yql @@ -0,0 +1,23 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# Struct<Int32, String, Utf8?> -> Struct<Uint8?, Utf8?> (good) +(let targetType (StructType '('a (OptionalType (DataType 'Uint8))) '('b (OptionalType (DataType 'Utf8))))) +(let value (AsStruct '('a (Int32 '1)) '('b (String 'one)) '('c (Nothing (OptionalType (DataType 'Utf8)))))) +(let cast (StrictCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Struct<Int32, String, String?> -> Struct<Int8, Utf8, Float?>? (fail) +(let targetType (StructType '('a (DataType 'Int8)) '('b (DataType 'Utf8)) '('c (OptionalType (DataType 'Float))))) +(let value (AsStruct '('a (Int32 '-1)) '('b (String 'one)) '('d (Just (String 'one))))) +(let cast (StrictCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +(let world (Commit! world res_sink)) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverTuple.yql b/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverTuple.yql new file mode 100644 index 0000000000..4f2319f1ea --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverTuple.yql @@ -0,0 +1,39 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let targetType (TupleType (DataType 'Uint8) (DataType 'Utf8))) + +# (Int32, String) -> (Uint8, Utf8) [good] +(let value '((Int32 '1) (String 'one))) +(let cast (StrictCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# (Int32, String) -> (Uint8, Utf8)? [null] +(let value '((Int32 '1) (String '"garbage\xff"))) +(let cast (StrictCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# (Int32?, String???) -> (Uint8??, Utf8?)? [good] +(let targetType (TupleType (OptionalType (OptionalType (DataType 'Uint8))) (OptionalType (DataType 'Utf8)))) +(let value '((Just (Int32 '1)) (Just (Nothing (OptionalType (DataType 'String)))))) +(let cast (StrictCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# (Int32?, String???) -> (Uint8??, Utf8?)? [fail] +(let value '((Just (Int32 '1)) (Nothing (OptionalType (OptionalType (DataType 'String)))))) +(let cast (StrictCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# (Int32?, String???) -> (Uint8??, Utf8?)? [fail] +(let value '((Just (Int32 '-1)) (Just (Nothing (OptionalType (DataType 'String)))))) +(let cast (StrictCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +(let world (Commit! world res_sink)) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverVariant.yql b/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverVariant.yql new file mode 100644 index 0000000000..b533e16780 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/StrictCastOverVariant.yql @@ -0,0 +1,39 @@ +( + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +### Tuple +(let srcType (VariantType (TupleType (DataType 'Int32) (DataType 'String)))) +(let targetType (VariantType (TupleType (DataType 'Uint8) (DataType 'Utf8)))) + +# Variant<Tuple<Int32, String>> -> Variant<Tuple<Uint8, Utf8>>? (good) +(let value (Variant (String 'one) '1 srcType)) +(let cast (StrictCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Variant<Tuple<Int32, String>> -> Variant<Tuple<Uint8, Utf8>>? (null) +(let value (Variant (String '"garbage\xff") '1 srcType)) +(let cast (StrictCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +### Struct +(let srcType (VariantType (StructType '('a (DataType 'Int32)) '('b (DataType 'String))))) +(let targetType (VariantType (StructType '('a (DataType 'Uint8)) '('b (DataType 'Utf8))))) + +# Variant<Struct<Int32, String>> -> Variant<Struct<Uint8, Utf8>>? (good) +(let value (Variant (Int32 '1) 'a srcType)) +(let cast (StrictCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +# Variant<Struct<Int32, String>> -> Variant<Struct<Uint8, Utf8>>? (null) +(let value (Variant (Int32 '"-1") 'a srcType)) +(let cast (StrictCast value targetType)) +(let world (Write! world res_sink (Key) cast '('('type)))) + +(let world (Commit! world res_sink)) + +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/TryRemoveAllOptionals.yql b/yql/essentials/tests/s-expressions/suites/Casts/TryRemoveAllOptionals.yql new file mode 100644 index 0000000000..1bc57c71bf --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/TryRemoveAllOptionals.yql @@ -0,0 +1,55 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +### Tuple + +# (Int8?, String?, (Int32, Int64)?) (success) +(let value '((Just (Int8 '1)) (Just (String 'str)) (Just '((Int32 '2) (Int64 '3))))) +(let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value)) +(let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type)))) + +# (Int8?, String, (Int32, Int64)?) (success) +(let value '((Just (Int8 '1)) (String 'str) (Just '((Int32 '2) (Int64 '3))))) +(let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value)) +(let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type)))) + +# (Int8?, Nothing(String?), (Int32, Int64)?) (fail) +(let value '((Just (Int8 '1)) (Nothing (OptionalType (DataType 'String))) (Just '((Int32 '2) (Int64 '3))))) +(let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value)) +(let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type)))) + +# () (success) +(let value '()) +(let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value)) +(let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type)))) + + +### Struct + +# Struct<Int8?, String?, (Int32, Int64)?> (success) +(let value (AsStruct '('a (Just (Int8 '1))) '('b (Just (String 'str))) '('c (Just '((Int32 '2) (Int64 '3)))))) +(let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value)) +(let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type)))) + +# Struct<Int8?, String, (Int32, Int64)?> (success) +(let value (AsStruct '('a (Just (Int8 '1))) '('b (String 'str)) '('c (Just '((Int32 '2) (Int64 '3)))))) +(let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value)) +(let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type)))) + +# Struct<Int8?, Nothing(String?), (Int32, Int64)?> (fail) +(let value (AsStruct '('a (Just (Int8 '1))) '('b (Nothing (OptionalType (DataType 'String)))) '('c (Just '((Int32 '2) (Int64 '3)))))) +(let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value)) +(let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type)))) + +# Struct<> (success) +(let value (Struct)) +(let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value)) +(let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/TryRemoveAllOptionals2.yql b/yql/essentials/tests/s-expressions/suites/Casts/TryRemoveAllOptionals2.yql new file mode 100644 index 0000000000..0649383205 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/TryRemoveAllOptionals2.yql @@ -0,0 +1,24 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +### Tuple + +# (Int8?, String, (Int32, Int64)?, Just(Nothing(String?)) (success) +(let value '((Just (Int8 '1)) (String 'str) (Just '((Int32 '2) (Int64 '3))) (Just (Nothing (OptionalType (DataType 'String)))))) +(let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value)) +(let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type)))) + +### Struct + +# Struct<Int8?, String, (Int32, Int64)?> (success) +(let value (AsStruct '('a (Just (Int8 '1))) '('b (String 'str)) '('c (Just '((Int32 '2) (Int64 '3)))) '('d (Just (Nothing (OptionalType (DataType 'String))))))) +(let tryRemoveAllOptionalsResult (TryRemoveAllOptionals value)) +(let world (Write! world res_sink (Key) tryRemoveAllOptionalsResult '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Casts/default.cfg b/yql/essentials/tests/s-expressions/suites/Casts/default.cfg new file mode 100644 index 0000000000..baa119f7c7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Casts/default.cfg @@ -0,0 +1,2 @@ +res result.txt +file alterto.yql DoAlterTo.yql.txt diff --git a/yql/essentials/tests/s-expressions/suites/Config/DataSinks.yql b/yql/essentials/tests/s-expressions/suites/Config/DataSinks.yql new file mode 100644 index 0000000000..b1a80a5660 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Config/DataSinks.yql @@ -0,0 +1,11 @@ +( +#comment +(let config (DataSource 'config)) +(let x (Read! world config (Key '('data_sinks)) '() '())) +(let world (Left! x)) +(let data (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Config/DataSources.yql b/yql/essentials/tests/s-expressions/suites/Config/DataSources.yql new file mode 100644 index 0000000000..0621a7e016 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Config/DataSources.yql @@ -0,0 +1,11 @@ +( +#comment +(let config (DataSource 'config)) +(let x (Read! world config (Key '('data_sources)) '() '())) +(let world (Left! x)) +(let data (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Config/PureCommit.cfg b/yql/essentials/tests/s-expressions/suites/Config/PureCommit.cfg new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Config/PureCommit.cfg diff --git a/yql/essentials/tests/s-expressions/suites/Config/PureCommit.yql b/yql/essentials/tests/s-expressions/suites/Config/PureCommit.yql new file mode 100644 index 0000000000..8578faff3c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Config/PureCommit.yql @@ -0,0 +1,5 @@ +( +#comment +(let world (Commit! world (DataSink 'yt 'plato))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Config/YtNativeRes.cfg b/yql/essentials/tests/s-expressions/suites/Config/YtNativeRes.cfg new file mode 100644 index 0000000000..00dec6c3f8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Config/YtNativeRes.cfg @@ -0,0 +1 @@ +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Config/YtNativeRes.yql b/yql/essentials/tests/s-expressions/suites/Config/YtNativeRes.yql new file mode 100644 index 0000000000..606e06e0e4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Config/YtNativeRes.yql @@ -0,0 +1,6 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Config/default.cfg b/yql/essentials/tests/s-expressions/suites/Config/default.cfg new file mode 100644 index 0000000000..00dec6c3f8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Config/default.cfg @@ -0,0 +1 @@ +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Dynamic/Copy.yql b/yql/essentials/tests/s-expressions/suites/Dynamic/Copy.yql new file mode 100644 index 0000000000..9b7882d255 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Dynamic/Copy.yql @@ -0,0 +1,13 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input1"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'renew)))) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Dynamic/Limit.yql b/yql/essentials/tests/s-expressions/suites/Dynamic/Limit.yql new file mode 100644 index 0000000000..c7190c8f88 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Dynamic/Limit.yql @@ -0,0 +1,15 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input1"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let input (Take input (Int32 '"3"))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Unordered input) '('('type)))) +(let world (Commit! world res_sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Dynamic/TablePull.yql b/yql/essentials/tests/s-expressions/suites/Dynamic/TablePull.yql new file mode 100644 index 0000000000..4ba424cb1e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Dynamic/TablePull.yql @@ -0,0 +1,16 @@ +( +(let mr_source (DataSource 'yt 'plato)) + +(let x (Read! world mr_source + (Key '('table (String 'Input1))) + (Void) '() +)) + +(let world (Left! x)) +(let data (Right! x)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Dynamic/TableScheme.yql b/yql/essentials/tests/s-expressions/suites/Dynamic/TableScheme.yql new file mode 100644 index 0000000000..b10df583ba --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Dynamic/TableScheme.yql @@ -0,0 +1,16 @@ +( +(let mr_source (DataSource 'yt 'plato)) + +(let x (Read! world mr_source + (Key '('tablescheme (String 'Input1))) + (Void) '() +)) + +(let world (Left! x)) +(let scheme (Right! x)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) scheme '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Dynamic/default.cfg b/yql/essentials/tests/s-expressions/suites/Dynamic/default.cfg new file mode 100644 index 0000000000..64df516e6f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Dynamic/default.cfg @@ -0,0 +1,3 @@ +in Input1 input1.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Dynamic/input1.txt b/yql/essentials/tests/s-expressions/suites/Dynamic/input1.txt new file mode 100644 index 0000000000..c2f900fd7c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Dynamic/input1.txt @@ -0,0 +1,7 @@ +{"key"="020";"subkey"="1";"value"="q"}; +{"key"="075";"subkey"="2";"value"="abc"}; +{"key"="075";"subkey"="3";"value"="abc"}; +{"key"="075";"subkey"="4";"value"="abc"}; +{"key"="075";"subkey"="5";"value"="abc"}; +{"key"="150";"subkey"="6";"value"="qzz"}; +{"key"="800";"subkey"="7";"value"="ddd"}; diff --git a/yql/essentials/tests/s-expressions/suites/Dynamic/input1.txt.attr b/yql/essentials/tests/s-expressions/suites/Dynamic/input1.txt.attr new file mode 100644 index 0000000000..9e3c33c4cb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Dynamic/input1.txt.attr @@ -0,0 +1,33 @@ +{ + "_yql_row_spec"={ + "Type"=["StructType";[ + ["key"; ["DataType"; "String"]]; + ["subkey"; ["DataType"; "String"]]; + ["value"; ["DataType"; "String"]]; + ]]; + "SortMembers"=["key"; "subkey"]; + "SortedBy"=["key"; "subkey"]; + "SortDirections"=[1; 1]; + "SortedByTypes"=[["DataType";"String"]; ["DataType";"String"]] + }; + "_yql_dynamic"=%true; + "schema"=< + "strict" = %true; + "unique_keys" = %true + >[ + { + "name" = "key"; + "type" = "string"; + "sort_order" = "ascending"; + }; + { + "name" = "subkey"; + "type" = "string"; + "sort_order" = "ascending"; + }; + { + "name" = "value"; + "type" = "string"; + }; + ] +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendAfterOverride.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/AppendAfterOverride.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendAfterOverride.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendAfterOverride.yql b/yql/essentials/tests/s-expressions/suites/Epochs/AppendAfterOverride.yql new file mode 100644 index 0000000000..00d991912a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendAfterOverride.yql @@ -0,0 +1,18 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'renew)))) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'append)))) + +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySorted.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySorted.cfg new file mode 100644 index 0000000000..48cd4555f7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySorted.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output non_empty.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySorted.yql b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySorted.yql new file mode 100644 index 0000000000..65db044c0d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySorted.yql @@ -0,0 +1,13 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedAfterCommit.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedAfterCommit.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedAfterCommit.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedAfterCommit.yql b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedAfterCommit.yql new file mode 100644 index 0000000000..b51c4e8418 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedAfterCommit.yql @@ -0,0 +1,21 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedDesc.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedDesc.cfg new file mode 100644 index 0000000000..48cd4555f7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedDesc.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output non_empty.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedDesc.yql b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedDesc.yql new file mode 100644 index 0000000000..46099b0328 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedDesc.yql @@ -0,0 +1,13 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'false) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedDescAfterCommit.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedDescAfterCommit.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedDescAfterCommit.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedDescAfterCommit.yql b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedDescAfterCommit.yql new file mode 100644 index 0000000000..587bc78b08 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedDescAfterCommit.yql @@ -0,0 +1,21 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'false) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedInSameCommit.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedInSameCommit.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedInSameCommit.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedInSameCommit.yql b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedInSameCommit.yql new file mode 100644 index 0000000000..e9a055f5d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendBySortedInSameCommit.yql @@ -0,0 +1,19 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'append)))) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) + +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSorted.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSorted.cfg new file mode 100644 index 0000000000..bffc8451cc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSorted.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output sorted.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSorted.yql b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSorted.yql new file mode 100644 index 0000000000..6b7ac4b175 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSorted.yql @@ -0,0 +1,12 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'append)))) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedAfterCommit.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedAfterCommit.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedAfterCommit.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedAfterCommit.yql b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedAfterCommit.yql new file mode 100644 index 0000000000..4aa7916884 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedAfterCommit.yql @@ -0,0 +1,21 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'append)))) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedBySorted.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedBySorted.cfg new file mode 100644 index 0000000000..bffc8451cc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedBySorted.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output sorted.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedBySorted.yql b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedBySorted.yql new file mode 100644 index 0000000000..65db044c0d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedBySorted.yql @@ -0,0 +1,13 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedBySortedAfterCommit.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedBySortedAfterCommit.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedBySortedAfterCommit.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedBySortedAfterCommit.yql b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedBySortedAfterCommit.yql new file mode 100644 index 0000000000..37fb7a1e86 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedBySortedAfterCommit.yql @@ -0,0 +1,22 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedInSameCommit.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedInSameCommit.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedInSameCommit.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedInSameCommit.yql b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedInSameCommit.yql new file mode 100644 index 0000000000..1b314c3f2e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/AppendToSortedInSameCommit.yql @@ -0,0 +1,19 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'append)))) + +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/Bug2318.yql b/yql/essentials/tests/s-expressions/suites/Epochs/Bug2318.yql new file mode 100644 index 0000000000..5734271142 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/Bug2318.yql @@ -0,0 +1,26 @@ +#USE plato; +#INSERT INTO Output WITH TRUNCATE SELECT key FROM Input; +#COMMIT; +#INSERT INTO Output WITH TRUNCATE SELECT key FROM CONCAT(Input, Output); + +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let read (Read! world source (MrTableConcat (Key '('table (String '"Input")))) '('"key") '())) +(let world (Left! read)) +(let input (Right! read)) +(let output (FlatMap input (lambda '(item) (AsList (AsStruct '('"key" (Member item '"key"))))))) +(let world (Write! world sink (Key '('table (String '"Output"))) output '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let read (Read! world source (MrTableConcat (Key '('table (String '"Input"))) (Key '('table (String '"Output")))) '('"key") '())) +(let world (Left! read)) +(let input (Right! read)) +(let output (FlatMap input (lambda '(item) (AsList (AsStruct '('"key" (Member item '"key"))))))) +(let world (Write! world sink (Key '('table (String '"Output"))) output '('('mode 'renew)))) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/CopySorted.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/CopySorted.cfg new file mode 100644 index 0000000000..66737248b8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/CopySorted.cfg @@ -0,0 +1,2 @@ +in Input sorted.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/CopySorted.yql b/yql/essentials/tests/s-expressions/suites/Epochs/CopySorted.yql new file mode 100644 index 0000000000..110b23d6ed --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/CopySorted.yql @@ -0,0 +1,31 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String 'Output))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"key")) + (let res (Coalesce (> key (String '"020")) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/DoubleAppend.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/DoubleAppend.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/DoubleAppend.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/DoubleAppend.yql b/yql/essentials/tests/s-expressions/suites/Epochs/DoubleAppend.yql new file mode 100644 index 0000000000..c834415dd1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/DoubleAppend.yql @@ -0,0 +1,18 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'append)))) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'append)))) + +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/DoubleAppendBySorted.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/DoubleAppendBySorted.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/DoubleAppendBySorted.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/DoubleAppendBySorted.yql b/yql/essentials/tests/s-expressions/suites/Epochs/DoubleAppendBySorted.yql new file mode 100644 index 0000000000..5803f92df9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/DoubleAppendBySorted.yql @@ -0,0 +1,20 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) + +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/DropTable.yql b/yql/essentials/tests/s-expressions/suites/Epochs/DropTable.yql new file mode 100644 index 0000000000..ab423f96a3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/DropTable.yql @@ -0,0 +1,45 @@ +#USE plato; +#INSERT INTO Output SELECT CAST(key as Int32) as item1, value as item2 FROM Input; +#COMMIT; +#DROP TABLE Output; +#COMMIT; +#INSERT INTO Output SELECT CAST(key as Int32) as item3, value as item4 FROM Input; + +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let conv1 (lambda '(item) (block '( + (let res (Struct)) + (let res (AddMember res '"item1" (Cast (Member item '"key") 'Int32))) + (let res (AddMember res '"item2" (Member item '"value"))) + (return (AsList res)) +)))) + +(let conv2 (lambda '(item) (block '( + (let res (Struct)) + (let res (AddMember res '"item3" (Cast (Member item '"key") 'Int32))) + (let res (AddMember res '"item4" (Member item '"value"))) + (return (AsList res)) +)))) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let out (FlatMap input conv1)) +(let world (Write! world sink (Key '('table (String 'Output))) out '('('mode 'append)))) +(let world (Commit! world sink)) + +(let world (Write! world sink (Key '('table (String 'Output))) (Void) '('('mode 'drop)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let out (FlatMap input conv2)) +(let world (Write! world sink (Key '('table (String 'Output))) out '('('mode 'append)))) + +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/FailDoubleOverride.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/FailDoubleOverride.cfg new file mode 100644 index 0000000000..a26fadcaa7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/FailDoubleOverride.cfg @@ -0,0 +1,3 @@ +xfail +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/FailDoubleOverride.yql b/yql/essentials/tests/s-expressions/suites/Epochs/FailDoubleOverride.yql new file mode 100644 index 0000000000..513c160992 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/FailDoubleOverride.yql @@ -0,0 +1,18 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'renew)))) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'renew)))) + +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/FailDropAndModify1.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/FailDropAndModify1.cfg new file mode 100644 index 0000000000..a26fadcaa7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/FailDropAndModify1.cfg @@ -0,0 +1,3 @@ +xfail +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/FailDropAndModify1.yql b/yql/essentials/tests/s-expressions/suites/Epochs/FailDropAndModify1.yql new file mode 100644 index 0000000000..27a8f34398 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/FailDropAndModify1.yql @@ -0,0 +1,26 @@ +#USE plato; +#DROP TABLE Output; +#INSERT INTO Output SELECT key FROM Input; + +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let conv (lambda '(item) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member item '"key"))) + (return (AsList res)) +)))) + +(let world (Write! world sink (Key '('table (String 'Output))) (Void) '('('mode 'drop)))) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let out (FlatMap input conv)) +(let world (Write! world sink (Key '('table (String 'Output))) out '('('mode 'append)))) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/FailDropAndModify2.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/FailDropAndModify2.cfg new file mode 100644 index 0000000000..a26fadcaa7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/FailDropAndModify2.cfg @@ -0,0 +1,3 @@ +xfail +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/FailDropAndModify2.yql b/yql/essentials/tests/s-expressions/suites/Epochs/FailDropAndModify2.yql new file mode 100644 index 0000000000..914cff8c91 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/FailDropAndModify2.yql @@ -0,0 +1,27 @@ +#USE plato; +#INSERT INTO Output SELECT key FROM Input; +#DROP TABLE Output; + +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let conv (lambda '(item) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member item '"key"))) + (return (AsList res)) +)))) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let out (FlatMap input conv)) +(let world (Write! world sink (Key '('table (String 'Output))) out '('('mode 'append)))) + +(let world (Write! world sink (Key '('table (String 'Output))) (Void) '('('mode 'drop)))) + +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/FailMixedAppendOverride.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/FailMixedAppendOverride.cfg new file mode 100644 index 0000000000..a26fadcaa7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/FailMixedAppendOverride.cfg @@ -0,0 +1,3 @@ +xfail +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/FailMixedAppendOverride.yql b/yql/essentials/tests/s-expressions/suites/Epochs/FailMixedAppendOverride.yql new file mode 100644 index 0000000000..f2047207e7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/FailMixedAppendOverride.yql @@ -0,0 +1,18 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'append)))) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'renew)))) + +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideBySorted.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideBySorted.cfg new file mode 100644 index 0000000000..48cd4555f7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideBySorted.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output non_empty.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideBySorted.yql b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideBySorted.yql new file mode 100644 index 0000000000..f27a896172 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideBySorted.yql @@ -0,0 +1,13 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'renew)))) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideBySortedAfterCommit.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideBySortedAfterCommit.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideBySortedAfterCommit.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideBySortedAfterCommit.yql b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideBySortedAfterCommit.yql new file mode 100644 index 0000000000..c08723a840 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideBySortedAfterCommit.yql @@ -0,0 +1,21 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'renew)))) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSorted.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSorted.cfg new file mode 100644 index 0000000000..bffc8451cc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSorted.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output sorted.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSorted.yql b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSorted.yql new file mode 100644 index 0000000000..383a70fad1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSorted.yql @@ -0,0 +1,12 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'renew)))) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedAfterCommit.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedAfterCommit.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedAfterCommit.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedAfterCommit.yql b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedAfterCommit.yql new file mode 100644 index 0000000000..a29f76402f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedAfterCommit.yql @@ -0,0 +1,21 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let world (Write! world sink (Key '('table (String 'Output))) input '('('mode 'renew)))) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedBySortedDesc.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedBySortedDesc.cfg new file mode 100644 index 0000000000..bffc8451cc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedBySortedDesc.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output sorted.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedBySortedDesc.yql b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedBySortedDesc.yql new file mode 100644 index 0000000000..b43deb2cd9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedBySortedDesc.yql @@ -0,0 +1,13 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'false) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'renew)))) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedBySortedDescAfterCommit.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedBySortedDescAfterCommit.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedBySortedDescAfterCommit.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedBySortedDescAfterCommit.yql b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedBySortedDescAfterCommit.yql new file mode 100644 index 0000000000..71c6b7ef4f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedBySortedDescAfterCommit.yql @@ -0,0 +1,22 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'false) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'renew)))) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedDescBySorted.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedDescBySorted.cfg new file mode 100644 index 0000000000..50b4461ad2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedDescBySorted.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output sorted_desc.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedDescBySorted.yql b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedDescBySorted.yql new file mode 100644 index 0000000000..f27a896172 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedDescBySorted.yql @@ -0,0 +1,13 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'renew)))) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedDescBySortedAfterCommit.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedDescBySortedAfterCommit.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedDescBySortedAfterCommit.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedDescBySortedAfterCommit.yql b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedDescBySortedAfterCommit.yql new file mode 100644 index 0000000000..643a22242b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideSortedDescBySortedAfterCommit.yql @@ -0,0 +1,22 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'false) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) + +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'renew)))) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideType.yql b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideType.yql new file mode 100644 index 0000000000..f9b513d556 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideType.yql @@ -0,0 +1,52 @@ +#USE plato; +#INSERT INTO Output SELECT CAST(key as Int32) as item1, value as item2 FROM Input; +#COMMIT; +#INSERT INTO Output SELECT CAST(key as Int32) as item1, value as item2 FROM Input; +#COMMIT; +#INSERT INTO Output WITH TRUNCATE SELECT CAST(key as Int32) as item3, value as item4 FROM Input; + + +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let conv1 (lambda '(item) (block '( + (let res (Struct)) + (let res (AddMember res '"item1" (Cast (Member item '"key") 'Int32))) + (let res (AddMember res '"item2" (Member item '"value"))) + (return (AsList res)) +)))) + +(let conv2 (lambda '(item) (block '( + (let res (Struct)) + (let res (AddMember res '"item3" (Cast (Member item '"key") 'Int32))) + (let res (AddMember res '"item4" (Member item '"value"))) + (return (AsList res)) +)))) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let out (FlatMap input conv1)) +(let world (Write! world sink (Key '('table (String 'Output))) out '('('mode 'append)))) + +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let out (FlatMap input conv1)) +(let world (Write! world sink (Key '('table (String 'Output))) out '('('mode 'append)))) + +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let out (FlatMap input conv2)) +(let world (Write! world sink (Key '('table (String 'Output))) out '('('mode 'renew)))) + +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/OverrideWithSort.yql b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideWithSort.yql new file mode 100644 index 0000000000..946c9f2d68 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/OverrideWithSort.yql @@ -0,0 +1,65 @@ +#USE plato; +#INSERT INTO Output SELECT COALESCE(CAST(key as Uint64), 0) as age1, value as name1 FROM Input ORDER by age1; +#COMMIT; +#INSERT INTO Output WITH TRUNCATE SELECT age1 as age2, name1 as name2 FROM Output WHERE age1 < 100 ORDER BY name2; +#COMMIT; +#SELECT * FROM Output where name2 < "zzz"; + + + +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let conv1 (lambda '(item) (block '( + (let res (Struct)) + (let res (AddMember res '"age1" (Coalesce (Cast (Member item '"key") 'Uint64) (Uint64 '0)))) + (let res (AddMember res '"name1" (Member item '"value"))) + (return (AsList res)) +)))) +(let out (FlatMap input conv1)) +(let out (Sort out (Bool 'true) (lambda '(item) (Member item '"age1")))) +(let world (Write! world sink (Key '('table (String 'Output))) out '('('mode 'append)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Output"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let filter (lambda '(item) (block '( + (let age (Member item '"age1")) + (let res (Coalesce (< age (Uint64 '100)) (Bool 'false))) + (return res) +) +))) +(let out (Filter input filter)) +(let conv2 (lambda '(item) (block '( + (let res (Struct)) + (let res (AddMember res '"age2" (Member item '"age1"))) + (let res (AddMember res '"name2" (Member item '"name1"))) + (return (AsList res)) +)))) +(let out (FlatMap out conv2)) +(let out (Sort out (Bool 'true) (lambda '(item) (Member item '"name2")))) +(let world (Write! world sink (Key '('table (String 'Output))) out '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Output"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let filter (lambda '(item) (block '( + (let name (Member item '"name2")) + (let res (Coalesce (< name (String '"zzz")) (Bool 'false))) + (return res) +) +))) +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/PredictSort.yql b/yql/essentials/tests/s-expressions/suites/Epochs/PredictSort.yql new file mode 100644 index 0000000000..b3f57179c3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/PredictSort.yql @@ -0,0 +1,30 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Output"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"key")) + (let res (Coalesce (< key (String '"100")) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/ReadFromGrandCommit.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/ReadFromGrandCommit.cfg new file mode 100644 index 0000000000..d611f0155e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/ReadFromGrandCommit.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +out Output2 output2.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/ReadFromGrandCommit.yql b/yql/essentials/tests/s-expressions/suites/Epochs/ReadFromGrandCommit.yql new file mode 100644 index 0000000000..f2266e36a6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/ReadFromGrandCommit.yql @@ -0,0 +1,46 @@ +#USE plato; +#INSERT INTO Output WITH TRUNCATE SELECT key as a, "value:" || value as b FROM Input; +#COMMIT; +#INSERT INTO Output2 WITH TRUNCATE SELECT 1 as x; +#COMMIT; +#SELECT * FROM Output; + +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let conv (lambda '(item) (block '( + (let res (Struct)) + (let res (AddMember res '"a" (Member item '"key"))) + (let res (AddMember res '"b" (Concat (String '"value:") (Member item '"value")))) + (return (AsList res)) +)))) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let out (FlatMap input conv)) +(let world (Write! world sink (Key '('table (String 'Output))) out '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let fill (lambda '(item) (block '( + (let res (Struct)) + (let res (AddMember res '"x" (Int64 '"1"))) + (return (AsList res)) +)))) + +(let out2 (FlatMap (AsList (Void)) fill)) +(let world (Write! world sink (Key '('table (String 'Output2))) out2 '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Output"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let world (Write! world result (Key) input '('('type) '('autoref)))) +(let world (Commit! world result)) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/ReorderPragmaBeforeTableScheme.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/ReorderPragmaBeforeTableScheme.cfg new file mode 100644 index 0000000000..6f99339756 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/ReorderPragmaBeforeTableScheme.cfg @@ -0,0 +1,2 @@ +in Input input.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/ReorderPragmaBeforeTableScheme.yql b/yql/essentials/tests/s-expressions/suites/Epochs/ReorderPragmaBeforeTableScheme.yql new file mode 100644 index 0000000000..ecb64cf46c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/ReorderPragmaBeforeTableScheme.yql @@ -0,0 +1,15 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let world (Configure! world (DataSource 'yt '$all) 'Attr 'externaltx '"0-0-0-0")) +(let x (Read! world mr_source + (Key '('tablescheme (String '"Input"))) + (Void) '( + '('do_not_fail_on_invalid_schema) + '('infer_scheme) + ) +)) +(let scheme (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) scheme '())) +(return (Commit! world res_sink)) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/ReorderPragmas.yql b/yql/essentials/tests/s-expressions/suites/Epochs/ReorderPragmas.yql new file mode 100644 index 0000000000..f3c7e35b7d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/ReorderPragmas.yql @@ -0,0 +1,63 @@ +#USE plato; +#PRAGMA yt.InferSchema = "1"; +#PRAGMA yt.MaxRowWeight = "128m"; +#INSERT INTO Output +#select * from Input +#WHERE key != "0"; +#commit; +#PRAGMA yt.InferSchema = "3"; +#select * from Input; +#PRAGMA yt.MaxRowWeight = "128m"; +#PRAGMA yt.InferSchema = "1"; +#select * from Input +#WHERE key != "0"; + +( +(let source (DataSource 'yt 'plato)) +(let source_any (DataSource 'yt '"$all")) +(let sink (DataSink 'yt 'plato)) +(let result (DataSink 'result)) + +(let world (Configure! world source_any '"Attr" '"inferschema" '"1")) +(let world (Configure! world source_any '"Attr" '"maxrowweight" '"128m")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let input (Right! r)) +(let world (Left! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"key")) + (let res (Coalesce (!= key (String '"0")) (Bool 'false))) + (return res) +)))) + +(let out (Filter input filter)) + +(let world (Write! world sink (Key '('table (String '"Output"))) out '('('mode 'append)))) +(let world (Commit! world sink)) + +(let world (Configure! world source_any '"Attr" '"inferschema" '"3")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let input (Right! r)) +(let world (Left! r)) + +(let world (Write! world result (Key) input '('('type) '('autoref)))) +(let world (Commit! world result)) + +(let world (Configure! world source_any '"Attr" '"maxrowweight" '"128m")) +(let world (Configure! world source_any '"Attr" '"inferschema" '"1")) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let input (Right! r)) +(let world (Left! r)) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type) '('autoref)))) + +(let world (Commit! world result)) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/UseAndOverrideType.yql b/yql/essentials/tests/s-expressions/suites/Epochs/UseAndOverrideType.yql new file mode 100644 index 0000000000..7980440ada --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/UseAndOverrideType.yql @@ -0,0 +1,44 @@ +#USE plato; +#INSERT INTO Output SELECT CAST(key as Int32) as item1, value as item2 FROM Input; +#COMMIT; +#INSERT INTO Output WITH TRUNCATE SELECT COALESCE(CAST(item1 as String), "") as key, "." as subkey, item2 as value FROM Output; + +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let conv (lambda '(item) (block '( + (let res (Struct)) + (let res (AddMember res '"item1" (Cast (Member item '"key") 'Int32))) + (let res (AddMember res '"item2" (Member item '"value"))) + (return (AsList res)) +)))) +(let out (FlatMap input conv)) + +(let world (Write! world sink (Key '('table (String 'Output))) out '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String 'Output))) (Void) '())) +(let world (Left! r)) +(let out (Right! r)) + +(let conv (lambda '(item) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Coalesce (Cast (Member item '"item1") 'String) (String '"")))) + (let res (AddMember res '"subkey" (String '"."))) + (let res (AddMember res '"value" (Member item '"item2"))) + (return (AsList res)) + +)))) +(let out (FlatMap out conv)) + +(let world (Write! world sink (Key '('table (String 'Output))) out '('('mode 'renew)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/default.cfg b/yql/essentials/tests/s-expressions/suites/Epochs/default.cfg new file mode 100644 index 0000000000..fe2b19a9ff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/default.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/Epochs/input.txt b/yql/essentials/tests/s-expressions/suites/Epochs/input.txt new file mode 100644 index 0000000000..65949ea745 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/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/Epochs/input.txt.attr b/yql/essentials/tests/s-expressions/suites/Epochs/input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/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/Epochs/non_empty.txt b/yql/essentials/tests/s-expressions/suites/Epochs/non_empty.txt new file mode 100644 index 0000000000..65949ea745 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/non_empty.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/Epochs/non_empty.txt.attr b/yql/essentials/tests/s-expressions/suites/Epochs/non_empty.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/non_empty.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/Epochs/sorted.txt b/yql/essentials/tests/s-expressions/suites/Epochs/sorted.txt new file mode 100644 index 0000000000..dd47b9a25e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/sorted.txt @@ -0,0 +1,4 @@ +{"key"="023";"subkey"="3";"value"="aaa"}; +{"key"="037";"subkey"="5";"value"="ddd"}; +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="150";"subkey"="8";"value"="zzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/sorted.txt.attr b/yql/essentials/tests/s-expressions/suites/Epochs/sorted.txt.attr new file mode 100644 index 0000000000..16aab8884b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/sorted.txt.attr @@ -0,0 +1,9 @@ +{ + "_yql_row_spec"={ + "SortMembers"=["key"]; + "SortedBy"=["key"]; + "SortDirections"=[1]; + "SortedByTypes"=[["DataType";"String"]]; + "Type"=["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/sorted_desc.txt b/yql/essentials/tests/s-expressions/suites/Epochs/sorted_desc.txt new file mode 100644 index 0000000000..ac8e34386d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/sorted_desc.txt @@ -0,0 +1,4 @@ +{"_yql_column_0"="\xE0\xC7\xCF\xCF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFE\xFC";"key"="800";"subkey"="2";"value"="ddd"}; +{"_yql_column_0"="\xE0\xCE\xCA\xCF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFE\xFC";"key"="150";"subkey"="4";"value"="qzz"}; +{"_yql_column_0"="\xE0\xCF\xC8\xCA\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFE\xFC";"key"="075";"subkey"="1";"value"="abc"}; +{"_yql_column_0"="\xE0\xCF\xCD\xCF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFE\xFC";"key"="020";"subkey"="3";"value"="q"}; diff --git a/yql/essentials/tests/s-expressions/suites/Epochs/sorted_desc.txt.attr b/yql/essentials/tests/s-expressions/suites/Epochs/sorted_desc.txt.attr new file mode 100644 index 0000000000..903b4c7d93 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Epochs/sorted_desc.txt.attr @@ -0,0 +1,46 @@ +{ + "_yql_row_spec" = { + "SortMembers" = [ + "key" + ]; + "SortDirections" = [ + 0 + ]; + "UniqueKeys" = %false; + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ]; + "SortedByTypes" = [ + [ + "DataType"; + "String" + ] + ]; + "SortedBy" = [ + "_yql_column_0" + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491.cfg new file mode 100644 index 0000000000..0db7c8a4b8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491.cfg @@ -0,0 +1,4 @@ +res result.txt +in Input1 Bug15491_Input1.txt +in Input2 Bug15491_Input2.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491.yql new file mode 100644 index 0000000000..89a1e02765 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491.yql @@ -0,0 +1,30 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey1 (Just (Member item 'subkey))) + '('value1 (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Member item 'key)) + '('subkey2 (Just (Member item 'subkey))) + '('value2 (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '('('flatten)))) + +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"key") (Member row '"subkey1")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491_Input1.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491_Input1.txt new file mode 100644 index 0000000000..1dc1bcc60b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491_Input1.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="3";"value"="abd"}; +{"key"="800";"subkey"="3";"value"="ddd"}; +{"key"="021";"subkey"="3";"value"="q"}; +{"key"="151";"subkey"="3";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491_Input1.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491_Input1.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491_Input1.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/EquiJoin/Bug15491_Input2.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491_Input2.txt new file mode 100644 index 0000000000..1dc1bcc60b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491_Input2.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="3";"value"="abd"}; +{"key"="800";"subkey"="3";"value"="ddd"}; +{"key"="021";"subkey"="3";"value"="q"}; +{"key"="151";"subkey"="3";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491_Input2.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491_Input2.txt.attr new file mode 100644 index 0000000000..e45f964f78 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug15491_Input2.txt.attr @@ -0,0 +1,30 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "Utf8" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "Utf8" + ] + ]; + [ + "value"; + [ + "DataType"; + "Utf8" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716.cfg new file mode 100644 index 0000000000..c828977eed --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716.cfg @@ -0,0 +1,4 @@ +res result.txt +in Input1 Bug1716_Input1.txt +in Input2 Bug1716_Input2.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716.yql new file mode 100644 index 0000000000..7f37ba29ab --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716.yql @@ -0,0 +1,305 @@ +( +(let data.source (DataSource 'yt 'plato)) +(let data.sink (DataSink 'yt 'plato)) + +(let first (String 'Input1)) +(let second (String 'Input2)) +(let output (String 'Output)) + +(let first.read + (Read! world data.source + (Key '('table first)) + (Void) + '('('infer_scheme)) + ) +) + +(let world (Left! first.read)) +(let first.read (Right! first.read)) + +(let second.read + (Read! world data.source + (Key '('table second)) + (Void) + '('('infer_scheme)) + ) +) + +(let world (Left! second.read)) +(let second.read (Right! second.read)) + +(let data + (EquiJoin + '((RemoveSystemMembers first.read) 'left) '((RemoveSystemMembers second.read) 'right) + '('Inner + 'left + 'right + # '('left 'id 'left 'id.nonzero 'left 'name 'left 'name.nonzero) + '('left 'id 'left 'name) + # '('right 'id 'right 'id.nonzero 'right 'name 'right 'name.nonzero) + '('right 'id 'right 'name) + '('('left 'small) '('right 'small))) + '('('flatten)) + ) +) + +(let data + (Sort data + '((Bool 'true) (Bool 'true)) + (lambda '(row) '((Member row 'id) (Member row 'name))) + ) +) + +(let world + (Write! world (DataSink 'result) + (Key) + data + '('('type)) + ) +) + +(let data + (EquiJoin + '((RemoveSystemMembers first.read) 'left) '((RemoveSystemMembers second.read) 'right) + '('Left + 'left + 'right + # '('left 'id 'left 'id.nonzero 'left 'name 'left 'name.nonzero) + '('left 'id 'left 'name) + # '('right 'id 'right 'id.nonzero 'right 'name 'right 'name.nonzero) + '('right 'id 'right 'name) + '('('left 'small) '('right 'small))) + '('('flatten)) + ) +) + +(let data + (Sort data + '((Bool 'true) (Bool 'true)) + (lambda '(row) '((Member row 'id) (Member row 'name))) + ) +) + +(let world + (Write! world (DataSink 'result) + (Key) + data + '('('type)) + ) +) + + +(let data + (EquiJoin + '((RemoveSystemMembers first.read) 'left) '((RemoveSystemMembers second.read) 'right) + '('Right + 'left + 'right + # '('left 'id 'left 'id.nonzero 'left 'name 'left 'name.nonzero) + '('left 'id 'left 'name) + # '('right 'id 'right 'id.nonzero 'right 'name 'right 'name.nonzero) + '('right 'id 'right 'name) + '('('left 'small) '('right 'small))) + '('('flatten)) + ) +) + +(let data + (Sort data + '((Bool 'true) (Bool 'true)) + (lambda '(row) '((Member row 'id) (Member row 'name))) + ) +) + +(let world + (Write! world (DataSink 'result) + (Key) + data + '('('type)) + ) +) + +(let data + (EquiJoin + '((RemoveSystemMembers first.read) 'left) '((RemoveSystemMembers second.read) 'right) + '('Full + 'left + 'right + # '('left 'id 'left 'id.nonzero 'left 'name 'left 'name.nonzero) + '('left 'id 'left 'name) + # '('right 'id 'right 'id.nonzero 'right 'name 'right 'name.nonzero) + '('right 'id 'right 'name) + '('('left 'small) '('right 'small))) + '('('flatten)) + ) +) + +(let data + (Sort data + '((Bool 'true) (Bool 'true)) + (lambda '(row) '((Member row 'id) (Member row 'name))) + ) +) + +(let world + (Write! world (DataSink 'result) + (Key) + data + '('('type)) + ) +) + +(let data + (EquiJoin + '((RemoveSystemMembers first.read) 'left) '((RemoveSystemMembers second.read) 'right) + '('LeftOnly + 'left + 'right + # '('left 'id 'left 'id.nonzero 'left 'name 'left 'name.nonzero) + '('left 'id 'left 'name) + # '('right 'id 'right 'id.nonzero 'right 'name 'right 'name.nonzero) + '('right 'id 'right 'name) + '('('left 'small) '('right 'small))) + '('('flatten)) + ) +) + +(let data + (Sort data + '((Bool 'true) (Bool 'true)) + (lambda '(row) '((Member row 'id) (Member row 'name))) + ) +) + +(let world + (Write! world (DataSink 'result) + (Key) + data + '('('type)) + ) +) + +(let data + (EquiJoin + '((RemoveSystemMembers first.read) 'left) '((RemoveSystemMembers second.read) 'right) + '('LeftSemi + 'left + 'right + # '('left 'id 'left 'id.nonzero 'left 'name 'left 'name.nonzero) + '('left 'id 'left 'name) + # '('right 'id 'right 'id.nonzero 'right 'name 'right 'name.nonzero) + '('right 'id 'right 'name) + '('('left 'small) '('right 'small))) + '('('flatten)) + ) +) + +(let data + (Sort data + '((Bool 'true) (Bool 'true)) + (lambda '(row) '((Member row 'id) (Member row 'name))) + ) +) + +(let world + (Write! world (DataSink 'result) + (Key) + data + '('('type)) + ) +) + +(let data + (EquiJoin + '((RemoveSystemMembers first.read) 'left) '((RemoveSystemMembers second.read) 'right) + '('RightOnly + 'left + 'right + # '('left 'id 'left 'id.nonzero 'left 'name 'left 'name.nonzero) + '('left 'id 'left 'name) + # '('right 'id 'right 'id.nonzero 'right 'name 'right 'name.nonzero) + '('right 'id 'right 'name) + '('('left 'small) '('right 'small))) + '('('flatten)) + ) +) + +(let data + (Sort data + '((Bool 'true) (Bool 'true)) + (lambda '(row) '((Member row 'id) (Member row 'name))) + ) +) + +(let world + (Write! world (DataSink 'result) + (Key) + data + '('('type)) + ) +) + +(let data + (EquiJoin + '((RemoveSystemMembers first.read) 'left) '((RemoveSystemMembers second.read) 'right) + '('RightSemi + 'left + 'right + # '('left 'id 'left 'id.nonzero 'left 'name 'left 'name.nonzero) + '('left 'id 'left 'name) + # '('right 'id 'right 'id.nonzero 'right 'name 'right 'name.nonzero) + '('right 'id 'right 'name) + '('('left 'small) '('right 'small))) + '('('flatten)) + ) +) + +(let data + (Sort data + '((Bool 'true) (Bool 'true)) + (lambda '(row) '((Member row 'id) (Member row 'name))) + ) +) + +(let world + (Write! world (DataSink 'result) + (Key) + data + '('('type)) + ) +) + +(let data + (EquiJoin + '((RemoveSystemMembers first.read) 'left) '((RemoveSystemMembers second.read) 'right) + '('Exclusion + 'left + 'right + # '('left 'id 'left 'id.nonzero 'left 'name 'left 'name.nonzero) + '('left 'id 'left 'name) + # '('right 'id 'right 'id.nonzero 'right 'name 'right 'name.nonzero) + '('right 'id 'right 'name) + '('('left 'small) '('right 'small))) + '('('flatten)) + ) +) + +(let data + (Sort data + '((Bool 'true) (Bool 'true)) + (lambda '(row) '((Member row 'id) (Member row 'name))) + ) +) + +(let world + (Write! world (DataSink 'result) + (Key) + data + '('('type)) + ) +) + +(let world (Commit! world (DataSink 'result))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716_Input1.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716_Input1.txt new file mode 100644 index 0000000000..7138a62f40 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716_Input1.txt @@ -0,0 +1,6 @@ +{"field1"="1_1";"field2"="2_1_1";"id"="1";"name"="name_1_1"}; +{"field1"="1_1";"field2"="2_1_2";"id"="1";"name"="name_1_1"}; +{"field1"="1_2";"field2"="2_1_1";"id"="1";"name"="name_1_2"}; +{"field1"="1_2";"field2"="2_1_2";"id"="1";"name"="name_1_2"}; +{"field1"="1_2";"id"="2";"name"="name_2_1"}; +{"field1"="1_3";"id"="3";"name"="name_3_1"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716_Input1.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716_Input1.txt.attr new file mode 100644 index 0000000000..54366c43a1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716_Input1.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"Type" = [ "StructType"; [["field1";["OptionalType";["DataType";"String"]]];["field2";["OptionalType";["DataType";"String"]]];["id";["OptionalType";["DataType";"String"]]];["name";["OptionalType";["DataType";"String"]]]]];"UniqueKeys" = %false} +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716_Input2.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716_Input2.txt new file mode 100644 index 0000000000..67606ea5fc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716_Input2.txt @@ -0,0 +1,3 @@ +{"field3"="3_1";"id"="1";"name"="name_1_1"}; +{"field3"="3_2";"id"="2";"name"="name_2_1"}; +{"field3"="3_3";"id"="2";"name"="name_2_2"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716_Input2.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716_Input2.txt.attr new file mode 100644 index 0000000000..268c3c5a6d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1716_Input2.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"Type" = [ "StructType"; [["field3";["OptionalType";["DataType";"String"]]];["id";["OptionalType";["DataType";"String"]]];["name";["OptionalType";["DataType";"String"]]]]];"UniqueKeys" = %false} +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1924.sql b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1924.sql new file mode 100644 index 0000000000..b14b63a04a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1924.sql @@ -0,0 +1,38 @@ +USE plato; + +$hash = (select key as devid, key as mmetric_devid from Input); +$rutaxi = (select key as DeviceID from Input); +$device = (select key as devid, key as yuid from Input); +$cripta = (select key as yuid, value as phones from Input); + +$x = + ( + select + hash.devid as devid + from $rutaxi as rutaxi + right semi join $hash as hash + on rutaxi.DeviceID = hash.mmetric_devid + ); + +$y = + ( + select + device.yuid as yuid + from $x as x + right semi join $device as device + using(devid) + ); + + +$z = + ( + select + cripta.phones as phones + from $y as y + right semi join $cripta as cripta on + y.yuid = cripta.yuid || "" + ); + +select + x.phones AS phone +from $z AS x; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1924.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1924.yql new file mode 100644 index 0000000000..2247aa8e0b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug1924.yql @@ -0,0 +1,117 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"InputSelf")))) '('"key" '"value") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core (Map (EquiJoin '((block '( + (let select (block '( + (let core (EquiJoin '((block '( + (let select (block '( + (let core (EquiJoin '((block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"DeviceID" (Member row '"key")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"rutaxi") '((block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"devid" (Member row '"key")) '('"mmetric_devid" (Member row '"key")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"hash") '('RightSemi '"rutaxi" '"hash" '('"rutaxi" '"DeviceID") '('"hash" '"mmetric_devid") '()) '())) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"devid" (Member row '"hash.devid")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"x") '((block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"devid" (Member row '"key")) '('"yuid" (Member row '"key")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"device") '('RightSemi '"x" '"device" '('"x" '"devid") '('"device" '"devid") '()) '())) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"yuid" (Member row '"device.yuid")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"y") '((Map (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"yuid" (Member row '"key")) '('"phones" (Member row '"value")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) (lambda '(row) (block '( + (let row (AddMember row '"_equijoin_column_0" ("Concat" (Member row '"yuid") (String '"")))) + (return row) + )))) '"cripta") '('RightSemi '"y" '"cripta" '('"y" '"yuid") '('"cripta" '"_equijoin_column_0") '()) '()) (lambda '(row) (block '( + (let row (ForceRemoveMember row '"cripta._equijoin_column_0")) + (return row) + ))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"phones" (Member row '"cripta.phones")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"phone" (Member row '"phones")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (let select (Sort select (Bool 'true) (lambda '(row) (Member row '"phone")))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"phone"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug2566.sql b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug2566.sql new file mode 100644 index 0000000000..b12f694803 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug2566.sql @@ -0,0 +1,5 @@ +use plato; +pragma yt.MapJoinLimit="1m"; +$a = (select cast(key as Uint64) as key,subkey from Input1); +$b = (select cast(key as Uint32) as key,subkey from Input1); +select * from $a as a join $b as b on a.key = b.key; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug2566.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug2566.yql new file mode 100644 index 0000000000..09a8847b4a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/Bug2566.yql @@ -0,0 +1,56 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(import core_module '"/lib/yql/core.yql") +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input1")))) '('"key" '"subkey") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (EquiJoin '((block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"key" (Cast (Member row '"key") 'Uint64)) '('"subkey" (Member row '"subkey")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"a") '((block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"key" (Cast (Member row '"key") 'Uint32)) '('"subkey" (Member row '"subkey")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"b") '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key") '()) '())) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/DoAllJoinsExceptCross.yql.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/DoAllJoinsExceptCross.yql.txt new file mode 100644 index 0000000000..9ef17f1842 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/DoAllJoinsExceptCross.yql.txt @@ -0,0 +1,48 @@ +( + +(let doAllJoinsExceptCross (lambda '(world t1 t2) ( block '( + + (let mr_source (DataSource 'yt 'plato)) + (let x (Read! world mr_source (Key '('table (String t1))) (Void) '())) + (let world (Left! x)) + (let list1 (Right! x)) + + (let x (Read! world mr_source (Key '('table (String t2))) (Void) '())) + (let world (Left! x)) + (let list2 (Right! x)) + + (let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key) '('b 'key) '()) '())) + (let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key) '('b 'key) '()) '())) + (let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key) '('b 'key) '()) '())) + (let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key) '('b 'key) '()) '())) + (let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key) '('b 'key) '()) '())) + (let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key) '('b 'key) '()) '())) + (let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key) '('b 'key) '()) '())) + (let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key) '('b 'key) '()) '())) + (let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key) '('b 'key) '()) '())) + + (let sortDir2 '((Bool 'true) (Bool 'true))) + (let sortDir1 '((Bool 'true))) + (let keySelectorAB (lambda '(row) '((Member row '"a.key") (Member row '"b.key")))) + (let keySelectorA (lambda '(row) '((Member row '"a.key")))) + (let keySelectorB (lambda '(row) '((Member row '"b.key")))) + + (let res_sink (DataSink 'result)) + (let world (Write! world res_sink (Key) (Sort joinInner sortDir2 keySelectorAB) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinLeft sortDir2 keySelectorAB) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinRight sortDir2 keySelectorAB) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinFull sortDir2 keySelectorAB) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir1 keySelectorA) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir1 keySelectorB) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinExclusion sortDir2 keySelectorAB) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir1 keySelectorA) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir1 keySelectorB) '('('type)))) + + (let world (Commit! world res_sink)) + (return world) + +)))) + +(export doAllJoinsExceptCross) + +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiConvertToCommonTypeAlias.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiConvertToCommonTypeAlias.yql new file mode 100644 index 0000000000..655f2a8207 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiConvertToCommonTypeAlias.yql @@ -0,0 +1,25 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('a.key1 (Int32 '-1)) '('k.value1 (Int32 '1)) '('k.s (String '"k1"))) +)) + +(let list2 (AsList + (AsStruct '('b.key2 (Uint32 '4294967295)) '('l.value2 (Uint32 '1)) '('l.s (String '"l1"))) +)) + +(let list3 (AsList + (AsStruct '('c.key3 (Int32 '1)) '('m.value3 (Uint16 '1)) '('m.s (String '"m1"))) +)) + +(let joinInnerInner (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Inner '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('l 'value2) '('c 'key3) '()) '())) + +(let res_sink (DataSink 'result)) + +(let world (Write! world res_sink (Key) joinInnerInner '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiCrossSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiCrossSelfStr.yql new file mode 100644 index 0000000000..944bb5f6de --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiCrossSelfStr.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Cross '"a" '"b" '() '() '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiExclusionSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiExclusionSelfStr.yql new file mode 100644 index 0000000000..0b94fa907f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiExclusionSelfStr.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Exclusion '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullCross3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullCross3OptStr.yql new file mode 100644 index 0000000000..dc7718c806 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullCross3OptStr.yql @@ -0,0 +1,39 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('Cross '"a" '"b" '() '() '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullCross3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullCross3Str.yql new file mode 100644 index 0000000000..894e36e1b9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullCross3Str.yql @@ -0,0 +1,25 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('Cross '"a" '"b" '() '() '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullExclusion3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullExclusion3OptStr.yql new file mode 100644 index 0000000000..b115bd6907 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullExclusion3OptStr.yql @@ -0,0 +1,39 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('Exclusion '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullExclusion3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullExclusion3Str.yql new file mode 100644 index 0000000000..0683a16ba8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullExclusion3Str.yql @@ -0,0 +1,25 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('Exclusion '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullFull3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullFull3OptStr.yql new file mode 100644 index 0000000000..db3690c50a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullFull3OptStr.yql @@ -0,0 +1,39 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('Full '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullFull3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullFull3Str.yql new file mode 100644 index 0000000000..2339478283 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullFull3Str.yql @@ -0,0 +1,25 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('Full '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullInner3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullInner3OptStr.yql new file mode 100644 index 0000000000..786062ec45 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullInner3OptStr.yql @@ -0,0 +1,39 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullInner3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullInner3Str.yql new file mode 100644 index 0000000000..4f4a0eda4d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullInner3Str.yql @@ -0,0 +1,25 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeft3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeft3OptStr.yql new file mode 100644 index 0000000000..293639aa22 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeft3OptStr.yql @@ -0,0 +1,39 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('Left '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeft3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeft3Str.yql new file mode 100644 index 0000000000..5d7c766dc5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeft3Str.yql @@ -0,0 +1,25 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('Left '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeftOnly3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeftOnly3OptStr.yql new file mode 100644 index 0000000000..0ed5172d92 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeftOnly3OptStr.yql @@ -0,0 +1,39 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('LeftOnly '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeftOnly3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeftOnly3Str.yql new file mode 100644 index 0000000000..bb8bb2e523 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeftOnly3Str.yql @@ -0,0 +1,25 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('LeftOnly '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeftSemi3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeftSemi3OptStr.yql new file mode 100644 index 0000000000..c5382a89c2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeftSemi3OptStr.yql @@ -0,0 +1,39 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('LeftSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeftSemi3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeftSemi3Str.yql new file mode 100644 index 0000000000..0afd1f691e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullLeftSemi3Str.yql @@ -0,0 +1,25 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('LeftSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRight3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRight3OptStr.yql new file mode 100644 index 0000000000..89ca16a047 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRight3OptStr.yql @@ -0,0 +1,39 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('Right '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRight3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRight3Str.yql new file mode 100644 index 0000000000..b5016c4e11 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRight3Str.yql @@ -0,0 +1,25 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('Right '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRightOnly3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRightOnly3OptStr.yql new file mode 100644 index 0000000000..d6e1605074 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRightOnly3OptStr.yql @@ -0,0 +1,39 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('RightOnly '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"b" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRightOnly3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRightOnly3Str.yql new file mode 100644 index 0000000000..97a13fa2b9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRightOnly3Str.yql @@ -0,0 +1,25 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('RightOnly '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"b" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRightSemi3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRightSemi3OptStr.yql new file mode 100644 index 0000000000..a64f8a6705 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRightSemi3OptStr.yql @@ -0,0 +1,39 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('RightSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"b" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRightSemi3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRightSemi3Str.yql new file mode 100644 index 0000000000..951e1d462b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullRightSemi3Str.yql @@ -0,0 +1,25 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Full + '('RightSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"b" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"b.key") (Member row '"b.subkey") (Member row '"c.key") (Member row '"c.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfStr.yql new file mode 100644 index 0000000000..1d50eb5959 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfStr.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Full '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnNoOpt1Opt2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnNoOpt1Opt2Str.yql new file mode 100644 index 0000000000..af309a36eb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnNoOpt1Opt2Str.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(table 'a) '(tableOpt3 'b) '('Full '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnOpt1NoOpt2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnOpt1NoOpt2Str.yql new file mode 100644 index 0000000000..536807ec3d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnOpt1NoOpt2Str.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(table 'b) '('Full '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnOpt1Opt2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnOpt1Opt2Str.yql new file mode 100644 index 0000000000..cae4788bf3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnOpt1Opt2Str.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(tableOpt3 'b) '('Full '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnOptPartial1OptPartial2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnOptPartial1OptPartial2Str.yql new file mode 100644 index 0000000000..08748168f6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnOptPartial1OptPartial2Str.yql @@ -0,0 +1,29 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt1a (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Member row 'subkey)) + '('value (Member row 'value)) + )) +))))) + +(let tableOpt1b (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Member row 'key)) + '('subkey (Just (Member row 'subkey))) + '('value (Member row 'value)) + )) +))))) + +(let join (EquiJoin '(tableOpt1a 'a) '(tableOpt1b 'b) '('Full '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnStr.yql new file mode 100644 index 0000000000..8f7d2e40d2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiFullSelfTwoColumnStr.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Full '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerCross3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerCross3OptStr.yql new file mode 100644 index 0000000000..9f014d1580 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerCross3OptStr.yql @@ -0,0 +1,37 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Cross '"a" '"b" '() '() '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerCross3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerCross3Str.yql new file mode 100644 index 0000000000..b9c69bf087 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerCross3Str.yql @@ -0,0 +1,23 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Cross '"a" '"b" '() '() '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerDiffIntTypes.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerDiffIntTypes.yql new file mode 100644 index 0000000000..6d7b8198a6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerDiffIntTypes.yql @@ -0,0 +1,25 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableKVInt64 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Int64) (Int64 '888))) + '('subkey (Just (Member row 'subkey))) + '('value (Member row 'value)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Member row 'key)) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '999))) + )) +))))) +(let join (EquiJoin '(tableKVInt64 'a) '(tableKVInt 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerExclusion3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerExclusion3OptStr.yql new file mode 100644 index 0000000000..7f144be37f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerExclusion3OptStr.yql @@ -0,0 +1,38 @@ +# ignore runonopt plan diff +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Exclusion '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerExclusion3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerExclusion3Str.yql new file mode 100644 index 0000000000..769cfb1657 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerExclusion3Str.yql @@ -0,0 +1,23 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Exclusion '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerFull3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerFull3OptStr.yql new file mode 100644 index 0000000000..5b0febe8af --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerFull3OptStr.yql @@ -0,0 +1,37 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Full '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerFull3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerFull3Str.yql new file mode 100644 index 0000000000..b2436aff7f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerFull3Str.yql @@ -0,0 +1,23 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Full '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerInner3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerInner3OptStr.yql new file mode 100644 index 0000000000..0c12e21175 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerInner3OptStr.yql @@ -0,0 +1,37 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerInner3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerInner3Str.yql new file mode 100644 index 0000000000..598c2ef4ec --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerInner3Str.yql @@ -0,0 +1,23 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerInner3StrRename.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerInner3StrRename.yql new file mode 100644 index 0000000000..a3258f553c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerInner3StrRename.yql @@ -0,0 +1,24 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) + '('('rename '"a.key" 'col1) '('rename '"b.subkey" '"") '('rename '"c.value" 'ccc)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeft3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeft3OptStr.yql new file mode 100644 index 0000000000..be7f6267c8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeft3OptStr.yql @@ -0,0 +1,37 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Left '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeft3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeft3Str.yql new file mode 100644 index 0000000000..03aa454da5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeft3Str.yql @@ -0,0 +1,23 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Left '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeftOnly3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeftOnly3OptStr.yql new file mode 100644 index 0000000000..5ec5cd9a3f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeftOnly3OptStr.yql @@ -0,0 +1,38 @@ +# ignore runonopt plan diff +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('LeftOnly '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeftOnly3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeftOnly3Str.yql new file mode 100644 index 0000000000..a081fd1505 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeftOnly3Str.yql @@ -0,0 +1,23 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('LeftOnly '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeftSemi3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeftSemi3OptStr.yql new file mode 100644 index 0000000000..eebaf0acbd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeftSemi3OptStr.yql @@ -0,0 +1,37 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('LeftSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeftSemi3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeftSemi3Str.yql new file mode 100644 index 0000000000..4b40b0c009 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerLeftSemi3Str.yql @@ -0,0 +1,23 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('LeftSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerOptDiffIntTypes.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerOptDiffIntTypes.yql new file mode 100644 index 0000000000..8a259534c3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerOptDiffIntTypes.yql @@ -0,0 +1,25 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableKVInt64 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (FromString (Member row 'key) 'Int64)) + '('subkey (Just (Member row 'subkey))) + '('value (Member row 'value)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Member row 'key)) + '('subkey (Just (Member row 'subkey))) + '('value (FromString (Member row 'value) 'Uint32)) + )) +))))) +(let join (EquiJoin '(tableKVInt64 'a) '(tableKVInt 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerOptDiffIntTypesTwoColumn.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerOptDiffIntTypesTwoColumn.yql new file mode 100644 index 0000000000..9abc122fd9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerOptDiffIntTypesTwoColumn.yql @@ -0,0 +1,25 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableKVInt64 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (FromString (Member row 'key) 'Int64)) + '('subkey (Just (Member row 'subkey))) + '('value (Member row 'value)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Member row 'key)) + '('subkey (Just (Member row 'subkey))) + '('value (FromString (Member row 'value) 'Uint32)) + )) +))))) +(let join (EquiJoin '(tableKVInt64 'a) '(tableKVInt 'b) '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRight3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRight3OptStr.yql new file mode 100644 index 0000000000..b4b825991e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRight3OptStr.yql @@ -0,0 +1,37 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Right '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRight3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRight3Str.yql new file mode 100644 index 0000000000..4e11a1b8c0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRight3Str.yql @@ -0,0 +1,23 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Right '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRightOnly3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRightOnly3OptStr.yql new file mode 100644 index 0000000000..2bf637ce0d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRightOnly3OptStr.yql @@ -0,0 +1,38 @@ +# ignore runonopt plan diff +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('RightOnly '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"b" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRightOnly3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRightOnly3Str.yql new file mode 100644 index 0000000000..f1f3eec7ac --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRightOnly3Str.yql @@ -0,0 +1,23 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('RightOnly '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"b" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRightSemi3OptStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRightSemi3OptStr.yql new file mode 100644 index 0000000000..6e5d4d95d0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRightSemi3OptStr.yql @@ -0,0 +1,37 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('RightSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"b" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRightSemi3Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRightSemi3Str.yql new file mode 100644 index 0000000000..808c44795b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerRightSemi3Str.yql @@ -0,0 +1,23 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('RightSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"b" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfIntSameDiff.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfIntSameDiff.yql new file mode 100644 index 0000000000..de061d0050 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfIntSameDiff.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Uint32) (Uint32 '666))) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '777))) + )) +))))) +(let tableKVInt1 (Take tableKVInt (Uint64 '6))) +(let tableKVInt2 (Take tableKVInt (Uint64 '6))) +(let join (EquiJoin '(tableKVInt1 'a) '(tableKVInt2 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfIntTakeDiff.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfIntTakeDiff.yql new file mode 100644 index 0000000000..479d476017 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfIntTakeDiff.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Uint32) (Uint32 '666))) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '777))) + )) +))))) +(let tableKVInt1 (Take tableKVInt (Uint64 '6))) +(let tableKVInt2 (Take tableKVInt (Uint64 '7))) +(let join (EquiJoin '(tableKVInt1 'a) '(tableKVInt2 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfStr.yql new file mode 100644 index 0000000000..9de2396e4d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfStr.yql @@ -0,0 +1,12 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfStrRename.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfStrRename.yql new file mode 100644 index 0000000000..932539b39a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfStrRename.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) + '('('rename '"a.key" 'col1) '('rename '"b.subkey" '"")))) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.subkey") (Member row '"a.value")))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnNoOpt1Opt2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnNoOpt1Opt2Str.yql new file mode 100644 index 0000000000..d02d26aafb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnNoOpt1Opt2Str.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(table 'a) '(tableOpt3 'b) '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1NoOpt2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1NoOpt2Str.yql new file mode 100644 index 0000000000..168fab831b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1NoOpt2Str.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(table 'b) '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2Str.yql new file mode 100644 index 0000000000..110a3b617b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2Str.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(tableOpt3 'b) '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2StrAliasOne1.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2StrAliasOne1.yql new file mode 100644 index 0000000000..5a9f9ca659 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2StrAliasOne1.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let tableOpt3a (Map table (lambda '(row) (block '( + (return (AsStruct + '('a.key (Just (Member row 'key))) + '('a.subkey (Just (Member row 'subkey))) + '('a.value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3a '('a)) '(tableOpt3 'b) '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2StrAliasOne12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2StrAliasOne12.yql new file mode 100644 index 0000000000..0d5b7d1601 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2StrAliasOne12.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3a (Map table (lambda '(row) (block '( + (return (AsStruct + '('a.key (Just (Member row 'key))) + '('a.subkey (Just (Member row 'subkey))) + '('a.value (Just (Member row 'value))) + )) +))))) +(let tableOpt3b (Map table (lambda '(row) (block '( + (return (AsStruct + '('b.key (Just (Member row 'key))) + '('b.subkey (Just (Member row 'subkey))) + '('b.value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3a '('a)) '(tableOpt3b '('b)) '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2StrAliasOne2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2StrAliasOne2.yql new file mode 100644 index 0000000000..5d15a2bab8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2StrAliasOne2.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let tableOpt3b (Map table (lambda '(row) (block '( + (return (AsStruct + '('b.key (Just (Member row 'key))) + '('b.subkey (Just (Member row 'subkey))) + '('b.value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(tableOpt3b '('b)) '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2StrAliasTwo.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2StrAliasTwo.yql new file mode 100644 index 0000000000..4c2225f7c5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOpt1Opt2StrAliasTwo.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3a (Map table (lambda '(row) (block '( + (return (AsStruct + '('a.key (Just (Member row 'key))) + '('a.subkey (Just (Member row 'subkey))) + '('c.value (Just (Member row 'value))) + )) +))))) +(let tableOpt3b (Map table (lambda '(row) (block '( + (return (AsStruct + '('d.key (Just (Member row 'key))) + '('b.subkey (Just (Member row 'subkey))) + '('b.value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3a '('a 'c)) '(tableOpt3b '('b 'd)) '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.value") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOptPartial1OptPartial2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOptPartial1OptPartial2Str.yql new file mode 100644 index 0000000000..c6d7543ed3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnOptPartial1OptPartial2Str.yql @@ -0,0 +1,29 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt1a (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Member row 'subkey)) + '('value (Member row 'value)) + )) +))))) + +(let tableOpt1b (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Member row 'key)) + '('subkey (Just (Member row 'subkey))) + '('value (Member row 'value)) + )) +))))) + +(let join (EquiJoin '(tableOpt1a 'a) '(tableOpt1b 'b) '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnStr.yql new file mode 100644 index 0000000000..7444baa207 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiInnerSelfTwoColumnStr.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertCommonI8U32.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertCommonI8U32.cfg new file mode 100644 index 0000000000..27d3c78b8e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertCommonI8U32.cfg @@ -0,0 +1,4 @@ +res result.txt +file joins.yql DoAllJoinsExceptCross.yql.txt +in InputInt8 InputInt8.txt +in InputUint32 InputUint32.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertCommonI8U32.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertCommonI8U32.yql new file mode 100644 index 0000000000..c07a92aa2a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertCommonI8U32.yql @@ -0,0 +1,9 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Apply (bind join_module 'doAllJoinsExceptCross) world 'InputInt8 'InputUint32)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertCommonI8U8.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertCommonI8U8.cfg new file mode 100644 index 0000000000..a4a0bb2fd7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertCommonI8U8.cfg @@ -0,0 +1,6 @@ +res result.txt +file joins.yql DoAllJoinsExceptCross.yql.txt +in InputInt8 InputInt8.txt +in InputInt8Opt InputInt8Opt.txt +in InputUint8 InputUint8.txt +in InputUint8Opt InputUint8Opt.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertCommonI8U8.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertCommonI8U8.yql new file mode 100644 index 0000000000..8fdfeda61a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertCommonI8U8.yql @@ -0,0 +1,12 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Apply (bind join_module 'doAllJoinsExceptCross) world 'InputInt8 'InputUint8)) +(let world (Apply (bind join_module 'doAllJoinsExceptCross) world 'InputInt8Opt 'InputUint8)) +(let world (Apply (bind join_module 'doAllJoinsExceptCross) world 'InputInt8 'InputUint8Opt)) +(let world (Apply (bind join_module 'doAllJoinsExceptCross) world 'InputInt8Opt 'InputUint8Opt)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertMapI8U32.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertMapI8U32.cfg new file mode 100644 index 0000000000..27d3c78b8e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertMapI8U32.cfg @@ -0,0 +1,4 @@ +res result.txt +file joins.yql DoAllJoinsExceptCross.yql.txt +in InputInt8 InputInt8.txt +in InputUint32 InputUint32.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertMapI8U32.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertMapI8U32.yql new file mode 100644 index 0000000000..f24772569c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertMapI8U32.yql @@ -0,0 +1,11 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) + +(let world (Apply (bind join_module 'doAllJoinsExceptCross) world 'InputInt8 'InputUint32)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertMapI8U8.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertMapI8U8.cfg new file mode 100644 index 0000000000..a4a0bb2fd7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertMapI8U8.cfg @@ -0,0 +1,6 @@ +res result.txt +file joins.yql DoAllJoinsExceptCross.yql.txt +in InputInt8 InputInt8.txt +in InputInt8Opt InputInt8Opt.txt +in InputUint8 InputUint8.txt +in InputUint8Opt InputUint8Opt.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertMapI8U8.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertMapI8U8.yql new file mode 100644 index 0000000000..54c482a624 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiJoinConvertMapI8U8.yql @@ -0,0 +1,14 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) + +(let world (Apply (bind join_module 'doAllJoinsExceptCross) world 'InputInt8 'InputUint8)) +(let world (Apply (bind join_module 'doAllJoinsExceptCross) world 'InputInt8Opt 'InputUint8)) +(let world (Apply (bind join_module 'doAllJoinsExceptCross) world 'InputInt8 'InputUint8Opt)) +(let world (Apply (bind join_module 'doAllJoinsExceptCross) world 'InputInt8Opt 'InputUint8Opt)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftOnlySelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftOnlySelfStr.yql new file mode 100644 index 0000000000..a7593fde40 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftOnlySelfStr.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('LeftOnly '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfStr.yql new file mode 100644 index 0000000000..d589fcda91 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfStr.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Left '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnNoOpt1Opt2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnNoOpt1Opt2Str.yql new file mode 100644 index 0000000000..78921fa69b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnNoOpt1Opt2Str.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(table 'a) '(tableOpt3 'b) '('Left '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnOpt1NoOpt2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnOpt1NoOpt2Str.yql new file mode 100644 index 0000000000..09a21c9a81 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnOpt1NoOpt2Str.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(table 'b) '('Left '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnOpt1Opt2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnOpt1Opt2Str.yql new file mode 100644 index 0000000000..8f36e81eb5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnOpt1Opt2Str.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(tableOpt3 'b) '('Left '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnOptPartial1OptPartial2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnOptPartial1OptPartial2Str.yql new file mode 100644 index 0000000000..25e1eb9240 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnOptPartial1OptPartial2Str.yql @@ -0,0 +1,29 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt1a (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Member row 'subkey)) + '('value (Member row 'value)) + )) +))))) + +(let tableOpt1b (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Member row 'key)) + '('subkey (Just (Member row 'subkey))) + '('value (Member row 'value)) + )) +))))) + +(let join (EquiJoin '(tableOpt1a 'a) '(tableOpt1b 'b) '('Left '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnStr.yql new file mode 100644 index 0000000000..c644c56a26 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSelfTwoColumnStr.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Left '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSemiSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSemiSelfStr.yql new file mode 100644 index 0000000000..e9aaf3442f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiLeftSemiSelfStr.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('LeftSemi '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12FullSelfInt.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12FullSelfInt.yql new file mode 100644 index 0000000000..5409c45d54 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12FullSelfInt.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOptKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (FromString (Member row 'key) 'Uint32)) + '('subkey (Just (Member row 'subkey))) + '('value (FromString (Member row 'value) 'Uint32)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Uint32) (Uint32 '888))) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '999))) + )) +))))) +(let join (EquiJoin '(tableOptKVInt 'a) '(tableOptKVInt 'b) '('Full '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12FullSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12FullSelfStr.yql new file mode 100644 index 0000000000..64ba1df974 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12FullSelfStr.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(tableOpt3 'b) '('Right '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12InnerSelfInt.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12InnerSelfInt.yql new file mode 100644 index 0000000000..ed5b9c6896 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12InnerSelfInt.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOptKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (FromString (Member row 'key) 'Uint32)) + '('subkey (Just (Member row 'subkey))) + '('value (FromString (Member row 'value) 'Uint32)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Uint32) (Uint32 '888))) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '999))) + )) +))))) +(let join (EquiJoin '(tableOptKVInt 'a) '(tableOptKVInt 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12InnerSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12InnerSelfStr.yql new file mode 100644 index 0000000000..9ed83ad59e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12InnerSelfStr.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(tableOpt3 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12LeftSelfInt.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12LeftSelfInt.yql new file mode 100644 index 0000000000..4896831f5a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12LeftSelfInt.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOptKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (FromString (Member row 'key) 'Uint32)) + '('subkey (Just (Member row 'subkey))) + '('value (FromString (Member row 'value) 'Uint32)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Uint32) (Uint32 '888))) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '999))) + )) +))))) +(let join (EquiJoin '(tableOptKVInt 'a) '(tableOptKVInt 'b) '('Left '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12LeftSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12LeftSelfStr.yql new file mode 100644 index 0000000000..c7d3ee062d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12LeftSelfStr.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(tableOpt3 'b) '('Left '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12RightSelfInt.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12RightSelfInt.yql new file mode 100644 index 0000000000..69e10681b2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12RightSelfInt.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOptKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (FromString (Member row 'key) 'Uint32)) + '('subkey (Just (Member row 'subkey))) + '('value (FromString (Member row 'value) 'Uint32)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Uint32) (Uint32 '888))) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '999))) + )) +))))) +(let join (EquiJoin '(tableOptKVInt 'a) '(tableOptKVInt 'b) '('Right '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12RightSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12RightSelfStr.yql new file mode 100644 index 0000000000..64ba1df974 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey12RightSelfStr.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(tableOpt3 'b) '('Right '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1FullSelfInt.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1FullSelfInt.yql new file mode 100644 index 0000000000..e664996232 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1FullSelfInt.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOptKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (FromString (Member row 'key) 'Uint32)) + '('subkey (Just (Member row 'subkey))) + '('value (FromString (Member row 'value) 'Uint32)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Uint32) (Uint32 '888))) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '999))) + )) +))))) +(let join (EquiJoin '(tableOptKVInt 'a) '(tableKVInt 'b) '('Full '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1FullSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1FullSelfStr.yql new file mode 100644 index 0000000000..24de4a45d8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1FullSelfStr.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(table 'b) '('Right '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1InnerSelfInt.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1InnerSelfInt.yql new file mode 100644 index 0000000000..c2340bb816 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1InnerSelfInt.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOptKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (FromString (Member row 'key) 'Uint32)) + '('subkey (Just (Member row 'subkey))) + '('value (FromString (Member row 'value) 'Uint32)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Uint32) (Uint32 '888))) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '999))) + )) +))))) +(let join (EquiJoin '(tableOptKVInt 'a) '(tableKVInt 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1InnerSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1InnerSelfStr.yql new file mode 100644 index 0000000000..9fe63d8ec2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1InnerSelfStr.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(table 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1LeftSelfInt.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1LeftSelfInt.yql new file mode 100644 index 0000000000..4cfb26b64e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1LeftSelfInt.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOptKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (FromString (Member row 'key) 'Uint32)) + '('subkey (Just (Member row 'subkey))) + '('value (FromString (Member row 'value) 'Uint32)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Uint32) (Uint32 '888))) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '999))) + )) +))))) +(let join (EquiJoin '(tableOptKVInt 'a) '(tableKVInt 'b) '('Left '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1LeftSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1LeftSelfStr.yql new file mode 100644 index 0000000000..5fa76d8942 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1LeftSelfStr.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(table 'b) '('Left '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1RightSelfInt.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1RightSelfInt.yql new file mode 100644 index 0000000000..fed99eefc5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1RightSelfInt.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOptKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (FromString (Member row 'key) 'Uint32)) + '('subkey (Just (Member row 'subkey))) + '('value (FromString (Member row 'value) 'Uint32)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Uint32) (Uint32 '888))) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '999))) + )) +))))) +(let join (EquiJoin '(tableOptKVInt 'a) '(tableKVInt 'b) '('Right '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1RightSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1RightSelfStr.yql new file mode 100644 index 0000000000..24de4a45d8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey1RightSelfStr.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(table 'b) '('Right '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2FullSelfInt.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2FullSelfInt.yql new file mode 100644 index 0000000000..02b042ac3a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2FullSelfInt.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOptKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (FromString (Member row 'key) 'Uint32)) + '('subkey (Just (Member row 'subkey))) + '('value (FromString (Member row 'value) 'Uint32)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Uint32) (Uint32 '888))) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '999))) + )) +))))) +(let join (EquiJoin '(tableKVInt 'a) '(tableOptKVInt 'b) '('Full '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2FullSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2FullSelfStr.yql new file mode 100644 index 0000000000..ba2798678f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2FullSelfStr.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(table 'a) '(tableOpt3 'b) '('Right '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2InnerSelfInt.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2InnerSelfInt.yql new file mode 100644 index 0000000000..435fdc1a9c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2InnerSelfInt.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOptKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (FromString (Member row 'key) 'Uint32)) + '('subkey (Just (Member row 'subkey))) + '('value (FromString (Member row 'value) 'Uint32)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Uint32) (Uint32 '888))) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '999))) + )) +))))) +(let join (EquiJoin '(tableKVInt 'a) '(tableOptKVInt 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2InnerSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2InnerSelfStr.yql new file mode 100644 index 0000000000..d61db9da69 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2InnerSelfStr.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(table 'a) '(tableOpt3 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2LeftSelfInt.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2LeftSelfInt.yql new file mode 100644 index 0000000000..924287c0f9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2LeftSelfInt.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOptKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (FromString (Member row 'key) 'Uint32)) + '('subkey (Just (Member row 'subkey))) + '('value (FromString (Member row 'value) 'Uint32)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Uint32) (Uint32 '888))) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '999))) + )) +))))) +(let join (EquiJoin '(tableKVInt 'a) '(tableOptKVInt 'b) '('Left '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2LeftSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2LeftSelfStr.yql new file mode 100644 index 0000000000..3d1c3605fc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2LeftSelfStr.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(table 'a) '(tableOpt3 'b) '('Left '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2RightSelfInt.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2RightSelfInt.yql new file mode 100644 index 0000000000..a2a085a722 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2RightSelfInt.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOptKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (FromString (Member row 'key) 'Uint32)) + '('subkey (Just (Member row 'subkey))) + '('value (FromString (Member row 'value) 'Uint32)) + )) +))))) +(let tableKVInt (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Coalesce (FromString (Member row 'key) 'Uint32) (Uint32 '888))) + '('subkey (Just (Member row 'subkey))) + '('value (Coalesce (FromString (Member row 'value) 'Uint32) (Uint32 '999))) + )) +))))) +(let join (EquiJoin '(tableKVInt 'a) '(tableOptKVInt 'b) '('Right '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2RightSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2RightSelfStr.yql new file mode 100644 index 0000000000..ba2798678f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiOptKey2RightSelfStr.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(table 'a) '(tableOpt3 'b) '('Right '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightOnlySelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightOnlySelfStr.yql new file mode 100644 index 0000000000..b528c14467 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightOnlySelfStr.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('RightOnly '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfStr.yql new file mode 100644 index 0000000000..76b372e52f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfStr.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Right '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnNoOpt1Opt2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnNoOpt1Opt2Str.yql new file mode 100644 index 0000000000..155db305bc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnNoOpt1Opt2Str.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(table 'a) '(tableOpt3 'b) '('Right '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnOpt1NoOpt2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnOpt1NoOpt2Str.yql new file mode 100644 index 0000000000..dc0928a52c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnOpt1NoOpt2Str.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(table 'b) '('Right '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnOpt1Opt2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnOpt1Opt2Str.yql new file mode 100644 index 0000000000..0d550e7db3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnOpt1Opt2Str.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt3 (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))) + )) +))))) +(let join (EquiJoin '(tableOpt3 'a) '(tableOpt3 'b) '('Right '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnOptPartial1OptPartial2Str.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnOptPartial1OptPartial2Str.yql new file mode 100644 index 0000000000..9d539854bd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnOptPartial1OptPartial2Str.yql @@ -0,0 +1,29 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableOpt1a (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Member row 'subkey)) + '('value (Member row 'value)) + )) +))))) + +(let tableOpt1b (Map table (lambda '(row) (block '( + (return (AsStruct + '('key (Member row 'key)) + '('subkey (Just (Member row 'subkey))) + '('value (Member row 'value)) + )) +))))) + +(let join (EquiJoin '(tableOpt1a 'a) '(tableOpt1b 'b) '('Right '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnStr.yql new file mode 100644 index 0000000000..5a6ff8cd0f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSelfTwoColumnStr.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Right '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSemiSelfStr.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSemiSelfStr.yql new file mode 100644 index 0000000000..71c2d26461 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/EquiRightSemiSelfStr.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('RightSemi '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/ExtractRenameFromFlatMapOverJoin.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/ExtractRenameFromFlatMapOverJoin.yql new file mode 100644 index 0000000000..33f059a964 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/ExtractRenameFromFlatMapOverJoin.yql @@ -0,0 +1,42 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let list1 (AsList + (AsStruct '('key1 (Int32 '1)) '('value1 (String 'A))) + (AsStruct '('key1 (Int32 '7)) '('value1 (String 'B))) + (AsStruct '('key1 (Int32 '4)) '('value1 (String 'C))) + (AsStruct '('key1 (Int32 '4)) '('value1 (String 'D))) +)) + +(let list2 (AsList + (AsStruct '('key2 (Int32 '9)) '('value2 (String 'Z))) + (AsStruct '('key2 (Int32 '4)) '('value2 (String 'Y))) + (AsStruct '('key2 (Int32 '3)) '('value2 (String 'X))) + (AsStruct '('key2 (Int32 '4)) '('value2 (String 'W))) + (AsStruct '('key2 (Int32 '8)) '('value2 (String 'V))) +)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let list (Map joinInner (lambda '(x) (block '( + (return (AsStruct + '('"a.key1" (Member x '"a.key1")) + '('"q" (Member x '"a.value1")) + '('"f.value2" (Member x '"b.value2")) + )) +))))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) list '('('type)))) + +(let joinInner2 (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) + '('('rename '"a.key1" 'z) '('rename '"b.key2" '"")))) +(let list2 (Map joinInner2 (lambda '(x) (block '( + (return (AsStruct + '('"yy" (Member x '"z")) + '('"q" (Member x '"b.value2")) + )) +))))) + +(let world (Write! world res_sink (Key) list2 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenInner.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenInner.yql new file mode 100644 index 0000000000..dee596e70a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenInner.yql @@ -0,0 +1,30 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey1 (Just (Member item 'subkey))) + '('value1 (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey2 (Just (Member item 'subkey))) + '('value2 (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '('('flatten)))) + +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"key") (Member row '"subkey1")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenInner3.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenInner3.yql new file mode 100644 index 0000000000..ded633225d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenInner3.yql @@ -0,0 +1,39 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey1 (Just (Member item 'subkey))) + '('value1 (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey2 (Just (Member item 'subkey))) + '('value2 (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey3 (Just (Member item 'subkey))) + '('value3 (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key" ) '()) + '('('flatten)))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenInnerTwoColumns.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenInnerTwoColumns.yql new file mode 100644 index 0000000000..4cbe3482ed --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenInnerTwoColumns.yql @@ -0,0 +1,30 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value1 (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value2 (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '('('flatten)))) + +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"key") (Member row '"subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenLeft.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenLeft.cfg new file mode 100644 index 0000000000..8402f5cd5f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenLeft.cfg @@ -0,0 +1,3 @@ +res result.txt +in Input4 input4.txt +in Input5 input5.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenLeft.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenLeft.yql new file mode 100644 index 0000000000..9533ee9fb8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenLeft.yql @@ -0,0 +1,26 @@ +( + (let data.source (DataSource 'yt 'plato)) + (let data.sink (DataSink 'yt 'plato)) + (let input_left (Read! world data.source (Key '('table (String 'Input4))) (Void) '())) + (let world (Left! input_left)) + (let input_left (Right! input_left)) + + (let input_right (Read! world data.source (Key '('table (String 'Input5))) (Void) '())) + (let world (Left! input_right)) + (let input_right (Right! input_right)) + + (let output (EquiJoin '((RemoveSystemMembers input_left) 'left) '((RemoveSystemMembers input_right) 'right) + '('Left 'left 'right '('left 'id) '('right 'id) '()) '('('flatten)) + )) + + (let output (Map output (lambda '(item) (block '( + (let item (AddMember item 'val (String '""))) + (return item) + ))))) + + (let res_sink (DataSink 'result)) + (let world (Write! world res_sink (Key) output '('('type)))) + (let world (Commit! world res_sink)) + + (return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenLeftSemi.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenLeftSemi.yql new file mode 100644 index 0000000000..2b3166643e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenLeftSemi.yql @@ -0,0 +1,30 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey1 (Just (Member item 'subkey))) + '('value1 (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey2 (Just (Member item 'subkey))) + '('value2 (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('LeftSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '('('flatten)))) + +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"key") (Member row '"subkey1")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenLeftSemi3.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenLeftSemi3.yql new file mode 100644 index 0000000000..4572699337 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/FlattenLeftSemi3.yql @@ -0,0 +1,39 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey1 (Just (Member item 'subkey))) + '('value1 (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey2 (Just (Member item 'subkey))) + '('value2 (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + +(let table3 (Map table3 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey3 (Just (Member item 'subkey))) + '('value3 (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('LeftSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key" ) '()) + '('('flatten)))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/HintLeftSmallInnerJoin.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintLeftSmallInnerJoin.yql new file mode 100644 index 0000000000..d0c8c821b6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintLeftSmallInnerJoin.yql @@ -0,0 +1,30 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (String '1))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '( + '('left 'small) + )) + '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/HintLeftSmallInnerJoinFat.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintLeftSmallInnerJoinFat.yql new file mode 100644 index 0000000000..94718f84d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintLeftSmallInnerJoinFat.yql @@ -0,0 +1,30 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (String '1))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (String '800))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '( + '('left 'small) + )) + '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/HintLeftUniqueRightMap.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintLeftUniqueRightMap.yql new file mode 100644 index 0000000000..d77b848dc7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintLeftUniqueRightMap.yql @@ -0,0 +1,29 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Right '"a" '"b" '('"a" '"key") '('"b" '"key" ) '('('left 'unique))) + '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightSmallInnerJoin.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightSmallInnerJoin.yql new file mode 100644 index 0000000000..6e842ae76b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightSmallInnerJoin.yql @@ -0,0 +1,30 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (String '1))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '( + '('right 'small) + )) + '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightSmallInnerJoinFat.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightSmallInnerJoinFat.yql new file mode 100644 index 0000000000..c9e4a7e0f6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightSmallInnerJoinFat.yql @@ -0,0 +1,30 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (String '800))) + '('subkey (Just (String '1))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '( + '('right 'small) + )) + '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightUniqueInnerMap.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightUniqueInnerMap.yql new file mode 100644 index 0000000000..16a90e3314 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightUniqueInnerMap.yql @@ -0,0 +1,29 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '('('right 'unique))) + '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightUniqueLeftMap.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightUniqueLeftMap.yql new file mode 100644 index 0000000000..a3e4e456ea --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightUniqueLeftMap.yql @@ -0,0 +1,29 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Left '"a" '"b" '('"a" '"key") '('"b" '"key" ) '('('right 'unique))) + '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightUniqueLeftSemiShardedMap.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightUniqueLeftSemiShardedMap.yql new file mode 100644 index 0000000000..c726a4c417 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/HintRightUniqueLeftSemiShardedMap.yql @@ -0,0 +1,30 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"150")) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinshardcount" '"2")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let table1 (Map table1 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let table2 (Map table2 (lambda '(item) (AsStruct + '('key (Just (Member item 'key))) + '('subkey (Just (Member item 'subkey))) + '('value (Just (Member item 'value))))))) + +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('LeftSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '('('right 'unique))) + '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/InOutSettings.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoin/InOutSettings.cfg new file mode 100644 index 0000000000..3673712415 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InOutSettings.cfg @@ -0,0 +1,3 @@ +res result.txt +in Input InputSelf.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/InOutSettings.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/InOutSettings.yql new file mode 100644 index 0000000000..707b389f4b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InOutSettings.yql @@ -0,0 +1,26 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let tableLeft (Right! x)) + +(let sorted (Sort tableLeft (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) +(let world (Commit! world mr_sink)) + +(let x (Read! world mr_source (Key '('table (String '"Output"))) (Void) '())) +(let world (Left! x)) +(let tableRight (Right! x)) + +(let tableLeft (Take tableLeft (Uint64 '3))) +(let tableRight (Filter tableRight (lambda '(item) (Coalesce (< (Member item '"key") (String '"100")) (Bool 'false))))) + +(let join (EquiJoin '(tableLeft 'a) '(tableRight 'b) '('Inner '"a" '"b" '('"a" '"value") '('"b" '"value" ) '()) '())) +(let join (Sort join (Bool 'true) (lambda '(item) (Member item '"a.key")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Take join (Uint64 '2)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/InputInt8.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputInt8.txt new file mode 100644 index 0000000000..c059f46f5b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputInt8.txt @@ -0,0 +1,5 @@ +{"key"=-1;"value"="Int8_a"}; +{"key"=127;"value"="Int8_b"}; +{"key"=0;"value"="Int8_c"}; +{"key"=1;"value"="Int8_d"}; +{"key"=2;"value"="Int8_e"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/InputInt8.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputInt8.txt.attr new file mode 100644 index 0000000000..d89274ff75 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputInt8.txt.attr @@ -0,0 +1,6 @@ +{"_yql_row_spec"={ + "Type"=["StructType";[ + ["key";["DataType";"Int8"]]; + ["value";["DataType";"String"]]] + ]; +}} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/InputInt8Opt.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputInt8Opt.txt new file mode 100644 index 0000000000..53ffddbb48 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputInt8Opt.txt @@ -0,0 +1,5 @@ +{"key"=-1;"value"="Int8Opt_a"}; +{"key"=127;"value"="Int8Opt_b"}; +{"key"=0;"value"="Int8Opt_c"}; +{"key"=1;"value"="Int8Opt_d"}; +{"key"=2;"value"="Int8Opt_e"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/InputInt8Opt.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputInt8Opt.txt.attr new file mode 100644 index 0000000000..cbb7ba3fd9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputInt8Opt.txt.attr @@ -0,0 +1,6 @@ +{"_yql_row_spec"={ + "Type"=["StructType";[ + ["key";["OptionalType";["DataType";"Int8"]]]; + ["value";["DataType";"String"]]] + ]; +}} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/InputSelf.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputSelf.txt new file mode 100644 index 0000000000..8ed0317c19 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputSelf.txt @@ -0,0 +1,8 @@ +{"key"="075";"subkey"=".";"value"="abc"}; +{"key"="911";"subkey"=".";"value"="kkk"}; +{"key"="023";"subkey"=".";"value"="075"}; +{"key"="527";"subkey"=".";"value"="bbb"}; +{"key"="037";"subkey"=".";"value"="ddd"}; +{"key"="761";"subkey"=".";"value"="023"}; +{"key"="200";"subkey"=".";"value"="qqq"}; +{"key"="150";"subkey"=".";"value"="zzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/InputSelf.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputSelf.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputSelf.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/EquiJoin/InputSelf2.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputSelf2.txt new file mode 100644 index 0000000000..cf8cf7a1e9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputSelf2.txt @@ -0,0 +1,8 @@ +{"key"="075";"subkey"="1";"value"="7"}; +{"key"="x911";"subkey"="2";"value"="6"}; +{"key"="x023";"subkey"="3";"value"="3"}; +{"key"="x527";"subkey"="4";"value"="x023"}; +{"key"="x037";"subkey"="5";"value"="075"}; +{"key"="x761";"subkey"="6";"value"="2"}; +{"key"="x200";"subkey"="7";"value"="075"}; +{"key"="150";"subkey"="8";"value"="2"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/InputSelf2.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputSelf2.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputSelf2.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/EquiJoin/InputUint32.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint32.txt new file mode 100644 index 0000000000..5508f63735 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint32.txt @@ -0,0 +1,5 @@ +{"key"=255u;"value"="Uint32_a"}; +{"key"=383u;"value"="Uint32_b"}; +{"key"=0u;"value"="Uint32_c"}; +{"key"=1u;"value"="Uint32_d"}; +{"key"=2u;"value"="Uint32_e"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint32.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint32.txt.attr new file mode 100644 index 0000000000..5ba9847c97 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint32.txt.attr @@ -0,0 +1,6 @@ +{"_yql_row_spec"={ + "Type"=["StructType";[ + ["key";["DataType";"Uint32"]]; + ["value";["DataType";"String"]]] + ]; +}} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint8.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint8.txt new file mode 100644 index 0000000000..96864d084c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint8.txt @@ -0,0 +1,5 @@ +{"key"=255u;"value"="Uint8_a"}; +{"key"=127u;"value"="Uint8_b"}; +{"key"=0u;"value"="Uint8_c"}; +{"key"=1u;"value"="Uint8_d"}; +{"key"=2u;"value"="Uint8_e"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint8.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint8.txt.attr new file mode 100644 index 0000000000..8d7e3bcc24 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint8.txt.attr @@ -0,0 +1,6 @@ +{"_yql_row_spec"={ + "Type"=["StructType";[ + ["key";["DataType";"Uint8"]]; + ["value";["DataType";"String"]]] + ]; +}} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint8Opt.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint8Opt.txt new file mode 100644 index 0000000000..3468f1080f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint8Opt.txt @@ -0,0 +1,5 @@ +{"key"=255u;"value"="Uint8Opt_a"}; +{"key"=127u;"value"="Uint8Opt_b"}; +{"key"=0u;"value"="Uint8Opt_c"}; +{"key"=1u;"value"="Uint8Opt_d"}; +{"key"=2u;"value"="Uint8Opt_e"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint8Opt.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint8Opt.txt.attr new file mode 100644 index 0000000000..e3b512108c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/InputUint8Opt.txt.attr @@ -0,0 +1,6 @@ +{"_yql_row_spec"={ + "Type"=["StructType";[ + ["key";["OptionalType";["DataType";"Uint8"]]]; + ["value";["DataType";"String"]]] + ]; +}} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMem.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMem.yql new file mode 100644 index 0000000000..59f07eb137 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMem.yql @@ -0,0 +1,42 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('key1 (Int32 '1)) '('value1 (String 'A))) + (AsStruct '('key1 (Int32 '4)) '('value1 (String 'C))) + (AsStruct '('key1 (Int32 '4)) '('value1 (String 'D))) +)) + +(let list2 (AsList + (AsStruct '('key2 (Uint64 '2)) '('value2 (String 'U))) + (AsStruct '('key2 (Uint64 '4)) '('value2 (String 'Y))) + (AsStruct '('key2 (Uint64 '4)) '('value2 (String 'W))) +)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinFull '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) +(let world (Write! world res_sink (Key) joinCross '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMem3.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMem3.yql new file mode 100644 index 0000000000..6245dd77bd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMem3.yql @@ -0,0 +1,79 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('key1 (Int32 '1)) '('value1 (String 'A))) + (AsStruct '('key1 (Int32 '7)) '('value1 (String 'B))) + (AsStruct '('key1 (Int32 '4)) '('value1 (String 'C))) + (AsStruct '('key1 (Int32 '4)) '('value1 (String 'D))) +)) + +(let list2 (AsList + (AsStruct '('key2 (Int32 '9)) '('value2 (String 'Z))) + (AsStruct '('key2 (Int32 '4)) '('value2 (String 'Y))) + (AsStruct '('key2 (Int32 '3)) '('value2 (String 'X))) + (AsStruct '('key2 (Int32 '4)) '('value2 (String 'W))) + (AsStruct '('key2 (Int32 '8)) '('value2 (String 'V))) +)) + +(let list3 (AsList + (AsStruct '('key3 (Int32 '1)) '('value3 (String 'G))) + (AsStruct '('key3 (Int32 '4)) '('value3 (String 'H))) + (AsStruct '('key3 (Int32 '2)) '('value3 (String 'I))) + (AsStruct '('key3 (Int32 '3)) '('value3 (String 'J))) + (AsStruct '('key3 (Int32 '3)) '('value3 (String 'K))) +)) + +(let joinInnerInner (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Inner '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinInnerLeft (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Inner '('Left 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinInnerRight (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Inner '('Right 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinInnerFull (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Inner '('Full 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinInnerLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Inner '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('a 'key1) '('c 'key3) '()) '())) +(let joinInnerRightOnly (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Inner '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinInnerExclusion (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Inner '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinInnerLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Inner '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('a 'key1) '('c 'key3) '()) '())) +(let joinInnerRightSemi (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Inner '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinInnerCross (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Inner '('Cross 'a 'b '() '() '()) 'c '('b 'key2) '('c 'key3) '()) '())) + +(let joinFullInner (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Full '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinFullLeft (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Full '('Left 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinFullRight (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Full '('Right 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinFullFull (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Full '('Full 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinFullLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Full '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('a 'key1) '('c 'key3) '()) '())) +(let joinFullRightOnly (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Full '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinFullExclusion (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Full '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinFullLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Full '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('a 'key1) '('c 'key3) '()) '())) +(let joinFullRightSemi (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Full '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinFullCross (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Full '('Cross 'a 'b '() '() '()) 'c '('b 'key2) '('c 'key3) '()) '())) + +(let joinCrossCross (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Cross '('Cross 'a 'b '() '() '()) 'c '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInnerInner '('('type)))) +(let world (Write! world res_sink (Key) joinInnerLeft '('('type)))) +(let world (Write! world res_sink (Key) joinInnerRight '('('type)))) +(let world (Write! world res_sink (Key) joinInnerFull '('('type)))) +(let world (Write! world res_sink (Key) joinInnerLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinInnerRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinInnerExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinInnerLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinInnerRightSemi '('('type)))) +(let world (Write! world res_sink (Key) joinInnerCross '('('type)))) + +(let world (Write! world res_sink (Key) joinFullInner '('('type)))) +(let world (Write! world res_sink (Key) joinFullLeft '('('type)))) +(let world (Write! world res_sink (Key) joinFullRight '('('type)))) +(let world (Write! world res_sink (Key) joinFullFull '('('type)))) +(let world (Write! world res_sink (Key) joinFullLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinFullRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinFullExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinFullLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinFullRightSemi '('('type)))) +(let world (Write! world res_sink (Key) joinFullCross '('('type)))) + +(let world (Write! world res_sink (Key) joinCrossCross '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMem3Alias12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMem3Alias12.yql new file mode 100644 index 0000000000..0063b7b7ef --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMem3Alias12.yql @@ -0,0 +1,71 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('a.key1 (Int32 '1)) '('k.value1 (String 'A))) + (AsStruct '('a.key1 (Int32 '7)) '('k.value1 (String 'B))) + (AsStruct '('a.key1 (Int32 '4)) '('k.value1 (String 'C))) + (AsStruct '('a.key1 (Int32 '4)) '('k.value1 (String 'D))) +)) + +(let list2 (AsList + (AsStruct '('b.key2 (Int32 '9)) '('l.value2 (String 'Z))) + (AsStruct '('b.key2 (Int32 '4)) '('l.value2 (String 'Y))) + (AsStruct '('b.key2 (Int32 '3)) '('l.value2 (String 'X))) + (AsStruct '('b.key2 (Int32 '4)) '('l.value2 (String 'W))) + (AsStruct '('b.key2 (Int32 '8)) '('l.value2 (String 'V))) +)) + +(let list3 (AsList + (AsStruct '('c.key3 (Int32 '1)) '('m.value3 (String 'G))) + (AsStruct '('c.key3 (Int32 '4)) '('m.value3 (String 'H))) + (AsStruct '('c.key3 (Int32 '2)) '('m.value3 (String 'I))) + (AsStruct '('c.key3 (Int32 '3)) '('m.value3 (String 'J))) + (AsStruct '('c.key3 (Int32 '3)) '('m.value3 (String 'K))) +)) + +(let joinInnerInner (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Inner '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinInnerLeft (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Inner '('Left 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinInnerRight (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Inner '('Right 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinInnerFull (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Inner '('Full 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinInnerLeftOnly (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Inner '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('a 'key1) '('c 'key3) '()) '())) +(let joinInnerRightOnly (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Inner '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinInnerExclusion (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Inner '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinInnerLeftSemi (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Inner '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('a 'key1) '('c 'key3) '()) '())) +(let joinInnerRightSemi (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Inner '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) + +(let joinFullInner (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Full '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinFullLeft (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Full '('Left 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinFullRight (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Full '('Right 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinFullFull (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Full '('Full 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinFullLeftOnly (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Full '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('a 'key1) '('c 'key3) '()) '())) +(let joinFullRightOnly (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Full '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinFullExclusion (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Full '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) +(let joinFullLeftSemi (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Full '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('a 'key1) '('c 'key3) '()) '())) +(let joinFullRightSemi (EquiJoin '(list1 '('a 'k)) '(list2 '('b 'l)) '(list3 '('c 'm)) '('Full '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInnerInner '('('type)))) +(let world (Write! world res_sink (Key) joinInnerLeft '('('type)))) +(let world (Write! world res_sink (Key) joinInnerRight '('('type)))) +(let world (Write! world res_sink (Key) joinInnerFull '('('type)))) +(let world (Write! world res_sink (Key) joinInnerLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinInnerRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinInnerExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinInnerLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinInnerRightSemi '('('type)))) + +(let world (Write! world res_sink (Key) joinFullInner '('('type)))) +(let world (Write! world res_sink (Key) joinFullLeft '('('type)))) +(let world (Write! world res_sink (Key) joinFullRight '('('type)))) +(let world (Write! world res_sink (Key) joinFullFull '('('type)))) +(let world (Write! world res_sink (Key) joinFullLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinFullRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinFullExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinFullLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinFullRightSemi '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMem3Rename.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMem3Rename.yql new file mode 100644 index 0000000000..7807ba6e08 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMem3Rename.yql @@ -0,0 +1,36 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('key1 (Int32 '1)) '('value1 (String 'A))) + (AsStruct '('key1 (Int32 '7)) '('value1 (String 'B))) + (AsStruct '('key1 (Int32 '4)) '('value1 (String 'C))) + (AsStruct '('key1 (Int32 '4)) '('value1 (String 'D))) +)) + +(let list2 (AsList + (AsStruct '('key2 (Int32 '9)) '('value2 (String 'Z))) + (AsStruct '('key2 (Int32 '4)) '('value2 (String 'Y))) + (AsStruct '('key2 (Int32 '3)) '('value2 (String 'X))) + (AsStruct '('key2 (Int32 '4)) '('value2 (String 'W))) + (AsStruct '('key2 (Int32 '8)) '('value2 (String 'V))) +)) + +(let list3 (AsList + (AsStruct '('key3 (Int32 '1)) '('value3 (String 'G))) + (AsStruct '('key3 (Int32 '4)) '('value3 (String 'H))) + (AsStruct '('key3 (Int32 '2)) '('value3 (String 'I))) + (AsStruct '('key3 (Int32 '3)) '('value3 (String 'J))) + (AsStruct '('key3 (Int32 '3)) '('value3 (String 'K))) +)) + +(let joinInnerInner (EquiJoin '(list1 'a) '(list2 'b) '(list3 'c) '('Inner '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) 'c '('b 'key2) '('c 'key3) '()) +'('('rename '"a.key1" 'col1) '('rename '"b.value2" '"") '('rename '"c.key3" 'ccc)))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInnerInner '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemAliasOne1.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemAliasOne1.yql new file mode 100644 index 0000000000..549fa2d302 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemAliasOne1.yql @@ -0,0 +1,43 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('a.key1 (Just (Int32 '1))) '('a.value1 (Just (String 'A)))) + (AsStruct '('a.key1 (Just (Int32 '7))) '('a.value1 (Just (String 'B)))) + (AsStruct '('a.key1 (Just (Int32 '4))) '('a.value1 (Just (String 'C)))) + (AsStruct '('a.key1 (Just (Int32 '4))) '('a.value1 (Just (String 'D)))) +)) + +(let list2 (AsList + (AsStruct '('key2 (Just (Int32 '9))) '('value2 (Just (String 'Z)))) + (AsStruct '('key2 (Just (Int32 '4))) '('value2 (Just (String 'Y)))) + (AsStruct '('key2 (Just (Int32 '3))) '('value2 (Just (String 'X)))) + (AsStruct '('key2 (Just (Int32 '4))) '('value2 (Just (String 'W)))) + (AsStruct '('key2 (Just (Int32 '8))) '('value2 (Just (String 'V)))) +)) + +(let joinInner (EquiJoin '(list1 '('a)) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 '('a)) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 '('a)) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 '('a)) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 '('a)) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 '('a)) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 '('a)) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 '('a)) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 '('a)) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinFull '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemAliasOne12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemAliasOne12.yql new file mode 100644 index 0000000000..50ee09cda0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemAliasOne12.yql @@ -0,0 +1,43 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('a.key1 (Just (Int32 '1))) '('a.value1 (Just (String 'A)))) + (AsStruct '('a.key1 (Just (Int32 '7))) '('a.value1 (Just (String 'B)))) + (AsStruct '('a.key1 (Just (Int32 '4))) '('a.value1 (Just (String 'C)))) + (AsStruct '('a.key1 (Just (Int32 '4))) '('a.value1 (Just (String 'D)))) +)) + +(let list2 (AsList + (AsStruct '('b.key2 (Just (Int32 '9))) '('b.value2 (Just (String 'Z)))) + (AsStruct '('b.key2 (Just (Int32 '4))) '('b.value2 (Just (String 'Y)))) + (AsStruct '('b.key2 (Just (Int32 '3))) '('b.value2 (Just (String 'X)))) + (AsStruct '('b.key2 (Just (Int32 '4))) '('b.value2 (Just (String 'W)))) + (AsStruct '('b.key2 (Just (Int32 '8))) '('b.value2 (Just (String 'V)))) +)) + +(let joinInner (EquiJoin '(list1 '('a)) '(list2 '('b)) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 '('a)) '(list2 '('b)) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 '('a)) '(list2 '('b)) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 '('a)) '(list2 '('b)) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 '('a)) '(list2 '('b)) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 '('a)) '(list2 '('b)) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 '('a)) '(list2 '('b)) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 '('a)) '(list2 '('b)) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 '('a)) '(list2 '('b)) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinFull '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemAliasOne2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemAliasOne2.yql new file mode 100644 index 0000000000..374fafce96 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemAliasOne2.yql @@ -0,0 +1,43 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A)))) + (AsStruct '('key1 (Just (Int32 '7))) '('value1 (Just (String 'B)))) + (AsStruct '('key1 (Just (Int32 '4))) '('value1 (Just (String 'C)))) + (AsStruct '('key1 (Just (Int32 '4))) '('value1 (Just (String 'D)))) +)) + +(let list2 (AsList + (AsStruct '('b.key2 (Just (Int32 '9))) '('b.value2 (Just (String 'Z)))) + (AsStruct '('b.key2 (Just (Int32 '4))) '('b.value2 (Just (String 'Y)))) + (AsStruct '('b.key2 (Just (Int32 '3))) '('b.value2 (Just (String 'X)))) + (AsStruct '('b.key2 (Just (Int32 '4))) '('b.value2 (Just (String 'W)))) + (AsStruct '('b.key2 (Just (Int32 '8))) '('b.value2 (Just (String 'V)))) +)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 '('b)) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 '('b)) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 '('b)) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 '('b)) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 '('b)) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 '('b)) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 '('b)) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 '('b)) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 '('b)) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinFull '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemAliasTwo12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemAliasTwo12.yql new file mode 100644 index 0000000000..e9c47c9c76 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemAliasTwo12.yql @@ -0,0 +1,43 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('a.key1 (Just (Int32 '1))) '('c.value1 (Just (String 'A)))) + (AsStruct '('a.key1 (Just (Int32 '7))) '('c.value1 (Just (String 'B)))) + (AsStruct '('a.key1 (Just (Int32 '4))) '('c.value1 (Just (String 'C)))) + (AsStruct '('a.key1 (Just (Int32 '4))) '('c.value1 (Just (String 'D)))) +)) + +(let list2 (AsList + (AsStruct '('b.key2 (Just (Int32 '9))) '('d.value2 (Just (String 'Z)))) + (AsStruct '('b.key2 (Just (Int32 '4))) '('d.value2 (Just (String 'Y)))) + (AsStruct '('b.key2 (Just (Int32 '3))) '('d.value2 (Just (String 'X)))) + (AsStruct '('b.key2 (Just (Int32 '4))) '('d.value2 (Just (String 'W)))) + (AsStruct '('b.key2 (Just (Int32 '8))) '('d.value2 (Just (String 'V)))) +)) + +(let joinInner (EquiJoin '(list1 '('a 'c)) '(list2 '('b 'd)) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 '('a 'c)) '(list2 '('b 'd)) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 '('a 'c)) '(list2 '('b 'd)) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 '('a 'c)) '(list2 '('b 'd)) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 '('a 'c)) '(list2 '('b 'd)) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 '('a 'c)) '(list2 '('b 'd)) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 '('a 'c)) '(list2 '('b 'd)) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 '('a 'c)) '(list2 '('b 'd)) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 '('a 'c)) '(list2 '('b 'd)) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinFull '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemDiffIntTypes.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemDiffIntTypes.yql new file mode 100644 index 0000000000..ef2ce92878 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemDiffIntTypes.yql @@ -0,0 +1,43 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('key1 (Int32 '1)) '('value1 (String 'A))) + (AsStruct '('key1 (Int32 '7)) '('value1 (String 'B))) + (AsStruct '('key1 (Int32 '4)) '('value1 (String 'C))) + (AsStruct '('key1 (Int32 '4)) '('value1 (String 'D))) +)) + +(let list2 (AsList + (AsStruct '('key2 (Uint64 '9)) '('value2 (String 'Z))) + (AsStruct '('key2 (Uint64 '4)) '('value2 (String 'Y))) + (AsStruct '('key2 (Uint64 '3)) '('value2 (String 'X))) + (AsStruct '('key2 (Uint64 '4)) '('value2 (String 'W))) + (AsStruct '('key2 (Uint64 '8)) '('value2 (String 'V))) +)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinFull '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemOpt1.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemOpt1.yql new file mode 100644 index 0000000000..7e0a5a7fc2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemOpt1.yql @@ -0,0 +1,45 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A)))) + (AsStruct '('key1 (Just (Int32 '4))) '('value1 (Just (String 'C)))) + (AsStruct '('key1 (Just (Int32 '4))) '('value1 (Just (String 'D)))) + (AsStruct '('key1 (Nothing (OptionalType (DataType 'Int32)))) '('value1 (Just (String 'E)))) + (AsStruct '('key1 (Nothing (OptionalType (DataType 'Int32)))) '('value1 (Just (String 'F)))) + (AsStruct '('key1 (Nothing (OptionalType (DataType 'Int32)))) '('value1 (Just (String 'G)))) +)) + +(let list2 (AsList + (AsStruct '('key2 (Uint64 '2)) '('value2 (String 'U))) + (AsStruct '('key2 (Uint64 '4)) '('value2 (String 'Y))) + (AsStruct '('key2 (Uint64 '4)) '('value2 (String 'W))) +)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinFull '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) +(let world (Write! world res_sink (Key) joinCross '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemOpt1Opt2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemOpt1Opt2.yql new file mode 100644 index 0000000000..759d3983ac --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemOpt1Opt2.yql @@ -0,0 +1,48 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A)))) + (AsStruct '('key1 (Just (Int32 '4))) '('value1 (Just (String 'C)))) + (AsStruct '('key1 (Just (Int32 '4))) '('value1 (Just (String 'D)))) + (AsStruct '('key1 (Nothing (OptionalType (DataType 'Int32)))) '('value1 (Just (String 'E)))) + (AsStruct '('key1 (Nothing (OptionalType (DataType 'Int32)))) '('value1 (Just (String 'F)))) + (AsStruct '('key1 (Nothing (OptionalType (DataType 'Int32)))) '('value1 (Just (String 'G)))) +)) + +(let list2 (AsList + (AsStruct '('key2 (Just (Uint64 '2))) '('value2 (Just (String 'U)))) + (AsStruct '('key2 (Just (Uint64 '4))) '('value2 (Just (String 'Y)))) + (AsStruct '('key2 (Just (Uint64 '4))) '('value2 (Just (String 'W)))) + (AsStruct '('key2 (Nothing (OptionalType (DataType 'Uint64)))) '('value2 (Just (String 'P)))) + (AsStruct '('key2 (Nothing (OptionalType (DataType 'Uint64)))) '('value2 (Just (String 'Q)))) + (AsStruct '('key2 (Nothing (OptionalType (DataType 'Uint64)))) '('value2 (Just (String 'R)))) +)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinFull '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) +(let world (Write! world res_sink (Key) joinCross '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemOpt2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemOpt2.yql new file mode 100644 index 0000000000..861a63112f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemOpt2.yql @@ -0,0 +1,45 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('key1 (Int32 '1)) '('value1 (String 'A))) + (AsStruct '('key1 (Int32 '4)) '('value1 (String 'C))) + (AsStruct '('key1 (Int32 '4)) '('value1 (String 'D))) +)) + +(let list2 (AsList + (AsStruct '('key2 (Just (Uint64 '2))) '('value2 (Just (String 'U)))) + (AsStruct '('key2 (Just (Uint64 '4))) '('value2 (Just (String 'Y)))) + (AsStruct '('key2 (Just (Uint64 '4))) '('value2 (Just (String 'W)))) + (AsStruct '('key2 (Nothing (OptionalType (DataType 'Uint64)))) '('value2 (Just (String 'P)))) + (AsStruct '('key2 (Nothing (OptionalType (DataType 'Uint64)))) '('value2 (Just (String 'Q)))) + (AsStruct '('key2 (Nothing (OptionalType (DataType 'Uint64)))) '('value2 (Just (String 'R)))) +)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinFull '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) +(let world (Write! world res_sink (Key) joinCross '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemRename.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemRename.yql new file mode 100644 index 0000000000..14636284d2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemRename.yql @@ -0,0 +1,28 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('key1 (Int32 '1)) '('value1 (String 'A))) + (AsStruct '('key1 (Int32 '7)) '('value1 (String 'B))) + (AsStruct '('key1 (Int32 '4)) '('value1 (String 'C))) + (AsStruct '('key1 (Int32 '4)) '('value1 (String 'D))) +)) + +(let list2 (AsList + (AsStruct '('key2 (Int32 '9)) '('value2 (String 'Z))) + (AsStruct '('key2 (Int32 '4)) '('value2 (String 'Y))) + (AsStruct '('key2 (Int32 '3)) '('value2 (String 'X))) + (AsStruct '('key2 (Int32 '4)) '('value2 (String 'W))) + (AsStruct '('key2 (Int32 '8)) '('value2 (String 'V))) +)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) + '('('rename '"a.key1" 'q) '('rename '"b.value2" '"")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemTwoColumns.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemTwoColumns.yql new file mode 100644 index 0000000000..0b21ecc24d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemTwoColumns.yql @@ -0,0 +1,43 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('key1a (Int32 '1)) '('key1b (Uint32 '1)) '('value1 (String 'A))) + (AsStruct '('key1a (Int32 '7)) '('key1b (Uint32 '1)) '('value1 (String 'B))) + (AsStruct '('key1a (Int32 '4)) '('key1b (Uint32 '2)) '('value1 (String 'C))) + (AsStruct '('key1a (Int32 '4)) '('key1b (Uint32 '2)) '('value1 (String 'D))) +)) + +(let list2 (AsList + (AsStruct '('key2a (Int32 '9)) '('key2b (Uint32 '3)) '('value2 (String 'Z))) + (AsStruct '('key2a (Int32 '4)) '('key2b (Uint32 '2)) '('value2 (String 'Y))) + (AsStruct '('key2a (Int32 '3)) '('key2b (Uint32 '3)) '('value2 (String 'X))) + (AsStruct '('key2a (Int32 '4)) '('key2b (Uint32 '2)) '('value2 (String 'W))) + (AsStruct '('key2a (Int32 '8)) '('key2b (Uint32 '1)) '('value2 (String 'V))) +)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinFull '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemTwoColumnsOpt1.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemTwoColumnsOpt1.yql new file mode 100644 index 0000000000..66060097b8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemTwoColumnsOpt1.yql @@ -0,0 +1,41 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('key1a (Just (Int32 '1))) '('key1b (Just (Uint32 '1))) '('value1 (Just (String 'A)))) + (AsStruct '('key1a (Just (Int32 '7))) '('key1b (Just (Uint32 '1))) '('value1 (Just (String 'B)))) + (AsStruct '('key1a (Just (Int32 '4))) '('key1b (Just (Uint32 '2))) '('value1 (Just (String 'C)))) + (AsStruct '('key1a (Just (Int32 '4))) '('key1b (Just (Uint32 '2))) '('value1 (Just (String 'D)))) +)) + +(let list2 (AsList + (AsStruct '('key2a (Int32 '9)) '('key2b (Uint32 '3)) '('value2 (String 'Z))) + (AsStruct '('key2a (Int32 '4)) '('key2b (Uint32 '2)) '('value2 (String 'Y))) + (AsStruct '('key2a (Int32 '3)) '('key2b (Uint32 '3)) '('value2 (String 'X))) + (AsStruct '('key2a (Int32 '4)) '('key2b (Uint32 '2)) '('value2 (String 'W))) + (AsStruct '('key2a (Int32 '8)) '('key2b (Uint32 '1)) '('value2 (String 'V))) +)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinFull '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinExclusion '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemTwoColumnsOpt1Opt2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemTwoColumnsOpt1Opt2.yql new file mode 100644 index 0000000000..15834403dd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemTwoColumnsOpt1Opt2.yql @@ -0,0 +1,43 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('key1a (Just (Int32 '1))) '('key1b (Just (Uint32 '1))) '('value1 (Just (String 'A)))) + (AsStruct '('key1a (Just (Int32 '7))) '('key1b (Just (Uint32 '1))) '('value1 (Just (String 'B)))) + (AsStruct '('key1a (Just (Int32 '4))) '('key1b (Just (Uint32 '2))) '('value1 (Just (String 'C)))) + (AsStruct '('key1a (Just (Int32 '4))) '('key1b (Just (Uint32 '2))) '('value1 (Just (String 'D)))) +)) + +(let list2 (AsList + (AsStruct '('key2a (Just (Int32 '9))) '('key2b (Just (Uint32 '3))) '('value2 (Just (String 'Z)))) + (AsStruct '('key2a (Just (Int32 '4))) '('key2b (Just (Uint32 '2))) '('value2 (Just (String 'Y)))) + (AsStruct '('key2a (Just (Int32 '3))) '('key2b (Just (Uint32 '3))) '('value2 (Just (String 'X)))) + (AsStruct '('key2a (Just (Int32 '4))) '('key2b (Just (Uint32 '2))) '('value2 (Just (String 'W)))) + (AsStruct '('key2a (Just (Int32 '8))) '('key2b (Just (Uint32 '1))) '('value2 (Just (String 'V)))) +)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinFull '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemTwoColumnsOpt2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemTwoColumnsOpt2.yql new file mode 100644 index 0000000000..0ddee9815b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/JoinInMemTwoColumnsOpt2.yql @@ -0,0 +1,43 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + (AsStruct '('key1a (Int32 '1)) '('key1b (Uint32 '1)) '('value1 (String 'A))) + (AsStruct '('key1a (Int32 '7)) '('key1b (Uint32 '1)) '('value1 (String 'B))) + (AsStruct '('key1a (Int32 '4)) '('key1b (Uint32 '2)) '('value1 (String 'C))) + (AsStruct '('key1a (Int32 '4)) '('key1b (Uint32 '2)) '('value1 (String 'D))) +)) + +(let list2 (AsList + (AsStruct '('key2a (Just (Int32 '9))) '('key2b (Just (Uint32 '3))) '('value2 (Just (String 'Z)))) + (AsStruct '('key2a (Just (Int32 '4))) '('key2b (Just (Uint32 '2))) '('value2 (Just (String 'Y)))) + (AsStruct '('key2a (Just (Int32 '3))) '('key2b (Just (Uint32 '3))) '('value2 (Just (String 'X)))) + (AsStruct '('key2a (Just (Int32 '4))) '('key2b (Just (Uint32 '2))) '('value2 (Just (String 'W)))) + (AsStruct '('key2a (Just (Int32 '8))) '('key2b (Just (Uint32 '1))) '('value2 (Just (String 'V)))) +)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1a 'a 'key1b) '('b 'key2a 'b 'key2b) '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinFull '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinExclusion '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/SelfJoinLimit1.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoin/SelfJoinLimit1.cfg new file mode 100644 index 0000000000..137266b187 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/SelfJoinLimit1.cfg @@ -0,0 +1,2 @@ +res result.txt +in Input SelfJoinLimit1.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/SelfJoinLimit1.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/SelfJoinLimit1.txt new file mode 100644 index 0000000000..717bdfe825 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/SelfJoinLimit1.txt @@ -0,0 +1,3 @@ +{"key"="1";"subkey"="1";"value"="3"}; +{"key"="2";"subkey"="2";"value"="1"}; +{"key"="3";"subkey"="3";"value"="2"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/SelfJoinLimit1.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/SelfJoinLimit1.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/SelfJoinLimit1.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/EquiJoin/SelfJoinLimit1.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/SelfJoinLimit1.yql new file mode 100644 index 0000000000..f142bfd3d6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/SelfJoinLimit1.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let table (Take table (Uint64 '2))) +(let join (EquiJoin '(table 'a) '(table 'b) +'('Inner '"a" '"b" '('"a" '"key") '('"b" '"value") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/SelfJoinMergeFields.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/SelfJoinMergeFields.yql new file mode 100644 index 0000000000..e5a08be9c9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/SelfJoinMergeFields.yql @@ -0,0 +1,17 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) +'('Inner '"a" '"b" '('"a" '"key") '('"b" '"value") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/SqlInToJoin.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/SqlInToJoin.yql new file mode 100644 index 0000000000..46ad794a8b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/SqlInToJoin.yql @@ -0,0 +1,59 @@ +( +(let mr_source (DataSource 'yt 'plato)) + +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) + + +(let list1 (AsList + (AsStruct '('k (String '800))) + (AsStruct '('k (String '020))) +)) + +(let list2 (AsList + (AsStruct '('k (String '020))) + (AsStruct '('k (String '800))) +)) + +(let list3 (AsList + (AsStruct '('k (String '021))) + (AsStruct '('k (String '800))) +)) + + +(let filtered1 (FlatMap table1 (lambda '(item) + (OptionalIf (SqlIn list1 (Member item 'key) '('('tableSource))) + (AsStruct '('value (Member item 'value)) '('subkey (Member item 'subkey)))) +))) + +(let filtered2 (FlatMap table2 (lambda '(item) (block '( + (let sqlInPred (SqlIn list2 (Member item 'key) '('('tableSource)))) + (return (OptionalIf (And sqlInPred (NotEqual (Member item 'value) (String 'ddd))) + (AsStruct '('value (Member item 'value)) '('subkey (Member item 'subkey))))) + )) +))) + +(let filtered3 (FlatMap table3 (lambda '(item) (block '( + (let sqlInPred (SqlIn list3 (Member item 'key) '('('tableSource)))) + (return (OptionalIf (And (NotEqual (Member item 'value) (String 'q)) sqlInPred) + (AsStruct '('value (Member item 'value)) '('subkey (Member item 'subkey))))) + )) +))) + + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort filtered1 '((Bool 'true) (Bool 'true)) (lambda '(row) '((Member row 'value) (Member row 'subkey)))) '('('type)))) +(let world (Write! world res_sink (Key) (Sort filtered2 '((Bool 'true) (Bool 'true)) (lambda '(row) '((Member row 'value) (Member row 'subkey)))) '('('type)))) +(let world (Write! world res_sink (Key) (Sort filtered3 '((Bool 'true) (Bool 'true)) (lambda '(row) '((Member row 'value) (Member row 'subkey)))) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiCrossSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiCrossSelf.yql new file mode 100644 index 0000000000..6d784c12f1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiCrossSelf.yql @@ -0,0 +1,11 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Cross '"a" '"b" '() '() '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiExclusionSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiExclusionSelf.yql new file mode 100644 index 0000000000..b3e903ce7b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiExclusionSelf.yql @@ -0,0 +1,11 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Exclusion '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiFullSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiFullSelf.yql new file mode 100644 index 0000000000..cf1497bcef --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiFullSelf.yql @@ -0,0 +1,11 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Full '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiFullTwoFieldsSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiFullTwoFieldsSelf.yql new file mode 100644 index 0000000000..a682416eff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiFullTwoFieldsSelf.yql @@ -0,0 +1,11 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Full '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerNested1EatOptSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerNested1EatOptSelf.yql new file mode 100644 index 0000000000..28be4deee9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerNested1EatOptSelf.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '(table 'c) '('Inner + '('Full '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) + '"c" '('"a" '"value") '('"c" '"subkey" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerNested1Self.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerNested1Self.yql new file mode 100644 index 0000000000..005fca072a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerNested1Self.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '(table 'c) '('Inner + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) + '"c" '('"a" '"value") '('"c" '"subkey" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerNested1bSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerNested1bSelf.yql new file mode 100644 index 0000000000..676843a418 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerNested1bSelf.yql @@ -0,0 +1,13 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '(table 'c) '('Right + '('Right '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) + '"c" '('"b" '"value") '('"c" '"subkey" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerNested2Self.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerNested2Self.yql new file mode 100644 index 0000000000..ecfc4263ec --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerNested2Self.yql @@ -0,0 +1,15 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '(table 'c) '(table 'd) '('Inner + '('Inner + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) + '"c" '('"b" '"key") '('"c" '"value" ) '()) + '"d" '('"a" '"value") '('"d" '"subkey" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerSelf.yql new file mode 100644 index 0000000000..633de6fcae --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerSelf.yql @@ -0,0 +1,11 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerTwoFieldsSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerTwoFieldsSelf.yql new file mode 100644 index 0000000000..793ee81306 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiInnerTwoFieldsSelf.yql @@ -0,0 +1,11 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiLeftOnlySelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiLeftOnlySelf.yql new file mode 100644 index 0000000000..867c048f8b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiLeftOnlySelf.yql @@ -0,0 +1,11 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('LeftOnly '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiLeftSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiLeftSelf.yql new file mode 100644 index 0000000000..1fc31dc350 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiLeftSelf.yql @@ -0,0 +1,11 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Left '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiLeftSemiSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiLeftSemiSelf.yql new file mode 100644 index 0000000000..15fa410fc6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiLeftSemiSelf.yql @@ -0,0 +1,11 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('LeftSemi '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiLeftTwoFieldsSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiLeftTwoFieldsSelf.yql new file mode 100644 index 0000000000..b305596d20 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiLeftTwoFieldsSelf.yql @@ -0,0 +1,11 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Left '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiOptFullSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiOptFullSelf.yql new file mode 100644 index 0000000000..2bb5d8dfc5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiOptFullSelf.yql @@ -0,0 +1,15 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let table (Map table (lambda '(row) (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))))))) +(let join (EquiJoin '(table 'a) '(table 'b) '('Full '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiOptInnerSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiOptInnerSelf.yql new file mode 100644 index 0000000000..d37d7f696b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiOptInnerSelf.yql @@ -0,0 +1,15 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let table (Map table (lambda '(row) (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))))))) +(let join (EquiJoin '(table 'a) '(table 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiOptLeftSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiOptLeftSelf.yql new file mode 100644 index 0000000000..74edcb9ae2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiOptLeftSelf.yql @@ -0,0 +1,15 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let table (Map table (lambda '(row) (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))))))) +(let join (EquiJoin '(table 'a) '(table 'b) '('Left '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiOptRightSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiOptRightSelf.yql new file mode 100644 index 0000000000..47f1a8923a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiOptRightSelf.yql @@ -0,0 +1,15 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let table (Map table (lambda '(row) (AsStruct + '('key (Just (Member row 'key))) + '('subkey (Just (Member row 'subkey))) + '('value (Just (Member row 'value))))))) +(let join (EquiJoin '(table 'a) '(table 'b) '('Right '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiRightOnlySelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiRightOnlySelf.yql new file mode 100644 index 0000000000..0a0a502ca6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiRightOnlySelf.yql @@ -0,0 +1,11 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('RightOnly '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiRightSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiRightSelf.yql new file mode 100644 index 0000000000..9fe527324c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiRightSelf.yql @@ -0,0 +1,11 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Right '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiRightSemiSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiRightSemiSelf.yql new file mode 100644 index 0000000000..4e69796c1f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiRightSemiSelf.yql @@ -0,0 +1,11 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('RightSemi '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiRightTwoFieldsSelf.yql b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiRightTwoFieldsSelf.yql new file mode 100644 index 0000000000..d5145b4dec --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/TypeEquiRightTwoFieldsSelf.yql @@ -0,0 +1,11 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputSelf))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Right '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"value" '"b" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf join)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/default.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoin/default.cfg new file mode 100644 index 0000000000..41fe7506e0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/default.cfg @@ -0,0 +1,6 @@ +res result.txt +in InputSelf InputSelf.txt +in InputSelf2 InputSelf2.txt +in Input1 input1.txt +in Input2 input2.txt +in Input3 input3.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/input1.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/input1.txt new file mode 100644 index 0000000000..f53757c309 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/input1.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="800";"subkey"="1";"value"="ddd"}; +{"key"="020";"subkey"="1";"value"="q"}; +{"key"="150";"subkey"="1";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/input1.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/input1.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/input1.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/EquiJoin/input2.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/input2.txt new file mode 100644 index 0000000000..07af3b4647 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/input2.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="2";"value"="abc"}; +{"key"="800";"subkey"="2";"value"="ddd"}; +{"key"="020";"subkey"="2";"value"="q"}; +{"key"="150";"subkey"="2";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/input2.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/input2.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/input2.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/EquiJoin/input3.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/input3.txt new file mode 100644 index 0000000000..1dc1bcc60b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/input3.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="3";"value"="abd"}; +{"key"="800";"subkey"="3";"value"="ddd"}; +{"key"="021";"subkey"="3";"value"="q"}; +{"key"="151";"subkey"="3";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/input3.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/input3.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/input3.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/EquiJoin/input4.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/input4.txt new file mode 100644 index 0000000000..8852c0825e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/input4.txt @@ -0,0 +1,2 @@ +{"payload_left"="aaa";"id"=1;}; +{"payload_left"="bbb";"id"=2;}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/input4.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/input4.txt.attr new file mode 100644 index 0000000000..4cd0c640ff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/input4.txt.attr @@ -0,0 +1,35 @@ +{ + "_yql_row_spec" = {"Type" = [ + "StructType"; + [ + [ + "id"; + [ + "DataType"; + "Int64" + ] + ]; + [ + "payload_left"; + [ + "DataType"; + "String" + ] + ] + ] + ]}; + "schema" = < + "strict" = %true; + "unique_keys" = %false + > + [ + { + "name" = "payload_left"; + "type" = "string" + }; + { + "name" = "id"; + "type" = "int64" + } + ]; +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/input5.txt b/yql/essentials/tests/s-expressions/suites/EquiJoin/input5.txt new file mode 100644 index 0000000000..398caa9279 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/input5.txt @@ -0,0 +1,2 @@ +{"payload_right"="ccc";"id"=1;}; +{"payload_right"="ddd";"id"=3;}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoin/input5.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoin/input5.txt.attr new file mode 100644 index 0000000000..cfc68e11aa --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoin/input5.txt.attr @@ -0,0 +1,35 @@ +{ + "_yql_row_spec" = {"Type" = [ + "StructType"; + [ + [ + "id"; + [ + "DataType"; + "Int64" + ] + ]; + [ + "payload_right"; + [ + "DataType"; + "String" + ] + ] + ] + ]}; + "schema" = < + "strict" = %true; + "unique_keys" = %false + > + [ + { + "name" = "payload_right"; + "type" = "string" + }; + { + "name" = "id"; + "type" = "int64" + } + ]; +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/CommonAllAny.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/CommonAllAny.yql new file mode 100644 index 0000000000..283fccceff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/CommonAllAny.yql @@ -0,0 +1,9 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossLink) world 'Input1 'Input2 '('('right 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/CommonAnyAll.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/CommonAnyAll.yql new file mode 100644 index 0000000000..af7dbd189d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/CommonAnyAll.yql @@ -0,0 +1,9 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossLink) world 'Input1 'Input2 '('('left 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/CommonAnyAny.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/CommonAnyAny.yql new file mode 100644 index 0000000000..e8016a1260 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/CommonAnyAny.yql @@ -0,0 +1,9 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossLink) world 'Input1 'Input2 '('('left 'any) '('right 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/DoAllJoinsExceptCross.yql.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/DoAllJoinsExceptCross.yql.txt new file mode 100644 index 0000000000..ebf3709fbe --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/DoAllJoinsExceptCross.yql.txt @@ -0,0 +1,54 @@ +( + +(let doAllJoinsExceptCrossEx (lambda '(world list1 list2 link) ( block '( + + (let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key) '('b 'key) link) '())) + (let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key) '('b 'key) link) '())) + (let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key) '('b 'key) link) '())) + (let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key) '('b 'key) link) '())) + (let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key) '('b 'key) link) '())) + (let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key) '('b 'key) link) '())) + (let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key) '('b 'key) link) '())) + (let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key) '('b 'key) link) '())) + (let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key) '('b 'key) link) '())) + + (let sortDir2 '((Bool 'true) (Bool 'true))) + (let sortDir1 '((Bool 'true))) + (let keySelectorAB (lambda '(row) '((Member row '"a.key") (Member row '"b.key")))) + (let keySelectorA (lambda '(row) '((Member row '"a.key")))) + (let keySelectorB (lambda '(row) '((Member row '"b.key")))) + + (let res_sink (DataSink 'result)) + (let world (Write! world res_sink (Key) (Sort joinInner sortDir2 keySelectorAB) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinLeft sortDir2 keySelectorAB) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinRight sortDir2 keySelectorAB) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinFull sortDir2 keySelectorAB) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir1 keySelectorA) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir1 keySelectorB) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinExclusion sortDir2 keySelectorAB) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir1 keySelectorA) '('('type)))) + (let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir1 keySelectorB) '('('type)))) + + (let world (Commit! world res_sink)) + (return world) + +)))) + +(let doAllJoinsExceptCrossLink (lambda '(world t1 t2 link) ( block '( + (let mr_source (DataSource 'yt 'plato)) + (let x (Read! world mr_source (Key '('table (String t1))) (Void) '())) + (let world (Left! x)) + (let list1 (Right! x)) + + (let x (Read! world mr_source (Key '('table (String t2))) (Void) '())) + (let world (Left! x)) + (let list2 (Right! x)) + + (return (Apply doAllJoinsExceptCrossEx world list1 list2 link)) +)))) + + +(export doAllJoinsExceptCrossLink) +(export doAllJoinsExceptCrossEx) + +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InMemAllAny.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InMemAllAny.yql new file mode 100644 index 0000000000..0db96ff654 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InMemAllAny.yql @@ -0,0 +1,31 @@ +( +(library "joins.yql") +(import join_module '"joins.yql") + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# Same as InputKV1 +(let list1 (AsList + (AsStruct '('key (String '1)) '('v1 (String 'v11))) + (AsStruct '('key (String '2)) '('v1 (String 'v12))) + (AsStruct '('key (String '2)) '('v1 (String 'v12))) + (AsStruct '('key (String '2)) '('v1 (String 'v12))) + (AsStruct '('key (String '3)) '('v1 (String 'v13))) + (AsStruct '('key (String '3)) '('v1 (String 'v13))) +)) + +# Same as InputKV2 +(let list2 (AsList + (AsStruct '('key (String '2)) '('v2 (String 'v22_extra_bytes))) + (AsStruct '('key (String '2)) '('v2 (String 'v22_extra_bytes))) + (AsStruct '('key (String '3)) '('v2 (String 'v23_extra_bytes))) + (AsStruct '('key (String '3)) '('v2 (String 'v23_extra_bytes))) + (AsStruct '('key (String '3)) '('v2 (String 'v23_extra_bytes))) + (AsStruct '('key (String '4)) '('v2 (String 'v24_extra_bytes))) +)) + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossEx) world list1 list2 '('('right 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InMemAnyAll.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InMemAnyAll.yql new file mode 100644 index 0000000000..42b1a60840 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InMemAnyAll.yql @@ -0,0 +1,31 @@ +( +(library "joins.yql") +(import join_module '"joins.yql") + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# Same as InputKV1 +(let list1 (AsList + (AsStruct '('key (String '1)) '('v1 (String 'v11))) + (AsStruct '('key (String '2)) '('v1 (String 'v12))) + (AsStruct '('key (String '2)) '('v1 (String 'v12))) + (AsStruct '('key (String '2)) '('v1 (String 'v12))) + (AsStruct '('key (String '3)) '('v1 (String 'v13))) + (AsStruct '('key (String '3)) '('v1 (String 'v13))) +)) + +# Same as InputKV2 +(let list2 (AsList + (AsStruct '('key (String '2)) '('v2 (String 'v22_extra_bytes))) + (AsStruct '('key (String '2)) '('v2 (String 'v22_extra_bytes))) + (AsStruct '('key (String '3)) '('v2 (String 'v23_extra_bytes))) + (AsStruct '('key (String '3)) '('v2 (String 'v23_extra_bytes))) + (AsStruct '('key (String '3)) '('v2 (String 'v23_extra_bytes))) + (AsStruct '('key (String '4)) '('v2 (String 'v24_extra_bytes))) +)) + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossEx) world list1 list2 '('('left 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InMemAnyAny.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InMemAnyAny.yql new file mode 100644 index 0000000000..53b2d9eaae --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InMemAnyAny.yql @@ -0,0 +1,31 @@ +( +(library "joins.yql") +(import join_module '"joins.yql") + +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# Same as InputKV1 +(let list1 (AsList + (AsStruct '('key (String '1)) '('v1 (String 'v11))) + (AsStruct '('key (String '2)) '('v1 (String 'v12))) + (AsStruct '('key (String '2)) '('v1 (String 'v12))) + (AsStruct '('key (String '2)) '('v1 (String 'v12))) + (AsStruct '('key (String '3)) '('v1 (String 'v13))) + (AsStruct '('key (String '3)) '('v1 (String 'v13))) +)) + +# Same as InputKV2 +(let list2 (AsList + (AsStruct '('key (String '2)) '('v2 (String 'v22_extra_bytes))) + (AsStruct '('key (String '2)) '('v2 (String 'v22_extra_bytes))) + (AsStruct '('key (String '3)) '('v2 (String 'v23_extra_bytes))) + (AsStruct '('key (String '3)) '('v2 (String 'v23_extra_bytes))) + (AsStruct '('key (String '3)) '('v2 (String 'v23_extra_bytes))) + (AsStruct '('key (String '4)) '('v2 (String 'v24_extra_bytes))) +)) + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossEx) world list1 list2 '('('left 'any) '('right 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InputKV1.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InputKV1.txt new file mode 100644 index 0000000000..895634d4f4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InputKV1.txt @@ -0,0 +1,6 @@ +{"key"="1";"v1"="v11"}; +{"key"="2";"v1"="v12"}; +{"key"="2";"v1"="v12"}; +{"key"="2";"v1"="v12"}; +{"key"="3";"v1"="v13"}; +{"key"="3";"v1"="v13"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InputKV1.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InputKV1.txt.attr new file mode 100644 index 0000000000..25b39416e2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InputKV1.txt.attr @@ -0,0 +1,10 @@ +{"_yql_row_spec"={ + "Type"=["StructType";[ + ["key";["DataType";"String"]]; + ["v1";["DataType";"String"]] + ]]; + "SortDirections"=[1;]; + "SortedBy"=["key";]; + "SortedByTypes"=[["DataType";"String";];]; + "SortMembers"=["key";]; +}} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InputKV2.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InputKV2.txt new file mode 100644 index 0000000000..b2ee98b41a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InputKV2.txt @@ -0,0 +1,6 @@ +{"key"="2";"v2"="v22_extra_bytes"}; +{"key"="2";"v2"="v22_extra_bytes"}; +{"key"="3";"v2"="v23_extra_bytes"}; +{"key"="3";"v2"="v23_extra_bytes"}; +{"key"="3";"v2"="v23_extra_bytes"}; +{"key"="4";"v2"="v24_extra_bytes"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InputKV2.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InputKV2.txt.attr new file mode 100644 index 0000000000..ca25d0f371 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/InputKV2.txt.attr @@ -0,0 +1,10 @@ +{"_yql_row_spec"={ + "Type"=["StructType";[ + ["key";["DataType";"String"]]; + ["v2";["DataType";"String"]] + ]]; + "SortDirections"=[1;]; + "SortedBy"=["key";]; + "SortedByTypes"=[["DataType";"String";];]; + "SortMembers"=["key";]; +}} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/LookupAllAny.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/LookupAllAny.yql new file mode 100644 index 0000000000..cca73e9d75 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/LookupAllAny.yql @@ -0,0 +1,11 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"lookupjoinlimit" '"64k")) + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossLink) world 'Input1 'Input2 '('('right 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/LookupAnyAll.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/LookupAnyAll.yql new file mode 100644 index 0000000000..e9547bfd31 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/LookupAnyAll.yql @@ -0,0 +1,11 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"lookupjoinlimit" '"64k")) + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossLink) world 'Input1 'Input2 '('('left 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/LookupAnyAny.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/LookupAnyAny.yql new file mode 100644 index 0000000000..e5bc5906b3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/LookupAnyAny.yql @@ -0,0 +1,11 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"lookupjoinlimit" '"64k")) + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossLink) world 'Input1 'Input2 '('('left 'any) '('right 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MapAllAny.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MapAllAny.yql new file mode 100644 index 0000000000..ad84352890 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MapAllAny.yql @@ -0,0 +1,11 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossLink) world 'Input1 'Input2 '('('right 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MapAnyAll.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MapAnyAll.yql new file mode 100644 index 0000000000..037e8aafc0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MapAnyAll.yql @@ -0,0 +1,11 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossLink) world 'Input1 'Input2 '('('left 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MapAnyAny.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MapAnyAny.yql new file mode 100644 index 0000000000..f1ce069c3e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MapAnyAny.yql @@ -0,0 +1,11 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossLink) world 'Input1 'Input2 '('('left 'any) '('right 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MergeAllAny.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MergeAllAny.yql new file mode 100644 index 0000000000..5845432182 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MergeAllAny.yql @@ -0,0 +1,11 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossLink) world 'Input1 'Input2 '('('right 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MergeAnyAll.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MergeAnyAll.yql new file mode 100644 index 0000000000..5f12b8e34e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MergeAnyAll.yql @@ -0,0 +1,11 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossLink) world 'Input1 'Input2 '('('left 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MergeAnyAny.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MergeAnyAny.yql new file mode 100644 index 0000000000..eaad119c21 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/MergeAnyAny.yql @@ -0,0 +1,11 @@ +( + +(library "joins.yql") +(import join_module '"joins.yql") + +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) + +(let world (Apply (bind join_module 'doAllJoinsExceptCrossLink) world 'Input1 'Input2 '('('left 'any) '('right 'any)))) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinAny/default.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/default.cfg new file mode 100644 index 0000000000..c73c7f566e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinAny/default.cfg @@ -0,0 +1,4 @@ +res result.txt +file joins.yql DoAllJoinsExceptCross.yql.txt +in Input1 InputKV1.txt +in Input2 InputKV2.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommon.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommon.yql new file mode 100644 index 0000000000..fd0cd3266b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommon.yql @@ -0,0 +1,42 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key2")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key2") (Member row '"b.subkey2")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinCross sortDir4 keySelectorAB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonKey2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonKey2.yql new file mode 100644 index 0000000000..04d4ac8e78 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonKey2.yql @@ -0,0 +1,42 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key2")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key2") (Member row '"b.subkey2")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinCross sortDir4 keySelectorAB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt1.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt1.yql new file mode 100644 index 0000000000..c2925077b4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt1.yql @@ -0,0 +1,42 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key2")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key2") (Member row '"b.subkey2")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinCross sortDir4 keySelectorAB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt12.yql new file mode 100644 index 0000000000..4f530fd62f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt12.yql @@ -0,0 +1,42 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key2")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key2") (Member row '"b.subkey2")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinCross sortDir4 keySelectorAB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt12Key2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt12Key2.yql new file mode 100644 index 0000000000..430c926921 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt12Key2.yql @@ -0,0 +1,42 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key2")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key2") (Member row '"b.subkey2")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinCross sortDir4 keySelectorAB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt1Key2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt1Key2.yql new file mode 100644 index 0000000000..da741bd831 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt1Key2.yql @@ -0,0 +1,42 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key2")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key2") (Member row '"b.subkey2")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinCross sortDir4 keySelectorAB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt2.yql new file mode 100644 index 0000000000..10ceca2c98 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt2.yql @@ -0,0 +1,42 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key2")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key2") (Member row '"b.subkey2")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinCross sortDir4 keySelectorAB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt2Key2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt2Key2.yql new file mode 100644 index 0000000000..0cd36f7c36 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/JoinCommonOpt2Key2.yql @@ -0,0 +1,42 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key2")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key2") (Member row '"b.subkey2")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinCross sortDir4 keySelectorAB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/default.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/default.cfg new file mode 100644 index 0000000000..3986c38117 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/default.cfg @@ -0,0 +1,5 @@ +res result.txt +in Input1 input1.txt +in Input2 input2.txt +in Input1Opt input1opt.txt +in Input2Opt input2opt.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input1.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input1.txt new file mode 100644 index 0000000000..6cacacff58 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input1.txt @@ -0,0 +1,3 @@ +{"key1"=1;subkey1=".";"value1"="A"}; +{"key1"=4;subkey1=".";"value1"="C"}; +{"key1"=4;subkey1=".";"value1"="D"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input1.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input1.txt.attr new file mode 100644 index 0000000000..8714765eb4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input1.txt.attr @@ -0,0 +1,30 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key1"; + [ + "DataType"; + "Int32" + ] + ]; + [ + "subkey1"; + [ + "DataType"; + "String" + ] + ]; + [ + "value1"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input1opt.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input1opt.txt new file mode 100644 index 0000000000..f03418b1bf --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input1opt.txt @@ -0,0 +1,6 @@ +{"key1"=1;subkey1=".";"value1"="A"}; +{"key1"=4;subkey1=".";"value1"="C"}; +{"key1"=4;subkey1=".";"value1"="D"}; +{"key1"=#;subkey1=".";"value1"="E"}; +{"key1"=#;subkey1=".";"value1"="F"}; +{"key1"=#;subkey1=".";"value1"="G"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input1opt.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input1opt.txt.attr new file mode 100644 index 0000000000..de343fa9cb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input1opt.txt.attr @@ -0,0 +1,39 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key1"; + [ + "OptionalType"; + [ + "DataType"; + "Int32" + ] + ] + ]; + [ + "subkey1"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ]; + [ + "value1"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input2.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input2.txt new file mode 100644 index 0000000000..7e4ea597de --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input2.txt @@ -0,0 +1,3 @@ +{"key2"=2u;subkey2=".";"value2"="U"}; +{"key2"=4u;subkey2=".";"value2"="Y"}; +{"key2"=4u;subkey2=".";"value2"="W"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input2.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input2.txt.attr new file mode 100644 index 0000000000..824353dafc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input2.txt.attr @@ -0,0 +1,30 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key2"; + [ + "DataType"; + "Uint64" + ] + ]; + [ + "subkey2"; + [ + "DataType"; + "String" + ] + ]; + [ + "value2"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input2opt.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input2opt.txt new file mode 100644 index 0000000000..17ff7232b7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input2opt.txt @@ -0,0 +1,6 @@ +{"key2"=2u;subkey2=".";"value2"="U"}; +{"key2"=4u;subkey2=".";"value2"="Y"}; +{"key2"=4u;subkey2=".";"value2"="W"}; +{"key2"=#;subkey2=".";"value2"="P"}; +{"key2"=#;subkey2=".";"value2"="Q"}; +{"key2"=#;subkey2=".";"value2"="R"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input2opt.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input2opt.txt.attr new file mode 100644 index 0000000000..990e5b6aee --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinCommon/input2opt.txt.attr @@ -0,0 +1,39 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key2"; + [ + "OptionalType"; + [ + "DataType"; + "Uint64" + ] + ] + ]; + [ + "subkey2"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ]; + [ + "value2"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMap.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMap.yql new file mode 100644 index 0000000000..8739797e8f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMap.yql @@ -0,0 +1,33 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) +(let world (Write! world res_sink (Key) joinCross '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapKey2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapKey2.yql new file mode 100644 index 0000000000..eef99f2886 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapKey2.yql @@ -0,0 +1,33 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) +(let world (Write! world res_sink (Key) joinCross '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt1.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt1.yql new file mode 100644 index 0000000000..e50b5b2bf5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt1.yql @@ -0,0 +1,33 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) +(let world (Write! world res_sink (Key) joinCross '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt12.yql new file mode 100644 index 0000000000..64367c4c33 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt12.yql @@ -0,0 +1,33 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) +(let world (Write! world res_sink (Key) joinCross '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt12Key2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt12Key2.yql new file mode 100644 index 0000000000..51af3fa6f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt12Key2.yql @@ -0,0 +1,33 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) +(let world (Write! world res_sink (Key) joinCross '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt1Key2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt1Key2.yql new file mode 100644 index 0000000000..3a089710e9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt1Key2.yql @@ -0,0 +1,33 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) +(let world (Write! world res_sink (Key) joinCross '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt2.yql new file mode 100644 index 0000000000..678ed1b9ea --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt2.yql @@ -0,0 +1,33 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) +(let world (Write! world res_sink (Key) joinCross '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt2Key2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt2Key2.yql new file mode 100644 index 0000000000..2e36542a53 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/JoinMapOpt2Key2.yql @@ -0,0 +1,33 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '('('type)))) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) +(let world (Write! world res_sink (Key) joinRight '('('type)))) +(let world (Write! world res_sink (Key) joinLeftOnly '('('type)))) +(let world (Write! world res_sink (Key) joinRightOnly '('('type)))) +(let world (Write! world res_sink (Key) joinLeftSemi '('('type)))) +(let world (Write! world res_sink (Key) joinRightSemi '('('type)))) +(let world (Write! world res_sink (Key) joinCross '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054.cfg new file mode 100644 index 0000000000..45bd8b2b81 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054.cfg @@ -0,0 +1,3 @@ +res result.txt +in Input1 bug3054_1.txt +in Input2 bug3054_2.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054.yql new file mode 100644 index 0000000000..58a877a388 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"mapjoinlimit" '"1m")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'key2) '('b 'key1 'b 'key2) '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinLeft '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054_1.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054_1.txt new file mode 100644 index 0000000000..6e6cc8a496 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054_1.txt @@ -0,0 +1,4 @@ +{"key1"="2017-08-10";"key2"=1}; +{"key1"="2017-08-10";"key2"=2}; +{"key1"="2017-08-11";"key2"=1}; +{"key1"="2017-08-11";"key2"=#}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054_1.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054_1.txt.attr new file mode 100644 index 0000000000..42dbb6a49b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054_1.txt.attr @@ -0,0 +1,29 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key1"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ]; + [ + "key2"; + [ + "OptionalType"; + [ + "DataType"; + "Int32" + ] + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054_2.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054_2.txt new file mode 100644 index 0000000000..b7262abbb7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054_2.txt @@ -0,0 +1,4 @@ +{"key1"="2017-08-10";"key2"=1}; +{"key1"="2017-08-10";"key2"=2}; +{"key1"="2017-08-11";"key2"=1}; +{"key1"="2017-08-11";"key2"=2}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054_2.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054_2.txt.attr new file mode 100644 index 0000000000..42dbb6a49b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/bug3054_2.txt.attr @@ -0,0 +1,29 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key1"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ]; + [ + "key2"; + [ + "OptionalType"; + [ + "DataType"; + "Int32" + ] + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/default.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/default.cfg new file mode 100644 index 0000000000..3986c38117 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/default.cfg @@ -0,0 +1,5 @@ +res result.txt +in Input1 input1.txt +in Input2 input2.txt +in Input1Opt input1opt.txt +in Input2Opt input2opt.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input1.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input1.txt new file mode 100644 index 0000000000..4b39db5bf3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input1.txt @@ -0,0 +1,3 @@ +{"key1"=1;subkey1="..";"value1"="A"}; +{"key1"=4;subkey1="..";"value1"="C"}; +{"key1"=4;subkey1="..";"value1"="D"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input1.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input1.txt.attr new file mode 100644 index 0000000000..8714765eb4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input1.txt.attr @@ -0,0 +1,30 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key1"; + [ + "DataType"; + "Int32" + ] + ]; + [ + "subkey1"; + [ + "DataType"; + "String" + ] + ]; + [ + "value1"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input1opt.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input1opt.txt new file mode 100644 index 0000000000..98331c5ee4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input1opt.txt @@ -0,0 +1,6 @@ +{"key1"=1;subkey1="...";"value1"="A"}; +{"key1"=4;subkey1="...";"value1"="C"}; +{"key1"=4;subkey1="...";"value1"="D"}; +{"key1"=#;subkey1="...";"value1"="E"}; +{"key1"=#;subkey1="...";"value1"="F"}; +{"key1"=#;subkey1="...";"value1"="G"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input1opt.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input1opt.txt.attr new file mode 100644 index 0000000000..de343fa9cb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input1opt.txt.attr @@ -0,0 +1,39 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key1"; + [ + "OptionalType"; + [ + "DataType"; + "Int32" + ] + ] + ]; + [ + "subkey1"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ]; + [ + "value1"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input2.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input2.txt new file mode 100644 index 0000000000..7e4ea597de --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input2.txt @@ -0,0 +1,3 @@ +{"key2"=2u;subkey2=".";"value2"="U"}; +{"key2"=4u;subkey2=".";"value2"="Y"}; +{"key2"=4u;subkey2=".";"value2"="W"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input2.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input2.txt.attr new file mode 100644 index 0000000000..824353dafc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input2.txt.attr @@ -0,0 +1,30 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key2"; + [ + "DataType"; + "Uint64" + ] + ]; + [ + "subkey2"; + [ + "DataType"; + "String" + ] + ]; + [ + "value2"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input2opt.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input2opt.txt new file mode 100644 index 0000000000..17ff7232b7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input2opt.txt @@ -0,0 +1,6 @@ +{"key2"=2u;subkey2=".";"value2"="U"}; +{"key2"=4u;subkey2=".";"value2"="Y"}; +{"key2"=4u;subkey2=".";"value2"="W"}; +{"key2"=#;subkey2=".";"value2"="P"}; +{"key2"=#;subkey2=".";"value2"="Q"}; +{"key2"=#;subkey2=".";"value2"="R"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input2opt.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input2opt.txt.attr new file mode 100644 index 0000000000..990e5b6aee --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMap/input2opt.txt.attr @@ -0,0 +1,39 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key2"; + [ + "OptionalType"; + [ + "DataType"; + "Uint64" + ] + ] + ]; + [ + "subkey2"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ]; + [ + "value2"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Bug2333.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Bug2333.cfg new file mode 100644 index 0000000000..06f0f4538a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Bug2333.cfg @@ -0,0 +1,3 @@ +in Input1 bug2333_l.txt +in Input2 bug2333_r.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Bug2333.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Bug2333.yql new file mode 100644 index 0000000000..f6b50489a6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Bug2333.yql @@ -0,0 +1,39 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"2")) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergeunsortedfactor" '"0.8")) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input1")))) '('"key") '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input2")))) '('"key") '())) + (let world (Left! x)) + (let table2 (Right! x)) + (let output (block '( + (let select (block '( + (let core (EquiJoin '(table1 '"L") '(table2 '"R") '('Left '"L" '"R" '('"L" '"key") '('"R" '"key") '()) '())) + (let core (FlatMap core (lambda '(row) (AsList (AsStruct '('"L.key" (Member row '"L.key")) '('"R.key" (Member row '"R.key")) '('"IsJoined" ("!=" ("Not" ("Exists" (SqlColumn row '"key" '"R"))) (Bool '"true")))))))) + (let core (Aggregate core '('"IsJoined") '('('Count0 (Apply (bind aggregate_module '"count_traits_factory") (TypeOf core) (lambda '(row) (SqlColumn row '"key" '"L"))))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"IsJoined" (Member row '"IsJoined")) '('"column1" (Member row 'Count0)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"IsJoined" '"column1"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Cross2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Cross2_12.yql new file mode 100644 index 0000000000..9b331b9f82 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Cross2_12.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Cross '"a" '"b" '() '() '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Exclusion2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Exclusion2_12.yql new file mode 100644 index 0000000000..3518a4c5d4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Exclusion2_12.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Exclusion '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Exclusion2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Exclusion2_1o2o.yql new file mode 100644 index 0000000000..90b210133a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Exclusion2_1o2o.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Exclusion '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Exclusion2key2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Exclusion2key2_12.yql new file mode 100644 index 0000000000..65f4e896c0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Exclusion2key2_12.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Exclusion '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Exclusion2key2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Exclusion2key2_1o2o.yql new file mode 100644 index 0000000000..a6f66f231e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Exclusion2key2_1o2o.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Exclusion '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_12.yql new file mode 100644 index 0000000000..ebb11c9560 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_12.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Full '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_12u.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_12u.yql new file mode 100644 index 0000000000..9047dae5cb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_12u.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2u))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Full '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_1o2o.yql new file mode 100644 index 0000000000..4f3b39aead --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_1o2o.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Full '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_1u2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_1u2.yql new file mode 100644 index 0000000000..cce29bdeba --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_1u2.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1u))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Full '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_1u2u.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_1u2u.yql new file mode 100644 index 0000000000..b2025d9f13 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2_1u2u.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1u))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2u))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Full '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2key12_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2key12_12.yql new file mode 100644 index 0000000000..e73d11378c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2key12_12.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Full '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2key12_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2key12_1o2o.yql new file mode 100644 index 0000000000..02fe6bd9b7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Full2key12_1o2o.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Full '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2_12.yql new file mode 100644 index 0000000000..6a0eca2a30 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2_12.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.value2")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2_12o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2_12o.yql new file mode 100644 index 0000000000..4aa5328146 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2_12o.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.value2")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2_1o2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2_1o2.yql new file mode 100644 index 0000000000..e114fdd320 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2_1o2.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.value2")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2_1o2o.yql new file mode 100644 index 0000000000..dfef6fe6c8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2_1o2o.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.value2")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2key2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2key2_12.yql new file mode 100644 index 0000000000..28175bd604 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2key2_12.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.value2")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2key2_12o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2key2_12o.yql new file mode 100644 index 0000000000..981d1a26d3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2key2_12o.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.value2")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2key2_1o2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2key2_1o2.yql new file mode 100644 index 0000000000..f217a74ac3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2key2_1o2.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.value2")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2key2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2key2_1o2o.yql new file mode 100644 index 0000000000..c397a2f86c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Inner2key2_1o2o.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.value2")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/InnerInner3_123.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/InnerInner3_123.yql new file mode 100644 index 0000000000..5f4c36f6e0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/InnerInner3_123.yql @@ -0,0 +1,24 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinallowcolumnrenames" 'true)) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value3) '())) +(let world (Left! x)) +(let table3 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.value2")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/InnerInner3_1o2o3o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/InnerInner3_1o2o3o.yql new file mode 100644 index 0000000000..959778c020 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/InnerInner3_1o2o3o.yql @@ -0,0 +1,24 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinallowcolumnrenames" 'true)) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input3opt))) '('key 'subkey 'value3) '())) +(let world (Left! x)) +(let table3 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '"c" '('"a" '"key") '('"c" '"key") '()) '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.value2")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/InnerInner3key2_123.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/InnerInner3key2_123.yql new file mode 100644 index 0000000000..af7186040d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/InnerInner3key2_123.yql @@ -0,0 +1,22 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinallowcolumnrenames" 'true)) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value3) '())) +(let world (Left! x)) +(let table3 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '"c" '('"a" '"key" '"a" '"subkey") '('"c" '"key" '"c" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/InnerInner3key2_1o2o3o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/InnerInner3key2_1o2o3o.yql new file mode 100644 index 0000000000..f1e98e1303 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/InnerInner3key2_1o2o3o.yql @@ -0,0 +1,22 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinallowcolumnrenames" 'true)) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input3opt))) '('key 'subkey 'value3) '())) +(let world (Left! x)) +(let table3 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) '(table3 'c) + '('Inner + '('Inner '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '"c" '('"a" '"key" '"a" '"subkey") '('"c" '"key" '"c" '"subkey") '()) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/JoinWithNonStrict.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/JoinWithNonStrict.cfg new file mode 100644 index 0000000000..f73a18f37a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/JoinWithNonStrict.cfg @@ -0,0 +1,3 @@ +in Input1 input1.txt +in Input2 infer_scheme.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/JoinWithNonStrict.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/JoinWithNonStrict.yql new file mode 100644 index 0000000000..46c35ef2a9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/JoinWithNonStrict.yql @@ -0,0 +1,19 @@ +( + +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergeunsortedfactor" '"3.0")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key) '('('infer_scheme)))) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/JoinWithSortedDesc.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/JoinWithSortedDesc.cfg new file mode 100644 index 0000000000..68f6b6b97b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/JoinWithSortedDesc.cfg @@ -0,0 +1,3 @@ +in Input1 bug2333_l.txt +in Input2 sorted_desc.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/JoinWithSortedDesc.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/JoinWithSortedDesc.yql new file mode 100644 index 0000000000..0cd1abd0e9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/JoinWithSortedDesc.yql @@ -0,0 +1,39 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"2")) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergeunsortedfactor" '"2")) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input1")))) '('"key") '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input2")))) '('"key") '())) + (let world (Left! x)) + (let table2 (Right! x)) + (let output (block '( + (let select (block '( + (let core (EquiJoin '(table1 '"L") '(table2 '"R") '('Left '"L" '"R" '('"L" '"key") '('"R" '"key") '()) '())) + (let core (FlatMap core (lambda '(row) (AsList (AsStruct '('"L.key" (Member row '"L.key")) '('"R.key" (Member row '"R.key")) '('"IsJoined" ("!=" ("Not" ("Exists" (SqlColumn row '"key" '"R"))) (Bool '"true")))))))) + (let core (Aggregate core '('"IsJoined") '('('Count0 (Apply (bind aggregate_module '"count_traits_factory") (TypeOf core) (lambda '(row) (SqlColumn row '"key" '"L"))))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"IsJoined" (Member row '"IsJoined")) '('"column1" (Member row 'Count0)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"IsJoined" '"column1"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Left2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Left2_12.yql new file mode 100644 index 0000000000..203d420f05 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Left2_12.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Left '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.value2")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Left2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Left2_1o2o.yql new file mode 100644 index 0000000000..1cc15375b5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Left2_1o2o.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Left '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey") (Member row '"b.value2")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Left2key2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Left2key2_12.yql new file mode 100644 index 0000000000..f376fd59f5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Left2key2_12.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Left '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Left2key2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Left2key2_1o2o.yql new file mode 100644 index 0000000000..ecbcf52649 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Left2key2_1o2o.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Left '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftOnly2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftOnly2_12.yql new file mode 100644 index 0000000000..7ad7499a36 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftOnly2_12.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('LeftOnly '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftOnly2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftOnly2_1o2o.yql new file mode 100644 index 0000000000..eee4c48726 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftOnly2_1o2o.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('LeftOnly '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftOnly2key2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftOnly2key2_12.yql new file mode 100644 index 0000000000..7983fd5c84 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftOnly2key2_12.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('LeftOnly '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftOnly2key2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftOnly2key2_1o2o.yql new file mode 100644 index 0000000000..72d92bae07 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftOnly2key2_1o2o.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('LeftOnly '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftSemi2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftSemi2_12.yql new file mode 100644 index 0000000000..b9b78b1e30 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftSemi2_12.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('LeftSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftSemi2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftSemi2_1o2o.yql new file mode 100644 index 0000000000..cbfc95831d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftSemi2_1o2o.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('LeftSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftSemi2key2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftSemi2key2_12.yql new file mode 100644 index 0000000000..fb3e649ac7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftSemi2key2_12.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('LeftSemi '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftSemi2key2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftSemi2key2_1o2o.yql new file mode 100644 index 0000000000..c97954aec4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/LeftSemi2key2_1o2o.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('LeftSemi '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Right2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Right2_12.yql new file mode 100644 index 0000000000..c0cfeddbac --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Right2_12.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Right '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Right2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Right2_1o2o.yql new file mode 100644 index 0000000000..0d9096f170 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Right2_1o2o.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Right '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Right2key2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Right2key2_12.yql new file mode 100644 index 0000000000..d6e27227a0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Right2key2_12.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Right '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Right2key2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Right2key2_1o2o.yql new file mode 100644 index 0000000000..26a9da603e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/Right2key2_1o2o.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('Right '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"a.key") (Member row '"a.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightOnly2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightOnly2_12.yql new file mode 100644 index 0000000000..ac557b7c39 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightOnly2_12.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('RightOnly '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightOnly2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightOnly2_1o2o.yql new file mode 100644 index 0000000000..818530c644 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightOnly2_1o2o.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('RightOnly '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightOnly2key2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightOnly2key2_12.yql new file mode 100644 index 0000000000..57525fe5cd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightOnly2key2_12.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('RightOnly '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightOnly2key2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightOnly2key2_1o2o.yql new file mode 100644 index 0000000000..d94a379a98 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightOnly2key2_1o2o.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('RightOnly '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightSemi2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightSemi2_12.yql new file mode 100644 index 0000000000..2d97e5de4f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightSemi2_12.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('RightSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightSemi2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightSemi2_1o2o.yql new file mode 100644 index 0000000000..78812b0504 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightSemi2_1o2o.yql @@ -0,0 +1,17 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('RightSemi '"a" '"b" '('"a" '"key") '('"b" '"key" ) '()) + '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightSemi2key2_12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightSemi2key2_12.yql new file mode 100644 index 0000000000..614f56af07 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightSemi2key2_12.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('RightSemi '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightSemi2key2_1o2o.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightSemi2key2_1o2o.yql new file mode 100644 index 0000000000..36754914d3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/RightSemi2key2_1o2o.yql @@ -0,0 +1,19 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1opt))) '('key 'subkey 'value1) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2opt))) '('key 'subkey 'value2) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let join (EquiJoin '(table1 'a) '(table2 'b) + '('RightSemi '"a" '"b" '('"a" '"key" '"a" '"subkey") '('"b" '"key" '"b" '"subkey") '()) + '())) +(let res_sink (DataSink 'result)) +(let sortDir '((Bool 'true) (Bool 'true))) +(let keySelector (lambda '(row) '((Member row '"b.key") (Member row '"b.subkey")))) +(let world (Write! world res_sink (Key) (Sort join sortDir keySelector) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/bug2333_l.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/bug2333_l.txt new file mode 100644 index 0000000000..629585c06e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/bug2333_l.txt @@ -0,0 +1,11 @@ +{"key"="020";"subkey"=1;"value1"="q"}; +{"key"="022";"subkey"=1;"value1"="q"}; +{"key"="030";"subkey"=1;"value1"="q"}; +{"key"="040";"subkey"=1;"value1"="abc"}; +{"key"="050";"subkey"=1;"value1"="abc"}; +{"key"="060";"subkey"=1;"value1"="abc"}; +{"key"="075";"subkey"=1;"value1"="abc"}; +{"key"="075";"subkey"=1;"value1"="qzz"}; +{"key"="100";"subkey"=1;"value1"="ddd"}; +{"key"="500";"subkey"=1;"value1"="ddd"}; +{"key"="800";"subkey"=1;"value1"="ddd"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/bug2333_l.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/bug2333_l.txt.attr new file mode 100644 index 0000000000..636afb35de --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/bug2333_l.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"SortMembers"=["key"];"SortedBy"=["key"];"SortDirections"=[1];"SortedByTypes"=[["DataType";"String"]];"Type"=["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"Int32"]];["value1";["DataType";"String"]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/bug2333_r.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/bug2333_r.txt new file mode 100644 index 0000000000..a2389716e5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/bug2333_r.txt @@ -0,0 +1,5 @@ +{"key"="320";"subkey"=1;"value1"="q"}; +{"key"="065";"subkey"=1;"value1"="abc"}; +{"key"="075";"subkey"=1;"value1"="qzz"}; +{"key"="850";"subkey"=1;"value1"="ddd"}; +{"key"="800";"subkey"=1;"value1"="ddd"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/bug2333_r.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/bug2333_r.txt.attr new file mode 100644 index 0000000000..905390e41e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/bug2333_r.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"Type"=["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"Int32"]];["value1";["DataType";"String"]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/default.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/default.cfg new file mode 100644 index 0000000000..17f55ef14f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/default.cfg @@ -0,0 +1,9 @@ +res result.txt +in Input1 input1.txt +in Input2 input2.txt +in Input1u input1u.txt +in Input2u input2u.txt +in Input3 input3.txt +in Input1opt input1opt.txt +in Input2opt input2opt.txt +in Input3opt input3opt.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/infer_scheme.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/infer_scheme.txt new file mode 100644 index 0000000000..79c1bc3e75 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/infer_scheme.txt @@ -0,0 +1,4 @@ +{"key"="020"}; +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="150";"subkey"="4";"value"="qzz"}; +{"key"="800";"subkey"="2";"value"="ddd"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/infer_scheme.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/infer_scheme.txt.attr new file mode 100644 index 0000000000..3c0f7e55c1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/infer_scheme.txt.attr @@ -0,0 +1,3 @@ +{ + "infer_schema" = %true +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1.txt new file mode 100644 index 0000000000..ad71c8be16 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1.txt @@ -0,0 +1,4 @@ +{"key"="020";"subkey"=1;"value1"="q"}; +{"key"="075";"subkey"=1;"value1"="abc"}; +{"key"="075";"subkey"=1;"value1"="qzz"}; +{"key"="800";"subkey"=1;"value1"="ddd"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1.txt.attr new file mode 100644 index 0000000000..22819a0f3b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"SortMembers"=["key";"subkey"];"SortedBy"=["key";"subkey"];"SortDirections"=[1;1];"SortedByTypes"=[["DataType";"String"];["DataType";"Int32"]];"Type"=["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"Int32"]];["value1";["DataType";"String"]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1opt.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1opt.txt new file mode 100644 index 0000000000..ad71c8be16 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1opt.txt @@ -0,0 +1,4 @@ +{"key"="020";"subkey"=1;"value1"="q"}; +{"key"="075";"subkey"=1;"value1"="abc"}; +{"key"="075";"subkey"=1;"value1"="qzz"}; +{"key"="800";"subkey"=1;"value1"="ddd"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1opt.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1opt.txt.attr new file mode 100644 index 0000000000..bd2fbd34c0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1opt.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"SortMembers"=["key";"subkey"];"SortedBy"=["key";"subkey"];"SortDirections"=[1;1];"SortedByTypes"=[["OptionalType";["DataType";"String"]];["OptionalType";["DataType";"Int32"]]];"Type"=["StructType";[["key";["OptionalType";["DataType";"String"]]];["subkey";["OptionalType";["DataType";"Int32"]]];["value1";["OptionalType";["DataType";"String"]]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1u.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1u.txt new file mode 100644 index 0000000000..630726fbc7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1u.txt @@ -0,0 +1,3 @@ +{"key"="020";"subkey"=1;"value1"="q"}; +{"key"="075";"subkey"=1;"value1"="abc"}; +{"key"="800";"subkey"=1;"value1"="ddd"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1u.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1u.txt.attr new file mode 100644 index 0000000000..d666ee078f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input1u.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"UniqueKeys"=%true;"SortMembers"=["key";"subkey"];"SortedBy"=["key";"subkey"];"SortDirections"=[1;1];"SortedByTypes"=[["DataType";"String"];["DataType";"Int32"]];"Type"=["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"Int32"]];["value1";["DataType";"String"]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2.txt new file mode 100644 index 0000000000..ea8b550fc1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"=1;"value2"=3.}; +{"key"="075";"subkey"=2;"value2"=4.5}; +{"key"="150";"subkey"=1;"value2"=5.5}; +{"key"="800";"subkey"=1;"value2"=1.}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2.txt.attr new file mode 100644 index 0000000000..2f3f372953 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"SortMembers"=["key";"subkey"];"SortedBy"=["key";"subkey"];"SortDirections"=[1;1];"SortedByTypes"=[["DataType";"String"];["DataType";"Int32"]];"Type"=["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"Int32"]];["value2";["DataType";"Double"]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2opt.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2opt.txt new file mode 100644 index 0000000000..ea8b550fc1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2opt.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"=1;"value2"=3.}; +{"key"="075";"subkey"=2;"value2"=4.5}; +{"key"="150";"subkey"=1;"value2"=5.5}; +{"key"="800";"subkey"=1;"value2"=1.}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2opt.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2opt.txt.attr new file mode 100644 index 0000000000..4a4ea783a0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2opt.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"SortMembers"=["key";"subkey"];"SortedBy"=["key";"subkey"];"SortDirections"=[1;1];"SortedByTypes"=[["OptionalType";["DataType";"String"]];["OptionalType";["DataType";"Int32"]]];"Type"=["StructType";[["key";["OptionalType";["DataType";"String"]]];["subkey";["OptionalType";["DataType";"Int32"]]];["value2";["OptionalType";["DataType";"Double"]]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2u.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2u.txt new file mode 100644 index 0000000000..3e93a3a132 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2u.txt @@ -0,0 +1,6 @@ +{"key"="075";"subkey"=1;"value2"=3.}; +{"key"="150";"subkey"=1;"value2"=5.5}; +{"key"="800";"subkey"=1;"value2"=1.}; +{"key"="801";"subkey"=1;"value2"=1.1}; +{"key"="802";"subkey"=1;"value2"=1.2}; +{"key"="803";"subkey"=1;"value2"=1.3}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2u.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2u.txt.attr new file mode 100644 index 0000000000..8ffdb455dd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input2u.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"UniqueKeys"=%true;"SortMembers"=["key";"subkey"];"SortedBy"=["key";"subkey"];"SortDirections"=[1;1];"SortedByTypes"=[["DataType";"String"];["DataType";"Int32"]];"Type"=["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"Int32"]];["value2";["DataType";"Double"]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input3.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input3.txt new file mode 100644 index 0000000000..71e5aa381b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input3.txt @@ -0,0 +1,4 @@ +{"key"="021";"subkey"=3;"value3"=-67}; +{"key"="075";"subkey"=3;"value3"=23}; +{"key"="151";"subkey"=3;"value3"=666}; +{"key"="800";"subkey"=1;"value3"=567}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input3.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input3.txt.attr new file mode 100644 index 0000000000..531b5fb378 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input3.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"SortMembers"=["key";"subkey"];"SortedBy"=["key";"subkey"];"SortDirections"=[1;1];"SortedByTypes"=[["DataType";"String"];["DataType";"Int32"]];"Type"=["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"Int32"]];["value3";["DataType";"Int64"]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input3opt.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input3opt.txt new file mode 100644 index 0000000000..71e5aa381b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input3opt.txt @@ -0,0 +1,4 @@ +{"key"="021";"subkey"=3;"value3"=-67}; +{"key"="075";"subkey"=3;"value3"=23}; +{"key"="151";"subkey"=3;"value3"=666}; +{"key"="800";"subkey"=1;"value3"=567}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input3opt.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input3opt.txt.attr new file mode 100644 index 0000000000..37e5810187 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/input3opt.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"SortMembers"=["key";"subkey"];"SortedBy"=["key";"subkey"];"SortDirections"=[1;1];"SortedByTypes"=[["OptionalType";["DataType";"String"]];["OptionalType";["DataType";"Int32"]]];"Type"=["StructType";[["key";["OptionalType";["DataType";"String"]]];["subkey";["OptionalType";["DataType";"Int32"]]];["value3";["OptionalType";["DataType";"Int64"]]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/sorted_desc.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/sorted_desc.txt new file mode 100644 index 0000000000..ac8e34386d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/sorted_desc.txt @@ -0,0 +1,4 @@ +{"_yql_column_0"="\xE0\xC7\xCF\xCF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFE\xFC";"key"="800";"subkey"="2";"value"="ddd"}; +{"_yql_column_0"="\xE0\xCE\xCA\xCF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFE\xFC";"key"="150";"subkey"="4";"value"="qzz"}; +{"_yql_column_0"="\xE0\xCF\xC8\xCA\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFE\xFC";"key"="075";"subkey"="1";"value"="abc"}; +{"_yql_column_0"="\xE0\xCF\xCD\xCF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFE\xFC";"key"="020";"subkey"="3";"value"="q"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/sorted_desc.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/sorted_desc.txt.attr new file mode 100644 index 0000000000..903b4c7d93 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinMerge/sorted_desc.txt.attr @@ -0,0 +1,46 @@ +{ + "_yql_row_spec" = { + "SortMembers" = [ + "key" + ]; + "SortDirections" = [ + 0 + ]; + "UniqueKeys" = %false; + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ]; + "SortedByTypes" = [ + [ + "DataType"; + "String" + ] + ]; + "SortedBy" = [ + "_yql_column_0" + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrdered.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrdered.yql new file mode 100644 index 0000000000..d16765b530 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrdered.yql @@ -0,0 +1,41 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key1) '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key1")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key1") (Member row '"b.subkey1")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedKey2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedKey2.yql new file mode 100644 index 0000000000..86ddc7edea --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedKey2.yql @@ -0,0 +1,41 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key1")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key1") (Member row '"b.subkey1")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt1.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt1.yql new file mode 100644 index 0000000000..dc6553ace8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt1.yql @@ -0,0 +1,41 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key1) '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key1")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key1") (Member row '"b.subkey1")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt12.yql new file mode 100644 index 0000000000..52ec551031 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt12.yql @@ -0,0 +1,41 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key1) '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key1")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key1") (Member row '"b.subkey1")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt12Key2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt12Key2.yql new file mode 100644 index 0000000000..c283681f65 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt12Key2.yql @@ -0,0 +1,41 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key1")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key1") (Member row '"b.subkey1")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt1Key2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt1Key2.yql new file mode 100644 index 0000000000..c0fd196bb3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt1Key2.yql @@ -0,0 +1,41 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key1")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key1") (Member row '"b.subkey1")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt2.yql new file mode 100644 index 0000000000..cc2f36e4b9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt2.yql @@ -0,0 +1,41 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key1) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key1) '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key1")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key1") (Member row '"b.subkey1")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt2Key2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt2Key2.yql new file mode 100644 index 0000000000..06a7f9e790 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/JoinOrderedOpt2Key2.yql @@ -0,0 +1,41 @@ +( +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"joinmergetableslimit" '"10")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key1 'b 'subkey1) '()) '())) + +(let sortDir4 '((Bool 'true) (Bool 'true) (Bool 'true) (Bool 'true))) +(let sortDir2 '((Bool 'true) (Bool 'true))) +(let keySelectorAB (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1") (Member row '"a.value1") (Member row '"b.key1")))) +(let keySelectorA (lambda '(row) '((Member row '"a.key1") (Member row '"a.subkey1")))) +(let keySelectorB (lambda '(row) '((Member row '"b.key1") (Member row '"b.subkey1")))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Sort joinInner sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeft sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRight sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinFull sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftOnly sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightOnly sortDir2 keySelectorB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinExclusion sortDir4 keySelectorAB) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinLeftSemi sortDir2 keySelectorA) '('('type)))) +(let world (Write! world res_sink (Key) (Sort joinRightSemi sortDir2 keySelectorB) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/default.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/default.cfg new file mode 100644 index 0000000000..3986c38117 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/default.cfg @@ -0,0 +1,5 @@ +res result.txt +in Input1 input1.txt +in Input2 input2.txt +in Input1Opt input1opt.txt +in Input2Opt input2opt.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input1.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input1.txt new file mode 100644 index 0000000000..6cacacff58 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input1.txt @@ -0,0 +1,3 @@ +{"key1"=1;subkey1=".";"value1"="A"}; +{"key1"=4;subkey1=".";"value1"="C"}; +{"key1"=4;subkey1=".";"value1"="D"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input1.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input1.txt.attr new file mode 100644 index 0000000000..886075ce6b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input1.txt.attr @@ -0,0 +1,31 @@ +{ + "_yql_row_spec" = { + "SortMembers"=["key1";"subkey1"];"SortedBy"=["key1";"subkey1"];"SortDirections"=[1;1];"SortedByTypes"=[["DataType";"Int32"];["DataType";"String"]]; + "Type" = [ + "StructType"; + [ + [ + "key1"; + [ + "DataType"; + "Int32" + ] + ]; + [ + "subkey1"; + [ + "DataType"; + "String" + ] + ]; + [ + "value1"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input1opt.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input1opt.txt new file mode 100644 index 0000000000..bfe21c14dd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input1opt.txt @@ -0,0 +1,6 @@ +{"key1"=#;subkey1="..";"value1"="E"}; +{"key1"=#;subkey1="..";"value1"="F"}; +{"key1"=#;subkey1="..";"value1"="G"}; +{"key1"=1;subkey1="..";"value1"="A"}; +{"key1"=4;subkey1="..";"value1"="C"}; +{"key1"=4;subkey1="..";"value1"="D"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input1opt.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input1opt.txt.attr new file mode 100644 index 0000000000..21ebb68dc9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input1opt.txt.attr @@ -0,0 +1,40 @@ +{ + "_yql_row_spec" = { + "SortMembers"=["key1";"subkey1"];"SortedBy"=["key1";"subkey1"];"SortDirections"=[1;1];"SortedByTypes"=[["OptionalType";["DataType";"Int32"]];["OptionalType";["DataType";"String"]]]; + "Type" = [ + "StructType"; + [ + [ + "key1"; + [ + "OptionalType"; + [ + "DataType"; + "Int32" + ] + ] + ]; + [ + "subkey1"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ]; + [ + "value1"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input2.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input2.txt new file mode 100644 index 0000000000..7536742f64 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input2.txt @@ -0,0 +1,3 @@ +{"key1"=2;subkey1=".";"value2"="U"}; +{"key1"=4;subkey1=".";"value2"="Y"}; +{"key1"=4;subkey1=".";"value2"="W"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input2.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input2.txt.attr new file mode 100644 index 0000000000..094fd53483 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input2.txt.attr @@ -0,0 +1,31 @@ +{ + "_yql_row_spec" = { + "SortMembers"=["key1";"subkey1"];"SortedBy"=["key1";"subkey1"];"SortDirections"=[1;1];"SortedByTypes"=[["DataType";"Int32"];["DataType";"String"]]; + "Type" = [ + "StructType"; + [ + [ + "key1"; + [ + "DataType"; + "Int32" + ] + ]; + [ + "subkey1"; + [ + "DataType"; + "String" + ] + ]; + [ + "value2"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input2opt.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input2opt.txt new file mode 100644 index 0000000000..a620f354f1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input2opt.txt @@ -0,0 +1,6 @@ +{"key1"=#;subkey1="..";"value2"="P"}; +{"key1"=#;subkey1="..";"value2"="Q"}; +{"key1"=#;subkey1="..";"value2"="R"}; +{"key1"=2;subkey1="..";"value2"="U"}; +{"key1"=4;subkey1="..";"value2"="Y"}; +{"key1"=4;subkey1="..";"value2"="W"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input2opt.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input2opt.txt.attr new file mode 100644 index 0000000000..97710dd6cd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinOrdered/input2opt.txt.attr @@ -0,0 +1,40 @@ +{ + "_yql_row_spec" = { + "SortMembers"=["key1";"subkey1"];"SortedBy"=["key1";"subkey1"];"SortDirections"=[1;1];"SortedByTypes"=[["OptionalType";["DataType";"Int32"]];["OptionalType";["DataType";"String"]]]; + "Type" = [ + "StructType"; + [ + [ + "key1"; + [ + "OptionalType"; + [ + "DataType"; + "Int32" + ] + ] + ]; + [ + "subkey1"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ]; + [ + "value2"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinType.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinType.yql new file mode 100644 index 0000000000..16d3de6d28 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinType.yql @@ -0,0 +1,36 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Concat (String '"Inner: ") (FormatType (TypeOf joinInner))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Left: ") (FormatType (TypeOf joinLeft))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Right: ") (FormatType (TypeOf joinRight))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Full: ") (FormatType (TypeOf joinFull))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftOnly: ") (FormatType (TypeOf joinLeftOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightOnly: ") (FormatType (TypeOf joinRightOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Exclusion: ") (FormatType (TypeOf joinExclusion))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftSemi: ") (FormatType (TypeOf joinLeftSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightSemi: ") (FormatType (TypeOf joinRightSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Cross: ") (FormatType (TypeOf joinCross))) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeKey2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeKey2.yql new file mode 100644 index 0000000000..7fc7ecf8ab --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeKey2.yql @@ -0,0 +1,36 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Concat (String '"Inner: ") (FormatType (TypeOf joinInner))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Left: ") (FormatType (TypeOf joinLeft))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Right: ") (FormatType (TypeOf joinRight))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Full: ") (FormatType (TypeOf joinFull))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftOnly: ") (FormatType (TypeOf joinLeftOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightOnly: ") (FormatType (TypeOf joinRightOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Exclusion: ") (FormatType (TypeOf joinExclusion))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftSemi: ") (FormatType (TypeOf joinLeftSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightSemi: ") (FormatType (TypeOf joinRightSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Cross: ") (FormatType (TypeOf joinCross))) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt1.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt1.yql new file mode 100644 index 0000000000..a20d8aec9b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt1.yql @@ -0,0 +1,36 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Concat (String '"Inner: ") (FormatType (TypeOf joinInner))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Left: ") (FormatType (TypeOf joinLeft))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Right: ") (FormatType (TypeOf joinRight))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Full: ") (FormatType (TypeOf joinFull))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftOnly: ") (FormatType (TypeOf joinLeftOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightOnly: ") (FormatType (TypeOf joinRightOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Exclusion: ") (FormatType (TypeOf joinExclusion))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftSemi: ") (FormatType (TypeOf joinLeftSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightSemi: ") (FormatType (TypeOf joinRightSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Cross: ") (FormatType (TypeOf joinCross))) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt12.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt12.yql new file mode 100644 index 0000000000..d566b92b1c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt12.yql @@ -0,0 +1,36 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Concat (String '"Inner: ") (FormatType (TypeOf joinInner))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Left: ") (FormatType (TypeOf joinLeft))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Right: ") (FormatType (TypeOf joinRight))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Full: ") (FormatType (TypeOf joinFull))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftOnly: ") (FormatType (TypeOf joinLeftOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightOnly: ") (FormatType (TypeOf joinRightOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Exclusion: ") (FormatType (TypeOf joinExclusion))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftSemi: ") (FormatType (TypeOf joinLeftSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightSemi: ") (FormatType (TypeOf joinRightSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Cross: ") (FormatType (TypeOf joinCross))) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt12Key2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt12Key2.yql new file mode 100644 index 0000000000..b2027e278b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt12Key2.yql @@ -0,0 +1,36 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Concat (String '"Inner: ") (FormatType (TypeOf joinInner))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Left: ") (FormatType (TypeOf joinLeft))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Right: ") (FormatType (TypeOf joinRight))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Full: ") (FormatType (TypeOf joinFull))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftOnly: ") (FormatType (TypeOf joinLeftOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightOnly: ") (FormatType (TypeOf joinRightOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Exclusion: ") (FormatType (TypeOf joinExclusion))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftSemi: ") (FormatType (TypeOf joinLeftSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightSemi: ") (FormatType (TypeOf joinRightSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Cross: ") (FormatType (TypeOf joinCross))) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt1Key2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt1Key2.yql new file mode 100644 index 0000000000..5ab66d2fc5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt1Key2.yql @@ -0,0 +1,36 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1Opt))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Concat (String '"Inner: ") (FormatType (TypeOf joinInner))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Left: ") (FormatType (TypeOf joinLeft))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Right: ") (FormatType (TypeOf joinRight))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Full: ") (FormatType (TypeOf joinFull))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftOnly: ") (FormatType (TypeOf joinLeftOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightOnly: ") (FormatType (TypeOf joinRightOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Exclusion: ") (FormatType (TypeOf joinExclusion))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftSemi: ") (FormatType (TypeOf joinLeftSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightSemi: ") (FormatType (TypeOf joinRightSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Cross: ") (FormatType (TypeOf joinCross))) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt2.yql new file mode 100644 index 0000000000..96f210378d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt2.yql @@ -0,0 +1,36 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1) '('b 'key2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Concat (String '"Inner: ") (FormatType (TypeOf joinInner))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Left: ") (FormatType (TypeOf joinLeft))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Right: ") (FormatType (TypeOf joinRight))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Full: ") (FormatType (TypeOf joinFull))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftOnly: ") (FormatType (TypeOf joinLeftOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightOnly: ") (FormatType (TypeOf joinRightOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Exclusion: ") (FormatType (TypeOf joinExclusion))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftSemi: ") (FormatType (TypeOf joinLeftSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightSemi: ") (FormatType (TypeOf joinRightSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Cross: ") (FormatType (TypeOf joinCross))) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt2Key2.yql b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt2Key2.yql new file mode 100644 index 0000000000..e5f7c57d6d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/JoinTypeOpt2Key2.yql @@ -0,0 +1,36 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2Opt))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (EquiJoin '(list1 'a) '(list2 'b) '('Inner 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeft (EquiJoin '(list1 'a) '(list2 'b) '('Left 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRight (EquiJoin '(list1 'a) '(list2 'b) '('Right 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinFull (EquiJoin '(list1 'a) '(list2 'b) '('Full 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftOnly (EquiJoin '(list1 'a) '(list2 'b) '('LeftOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightOnly (EquiJoin '(list1 'a) '(list2 'b) '('RightOnly 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinExclusion (EquiJoin '(list1 'a) '(list2 'b) '('Exclusion 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinLeftSemi (EquiJoin '(list1 'a) '(list2 'b) '('LeftSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinRightSemi (EquiJoin '(list1 'a) '(list2 'b) '('RightSemi 'a 'b '('a 'key1 'a 'subkey1) '('b 'key2 'b 'subkey2) '()) '())) +(let joinCross (EquiJoin '(list1 'a) '(list2 'b) '('Cross 'a 'b '() '() '()) '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Concat (String '"Inner: ") (FormatType (TypeOf joinInner))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Left: ") (FormatType (TypeOf joinLeft))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Right: ") (FormatType (TypeOf joinRight))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Full: ") (FormatType (TypeOf joinFull))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftOnly: ") (FormatType (TypeOf joinLeftOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightOnly: ") (FormatType (TypeOf joinRightOnly))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Exclusion: ") (FormatType (TypeOf joinExclusion))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"LeftSemi: ") (FormatType (TypeOf joinLeftSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"RightSemi: ") (FormatType (TypeOf joinRightSemi))) '())) +(let world (Write! world res_sink (Key) (Concat (String '"Cross: ") (FormatType (TypeOf joinCross))) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/default.cfg b/yql/essentials/tests/s-expressions/suites/EquiJoinType/default.cfg new file mode 100644 index 0000000000..3986c38117 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/default.cfg @@ -0,0 +1,5 @@ +res result.txt +in Input1 input1.txt +in Input2 input2.txt +in Input1Opt input1opt.txt +in Input2Opt input2opt.txt diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/input1.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input1.txt new file mode 100644 index 0000000000..6cacacff58 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input1.txt @@ -0,0 +1,3 @@ +{"key1"=1;subkey1=".";"value1"="A"}; +{"key1"=4;subkey1=".";"value1"="C"}; +{"key1"=4;subkey1=".";"value1"="D"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/input1.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input1.txt.attr new file mode 100644 index 0000000000..8714765eb4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input1.txt.attr @@ -0,0 +1,30 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key1"; + [ + "DataType"; + "Int32" + ] + ]; + [ + "subkey1"; + [ + "DataType"; + "String" + ] + ]; + [ + "value1"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/input1opt.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input1opt.txt new file mode 100644 index 0000000000..f03418b1bf --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input1opt.txt @@ -0,0 +1,6 @@ +{"key1"=1;subkey1=".";"value1"="A"}; +{"key1"=4;subkey1=".";"value1"="C"}; +{"key1"=4;subkey1=".";"value1"="D"}; +{"key1"=#;subkey1=".";"value1"="E"}; +{"key1"=#;subkey1=".";"value1"="F"}; +{"key1"=#;subkey1=".";"value1"="G"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/input1opt.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input1opt.txt.attr new file mode 100644 index 0000000000..de343fa9cb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input1opt.txt.attr @@ -0,0 +1,39 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key1"; + [ + "OptionalType"; + [ + "DataType"; + "Int32" + ] + ] + ]; + [ + "subkey1"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ]; + [ + "value1"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/input2.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input2.txt new file mode 100644 index 0000000000..7e4ea597de --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input2.txt @@ -0,0 +1,3 @@ +{"key2"=2u;subkey2=".";"value2"="U"}; +{"key2"=4u;subkey2=".";"value2"="Y"}; +{"key2"=4u;subkey2=".";"value2"="W"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/input2.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input2.txt.attr new file mode 100644 index 0000000000..824353dafc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input2.txt.attr @@ -0,0 +1,30 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key2"; + [ + "DataType"; + "Uint64" + ] + ]; + [ + "subkey2"; + [ + "DataType"; + "String" + ] + ]; + [ + "value2"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/input2opt.txt b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input2opt.txt new file mode 100644 index 0000000000..17ff7232b7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input2opt.txt @@ -0,0 +1,6 @@ +{"key2"=2u;subkey2=".";"value2"="U"}; +{"key2"=4u;subkey2=".";"value2"="Y"}; +{"key2"=4u;subkey2=".";"value2"="W"}; +{"key2"=#;subkey2=".";"value2"="P"}; +{"key2"=#;subkey2=".";"value2"="Q"}; +{"key2"=#;subkey2=".";"value2"="R"}; diff --git a/yql/essentials/tests/s-expressions/suites/EquiJoinType/input2opt.txt.attr b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input2opt.txt.attr new file mode 100644 index 0000000000..990e5b6aee --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/EquiJoinType/input2opt.txt.attr @@ -0,0 +1,39 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key2"; + [ + "OptionalType"; + [ + "DataType"; + "Uint64" + ] + ] + ]; + [ + "subkey2"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ]; + [ + "value2"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/File/ConfigureFileFromUrl.yql b/yql/essentials/tests/s-expressions/suites/File/ConfigureFileFromUrl.yql new file mode 100644 index 0000000000..b6d23e3c3e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/ConfigureFileFromUrl.yql @@ -0,0 +1,11 @@ +# canonize yson here +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let world (Configure! world config 'AddFileByUrl 'Tony 'https://yadi.sk/a/pk0iwMkNuNYgM/57b9c14c6fcc2a565515fab9)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Files '/home) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/File/DifferentAliasesToOneFile.cfg b/yql/essentials/tests/s-expressions/suites/File/DifferentAliasesToOneFile.cfg new file mode 100644 index 0000000000..03037b8d6f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/DifferentAliasesToOneFile.cfg @@ -0,0 +1,3 @@ +res result.txt +file OneFile one_file.txt +file AnotherFile one_file.txt diff --git a/yql/essentials/tests/s-expressions/suites/File/DifferentAliasesToOneFile.yql b/yql/essentials/tests/s-expressions/suites/File/DifferentAliasesToOneFile.yql new file mode 100644 index 0000000000..6e65cc1e65 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/DifferentAliasesToOneFile.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let results (AsDict + '((String 'OneFile) (FileContent 'OneFile)) + '((String 'AnotherFile) (FileContent 'AnotherFile)) +)) +(let world (Write! world res_sink (Key) results '('('type)))) +(return (Commit! world res_sink)) +) diff --git a/yql/essentials/tests/s-expressions/suites/File/DifferentAliasesToSameFiles.cfg b/yql/essentials/tests/s-expressions/suites/File/DifferentAliasesToSameFiles.cfg new file mode 100644 index 0000000000..a566dd4aa0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/DifferentAliasesToSameFiles.cfg @@ -0,0 +1,3 @@ +res result.txt +file OneFile one_file.txt +file AnotherFile another_file.txt diff --git a/yql/essentials/tests/s-expressions/suites/File/DifferentAliasesToSameFiles.yql b/yql/essentials/tests/s-expressions/suites/File/DifferentAliasesToSameFiles.yql new file mode 100644 index 0000000000..6e65cc1e65 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/DifferentAliasesToSameFiles.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let results (AsDict + '((String 'OneFile) (FileContent 'OneFile)) + '((String 'AnotherFile) (FileContent 'AnotherFile)) +)) +(let world (Write! world res_sink (Key) results '('('type)))) +(return (Commit! world res_sink)) +) diff --git a/yql/essentials/tests/s-expressions/suites/File/FileContent.yql b/yql/essentials/tests/s-expressions/suites/File/FileContent.yql new file mode 100644 index 0000000000..3e34cb8a58 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/FileContent.yql @@ -0,0 +1,10 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FileContent 'MyFile) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/File/FilePath.yql b/yql/essentials/tests/s-expressions/suites/File/FilePath.yql new file mode 100644 index 0000000000..1b036e6da4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/FilePath.yql @@ -0,0 +1,11 @@ +# do not check yson here +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FilePath 'MyFile) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/File/FilePathFromRoot.yql b/yql/essentials/tests/s-expressions/suites/File/FilePathFromRoot.yql new file mode 100644 index 0000000000..fa4d5835ce --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/FilePathFromRoot.yql @@ -0,0 +1,11 @@ +# do not check yson here +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FilePath '/home/MyFile) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/File/FillWithFileContent.cfg b/yql/essentials/tests/s-expressions/suites/File/FillWithFileContent.cfg new file mode 100644 index 0000000000..5c9bcce3f8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/FillWithFileContent.cfg @@ -0,0 +1,3 @@ +file MyFile file1.txt +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/File/FillWithFileContent.yql b/yql/essentials/tests/s-expressions/suites/File/FillWithFileContent.yql new file mode 100644 index 0000000000..203ac40254 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/FillWithFileContent.yql @@ -0,0 +1,11 @@ +( +#comment +(let data (AsList +(AsStruct '('key (String 'key1)) '('subkey (String '"")) '('value (FileContent 'MyFile))) +)) + +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) data '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/File/FolderPath.yql b/yql/essentials/tests/s-expressions/suites/File/FolderPath.yql new file mode 100644 index 0000000000..e676a8a14d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/FolderPath.yql @@ -0,0 +1,11 @@ +# canonize yson here +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FolderPath '"/lib") '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/File/HomeFiles.yql b/yql/essentials/tests/s-expressions/suites/File/HomeFiles.yql new file mode 100644 index 0000000000..78799b4126 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/HomeFiles.yql @@ -0,0 +1,11 @@ +# canonize yson here +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Files '/home) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/File/MapWithFileContent.cfg b/yql/essentials/tests/s-expressions/suites/File/MapWithFileContent.cfg new file mode 100644 index 0000000000..5c9bcce3f8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/MapWithFileContent.cfg @@ -0,0 +1,3 @@ +file MyFile file1.txt +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/File/MapWithFileContent.yql b/yql/essentials/tests/s-expressions/suites/File/MapWithFileContent.yql new file mode 100644 index 0000000000..d481de6809 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/MapWithFileContent.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 (FileContent 'MyFile)) + (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/File/MapWithFilePath.cfg b/yql/essentials/tests/s-expressions/suites/File/MapWithFilePath.cfg new file mode 100644 index 0000000000..b99236a7de --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/MapWithFilePath.cfg @@ -0,0 +1,4 @@ +file MyFile file1.txt +in Input input.txt +out Output output.txt +udf re2_udf diff --git a/yql/essentials/tests/s-expressions/suites/File/MapWithFilePath.yql b/yql/essentials/tests/s-expressions/suites/File/MapWithFilePath.yql new file mode 100644 index 0000000000..fcd006e0aa --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/MapWithFilePath.yql @@ -0,0 +1,22 @@ +# canonize yson here +( +#comment +(let udf (Udf '"Re2.Replace" '((String '"(^|.*/)([^/]+)$") (Null)))) +(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 (FilePath 'MyFile)) + (let newValue (Apply udf newValue (String '"./\\2"))) + (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/File/MapWithFolderPath.cfg b/yql/essentials/tests/s-expressions/suites/File/MapWithFolderPath.cfg new file mode 100644 index 0000000000..f1a778e02d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/MapWithFolderPath.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +mount ../mounts.txt +udf re2_udf diff --git a/yql/essentials/tests/s-expressions/suites/File/MapWithFolderPath.yql b/yql/essentials/tests/s-expressions/suites/File/MapWithFolderPath.yql new file mode 100644 index 0000000000..a9bd5a3ada --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/MapWithFolderPath.yql @@ -0,0 +1,22 @@ +# canonize yson here +( +#comment +(let udf (Udf '"Re2.Replace" '((String '"(^|.*/)([^/]+/?)$") (Null)))) +(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 (FolderPath '"/lib")) + (let newValue (Apply udf newValue (String '"./\\2"))) + (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/File/RootFiles.yql b/yql/essentials/tests/s-expressions/suites/File/RootFiles.yql new file mode 100644 index 0000000000..cf275fb841 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/RootFiles.yql @@ -0,0 +1,11 @@ +# canonize yson here +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Files '/) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/File/another_file.txt b/yql/essentials/tests/s-expressions/suites/File/another_file.txt new file mode 100644 index 0000000000..b07dc8bb88 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/another_file.txt @@ -0,0 +1 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit... diff --git a/yql/essentials/tests/s-expressions/suites/File/default.cfg b/yql/essentials/tests/s-expressions/suites/File/default.cfg new file mode 100644 index 0000000000..c870e59de5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/default.cfg @@ -0,0 +1,4 @@ +file MyFile file1.txt +res result.txt +mount ../mounts.txt +udf string_udf diff --git a/yql/essentials/tests/s-expressions/suites/File/file1.txt b/yql/essentials/tests/s-expressions/suites/File/file1.txt new file mode 100644 index 0000000000..882c86d1f1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/file1.txt @@ -0,0 +1,2 @@ +some data 1 +some data 2 diff --git a/yql/essentials/tests/s-expressions/suites/File/input.txt b/yql/essentials/tests/s-expressions/suites/File/input.txt new file mode 100644 index 0000000000..65949ea745 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/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/File/input.txt.attr b/yql/essentials/tests/s-expressions/suites/File/input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/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/File/one_file.txt b/yql/essentials/tests/s-expressions/suites/File/one_file.txt new file mode 100644 index 0000000000..b07dc8bb88 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/File/one_file.txt @@ -0,0 +1 @@ +Lorem ipsum dolor sit amet, consectetur adipiscing elit... diff --git a/yql/essentials/tests/s-expressions/suites/Filter/AggregateWithFilter.yql b/yql/essentials/tests/s-expressions/suites/Filter/AggregateWithFilter.yql new file mode 100644 index 0000000000..0f811313c6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/AggregateWithFilter.yql @@ -0,0 +1,51 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Output"))) '('"key" '"subkey") '())) +(let world (Left! r)) +(let input (Right! r)) +(let filter (lambda '(rec) (block '( + (return (Coalesce (> (Member rec '"key") (String '"100")) (Bool 'false))) +)))) +(let res (Filter input filter)) +(let l1 (lambda '(rec) (block '( + (return (Convert (Exists (Member rec '"subkey")) 'Uint64)) +)))) +(let l2 (lambda '(rec state) (block '( + (let l (lambda '(r1 r2) (block '( + (return (+ r1 r2)) + )))) + (let state (OptionalReduce state (Convert (Exists (Member rec '"subkey")) 'Uint64) l)) + (return state) +)))) +(let identity (lambda '(s) (block '( + (return s) +)))) +(let l5 (lambda '(rec state) (block '( + (let l (lambda '(r1 r2) (block '( + (return (+ r1 r2)) + )))) + (return (OptionalReduce rec state l)) +)))) +(let res (Aggregate res '('"key") '('('Count0 (AggregationTraits (ListItemType (TypeOf res)) l1 l2 identity identity l5 identity (Null)))))) +(let l (lambda '(state) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member state '"key"))) + (let res (AddMember res '"subkey" (Cast (Member state 'Count0) 'String))) + (let res (AddMember res '"value" (String '""))) + (return (AsList res)) +)))) +(let res (FlatMap res l)) +(let world (Write! world sink (Key '('table (String '"Output"))) res '())) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/CloseRange.yql b/yql/essentials/tests/s-expressions/suites/Filter/CloseRange.yql new file mode 100644 index 0000000000..8f8a2ebb28 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/CloseRange.yql @@ -0,0 +1,23 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"key")) + (let res (Coalesce (And (>= key (String '"020")) (<= key (String '"700"))) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/CloseRangeOnSortedInput.yql b/yql/essentials/tests/s-expressions/suites/Filter/CloseRangeOnSortedInput.yql new file mode 100644 index 0000000000..67767e39c0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/CloseRangeOnSortedInput.yql @@ -0,0 +1,30 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Output"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"key")) + (let res (Coalesce (And (>= key (String '"020")) (<= key (String '"700"))) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/EmptyRange.yql b/yql/essentials/tests/s-expressions/suites/Filter/EmptyRange.yql new file mode 100644 index 0000000000..5e3c989afa --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/EmptyRange.yql @@ -0,0 +1,23 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"key")) + (let res (Coalesce (And (>= key (String '"100")) (< key (String '"090"))) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/EmptyRangeOnSortedInput.yql b/yql/essentials/tests/s-expressions/suites/Filter/EmptyRangeOnSortedInput.yql new file mode 100644 index 0000000000..4dca20b467 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/EmptyRangeOnSortedInput.yql @@ -0,0 +1,30 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Output"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"key")) + (let res (Coalesce (And (>= key (String '"100")) (< key (String '"090"))) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/Equal.yql b/yql/essentials/tests/s-expressions/suites/Filter/Equal.yql new file mode 100644 index 0000000000..77d9b0ea8a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/Equal.yql @@ -0,0 +1,23 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"key")) + (let res (Coalesce (== key (String '"020")) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/EqualOnSortedInput.yql b/yql/essentials/tests/s-expressions/suites/Filter/EqualOnSortedInput.yql new file mode 100644 index 0000000000..f69dde24bf --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/EqualOnSortedInput.yql @@ -0,0 +1,30 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Output"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"key")) + (let res (Coalesce (== key (String '"020")) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Double.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Double.cfg new file mode 100644 index 0000000000..f03903c558 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Double.cfg @@ -0,0 +1,2 @@ +in Input input_ui8.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Double.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Double.yql new file mode 100644 index 0000000000..25e70ab080 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Double.yql @@ -0,0 +1,40 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (> key (Double '0)) (< key (Double '10)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '0)) (<= key (Double '10)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-0.5)) (< key (Double '10.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-0.5)) (<= key (Double '10.5)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '0.5)) (< key (Double '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '0.5)) (<= key (Double '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '0)) (<= key (Double '1000)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '0)) (<= key (Double '255)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '0)) (< key (Double '255)))))) +(let world (Apply test world (lambda '(key) (> key (Double '255))))) +(let world (Apply test world (lambda '(key) (>= key (Double '255))))) +(let world (Apply test world (lambda '(key) (>= key (Double '1000))))) +(let world (Apply test world (lambda '(key) (< key (Double '0))))) +(let world (Apply test world (lambda '(key) (<= key (Double '0))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Float.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Float.cfg new file mode 100644 index 0000000000..f03903c558 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Float.cfg @@ -0,0 +1,2 @@ +in Input input_ui8.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Float.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Float.yql new file mode 100644 index 0000000000..7e51737f4f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Float.yql @@ -0,0 +1,40 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (> key (Float '0)) (< key (Float '10)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '0)) (<= key (Float '10)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '-0.5)) (< key (Float '10.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '-0.5)) (<= key (Float '10.5)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '0.5)) (< key (Float '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '0.5)) (<= key (Float '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '0)) (<= key (Float '1000)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '0)) (<= key (Float '255)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '0)) (< key (Float '255)))))) +(let world (Apply test world (lambda '(key) (> key (Float '255))))) +(let world (Apply test world (lambda '(key) (>= key (Float '255))))) +(let world (Apply test world (lambda '(key) (>= key (Float '1000))))) +(let world (Apply test world (lambda '(key) (< key (Float '0))))) +(let world (Apply test world (lambda '(key) (<= key (Float '0))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Int32.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Int32.cfg new file mode 100644 index 0000000000..f03903c558 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Int32.cfg @@ -0,0 +1,2 @@ +in Input input_ui8.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Int32.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Int32.yql new file mode 100644 index 0000000000..9b61dfc633 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Int32.yql @@ -0,0 +1,35 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Int32 '-10)) (<= key (Int32 '1000)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Int32 '0)) (<= key (Int32 '255)))))) +(let world (Apply test world (lambda '(key) (And (> key (Int32 '0)) (< key (Int32 '255)))))) +(let world (Apply test world (lambda '(key) (> key (Int32 '255))))) +(let world (Apply test world (lambda '(key) (>= key (Int32 '255))))) +(let world (Apply test world (lambda '(key) (>= key (Int32 '1000))))) +(let world (Apply test world (lambda '(key) (< key (Int32 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Int32 '0))))) +(let world (Apply test world (lambda '(key) (< key (Int32 '-10))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Int64.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Int64.cfg new file mode 100644 index 0000000000..f03903c558 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Int64.cfg @@ -0,0 +1,2 @@ +in Input input_ui8.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Int64.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Int64.yql new file mode 100644 index 0000000000..bd121653b7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Int64.yql @@ -0,0 +1,35 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Int64 '-10)) (< key (Int64 '1000)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Int64 '0)) (<= key (Int64 '255)))))) +(let world (Apply test world (lambda '(key) (And (> key (Int64 '0)) (< key (Int64 '255)))))) +(let world (Apply test world (lambda '(key) (> key (Int64 '255))))) +(let world (Apply test world (lambda '(key) (>= key (Int64 '255))))) +(let world (Apply test world (lambda '(key) (>= key (Int64 '1000))))) +(let world (Apply test world (lambda '(key) (< key (Int64 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Int64 '0))))) +(let world (Apply test world (lambda '(key) (< key (Int64 '-10))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Uint32.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Uint32.cfg new file mode 100644 index 0000000000..f03903c558 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Uint32.cfg @@ -0,0 +1,2 @@ +in Input input_ui8.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Uint32.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Uint32.yql new file mode 100644 index 0000000000..91c443c6a8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Uint32.yql @@ -0,0 +1,34 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Uint32 '0)) (<= key (Uint32 '1000)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Uint32 '0)) (<= key (Uint32 '255)))))) +(let world (Apply test world (lambda '(key) (And (> key (Uint32 '0)) (< key (Uint32 '255)))))) +(let world (Apply test world (lambda '(key) (> key (Uint32 '255))))) +(let world (Apply test world (lambda '(key) (>= key (Uint32 '255))))) +(let world (Apply test world (lambda '(key) (>= key (Uint32 '1000))))) +(let world (Apply test world (lambda '(key) (< key (Uint32 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Uint32 '0))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Uint64.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Uint64.cfg new file mode 100644 index 0000000000..f03903c558 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Uint64.cfg @@ -0,0 +1,2 @@ +in Input input_ui8.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Uint64.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Uint64.yql new file mode 100644 index 0000000000..dcd71898d4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvByte-Uint64.yql @@ -0,0 +1,34 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Uint64 '0)) (<= key (Uint64 '1000)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Uint64 '0)) (<= key (Uint64 '255)))))) +(let world (Apply test world (lambda '(key) (And (> key (Uint64 '0)) (< key (Uint64 '255)))))) +(let world (Apply test world (lambda '(key) (> key (Uint64 '255))))) +(let world (Apply test world (lambda '(key) (>= key (Uint64 '255))))) +(let world (Apply test world (lambda '(key) (>= key (Uint64 '1000))))) +(let world (Apply test world (lambda '(key) (< key (Uint64 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Uint64 '0))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Byte.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Byte.cfg new file mode 100644 index 0000000000..6eef6ec30d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Byte.cfg @@ -0,0 +1,2 @@ +in Input input_dbl.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Byte.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Byte.yql new file mode 100644 index 0000000000..f3e31ddd82 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Byte.yql @@ -0,0 +1,27 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (> key (Uint8 '0)) (<= key (Uint8 '10)))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Float.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Float.cfg new file mode 100644 index 0000000000..6eef6ec30d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Float.cfg @@ -0,0 +1,2 @@ +in Input input_dbl.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Float.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Float.yql new file mode 100644 index 0000000000..01b53116ac --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Float.yql @@ -0,0 +1,32 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (> key (Float '-10)) (< key (Float '10)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '-10)) (<= key (Float '10)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '-10.5)) (< key (Float '10.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '-10.5)) (<= key (Float '10.5)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '-9.5)) (< key (Float '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '-9.5)) (<= key (Float '9.5)))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Int32.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Int32.cfg new file mode 100644 index 0000000000..6eef6ec30d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Int32.cfg @@ -0,0 +1,2 @@ +in Input input_dbl.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Int32.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Int32.yql new file mode 100644 index 0000000000..9c6f02ce77 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Int32.yql @@ -0,0 +1,27 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Int32 '-10)) (< key (Int32 '20)))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Int64.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Int64.cfg new file mode 100644 index 0000000000..6eef6ec30d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Int64.cfg @@ -0,0 +1,2 @@ +in Input input_dbl.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Int64.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Int64.yql new file mode 100644 index 0000000000..c2e5812eaf --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Int64.yql @@ -0,0 +1,30 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Int64 '-10)) (< key (Int64 '20)))))) +(let world (Apply test world (lambda '(key) (And (> key (Int64 '-9223372036854775808)) (< key (Int64 '9223372036854775807)))))) +(let world (Apply test world (lambda '(key) (> key (Int64 '3147483647))))) +(let world (Apply test world (lambda '(key) (< key (Int64 '-3147483647))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Uint32.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Uint32.cfg new file mode 100644 index 0000000000..6eef6ec30d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Uint32.cfg @@ -0,0 +1,2 @@ +in Input input_dbl.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Uint32.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Uint32.yql new file mode 100644 index 0000000000..ddf42e56cc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Uint32.yql @@ -0,0 +1,28 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Uint32 '0)) (<= key (Uint32 '1000)))))) +(let world (Apply test world (lambda '(key) (And (> key (Uint32 '0)) (< key (Uint32 '1000)))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Uint64.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Uint64.cfg new file mode 100644 index 0000000000..6eef6ec30d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Uint64.cfg @@ -0,0 +1,2 @@ +in Input input_dbl.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Uint64.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Uint64.yql new file mode 100644 index 0000000000..f34acbcdba --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvDouble-Uint64.yql @@ -0,0 +1,29 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Uint64 '0)) (< key (Uint64 '20)))))) +(let world (Apply test world (lambda '(key) (< key (Uint64 '9223372036854775807))))) +(let world (Apply test world (lambda '(key) (< key (Uint64 '0))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Double.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Double.cfg new file mode 100644 index 0000000000..1ecb755e34 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Double.cfg @@ -0,0 +1,2 @@ +in Input input_flt.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Double.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Double.yql new file mode 100644 index 0000000000..ea85b0f4f8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Double.yql @@ -0,0 +1,35 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (> key (Double '-10)) (< key (Double '10)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-10)) (<= key (Double '10)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-10.5)) (< key (Double '10.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-10.5)) (<= key (Double '10.5)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-9.5)) (< key (Double '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-9.5)) (<= key (Double '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-3147483647)) (<= key (Double '3147483647)))))) +(let world (Apply test world (lambda '(key) (> key (Double '3147483647))))) +(let world (Apply test world (lambda '(key) (< key (Double '-3147483647))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Int32.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Int32.cfg new file mode 100644 index 0000000000..1ecb755e34 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Int32.cfg @@ -0,0 +1,2 @@ +in Input input_flt.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Int32.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Int32.yql new file mode 100644 index 0000000000..9c6f02ce77 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Int32.yql @@ -0,0 +1,27 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Int32 '-10)) (< key (Int32 '20)))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Int64.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Int64.cfg new file mode 100644 index 0000000000..1ecb755e34 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Int64.cfg @@ -0,0 +1,2 @@ +in Input input_flt.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Int64.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Int64.yql new file mode 100644 index 0000000000..c2e5812eaf --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Int64.yql @@ -0,0 +1,30 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Int64 '-10)) (< key (Int64 '20)))))) +(let world (Apply test world (lambda '(key) (And (> key (Int64 '-9223372036854775808)) (< key (Int64 '9223372036854775807)))))) +(let world (Apply test world (lambda '(key) (> key (Int64 '3147483647))))) +(let world (Apply test world (lambda '(key) (< key (Int64 '-3147483647))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Uint32.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Uint32.cfg new file mode 100644 index 0000000000..1ecb755e34 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Uint32.cfg @@ -0,0 +1,2 @@ +in Input input_flt.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Uint32.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Uint32.yql new file mode 100644 index 0000000000..ddf42e56cc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Uint32.yql @@ -0,0 +1,28 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Uint32 '0)) (<= key (Uint32 '1000)))))) +(let world (Apply test world (lambda '(key) (And (> key (Uint32 '0)) (< key (Uint32 '1000)))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Uint64.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Uint64.cfg new file mode 100644 index 0000000000..1ecb755e34 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Uint64.cfg @@ -0,0 +1,2 @@ +in Input input_flt.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Uint64.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Uint64.yql new file mode 100644 index 0000000000..f34acbcdba --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvFloat-Uint64.yql @@ -0,0 +1,29 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Uint64 '0)) (< key (Uint64 '20)))))) +(let world (Apply test world (lambda '(key) (< key (Uint64 '9223372036854775807))))) +(let world (Apply test world (lambda '(key) (< key (Uint64 '0))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Double.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Double.cfg new file mode 100644 index 0000000000..cc557dfb6e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Double.cfg @@ -0,0 +1,2 @@ +in Input input_i32.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Double.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Double.yql new file mode 100644 index 0000000000..7fd743bdee --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Double.yql @@ -0,0 +1,40 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (> key (Double '-10)) (< key (Double '10)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-10)) (<= key (Double '10)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-10.5)) (< key (Double '10.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-10.5)) (<= key (Double '10.5)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-9.5)) (< key (Double '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-9.5)) (<= key (Double '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-2147483648)) (<= key (Double '2147483647)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-2147483648)) (< key (Double '2147483647)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-3147483648)) (< key (Double '3147483647)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-10223372036854775808)) (< key (Double '18446744073709551615)))))) +(let world (Apply test world (lambda '(key) (> key (Double '2147483647))))) +(let world (Apply test world (lambda '(key) (>= key (Double '2147483647))))) +(let world (Apply test world (lambda '(key) (< key (Double '-2147483648))))) +(let world (Apply test world (lambda '(key) (<= key (Double '-2147483648))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Float.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Float.cfg new file mode 100644 index 0000000000..cc557dfb6e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Float.cfg @@ -0,0 +1,2 @@ +in Input input_i32.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Float.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Float.yql new file mode 100644 index 0000000000..520276f126 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Float.yql @@ -0,0 +1,38 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (> key (Float '-10)) (< key (Float '10)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '-10)) (<= key (Float '10)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '-10.5)) (< key (Float '10.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '-10.5)) (<= key (Float '10.5)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '-9.5)) (< key (Float '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '-9.5)) (<= key (Float '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '-2147483648)) (<= key (Float '2147483647)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '-2147483648)) (< key (Float '2147483647)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '-3147483648)) (< key (Float '3147483647)))))) +(let world (Apply test world (lambda '(key) (> key (Float '2147483647))))) +(let world (Apply test world (lambda '(key) (< key (Float '-2147483648))))) +(let world (Apply test world (lambda '(key) (<= key (Float '-2147483648))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Int64.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Int64.cfg new file mode 100644 index 0000000000..cc557dfb6e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Int64.cfg @@ -0,0 +1,2 @@ +in Input input_i32.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Int64.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Int64.yql new file mode 100644 index 0000000000..b921b10b20 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Int64.yql @@ -0,0 +1,34 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Int64 '-10)) (< key (Int64 '20)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Int64 '-2147483648)) (<= key (Int64 '2147483647)))))) +(let world (Apply test world (lambda '(key) (And (> key (Int64 '-2147483648)) (< key (Int64 '2147483647)))))) +(let world (Apply test world (lambda '(key) (And (> key (Int64 '-9223372036854775808)) (< key (Int64 '9223372036854775807)))))) +(let world (Apply test world (lambda '(key) (> key (Int64 '2147483647))))) +(let world (Apply test world (lambda '(key) (>= key (Int64 '2147483647))))) +(let world (Apply test world (lambda '(key) (< key (Int64 '-2147483648))))) +(let world (Apply test world (lambda '(key) (<= key (Int64 '-2147483648))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Uint32.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Uint32.cfg new file mode 100644 index 0000000000..cc557dfb6e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Uint32.cfg @@ -0,0 +1,2 @@ +in Input input_i32.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Uint32.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Uint32.yql new file mode 100644 index 0000000000..6dc9e5769c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Uint32.yql @@ -0,0 +1,32 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Uint32 '0)) (<= key (Uint32 '2147483647)))))) +(let world (Apply test world (lambda '(key) (And (> key (Uint32 '0)) (< key (Uint32 '2147483647)))))) +(let world (Apply test world (lambda '(key) (> key (Uint32 '2147483647))))) +(let world (Apply test world (lambda '(key) (>= key (Uint32 '2147483647))))) +(let world (Apply test world (lambda '(key) (< key (Uint32 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Uint32 '0))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Uint64.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Uint64.cfg new file mode 100644 index 0000000000..cc557dfb6e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Uint64.cfg @@ -0,0 +1,2 @@ +in Input input_i32.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Uint64.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Uint64.yql new file mode 100644 index 0000000000..df99564b89 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt32-Uint64.yql @@ -0,0 +1,34 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Uint64 '0)) (< key (Uint64 '20)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Uint64 '0)) (<= key (Uint64 '2147483647)))))) +(let world (Apply test world (lambda '(key) (And (> key (Uint64 '0)) (< key (Uint64 '2147483647)))))) +(let world (Apply test world (lambda '(key) (> key (Uint64 '2147483647))))) +(let world (Apply test world (lambda '(key) (>= key (Uint64 '2147483647))))) +(let world (Apply test world (lambda '(key) (< key (Uint64 '9223372036854775807))))) +(let world (Apply test world (lambda '(key) (< key (Uint64 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Uint64 '0))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Double.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Double.cfg new file mode 100644 index 0000000000..33b4e93ec7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Double.cfg @@ -0,0 +1,2 @@ +in Input input_i64.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Double.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Double.yql new file mode 100644 index 0000000000..cbfb7cad03 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Double.yql @@ -0,0 +1,39 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (> key (Double '-10)) (< key (Double '10)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-10)) (<= key (Double '10)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-10.5)) (< key (Double '10.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-10.5)) (<= key (Double '10.5)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-9.5)) (< key (Double '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-9.5)) (<= key (Double '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-9223372036854775808)) (<= key (Double '9223372036854775807)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-9223372036854775808)) (< key (Double '9223372036854775807)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-10223372036854775808)) (< key (Double '18446744073709551615)))))) +(let world (Apply test world (lambda '(key) (> key (Double '9223372036854775807))))) +(let world (Apply test world (lambda '(key) (>= key (Double '9223372036854775807))))) +(let world (Apply test world (lambda '(key) (< key (Double '-9223372036854775808))))) +(let world (Apply test world (lambda '(key) (<= key (Double '-9223372036854775808))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Float.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Float.cfg new file mode 100644 index 0000000000..33b4e93ec7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Float.cfg @@ -0,0 +1,2 @@ +in Input input_i64.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Float.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Float.yql new file mode 100644 index 0000000000..b94c11aecc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Float.yql @@ -0,0 +1,34 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (> key (Float '-10)) (< key (Float '10)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '-10)) (<= key (Float '10)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '-10.5)) (< key (Float '10.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '-10.5)) (<= key (Float '10.5)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '-9.5)) (< key (Float '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '-9.5)) (<= key (Float '9.5)))))) +(let world (Apply test world (lambda '(key) (> key (Float '2147483647))))) +(let world (Apply test world (lambda '(key) (< key (Float '-2147483648))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Int32.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Int32.cfg new file mode 100644 index 0000000000..33b4e93ec7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Int32.cfg @@ -0,0 +1,2 @@ +in Input input_i64.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Int32.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Int32.yql new file mode 100644 index 0000000000..e3a5b10cbb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Int32.yql @@ -0,0 +1,33 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Int32 '-10)) (< key (Int32 '20)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Int32 '-2147483648)) (<= key (Int32 '2147483647)))))) +(let world (Apply test world (lambda '(key) (And (> key (Int32 '-2147483648)) (< key (Int32 '2147483647)))))) +(let world (Apply test world (lambda '(key) (> key (Int32 '2147483647))))) +(let world (Apply test world (lambda '(key) (>= key (Int32 '2147483647))))) +(let world (Apply test world (lambda '(key) (< key (Int32 '-2147483648))))) +(let world (Apply test world (lambda '(key) (<= key (Int32 '-2147483648))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Uint32.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Uint32.cfg new file mode 100644 index 0000000000..33b4e93ec7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Uint32.cfg @@ -0,0 +1,2 @@ +in Input input_i64.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Uint32.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Uint32.yql new file mode 100644 index 0000000000..6dc9e5769c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Uint32.yql @@ -0,0 +1,32 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Uint32 '0)) (<= key (Uint32 '2147483647)))))) +(let world (Apply test world (lambda '(key) (And (> key (Uint32 '0)) (< key (Uint32 '2147483647)))))) +(let world (Apply test world (lambda '(key) (> key (Uint32 '2147483647))))) +(let world (Apply test world (lambda '(key) (>= key (Uint32 '2147483647))))) +(let world (Apply test world (lambda '(key) (< key (Uint32 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Uint32 '0))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Uint64.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Uint64.cfg new file mode 100644 index 0000000000..33b4e93ec7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Uint64.cfg @@ -0,0 +1,2 @@ +in Input input_i64.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Uint64.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Uint64.yql new file mode 100644 index 0000000000..eb43b46130 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvInt64-Uint64.yql @@ -0,0 +1,36 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Uint64 '0)) (< key (Uint64 '20)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Uint64 '0)) (<= key (Uint64 '18446744073709551615)))))) +(let world (Apply test world (lambda '(key) (And (> key (Uint64 '0)) (< key (Uint64 '18446744073709551615)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Uint64 '0)) (<= key (Uint64 '9223372036854775807)))))) +(let world (Apply test world (lambda '(key) (And (> key (Uint64 '0)) (< key (Uint64 '9223372036854775807)))))) +(let world (Apply test world (lambda '(key) (> key (Uint64 '9223372036854775807))))) +(let world (Apply test world (lambda '(key) (>= key (Uint64 '9223372036854775807))))) +(let world (Apply test world (lambda '(key) (< key (Uint64 '18446744073709551615))))) +(let world (Apply test world (lambda '(key) (< key (Uint64 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Uint64 '0))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Double.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Double.cfg new file mode 100644 index 0000000000..d339183514 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Double.cfg @@ -0,0 +1,2 @@ +in Input input_ui32.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Double.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Double.yql new file mode 100644 index 0000000000..d74c89079d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Double.yql @@ -0,0 +1,39 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (> key (Double '0)) (< key (Double '10)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '0)) (<= key (Double '10)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-0.5)) (< key (Double '10.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-0.5)) (<= key (Double '10.5)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '0.5)) (< key (Double '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '0.5)) (<= key (Double '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '0)) (<= key (Double '4294967295)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '0)) (< key (Double '4294967295)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-1000000000000)) (< key (Double '1000000000000)))))) +(let world (Apply test world (lambda '(key) (> key (Double '4294967295))))) +(let world (Apply test world (lambda '(key) (>= key (Double '4294967295))))) +(let world (Apply test world (lambda '(key) (< key (Double '0))))) +(let world (Apply test world (lambda '(key) (<= key (Double '0))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Float.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Float.cfg new file mode 100644 index 0000000000..d339183514 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Float.cfg @@ -0,0 +1,2 @@ +in Input input_ui32.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Float.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Float.yql new file mode 100644 index 0000000000..119a06c083 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Float.yql @@ -0,0 +1,32 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (> key (Float '0)) (< key (Float '10)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '0)) (<= key (Float '10)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '-0.5)) (< key (Float '10.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '-0.5)) (<= key (Float '10.5)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '0.5)) (< key (Float '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '0.5)) (<= key (Float '9.5)))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Int32.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Int32.cfg new file mode 100644 index 0000000000..d339183514 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Int32.cfg @@ -0,0 +1,2 @@ +in Input input_ui32.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Int32.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Int32.yql new file mode 100644 index 0000000000..0ef31b3b21 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Int32.yql @@ -0,0 +1,33 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Int32 '-10)) (< key (Int32 '20)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Int32 '0)) (<= key (Int32 '2147483647)))))) +(let world (Apply test world (lambda '(key) (And (> key (Int32 '0)) (< key (Int32 '2147483647)))))) +(let world (Apply test world (lambda '(key) (> key (Int32 '2147483647))))) +(let world (Apply test world (lambda '(key) (>= key (Int32 '2147483647))))) +(let world (Apply test world (lambda '(key) (< key (Int32 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Int32 '0))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Int64.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Int64.cfg new file mode 100644 index 0000000000..d339183514 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Int64.cfg @@ -0,0 +1,2 @@ +in Input input_ui32.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Int64.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Int64.yql new file mode 100644 index 0000000000..029097b6fd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Int64.yql @@ -0,0 +1,35 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Int64 '-10)) (< key (Int64 '20)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Int64 '0)) (<= key (Int64 '4294967295)))))) +(let world (Apply test world (lambda '(key) (And (> key (Int64 '0)) (< key (Int64 '4294967295)))))) +(let world (Apply test world (lambda '(key) (And (> key (Int64 '-9223372036854775808)) (< key (Int64 '9223372036854775807)))))) +(let world (Apply test world (lambda '(key) (> key (Int64 '4294967295))))) +(let world (Apply test world (lambda '(key) (>= key (Int64 '4294967295))))) +(let world (Apply test world (lambda '(key) (< key (Int64 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Int64 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Int64 '-10))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Uint64.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Uint64.cfg new file mode 100644 index 0000000000..d339183514 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Uint64.cfg @@ -0,0 +1,2 @@ +in Input input_ui32.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Uint64.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Uint64.yql new file mode 100644 index 0000000000..5350dcda71 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint32-Uint64.yql @@ -0,0 +1,35 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Uint64 '0)) (<= key (Uint64 '1000)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Uint64 '0)) (<= key (Uint64 '4294967295)))))) +(let world (Apply test world (lambda '(key) (And (> key (Uint64 '0)) (< key (Uint64 '4294967295)))))) +(let world (Apply test world (lambda '(key) (And (> key (Uint64 '0)) (< key (Uint64 '9223372036854775807)))))) +(let world (Apply test world (lambda '(key) (> key (Uint64 '1000000000000))))) +(let world (Apply test world (lambda '(key) (> key (Uint64 '4294967295))))) +(let world (Apply test world (lambda '(key) (>= key (Uint64 '4294967295))))) +(let world (Apply test world (lambda '(key) (< key (Uint64 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Uint64 '0))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Double.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Double.cfg new file mode 100644 index 0000000000..fa976ebe64 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Double.cfg @@ -0,0 +1,2 @@ +in Input input_ui64.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Double.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Double.yql new file mode 100644 index 0000000000..d7caabfc19 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Double.yql @@ -0,0 +1,39 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (> key (Double '0)) (< key (Double '10)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '0)) (<= key (Double '10)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '-0.5)) (< key (Double '10.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '-0.5)) (<= key (Double '10.5)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '0.5)) (< key (Double '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '0.5)) (<= key (Double '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Double '0)) (<= key (Double '18446744073709551615)))))) +(let world (Apply test world (lambda '(key) (And (> key (Double '0)) (< key (Double '18446744073709551615)))))) +(let world (Apply test world (lambda '(key) (> key (Double '18446744073709551615))))) +(let world (Apply test world (lambda '(key) (>= key (Double '18446744073709551615))))) +(let world (Apply test world (lambda '(key) (< key (Double '0))))) +(let world (Apply test world (lambda '(key) (<= key (Double '0))))) +(let world (Apply test world (lambda '(key) (< key (Double '-10))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Float.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Float.cfg new file mode 100644 index 0000000000..fa976ebe64 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Float.cfg @@ -0,0 +1,2 @@ +in Input input_ui64.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Float.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Float.yql new file mode 100644 index 0000000000..119a06c083 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Float.yql @@ -0,0 +1,32 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (> key (Float '0)) (< key (Float '10)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '0)) (<= key (Float '10)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '-0.5)) (< key (Float '10.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '-0.5)) (<= key (Float '10.5)))))) +(let world (Apply test world (lambda '(key) (And (> key (Float '0.5)) (< key (Float '9.5)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Float '0.5)) (<= key (Float '9.5)))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Int32.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Int32.cfg new file mode 100644 index 0000000000..fa976ebe64 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Int32.cfg @@ -0,0 +1,2 @@ +in Input input_ui64.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Int32.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Int32.yql new file mode 100644 index 0000000000..638bf6954a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Int32.yql @@ -0,0 +1,34 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Int32 '-10)) (< key (Int32 '20)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Int32 '0)) (<= key (Int32 '2147483647)))))) +(let world (Apply test world (lambda '(key) (And (> key (Int32 '0)) (< key (Int32 '2147483647)))))) +(let world (Apply test world (lambda '(key) (> key (Int32 '2147483647))))) +(let world (Apply test world (lambda '(key) (>= key (Int32 '2147483647))))) +(let world (Apply test world (lambda '(key) (< key (Int32 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Int32 '0))))) +(let world (Apply test world (lambda '(key) (< key (Int32 '-10))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Int64.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Int64.cfg new file mode 100644 index 0000000000..fa976ebe64 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Int64.cfg @@ -0,0 +1,2 @@ +in Input input_ui64.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Int64.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Int64.yql new file mode 100644 index 0000000000..7e29e229f3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Int64.yql @@ -0,0 +1,35 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Int64 '-10)) (< key (Int64 '20)))))) +(let world (Apply test world (lambda '(key) (And (>= key (Int64 '0)) (<= key (Int64 '9223372036854775807)))))) +(let world (Apply test world (lambda '(key) (And (> key (Int64 '0)) (< key (Int64 '9223372036854775807)))))) +(let world (Apply test world (lambda '(key) (And (> key (Int64 '-9223372036854775808)) (< key (Int64 '9223372036854775807)))))) +(let world (Apply test world (lambda '(key) (> key (Int64 '9223372036854775807))))) +(let world (Apply test world (lambda '(key) (>= key (Int64 '9223372036854775807))))) +(let world (Apply test world (lambda '(key) (< key (Int64 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Int64 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Int64 '-10))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Uint32.cfg b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Uint32.cfg new file mode 100644 index 0000000000..fa976ebe64 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Uint32.cfg @@ -0,0 +1,2 @@ +in Input input_ui64.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Uint32.yql b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Uint32.yql new file mode 100644 index 0000000000..9cf0b972e2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/ImplicitConvUint64-Uint32.yql @@ -0,0 +1,32 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let value (Member item 'value)) + (let res (Coalesce (Apply cmp value) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(key) (And (>= key (Uint32 '0)) (<= key (Uint32 '4294967295)))))) +(let world (Apply test world (lambda '(key) (And (> key (Uint32 '0)) (< key (Uint32 '4294967295)))))) +(let world (Apply test world (lambda '(key) (> key (Uint32 '4294967295))))) +(let world (Apply test world (lambda '(key) (>= key (Uint32 '4294967295))))) +(let world (Apply test world (lambda '(key) (< key (Uint32 '0))))) +(let world (Apply test world (lambda '(key) (<= key (Uint32 '0))))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/LMapCombineWithFilter.cfg b/yql/essentials/tests/s-expressions/suites/Filter/LMapCombineWithFilter.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/LMapCombineWithFilter.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Filter/LMapCombineWithFilter.yql b/yql/essentials/tests/s-expressions/suites/Filter/LMapCombineWithFilter.yql new file mode 100644 index 0000000000..887bad3350 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/LMapCombineWithFilter.yql @@ -0,0 +1,53 @@ +( +# read data from Input table +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt (quote plato))) +(let res_sink (DataSink 'result)) + +(let x (Read! world mr_source (Key '('table (String 'Input))) (Void) '())) +(let world (Left! x)) +(let table (Right! x)) + +(let sorted (Sort table (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) sorted '('('mode 'renew)))) +(let world (Commit! world mr_sink)) + +(let x (Read! world mr_source (Key '('table (String 'Output))) (Void) '())) +(let world (Left! x)) +(let table (Right! x)) + +# prepare python udf +(let streamType (StreamType (ListItemType (TypeOf table)))) +(let udfType (CallableType '() '(streamType) '(streamType))) +(let udfScript (String '@@ +def MyFunc(list): + return list +@@)) +(let udf (ScriptUdf 'Python 'MyFunc udfType udfScript)) + +# filter keys less than '100' +(let table (Filter table (lambda '(item) + (Coalesce (> (Member item 'key) (String '100)) (Bool 'false)) +))) +# Produce LMap +(let table (LMap table (lambda '($stream) (Apply udf $stream)))) + +(let Count_create (lambda '(row) (Convert (Exists row) 'Uint64))) +(let Count_update (lambda '(row state) (OptionalReduce state (Convert (Exists row) 'Uint64) (lambda '(a b) (+ a b))))) +(let Count_save (lambda '(state) state)) +(let Count_load (lambda '(item) item)) +(let Count_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) +(let Count_finish (lambda '(state) state)) +(let table (Aggregate table '('"key") '('('Count0 (AggregationTraits (DataType 'String) + Count_create Count_update Count_save Count_load Count_merge Count_finish (Uint64 '0)) '"value")))) +(let table (Sort table '((Bool 'true) (Bool 'true)) (lambda '(row) '((Member row '"key") (Member row '"Count0"))))) + +# write table +(let world (Write! world mr_sink (Key '('table (String 'Output))) table '('('mode 'renew)))) +(let world (Write! world res_sink (Key) table '())) + +# finish +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/LMapWithFilter.cfg b/yql/essentials/tests/s-expressions/suites/Filter/LMapWithFilter.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/LMapWithFilter.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Filter/LMapWithFilter.yql b/yql/essentials/tests/s-expressions/suites/Filter/LMapWithFilter.yql new file mode 100644 index 0000000000..68bb0ad6da --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/LMapWithFilter.yql @@ -0,0 +1,43 @@ +( +# read data from Input table +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt (quote plato))) +(let res_sink (DataSink 'result)) + +(let x (Read! world mr_source (Key '('table (String 'Input))) (Void) '())) +(let world (Left! x)) +(let table (Right! x)) + +(let sorted (Sort table (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) sorted '('('mode 'renew)))) +(let world (Commit! world mr_sink)) + +(let x (Read! world mr_source (Key '('table (String 'Output))) (Void) '())) +(let world (Left! x)) +(let table (Right! x)) + +# prepare python udf +(let streamType (StreamType (ListItemType (TypeOf table)))) +(let udfType (CallableType '() '(streamType) '(streamType))) +(let udfScript (String '@@ +def MyFunc(list): + return list +@@)) +(let udf (ScriptUdf 'Python 'MyFunc udfType udfScript '('('cpu '"5.0") '('extraMem '"12345")))) + +# filter keys less than '100' +(let table (Filter table (lambda '(item) + (Coalesce (> (Member item 'key) (String '100)) (Bool 'false)) +))) +# Produce LMap +(let table (LMap table (lambda '($stream) (Apply udf $stream)))) + +# write table +(let world (Write! world mr_sink (Key '('table (String 'Output))) table '('('mode 'renew)))) +(let world (Write! world res_sink (Key) table '())) + +# finish +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/MixedTypeRange.cfg b/yql/essentials/tests/s-expressions/suites/Filter/MixedTypeRange.cfg new file mode 100644 index 0000000000..33b4e93ec7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/MixedTypeRange.cfg @@ -0,0 +1,2 @@ +in Input input_i64.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/MixedTypeRange.yql b/yql/essentials/tests/s-expressions/suites/Filter/MixedTypeRange.yql new file mode 100644 index 0000000000..8d737e225f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/MixedTypeRange.yql @@ -0,0 +1,23 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"value")) + (let res (Coalesce (And (> key (Int32 '0)) (< key (Int64 '700))) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/NullBoundary.cfg b/yql/essentials/tests/s-expressions/suites/Filter/NullBoundary.cfg new file mode 100644 index 0000000000..33b4e93ec7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/NullBoundary.cfg @@ -0,0 +1,2 @@ +in Input input_i64.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/NullBoundary.yql b/yql/essentials/tests/s-expressions/suites/Filter/NullBoundary.yql new file mode 100644 index 0000000000..702b00544b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/NullBoundary.yql @@ -0,0 +1,23 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"value")) + (let res (Coalesce (< key (Nothing (OptionalType (DataType 'Int64)))) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/OpenRange.yql b/yql/essentials/tests/s-expressions/suites/Filter/OpenRange.yql new file mode 100644 index 0000000000..dcc95c7353 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/OpenRange.yql @@ -0,0 +1,23 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"key")) + (let res (Coalesce (And (> key (String '"020")) (< key (String '"700"))) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/OpenRangeOnSortedInput.yql b/yql/essentials/tests/s-expressions/suites/Filter/OpenRangeOnSortedInput.yql new file mode 100644 index 0000000000..83df5958d9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/OpenRangeOnSortedInput.yql @@ -0,0 +1,30 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Output"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"key")) + (let res (Coalesce (And (> key (String '"020")) (< key (String '"700"))) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/OptionalBoundary.cfg b/yql/essentials/tests/s-expressions/suites/Filter/OptionalBoundary.cfg new file mode 100644 index 0000000000..33b4e93ec7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/OptionalBoundary.cfg @@ -0,0 +1,2 @@ +in Input input_i64.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/OptionalBoundary.yql b/yql/essentials/tests/s-expressions/suites/Filter/OptionalBoundary.yql new file mode 100644 index 0000000000..7f4a8281fb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/OptionalBoundary.yql @@ -0,0 +1,23 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"value")) + (let res (Coalesce (< key (Just (Int64 '700))) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/PartialKey.cfg b/yql/essentials/tests/s-expressions/suites/Filter/PartialKey.cfg new file mode 100644 index 0000000000..eb5df7a613 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/PartialKey.cfg @@ -0,0 +1,2 @@ +in Input partkey.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Filter/PartialKey.yql b/yql/essentials/tests/s-expressions/suites/Filter/PartialKey.yql new file mode 100644 index 0000000000..0d5342fa93 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/PartialKey.yql @@ -0,0 +1,29 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let test (lambda '(world cmp) (block '( + (let filter (lambda '(item) (block '( + (let key (Member item '"key")) + (let subkey (Member item '"subkey")) + (let res (Coalesce (Apply cmp '(key subkey)) (Bool 'false))) + (return res) + )))) + + (let out (Filter input filter)) + (let world (Write! world result (Key) out '())) + (return world) +)))) + +(let world (Apply test world (lambda '(item) (And (> (Nth item '0) (String '"020")) (<= (Nth item '0) (String '"150"))) ))) +(let world (Apply test world (lambda '(item) (And (== (Nth item '0) (String '"075")) (And (> (Nth item '1) (String '"2")) (<= (Nth item '1) (String '"5")))) ))) + +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/RangeIntersection.yql b/yql/essentials/tests/s-expressions/suites/Filter/RangeIntersection.yql new file mode 100644 index 0000000000..35aec35fb1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/RangeIntersection.yql @@ -0,0 +1,25 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"key")) + (let a1 (And (> key (String '"100")) (< key (String '"400")))) + (let a2 (And (> key (String '"020")) (< key (String '"200")))) + (let res (Coalesce (And a1 a2) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/RangeIntersectionOnSortedInput.yql b/yql/essentials/tests/s-expressions/suites/Filter/RangeIntersectionOnSortedInput.yql new file mode 100644 index 0000000000..59803168e1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/RangeIntersectionOnSortedInput.yql @@ -0,0 +1,32 @@ +( +(let source (DataSource '"yt" '"plato")) +(let sink (DataSink '"yt" '"plato")) +(let result (DataSink 'result)) + +(let r (Read! world source (Key '('table (String '"Input"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) +(let sorted (Sort input (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world sink (Key '('table (String 'Output))) sorted '('('mode 'append)))) +(let world (Commit! world sink)) + +(let r (Read! world source (Key '('table (String '"Output"))) (Void) '())) +(let world (Left! r)) +(let input (Right! r)) + +(let filter (lambda '(item) (block '( + (let key (Member item '"key")) + (let a1 (And (> key (String '"100")) (< key (String '"400")))) + (let a2 (And (> key (String '"020")) (< key (String '"200")))) + (let res (Coalesce (And a1 a2) (Bool 'false))) + (return res) +) +))) + +(let out (Filter input filter)) + +(let world (Write! world result (Key) out '('('type)))) +(let world (Commit! world sink)) +(let world (Commit! world result)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Filter/default.cfg b/yql/essentials/tests/s-expressions/suites/Filter/default.cfg new file mode 100644 index 0000000000..fe2b19a9ff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/default.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/Filter/input.txt b/yql/essentials/tests/s-expressions/suites/Filter/input.txt new file mode 100644 index 0000000000..65949ea745 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/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/Filter/input.txt.attr b/yql/essentials/tests/s-expressions/suites/Filter/input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/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/Filter/input_dbl.txt b/yql/essentials/tests/s-expressions/suites/Filter/input_dbl.txt new file mode 100644 index 0000000000..9e8c8c997b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/input_dbl.txt @@ -0,0 +1,5 @@ +{"value"=-1000.}; +{"value"=-10.}; +{"value"=0.}; +{"value"=10.}; +{"value"=1000.}; diff --git a/yql/essentials/tests/s-expressions/suites/Filter/input_dbl.txt.attr b/yql/essentials/tests/s-expressions/suites/Filter/input_dbl.txt.attr new file mode 100644 index 0000000000..8aaee30aa6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/input_dbl.txt.attr @@ -0,0 +1,11 @@ +{ + "_yql_row_spec"={ + "Type"=["StructType";[ + ["value";["DataType";"Double"]] + ]]; + "SortMembers"=["value"]; + "SortedBy"=["value"]; + "SortDirections"=[1]; + "SortedByTypes"=[["DataType";"Double"]] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Filter/input_flt.txt b/yql/essentials/tests/s-expressions/suites/Filter/input_flt.txt new file mode 100644 index 0000000000..9e8c8c997b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/input_flt.txt @@ -0,0 +1,5 @@ +{"value"=-1000.}; +{"value"=-10.}; +{"value"=0.}; +{"value"=10.}; +{"value"=1000.}; diff --git a/yql/essentials/tests/s-expressions/suites/Filter/input_flt.txt.attr b/yql/essentials/tests/s-expressions/suites/Filter/input_flt.txt.attr new file mode 100644 index 0000000000..69560d7e0b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/input_flt.txt.attr @@ -0,0 +1,11 @@ +{ + "_yql_row_spec"={ + "Type"=["StructType";[ + ["value";["DataType";"Float"]] + ]]; + "SortMembers"=["value"]; + "SortedBy"=["value"]; + "SortDirections"=[1]; + "SortedByTypes"=[["DataType";"Float"]] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Filter/input_i32.txt b/yql/essentials/tests/s-expressions/suites/Filter/input_i32.txt new file mode 100644 index 0000000000..f71e6df2d4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/input_i32.txt @@ -0,0 +1,5 @@ +{"value"=-2147483648}; +{"value"=-10}; +{"value"=0}; +{"value"=10}; +{"value"=2147483647}; diff --git a/yql/essentials/tests/s-expressions/suites/Filter/input_i32.txt.attr b/yql/essentials/tests/s-expressions/suites/Filter/input_i32.txt.attr new file mode 100644 index 0000000000..7fcf7442be --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/input_i32.txt.attr @@ -0,0 +1,11 @@ +{ + "schema" = <"strict" = %true;"unique_keys" = %false> + [ + { + "name" = "value"; + "sort_order" = "ascending"; + "type" = "int32"; + "required" = %true; + } + ] +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Filter/input_i64.txt b/yql/essentials/tests/s-expressions/suites/Filter/input_i64.txt new file mode 100644 index 0000000000..355772bb75 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/input_i64.txt @@ -0,0 +1,5 @@ +{"value"=-9223372036854775808}; +{"value"=-10}; +{"value"=0}; +{"value"=10}; +{"value"=9223372036854775807}; diff --git a/yql/essentials/tests/s-expressions/suites/Filter/input_i64.txt.attr b/yql/essentials/tests/s-expressions/suites/Filter/input_i64.txt.attr new file mode 100644 index 0000000000..30006e3aad --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/input_i64.txt.attr @@ -0,0 +1,10 @@ +{ + "schema" = <"strict" = %true;"unique_keys" = %false> + [ + { + "name" = "value"; + "sort_order" = "ascending"; + "type" = "int64" + } + ] +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Filter/input_ui32.txt b/yql/essentials/tests/s-expressions/suites/Filter/input_ui32.txt new file mode 100644 index 0000000000..32d26ed58e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/input_ui32.txt @@ -0,0 +1,3 @@ +{"value"=0u}; +{"value"=10u}; +{"value"=4294967295u}; diff --git a/yql/essentials/tests/s-expressions/suites/Filter/input_ui32.txt.attr b/yql/essentials/tests/s-expressions/suites/Filter/input_ui32.txt.attr new file mode 100644 index 0000000000..edb661f4ea --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/input_ui32.txt.attr @@ -0,0 +1,11 @@ +{ + "schema" = <"strict" = %true;"unique_keys" = %false> + [ + { + "name" = "value"; + "sort_order" = "ascending"; + "type" = "uint32"; + "required" = %true; + } + ] +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Filter/input_ui64.txt b/yql/essentials/tests/s-expressions/suites/Filter/input_ui64.txt new file mode 100644 index 0000000000..c4e744a58c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/input_ui64.txt @@ -0,0 +1,3 @@ +{"value"=0u}; +{"value"=10u}; +{"value"=18446744073709551615u}; diff --git a/yql/essentials/tests/s-expressions/suites/Filter/input_ui64.txt.attr b/yql/essentials/tests/s-expressions/suites/Filter/input_ui64.txt.attr new file mode 100644 index 0000000000..5028e033d5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/input_ui64.txt.attr @@ -0,0 +1,11 @@ +{ + "schema" = <"strict" = %true;"unique_keys" = %false> + [ + { + "name" = "value"; + "sort_order" = "ascending"; + "type" = "uint64"; + "required" = %true; + } + ] +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Filter/input_ui8.txt b/yql/essentials/tests/s-expressions/suites/Filter/input_ui8.txt new file mode 100644 index 0000000000..d61b1d35da --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/input_ui8.txt @@ -0,0 +1,3 @@ +{"value"=0u}; +{"value"=10u}; +{"value"=255u}; diff --git a/yql/essentials/tests/s-expressions/suites/Filter/input_ui8.txt.attr b/yql/essentials/tests/s-expressions/suites/Filter/input_ui8.txt.attr new file mode 100644 index 0000000000..6d04b983e9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/input_ui8.txt.attr @@ -0,0 +1,11 @@ +{ + "schema" = <"strict" = %true;"unique_keys" = %false> + [ + { + "name" = "value"; + "sort_order" = "ascending"; + "type" = "uint8"; + "required" = %true; + } + ] +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Filter/partkey.txt b/yql/essentials/tests/s-expressions/suites/Filter/partkey.txt new file mode 100644 index 0000000000..c2f900fd7c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/partkey.txt @@ -0,0 +1,7 @@ +{"key"="020";"subkey"="1";"value"="q"}; +{"key"="075";"subkey"="2";"value"="abc"}; +{"key"="075";"subkey"="3";"value"="abc"}; +{"key"="075";"subkey"="4";"value"="abc"}; +{"key"="075";"subkey"="5";"value"="abc"}; +{"key"="150";"subkey"="6";"value"="qzz"}; +{"key"="800";"subkey"="7";"value"="ddd"}; diff --git a/yql/essentials/tests/s-expressions/suites/Filter/partkey.txt.attr b/yql/essentials/tests/s-expressions/suites/Filter/partkey.txt.attr new file mode 100644 index 0000000000..ba33fb7074 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Filter/partkey.txt.attr @@ -0,0 +1,13 @@ +{ + "_yql_row_spec"={ + "Type"=["StructType";[ + ["key"; ["DataType"; "String"]]; + ["subkey"; ["DataType"; "String"]]; + ["value"; ["DataType"; "String"]]; + ]]; + "SortMembers"=["key"; "subkey"]; + "SortedBy"=["key"; "subkey"]; + "SortDirections"=[1; 1]; + "SortedByTypes"=[["DataType";"String"]; ["DataType";"String"]] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/GraceJoin/GraceJoinCore_Flow.yql b/yql/essentials/tests/s-expressions/suites/GraceJoin/GraceJoinCore_Flow.yql new file mode 100644 index 0000000000..da309347a4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/GraceJoin/GraceJoinCore_Flow.yql @@ -0,0 +1,23 @@ +( +(let world (Configure! world (DataSource '"config") '"LLVM" '"OFF")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let list2 (Right! x)) + +(let joinInner (GraceJoinCore +(ExpandMap (ToFlow list1) (lambda '(m)(Member m 'key1))) +(ExpandMap (ToFlow list2) (lambda '(m)(Member m 'key2))) +'Inner '('0) '('0) '('0 '0) '('0 '1) '('key1) '('key2) '())) + +(let res_sink (DataSink 'result)) + +(let world (Write! world res_sink (Key) (Collect (NarrowMap joinInner (lambda '(a b) (AsStruct '('a a) '('b b))))) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/GraceJoin/SelfJoinCore_Flow.yql b/yql/essentials/tests/s-expressions/suites/GraceJoin/SelfJoinCore_Flow.yql new file mode 100644 index 0000000000..e184b34935 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/GraceJoin/SelfJoinCore_Flow.yql @@ -0,0 +1,18 @@ +( +(let world (Configure! world (DataSource '"config") '"LLVM" '"OFF")) +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let list1 (Right! x)) + +(let joinInner (GraceSelfJoinCore +(ExpandMap (ToFlow list1) (lambda '(m)(Member m 'key1))) +'Inner '('0) '('0) '('0 '0) '('0 '1) '('key1) '('key1) '())) + +(let res_sink (DataSink 'result)) + +(let world (Write! world res_sink (Key) (Collect (NarrowMap joinInner (lambda '(a b) (AsStruct '('a a) '('b b))))) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/GraceJoin/default.cfg b/yql/essentials/tests/s-expressions/suites/GraceJoin/default.cfg new file mode 100644 index 0000000000..3986c38117 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/GraceJoin/default.cfg @@ -0,0 +1,5 @@ +res result.txt +in Input1 input1.txt +in Input2 input2.txt +in Input1Opt input1opt.txt +in Input2Opt input2opt.txt diff --git a/yql/essentials/tests/s-expressions/suites/GraceJoin/input1.txt b/yql/essentials/tests/s-expressions/suites/GraceJoin/input1.txt new file mode 100644 index 0000000000..4393708fba --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/GraceJoin/input1.txt @@ -0,0 +1,3 @@ +{"key1"=1u;subkey1="..";"value1"="A"}; +{"key1"=4u;subkey1="..";"value1"="C"}; +{"key1"=4u;subkey1="..";"value1"="D"}; diff --git a/yql/essentials/tests/s-expressions/suites/GraceJoin/input1.txt.attr b/yql/essentials/tests/s-expressions/suites/GraceJoin/input1.txt.attr new file mode 100644 index 0000000000..3f78440b17 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/GraceJoin/input1.txt.attr @@ -0,0 +1,30 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key1"; + [ + "DataType"; + "Uint64" + ] + ]; + [ + "subkey1"; + [ + "DataType"; + "String" + ] + ]; + [ + "value1"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/GraceJoin/input1opt.txt b/yql/essentials/tests/s-expressions/suites/GraceJoin/input1opt.txt new file mode 100644 index 0000000000..98331c5ee4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/GraceJoin/input1opt.txt @@ -0,0 +1,6 @@ +{"key1"=1;subkey1="...";"value1"="A"}; +{"key1"=4;subkey1="...";"value1"="C"}; +{"key1"=4;subkey1="...";"value1"="D"}; +{"key1"=#;subkey1="...";"value1"="E"}; +{"key1"=#;subkey1="...";"value1"="F"}; +{"key1"=#;subkey1="...";"value1"="G"}; diff --git a/yql/essentials/tests/s-expressions/suites/GraceJoin/input1opt.txt.attr b/yql/essentials/tests/s-expressions/suites/GraceJoin/input1opt.txt.attr new file mode 100644 index 0000000000..de343fa9cb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/GraceJoin/input1opt.txt.attr @@ -0,0 +1,39 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key1"; + [ + "OptionalType"; + [ + "DataType"; + "Int32" + ] + ] + ]; + [ + "subkey1"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ]; + [ + "value1"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/GraceJoin/input2.txt b/yql/essentials/tests/s-expressions/suites/GraceJoin/input2.txt new file mode 100644 index 0000000000..7e4ea597de --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/GraceJoin/input2.txt @@ -0,0 +1,3 @@ +{"key2"=2u;subkey2=".";"value2"="U"}; +{"key2"=4u;subkey2=".";"value2"="Y"}; +{"key2"=4u;subkey2=".";"value2"="W"}; diff --git a/yql/essentials/tests/s-expressions/suites/GraceJoin/input2.txt.attr b/yql/essentials/tests/s-expressions/suites/GraceJoin/input2.txt.attr new file mode 100644 index 0000000000..824353dafc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/GraceJoin/input2.txt.attr @@ -0,0 +1,30 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key2"; + [ + "DataType"; + "Uint64" + ] + ]; + [ + "subkey2"; + [ + "DataType"; + "String" + ] + ]; + [ + "value2"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/GraceJoin/input2opt.txt b/yql/essentials/tests/s-expressions/suites/GraceJoin/input2opt.txt new file mode 100644 index 0000000000..17ff7232b7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/GraceJoin/input2opt.txt @@ -0,0 +1,6 @@ +{"key2"=2u;subkey2=".";"value2"="U"}; +{"key2"=4u;subkey2=".";"value2"="Y"}; +{"key2"=4u;subkey2=".";"value2"="W"}; +{"key2"=#;subkey2=".";"value2"="P"}; +{"key2"=#;subkey2=".";"value2"="Q"}; +{"key2"=#;subkey2=".";"value2"="R"}; diff --git a/yql/essentials/tests/s-expressions/suites/GraceJoin/input2opt.txt.attr b/yql/essentials/tests/s-expressions/suites/GraceJoin/input2opt.txt.attr new file mode 100644 index 0000000000..990e5b6aee --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/GraceJoin/input2opt.txt.attr @@ -0,0 +1,39 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key2"; + [ + "OptionalType"; + [ + "DataType"; + "Uint64" + ] + ] + ]; + [ + "subkey2"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ]; + [ + "value2"; + [ + "OptionalType"; + [ + "DataType"; + "String" + ] + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/Arithmetic.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/Arithmetic.yql new file mode 100644 index 0000000000..dfc37d30de --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/Arithmetic.yql @@ -0,0 +1,33 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let res (List (ListType (DataType 'Uint64)))) +(let res (Append res (+ (Int32 '5) (Uint64 '5)))) +(let res (Append res (+ (Int32 '-5) (Uint64 '5)))) +(let res (Append res (+ (Uint64 '5) (Int32 '-5)))) +(let world (Write! world res_sink (Key) res '('('type)))) +(let res (List (ListType (DataType 'Uint64)))) +(let res (Append res (- (Int32 '5) (Uint64 '5)))) +(let res (Append res (- (Int32 '-5) (Uint64 '5)))) +(let res (Append res (- (Uint64 '5) (Int32 '-5)))) +(let world (Write! world res_sink (Key) res '('('type)))) +(let res (List (ListType (DataType 'Uint64)))) +(let res (Append res (* (Int32 '5) (Uint64 '5)))) +(let res (Append res (* (Int32 '-5) (Uint64 '5)))) +(let res (Append res (* (Uint64 '5) (Int32 '-5)))) +(let world (Write! world res_sink (Key) res '('('type)))) +(let res (List (ListType (OptionalType (DataType 'Uint64))))) +(let res (Append res (/ (Int32 '5) (Uint64 '5)))) +(let res (Append res (/ (Int32 '-5) (Uint64 '5)))) +(let res (Append res (/ (Uint64 '5) (Int32 '-5)))) +(let world (Write! world res_sink (Key) res '('('type)))) +(let res (List (ListType (OptionalType (DataType 'Uint64))))) +(let res (Append res (% (Int32 '5) (Uint64 '5)))) +(let res (Append res (% (Int32 '-5) (Uint64 '5)))) +(let res (Append res (% (Uint64 '5) (Int32 '-5)))) +(let world (Write! world res_sink (Key) res '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/AsListInferCommonTypeOpt.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AsListInferCommonTypeOpt.yql new file mode 100644 index 0000000000..9e4f52e93d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AsListInferCommonTypeOpt.yql @@ -0,0 +1,28 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# Int32, Uint16??? -> Int32??? +(let data (AsList (Int32 '1) (Just (Just (Just (Uint16 '2)))))) +(let world (Write! world res_sink (Key) data '('('type)))) + +# Int32?, Uint16??? -> Int32??? +(let data (AsList (Just (Int32 '1)) (Just (Just (Just (Uint16 '2)))))) +(let world (Write! world res_sink (Key) data '('('type)))) + +# Int64?, Null -> Int64? +(let data (AsList (Just (Int64 '1)) (Null))) +(let world (Write! world res_sink (Key) data '('('type)))) + +# Int64?, Nothing(Null?) -> Int64?? +(let data (AsList (Just (Int64 '1)) (Nothing (OptionalType (NullType))))) +(let world (Write! world res_sink (Key) data '('('type)))) + +# Int64?, Nothing(Null?)? -> Int64??? +(let data (AsList (Just (Int64 '1)) (Just (Nothing (OptionalType (NullType)))))) +(let world (Write! world res_sink (Key) data '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvert.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvert.yql new file mode 100644 index 0000000000..a326656deb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvert.yql @@ -0,0 +1,35 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (Int32 '1))) +(let data (Append data (Uint8 '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Uint32 '1))) +(let data (Append data (Uint8 '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Uint64 '1))) +(let data (Append data (Uint8 '2))) +(let data (Append data (Uint32 '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Int64 '1))) +(let data (Append data (Uint8 '2))) +(let data (Append data (Int32 '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Float '1))) +(let data (Append data (Uint8 '2))) +(let data (Append data (Int32 '2))) +(let data (Append data (Uint32 '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Double '1))) +(let data (Append data (Uint8 '2))) +(let data (Append data (Int32 '2))) +(let data (Append data (Uint32 '2))) +(let data (Append data (Int64 '2))) +(let data (Append data (Uint64 '2))) +(let data (Append data (Float '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByBinContent.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByBinContent.yql new file mode 100644 index 0000000000..d3a2fa7c5a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByBinContent.yql @@ -0,0 +1,38 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (Uint8 '1))) +(let data (Append data (Uint32 'x"02000000"))) +(let data (Append data (Int32 'x"02000000"))) +(let data (Append data (Uint64 'x"0200000000000000"))) +(let data (Append data (Int64 'x"0200000000000000"))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Int32 '1))) +(let data (Append data (Uint32 'x"02000000"))) +(let data (Append data (Int32 'x"02000000"))) +(let data (Append data (Uint64 'x"0200000000000000"))) +(let data (Append data (Int64 'x"0200000000000000"))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Uint32 '1))) +(let data (Append data (Uint32 'x"02000000"))) +(let data (Append data (Int32 'x"02000000"))) +(let data (Append data (Uint64 'x"0200000000000000"))) +(let data (Append data (Int64 'x"0200000000000000"))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Int64 '1))) +(let data (Append data (Uint32 'x"02000000"))) +(let data (Append data (Int32 'x"02000000"))) +(let data (Append data (Uint64 'x"0200000000000000"))) +(let data (Append data (Int64 'x"0200000000000000"))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Uint64 '1))) +(let data (Append data (Uint32 'x"02000000"))) +(let data (Append data (Int32 'x"02000000"))) +(let data (Append data (Uint64 'x"0200000000000000"))) +(let data (Append data (Int64 'x"0200000000000000"))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByContent.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByContent.yql new file mode 100644 index 0000000000..478ba0b492 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByContent.yql @@ -0,0 +1,38 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (Uint8 '1))) +(let data (Append data (Uint32 '2))) +(let data (Append data (Int32 '2))) +(let data (Append data (Uint64 '2))) +(let data (Append data (Int64 '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Int32 '1))) +(let data (Append data (Uint32 '2))) +(let data (Append data (Int32 '2))) +(let data (Append data (Uint64 '2))) +(let data (Append data (Int64 '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Uint32 '1))) +(let data (Append data (Uint32 '2))) +(let data (Append data (Int32 '2))) +(let data (Append data (Uint64 '2))) +(let data (Append data (Int64 '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Int64 '1))) +(let data (Append data (Uint32 '2))) +(let data (Append data (Int32 '2))) +(let data (Append data (Uint64 '2))) +(let data (Append data (Int64 '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Uint64 '1))) +(let data (Append data (Uint32 '2))) +(let data (Append data (Int32 '2))) +(let data (Append data (Uint64 '2))) +(let data (Append data (Int64 '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByIf.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByIf.yql new file mode 100644 index 0000000000..1008cf6499 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByIf.yql @@ -0,0 +1,11 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (Uint64 '1)) +(let data (If (Bool 'true) data (Double '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByMinusContent.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByMinusContent.yql new file mode 100644 index 0000000000..afe7c04735 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByMinusContent.yql @@ -0,0 +1,42 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (Uint8 '1))) +(let data (Append data (Minus (Int32 '-2)))) +(let data (Append data (Minus (Uint32 'x"FCFFFFFF")))) +(let data (Append data (Minus (Int64 '-2)))) +(let data (Append data (Minus (Uint64 'x"FCFFFFFFFFFFFFFF")))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Int32 '1))) +(let data (Append data (Minus (Int32 '-2)))) +(let data (Append data (Minus (Int32 '2)))) +(let data (Append data (Minus (Uint32 'x"FCFFFFFF")))) +(let data (Append data (Minus (Int64 '-2)))) +(let data (Append data (Minus (Int64 '2)))) +(let data (Append data (Minus (Uint64 'x"FCFFFFFFFFFFFFFF")))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Uint32 '1))) +(let data (Append data (Minus (Int32 '-2)))) +(let data (Append data (Minus (Uint32 'x"FCFFFFFF")))) +(let data (Append data (Minus (Int64 '-2)))) +(let data (Append data (Minus (Uint64 'x"FCFFFFFFFFFFFFFF")))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Int64 '1))) +(let data (Append data (Minus (Int32 '-2)))) +(let data (Append data (Minus (Int32 '2)))) +(let data (Append data (Minus (Uint32 'x"FCFFFFFF")))) +(let data (Append data (Minus (Int64 '-2)))) +(let data (Append data (Minus (Int64 '2)))) +(let data (Append data (Minus (Uint64 'x"FCFFFFFFFFFFFFFF")))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Uint64 '1))) +(let data (Append data (Minus (Int32 '-2)))) +(let data (Append data (Minus (Uint32 'x"FCFFFFFF")))) +(let data (Append data (Minus (Int64 '-2)))) +(let data (Append data (Minus (Uint64 'x"FCFFFFFFFFFFFFFF")))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByPlusContent.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByPlusContent.yql new file mode 100644 index 0000000000..27ac41dba1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertByPlusContent.yql @@ -0,0 +1,38 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (Uint8 '1))) +(let data (Append data (Plus (Uint32 '2)))) +(let data (Append data (Plus (Int32 '2)))) +(let data (Append data (Plus (Uint64 '2)))) +(let data (Append data (Plus (Int64 '2)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Int32 '1))) +(let data (Append data (Plus (Uint32 '2)))) +(let data (Append data (Plus (Int32 '2)))) +(let data (Append data (Plus (Uint64 '2)))) +(let data (Append data (Plus (Int64 '2)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Uint32 '1))) +(let data (Append data (Plus (Uint32 '2)))) +(let data (Append data (Plus (Int32 '2)))) +(let data (Append data (Plus (Uint64 '2)))) +(let data (Append data (Plus (Int64 '2)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Int64 '1))) +(let data (Append data (Plus (Uint32 '2)))) +(let data (Append data (Plus (Int32 '2)))) +(let data (Append data (Plus (Uint64 '2)))) +(let data (Append data (Plus (Int64 '2)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (AsList (Uint64 '1))) +(let data (Append data (Plus (Uint32 '2)))) +(let data (Append data (Plus (Int32 '2)))) +(let data (Append data (Plus (Uint64 '2)))) +(let data (Append data (Plus (Int64 '2)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertCoalesce.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertCoalesce.yql new file mode 100644 index 0000000000..9977eefc30 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertCoalesce.yql @@ -0,0 +1,16 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (Coalesce (Nothing (OptionalType (DataType 'Uint32))) (Uint64 '1))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (Coalesce (Nothing (OptionalType (DataType 'Uint64))) (Int64 '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (Coalesce (Nothing (OptionalType (DataType 'Int64))) (+ (Uint32 '1) (Uint32 '2)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (Coalesce (Nothing (OptionalType (DataType 'Uint32))) (Just (Uint32 '4)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertCoalesceSrtucts.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertCoalesceSrtucts.yql new file mode 100644 index 0000000000..4ea96cadab --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoConvertCoalesceSrtucts.yql @@ -0,0 +1,10 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (Coalesce (AsStruct '('"a" (Int32 '1))) (AsStruct))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoJust.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoJust.yql new file mode 100644 index 0000000000..ce67a47d55 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoJust.yql @@ -0,0 +1,11 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (Just (Just (String 'a))))) +(let data (Append data (String 'b))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoJustByIf.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoJustByIf.yql new file mode 100644 index 0000000000..88c2e397a7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/AutoJustByIf.yql @@ -0,0 +1,11 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (Just (Just (String 'a)))) +(let data (If (Bool 'true) data (String 'b))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/Compare.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/Compare.yql new file mode 100644 index 0000000000..3f2fa9519d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/Compare.yql @@ -0,0 +1,42 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let res (List (ListType (DataType 'Bool)))) +(let res (Append res (== (Int32 '5) (Uint64 '5)))) +(let res (Append res (== (Int32 '-5) (Uint64 '5)))) +(let res (Append res (== (Uint64 '5) (Int32 '-5)))) +(let world (Write! world res_sink (Key) res '('('type)))) +(let res (List (ListType (DataType 'Bool)))) +(let res (Append res (!= (Int32 '5) (Uint64 '5)))) +(let res (Append res (!= (Int32 '-5) (Uint64 '5)))) +(let res (Append res (!= (Uint64 '5) (Int32 '-5)))) +(let world (Write! world res_sink (Key) res '('('type)))) +(let res (List (ListType (DataType 'Bool)))) +(let res (Append res (< (Int32 '5) (Uint64 '5)))) +(let res (Append res (< (Int32 '-1) (Uint64 '5)))) +(let res (Append res (< (Int32 '1) (Uint64 '5)))) +(let res (Append res (< (Uint64 '1) (Int32 '-2)))) +(let world (Write! world res_sink (Key) res '('('type)))) +(let res (List (ListType (DataType 'Bool)))) +(let res (Append res (<= (Int32 '5) (Uint64 '5)))) +(let res (Append res (<= (Int32 '-1) (Uint64 '5)))) +(let res (Append res (<= (Int32 '1) (Uint64 '5)))) +(let res (Append res (<= (Uint64 '1) (Int32 '-2)))) +(let world (Write! world res_sink (Key) res '('('type)))) +(let res (List (ListType (DataType 'Bool)))) +(let res (Append res (> (Int32 '5) (Uint64 '5)))) +(let res (Append res (> (Int32 '-1) (Uint64 '5)))) +(let res (Append res (> (Int32 '1) (Uint64 '5)))) +(let res (Append res (> (Uint64 '1) (Int32 '-2)))) +(let world (Write! world res_sink (Key) res '('('type)))) +(let res (List (ListType (DataType 'Bool)))) +(let res (Append res (>= (Int32 '5) (Uint64 '5)))) +(let res (Append res (>= (Int32 '-1) (Uint64 '5)))) +(let res (Append res (>= (Int32 '1) (Uint64 '5)))) +(let res (Append res (>= (Uint64 '1) (Int32 '-2)))) +(let world (Write! world res_sink (Key) res '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/Enumerate.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/Enumerate.yql new file mode 100644 index 0000000000..20547b0aaa --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/Enumerate.yql @@ -0,0 +1,10 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (Enumerate (AsList (String 'a) (String 'b)) (Int64 '2) (Uint32 '1))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverData.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverData.yql new file mode 100644 index 0000000000..4da2353218 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverData.yql @@ -0,0 +1,30 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +# result is true for all tests below + +# To float +(let value (Uint64 '18446744073709551615)) +(let commonType (DataType 'Float)) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# To double +(let value (Int64 '"-9223372036854775808")) +(let commonType (DataType 'Double)) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# To string +(let value (Utf8 '"проверка")) +(let commonType (DataType 'String)) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverDataIntegralTypes.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverDataIntegralTypes.yql new file mode 100644 index 0000000000..bab448cfa0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverDataIntegralTypes.yql @@ -0,0 +1,70 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +# Both signed (true) +(let value (Int32 '0)) +(let commonType (DataType 'Int64)) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# Both unsigned (true) +(let value (Uint8 '0)) +(let commonType (DataType 'Uint16)) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# uint32(0) -> int32 (true) +(let value (Uint32 '0)) +(let commonType (DataType 'Int32)) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# uint32(2^31-1) -> int32 (true) +(let value (Uint32 '2147483647)) +(let commonType (DataType 'Int32)) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# uint32(2^31) -> int32 (false) +(let value (Uint32 '2147483648)) +(let commonType (DataType 'Int32)) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# uint32(2^32-1) -> int32 (false) +(let value (Uint32 '4294967295)) +(let commonType (DataType 'Int32)) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# int16(0) -> uint32 (true) +(let value (Int16 '0)) +(let commonType (DataType 'Uint32)) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# int16(32767) -> uint32 (true) +(let value (Int16 '32767)) +(let commonType (DataType 'Uint32)) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# int16(-1) -> uint32 (false) +(let value (Int16 '"-1")) +(let commonType (DataType 'Uint32)) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# int16(-32768) -> uint32 (false) +(let value (Int16 '"-32768")) +(let commonType (DataType 'Uint32)) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverDict.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverDict.yql new file mode 100644 index 0000000000..17dbdd3de4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverDict.yql @@ -0,0 +1,23 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +# Dict<Uint32, Int16>> -> Dict<Uint32, Uint64> (false) +(let value (AsDict '((Uint32 '0) (Int16 '"-1")))) +(let commonType (DictType (DataType 'Uint32) (DataType 'Uint64))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# Dict<Uint32, Uint16>> -> Dict<Uint32, Uint64> (true) +(let value (AsDict '((Uint32 '0) (Uint16 '0)))) +(let commonType (DictType (DataType 'Uint32) (DataType 'Uint64))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverList.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverList.yql new file mode 100644 index 0000000000..9622fabe4b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverList.yql @@ -0,0 +1,24 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +# List<Uint16> -> List<Int16> (false) +(let value (AsList (Uint16 '32767))) +(let value (Append value (Uint16 '32768))) +(let commonType (ListType (DataType 'Int16))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# List<Uint16> -> List<UInt32> (true) +(let value (AsList (Uint16 '32767))) +(let value (Append value (Uint16 '32768))) +(let commonType (ListType (DataType 'Uint32))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverOptional.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverOptional.yql new file mode 100644 index 0000000000..468cab9df7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverOptional.yql @@ -0,0 +1,30 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +# result is true for all tests below + +# Int32 -> Uint64?? (false) +(let value (Int32 '"-1")) +(let commonType (OptionalType (OptionalType (DataType 'Uint64)))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# Just(Int32) -> Uint64?? (false) +(let value (Just (Int32 '"-1"))) +(let commonType (OptionalType (OptionalType (DataType 'Uint64)))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# Nothing(Int32)? -> Uint64?? (true) +(let value (Just (Nothing (OptionalType (DataType 'Int32))))) +(let commonType (OptionalType (OptionalType (DataType 'Uint64)))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverStruct.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverStruct.yql new file mode 100644 index 0000000000..ae8830e61f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverStruct.yql @@ -0,0 +1,22 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +# Struct<Int16, Int16>> -> Struct<Uint32, Uint64> (false) +(let value (AsStruct '('"a" (Int16 '0)) '('"b" (Int16 '"-1")))) +(let commonType (StructType '('"a" (DataType 'Uint32)) '('"b" (DataType 'Uint64)))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# Struct<Uint16, Uint16>> -> Struct<Uint32, Uint64> (true) +(let value (AsStruct '('"a" (Uint16 '0)) '('"b" (Uint16 '0)))) +(let commonType (StructType '('"a" (DataType 'Uint32)) '('"b" (DataType 'Uint64)))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverTuple.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverTuple.yql new file mode 100644 index 0000000000..3461a8d239 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverTuple.yql @@ -0,0 +1,22 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +# (Int16, Int16, Int16, Int16, Int16) -> (Uint32, Uint32, Uint64, Uint32, Uint64) (false) +(let value '((Int16 '0) (Int16 '"-1") (Int16 '0) (Int16 '0) (Int16 '0))) +(let commonType (TupleType (DataType 'Uint32) (DataType 'Uint32) (DataType 'Uint64) (DataType 'Uint32) (DataType 'Uint64))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# (Uint16, Uint16, Uint16, Uint16, Uint16) -> (Uint32, Uint32, Uint64, Uint32, Uint64) (true) +(let value '((Uint16 '0) (Uint16 '0) (Uint16 '0) (Uint16 '0) (Uint16 '0))) +(let commonType (TupleType (DataType 'Uint32) (DataType 'Uint32) (DataType 'Uint64) (DataType 'Uint32) (DataType 'Uint64))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverVariantStruct.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverVariantStruct.yql new file mode 100644 index 0000000000..a6de909851 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverVariantStruct.yql @@ -0,0 +1,24 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +# Variant<Struct<Int16, Int16>>> -> Variant<Struct<Uint32, Uint64>> (false) +(let variantType (VariantType (StructType '('"a" (DataType 'Int16)) '('"b" (DataType 'Int16))))) +(let value (Variant (Int16 '"-1") '"a" variantType)) +(let commonType (VariantType (StructType '('"a" (DataType 'Uint32)) '('"b" (DataType 'Uint64))))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# Variant<Struct<Uint16, Uint16>>> -> Variant<Struct<Uint32, Uint64>> (true) +(let variantType (VariantType (StructType '('"a" (DataType 'Uint16)) '('"b" (DataType 'Uint16))))) +(let value (Variant (Uint16 '0) '"a" variantType)) +(let commonType (VariantType (StructType '('"a" (DataType 'Uint32)) '('"b" (DataType 'Uint64))))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverVariantTuple.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverVariantTuple.yql new file mode 100644 index 0000000000..28dd639e69 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/ImplicitEqualsOverVariantTuple.yql @@ -0,0 +1,24 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +# Variant<Tuple<Int16, Int32>>> -> Variant<Tuple<Uint32, Uint64>> (false) +(let variantType (VariantType (TupleType (DataType 'Int16) (DataType 'Int32)))) +(let value (Variant (Int32 '"-1") '1 variantType)) +(let commonType (VariantType (TupleType (DataType 'Uint32) (DataType 'Uint64)))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +# Variant<Tuple<Uint16, Uint32>>> -> Variant<Tuple<Uint32, Uint64>> (true) +(let variantType (VariantType (TupleType (DataType 'Uint16) (DataType 'Uint32)))) +(let value (Variant (Uint32 '0) '1 variantType)) +(let commonType (VariantType (TupleType (DataType 'Uint32) (DataType 'Uint64)))) +(let imlicitEqualsResult (Exists (StrictCast value commonType))) +(let world (Write! world res_sink (Key) imlicitEqualsResult '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideDictLiteral.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideDictLiteral.yql new file mode 100644 index 0000000000..f7393666cc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideDictLiteral.yql @@ -0,0 +1,13 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (AsDict '((Uint32 '12) (Uint32 '34))))) +(let data (Append data (AsDict '((Uint32 '56) (Int64 '78))))) +(let dt (DictType (DataType 'Uint32) (DataType 'Int64))) +(let data (Append data (Dict dt '((Uint32 '90) (Int64 '12))))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideList.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideList.yql new file mode 100644 index 0000000000..b2259327f1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideList.yql @@ -0,0 +1,11 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (AsList (Int64 '12)))) +(let data (Append data (AsList (Int32 '-5)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideListLiteral.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideListLiteral.yql new file mode 100644 index 0000000000..bd0adcd454 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideListLiteral.yql @@ -0,0 +1,13 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (AsList (Uint32 '12)))) +(let data (Append data (AsList (Int64 '34)))) +(let lt (ListType (DataType 'Int64))) +(let data (Append data (List lt (Int64 '56)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideOpt.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideOpt.yql new file mode 100644 index 0000000000..ddf3ad70b0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideOpt.yql @@ -0,0 +1,11 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (Just (Int64 '12)))) +(let data (Append data (Just (Int32 '-5)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideOptLiteral.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideOptLiteral.yql new file mode 100644 index 0000000000..52b4d2872a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideOptLiteral.yql @@ -0,0 +1,11 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (Just (Uint32 '12)))) +(let data (Append data (Just (Int64 '34)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideStruct.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideStruct.yql new file mode 100644 index 0000000000..4bf5f79adb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideStruct.yql @@ -0,0 +1,11 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (AsStruct '('key (Just (Int64 '12)))))) +(let data (Append data (AsStruct '('key (Int64 '34))))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideStructLiteral.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideStructLiteral.yql new file mode 100644 index 0000000000..69051e7c19 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideStructLiteral.yql @@ -0,0 +1,13 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (AsStruct '('x (Uint32 '12))))) +(let data (Append data (AsStruct '('x (Int64 '34))))) +(let st (StructType '('x (DataType 'Int64)))) +(let data (Append data (Struct st '('x (Int64 '56))))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideTuple.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideTuple.yql new file mode 100644 index 0000000000..a06b03fe9d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideTuple.yql @@ -0,0 +1,11 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList '((Just (Int64 '12))))) +(let data (Append data '((Int64 '34)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideTupleLiteral.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideTupleLiteral.yql new file mode 100644 index 0000000000..28da7c8617 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideTupleLiteral.yql @@ -0,0 +1,11 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList '((Uint32 '12)))) +(let data (Append data '((Int64 '34)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideVariant.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideVariant.yql new file mode 100644 index 0000000000..2acee2f12b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideVariant.yql @@ -0,0 +1,54 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# Variant over tuple + +(let vt (ParseType '"Variant<Int64, Struct<A:Int64, B:Double>>")) +(let vt2 (ParseType '"Variant<Int32, Struct<A:Int32, B:Double>>")) + +(let testcase1 (AsList (Variant (Int64 '10) '0 vt))) + +(let argBody (lambda '() (Variant (Int32 '11) '0 vt2))) +(let argType (CallableType '() '(vt2))) +(let argCallable (Callable argType argBody)) +(let arg (Apply argCallable)) +(let testcase1 (Append testcase1 arg)) + +(let argBody (lambda '() (Variant (AsStruct '('A (Int64 '25)) '('B (Double '15.5))) '1 vt2))) +(let argType (CallableType '() '(vt2))) +(let argCallable (Callable argType argBody)) +(let arg (Apply argCallable)) +(let testcase1 (Append testcase1 arg)) + +# Variant over struct + +(let vts (ParseType '"Variant<A:Int64, B:Struct<A:Int64, B:Double>>")) +(let vts2 (ParseType '"Variant<A:Int32, B:Struct<A:Int32, B:Double>>")) +(let vts3 (ParseType '"Variant<A:Int32>")) + +(let testcase2 (AsList (Variant (Int64 '10) 'A vts))) + +(let argBody (lambda '() (Variant (Int32 '11) 'A vts2))) +(let argType (CallableType '() '(vts2))) +(let argCallable (Callable argType argBody)) +(let arg (Apply argCallable)) +(let testcase2 (Append testcase2 arg)) + +(let argBody (lambda '() (Variant (AsStruct '('A (Int64 '25)) '('B (Double '15.5))) 'B vts2))) +(let argType (CallableType '() '(vts2))) +(let argCallable (Callable argType argBody)) +(let arg (Apply argCallable)) +(let testcase2 (Append testcase2 arg)) + +(let argBody (lambda '() (Variant (Int32 '11) 'A vts3))) +(let argType (CallableType '() '(vts3))) +(let argCallable (Callable argType argBody)) +(let arg (Apply argCallable)) +(let testcase2 (Append testcase2 arg)) + +(let world (Write! world res_sink (Key) '(testcase1 testcase2) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideVariantLiteral.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideVariantLiteral.yql new file mode 100644 index 0000000000..bbc1bfa584 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/InsideVariantLiteral.yql @@ -0,0 +1,29 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +# Variant over struct + +(let vt (ParseType '"Variant<Int64, Struct<A:Int64, B:Double>>")) +(let vt2 (ParseType '"Variant<Int32, Struct<A:Int32, B:Double>>")) + +(let testcase1 (AsList (Variant (Int64 '10) '0 vt))) +(let testcase1 (Append testcase1 (Variant (Int32 '11) '0 vt2))) +(let testcase1 (Append testcase1 (Variant (AsStruct '('A (Int64 '25)) '('B (Double '15.5))) '1 vt2))) + +# Variant over tuple + +(let vts (ParseType '"Variant<A:Int64, B:Struct<A:Int64, B:Double>>")) +(let vts2 (ParseType '"Variant<A:Int32, B:Struct<A:Int32, B:Double>>")) +(let vts3 (ParseType '"Variant<A:Int32>")) + +(let testcase2 (AsList (Variant (Int64 '10) 'A vts))) +(let testcase2 (Append testcase2 (Variant (Int32 '11) 'A vts2))) +(let testcase2 (Append testcase2 (Variant (AsStruct '('A (Int64 '25)) '('B (Double '15.5))) 'B vts2))) +(let testcase2 (Append testcase2 (Variant (Int32 '11) 'A vts3))) + +(let world (Write! world res_sink (Key) '(testcase1 testcase2) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/NarrowStruct.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/NarrowStruct.yql new file mode 100644 index 0000000000..8c5bc62595 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/NarrowStruct.yql @@ -0,0 +1,11 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (AsStruct '('key (Just (Int64 '12)))))) +(let data (Append data (AsStruct '('key (Int64 '34)) '('value (String 'foo))))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/NullAsOpt.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/NullAsOpt.yql new file mode 100644 index 0000000000..cf59f2bb0c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/NullAsOpt.yql @@ -0,0 +1,11 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let ct (ParseType '"(Uint32?,Uint32)->Uint32")) +(let callable (Callable ct (lambda '(x y) (Coalesce x y)))) +(let world (Write! world res_sink (Key) (Apply callable (Null) (Uint32 '2)) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/Shift.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/Shift.yql new file mode 100644 index 0000000000..718fabeac3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/Shift.yql @@ -0,0 +1,25 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (ShiftLeft (Int32 '"1") (Int64 '"10"))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (ShiftLeft (Int64 '"1") (Int64 '"10"))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (ShiftLeft (Int32 '"1") (Int64 '"40"))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (ShiftLeft (Int64 '"1") (Int64 '"40"))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(let data (ShiftLeft (Just (Int32 '"1")) (Int64 '"10"))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (ShiftLeft (Just (Int64 '"1")) (Int64 '"10"))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (ShiftLeft (Just (Int32 '"1")) (Int64 '"40"))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (ShiftLeft (Just (Int64 '"1")) (Int64 '"40"))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/Skip.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/Skip.yql new file mode 100644 index 0000000000..e906d237e5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/Skip.yql @@ -0,0 +1,10 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (Skip (AsList (String 'a) (String 'b)) (Int64 '1))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/Substring.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/Substring.yql new file mode 100644 index 0000000000..2de7c5efe9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/Substring.yql @@ -0,0 +1,10 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (Substring (String 'abcde) (Int64 '2) (Uint64 '1))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/Take.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/Take.yql new file mode 100644 index 0000000000..b91a23e1de --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/Take.yql @@ -0,0 +1,10 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (Take (AsList (String 'a) (String 'b)) (Int64 '1))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructExtraItemsFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructExtraItemsFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructExtraItemsFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructExtraItemsFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructExtraItemsFail.yql new file mode 100644 index 0000000000..a2d9759568 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructExtraItemsFail.yql @@ -0,0 +1,19 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Int32))))) +(let orig (Variant (Int32 '0) 'B origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Int32)) '('D (DataType 'Int32))))) +(let test (Variant (Int32 '0) 'B testType)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructNameMismatchFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructNameMismatchFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructNameMismatchFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructNameMismatchFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructNameMismatchFail.yql new file mode 100644 index 0000000000..ac57358f03 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructNameMismatchFail.yql @@ -0,0 +1,19 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Int32))))) +(let orig (Variant (Int32 '0) 'B origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('X (DataType 'Int32))))) +(let test (Variant (Int32 '0) 'B testType)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTargetNameMismatchFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTargetNameMismatchFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTargetNameMismatchFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTargetNameMismatchFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTargetNameMismatchFail.yql new file mode 100644 index 0000000000..a4e5f7dd40 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTargetNameMismatchFail.yql @@ -0,0 +1,19 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Int32))))) +(let orig (Variant (Int32 '0) 'B origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (StructType '('A (DataType 'Int32)) '('X (DataType 'Int32)) '('C (DataType 'Int32))))) +(let test (Variant (Int32 '0) 'X testType)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTargetTypeMismatchFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTargetTypeMismatchFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTargetTypeMismatchFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTargetTypeMismatchFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTargetTypeMismatchFail.yql new file mode 100644 index 0000000000..a7bfc3ca2a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTargetTypeMismatchFail.yql @@ -0,0 +1,19 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Int32))))) +(let orig (Variant (Int32 '0) 'B origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Float)) '('C (DataType 'Int32))))) +(let test (Variant (Float '0) 'B testType)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTypeMismatchFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTypeMismatchFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTypeMismatchFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTypeMismatchFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTypeMismatchFail.yql new file mode 100644 index 0000000000..cc6a372e44 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverStructTypeMismatchFail.yql @@ -0,0 +1,19 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Int32))))) +(let orig (Variant (Int32 '0) 'B origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Float))))) +(let test (Variant (Int32 '0) 'B testType)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleExtraItemsFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleExtraItemsFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleExtraItemsFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleExtraItemsFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleExtraItemsFail.yql new file mode 100644 index 0000000000..d6e73eab29 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleExtraItemsFail.yql @@ -0,0 +1,19 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Int32)))) +(let orig (Variant (Int32 '0) '1 origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Int32) (DataType 'Int32)))) +(let test (Variant (Int32 '0) '1 testType)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleNotEnoughItemsFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleNotEnoughItemsFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleNotEnoughItemsFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleNotEnoughItemsFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleNotEnoughItemsFail.yql new file mode 100644 index 0000000000..e0419e94da --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleNotEnoughItemsFail.yql @@ -0,0 +1,19 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Int32) (DataType 'Int32)))) +(let orig (Variant (Int32 '0) '1 origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Int32)))) +(let test (Variant (Int32 '0) '1 testType)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleTargetTypeMismatchFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleTargetTypeMismatchFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleTargetTypeMismatchFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleTargetTypeMismatchFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleTargetTypeMismatchFail.yql new file mode 100644 index 0000000000..615950d586 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleTargetTypeMismatchFail.yql @@ -0,0 +1,19 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Int32)))) +(let orig (Variant (Int32 '0) '1 origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (TupleType (DataType 'Int32) (DataType 'Float) (DataType 'Int32)))) +(let test (Variant (Float '0) '1 testType)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleTypeMismatchFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleTypeMismatchFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleTypeMismatchFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleTypeMismatchFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleTypeMismatchFail.yql new file mode 100644 index 0000000000..b9d7408383 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralOverTupleTypeMismatchFail.yql @@ -0,0 +1,19 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Int32)))) +(let orig (Variant (Int32 '0) '1 origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Float)))) +(let test (Variant (Int32 '0) '1 testType)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralUnderlyingTypeMismatchFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralUnderlyingTypeMismatchFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralUnderlyingTypeMismatchFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralUnderlyingTypeMismatchFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralUnderlyingTypeMismatchFail.yql new file mode 100644 index 0000000000..d58f23fe27 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantLiteralUnderlyingTypeMismatchFail.yql @@ -0,0 +1,19 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Int32))))) +(let orig (Variant (Int32 '0) 'B origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Int32)))) +(let test (Variant (Int32 '0) '1 testType)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructExtraItemsFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructExtraItemsFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructExtraItemsFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructExtraItemsFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructExtraItemsFail.yql new file mode 100644 index 0000000000..80492a709e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructExtraItemsFail.yql @@ -0,0 +1,22 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Int32))))) +(let orig (Variant (Int32 '0) 'B origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Int32)) '('D (DataType 'Int32))))) +(let testCallableType (CallableType '() '(testType))) +(let testBody (lambda '() (Variant (Int32 '0) 'B testType))) +(let testCallable (Callable testCallableType testBody)) +(let test (Apply testCallable)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructNameMismatchFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructNameMismatchFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructNameMismatchFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructNameMismatchFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructNameMismatchFail.yql new file mode 100644 index 0000000000..b71b50dff7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructNameMismatchFail.yql @@ -0,0 +1,22 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Int32))))) +(let orig (Variant (Int32 '0) 'B origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('X (DataType 'Int32))))) +(let testCallableType (CallableType '() '(testType))) +(let testBody (lambda '() (Variant (Int32 '0) 'B testType))) +(let testCallable (Callable testCallableType testBody)) +(let test (Apply testCallable)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTargetNameMismatchFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTargetNameMismatchFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTargetNameMismatchFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTargetNameMismatchFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTargetNameMismatchFail.yql new file mode 100644 index 0000000000..bd91e105e0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTargetNameMismatchFail.yql @@ -0,0 +1,22 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Int32))))) +(let orig (Variant (Int32 '0) 'B origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (StructType '('A (DataType 'Int32)) '('X (DataType 'Int32)) '('C (DataType 'Int32))))) +(let testCallableType (CallableType '() '(testType))) +(let testBody (lambda '() (Variant (Int32 '0) 'X testType))) +(let testCallable (Callable testCallableType testBody)) +(let test (Apply testCallable)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTargetTypeMismatchFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTargetTypeMismatchFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTargetTypeMismatchFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTargetTypeMismatchFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTargetTypeMismatchFail.yql new file mode 100644 index 0000000000..f40ab1d5d8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTargetTypeMismatchFail.yql @@ -0,0 +1,22 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Int32))))) +(let orig (Variant (Int32 '0) 'B origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Float)) '('C (DataType 'Int32))))) +(let testCallableType (CallableType '() '(testType))) +(let testBody (lambda '() (Variant (Float '0) 'B testType))) +(let testCallable (Callable testCallableType testBody)) +(let test (Apply testCallable)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTypeMismatchFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTypeMismatchFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTypeMismatchFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTypeMismatchFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTypeMismatchFail.yql new file mode 100644 index 0000000000..aa0ab07e67 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverStructTypeMismatchFail.yql @@ -0,0 +1,22 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Int32))))) +(let orig (Variant (Int32 '0) 'B origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Float))))) +(let testCallableType (CallableType '() '(testType))) +(let testBody (lambda '() (Variant (Int32 '0) 'B testType))) +(let testCallable (Callable testCallableType testBody)) +(let test (Apply testCallable)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleExtraItemsFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleExtraItemsFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleExtraItemsFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleExtraItemsFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleExtraItemsFail.yql new file mode 100644 index 0000000000..5c9d947981 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleExtraItemsFail.yql @@ -0,0 +1,22 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Int32)))) +(let orig (Variant (Int32 '0) '1 origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Int32) (DataType 'Int32)))) +(let testCallableType (CallableType '() '(testType))) +(let testBody (lambda '() (Variant (Int32 '0) '1 testType))) +(let testCallable (Callable testCallableType testBody)) +(let test (Apply testCallable)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleNotEnoughItemsFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleNotEnoughItemsFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleNotEnoughItemsFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleNotEnoughItemsFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleNotEnoughItemsFail.yql new file mode 100644 index 0000000000..2ececbce27 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleNotEnoughItemsFail.yql @@ -0,0 +1,22 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Int32) (DataType 'Int32)))) +(let orig (Variant (Int32 '0) '1 origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Int32)))) +(let testCallableType (CallableType '() '(testType))) +(let testBody (lambda '() (Variant (Int32 '0) '1 testType))) +(let testCallable (Callable testCallableType testBody)) +(let test (Apply testCallable)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleTargetTypeMismatchFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleTargetTypeMismatchFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleTargetTypeMismatchFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleTargetTypeMismatchFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleTargetTypeMismatchFail.yql new file mode 100644 index 0000000000..21c992bea5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleTargetTypeMismatchFail.yql @@ -0,0 +1,22 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Int32)))) +(let orig (Variant (Int32 '0) '1 origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (TupleType (DataType 'Int32) (DataType 'Float) (DataType 'Int32)))) +(let testCallableType (CallableType '() '(testType))) +(let testBody (lambda '() (Variant (Float '0) '1 testType))) +(let testCallable (Callable testCallableType testBody)) +(let test (Apply testCallable)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleTypeMismatchFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleTypeMismatchFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleTypeMismatchFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleTypeMismatchFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleTypeMismatchFail.yql new file mode 100644 index 0000000000..be762d2421 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantOverTupleTypeMismatchFail.yql @@ -0,0 +1,22 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Int32)))) +(let orig (Variant (Int32 '0) '1 origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Float)))) +(let testCallableType (CallableType '() '(testType))) +(let testBody (lambda '() (Variant (Int32 '0) '1 testType))) +(let testCallable (Callable testCallableType testBody)) +(let test (Apply testCallable)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantUnderlyingTypeMismatchFail.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantUnderlyingTypeMismatchFail.cfg new file mode 100644 index 0000000000..eb2e5315d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantUnderlyingTypeMismatchFail.cfg @@ -0,0 +1 @@ +xfail
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantUnderlyingTypeMismatchFail.yql b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantUnderlyingTypeMismatchFail.yql new file mode 100644 index 0000000000..01a658c16e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/VariantUnderlyingTypeMismatchFail.yql @@ -0,0 +1,22 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let origType (VariantType (StructType '('A (DataType 'Int32)) '('B (DataType 'Int32)) '('C (DataType 'Int32))))) +(let orig (Variant (Int32 '0) 'B origType)) + +(let testcase (AsList orig)) + +(let testType (VariantType (TupleType (DataType 'Int32) (DataType 'Int32) (DataType 'Int32)))) +(let testCallableType (CallableType '() '(testType))) +(let testBody (lambda '() (Variant (Int32 '0) '1 testType))) +(let testCallable (Callable testCallableType testBody)) +(let test (Apply testCallable)) + +(let testcase (Append testcase test)) + +(let world (Write! world res_sink (Key) testcase '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/ImplictCasts/default.cfg b/yql/essentials/tests/s-expressions/suites/ImplictCasts/default.cfg new file mode 100644 index 0000000000..00dec6c3f8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ImplictCasts/default.cfg @@ -0,0 +1 @@ +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/InMem/AccessDictOpt.yql b/yql/essentials/tests/s-expressions/suites/InMem/AccessDictOpt.yql new file mode 100644 index 0000000000..e41c01a7b4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/AccessDictOpt.yql @@ -0,0 +1,29 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let t (ToDict (AsList '((String 'dkey1) (String 'dvalue1)) '((String 'dkey2) (String 'dvalue2))) + (lambda '(x) (Nth x '0)) (lambda '(x) (Nth x '1)) '('Sorted 'One) +)) + +(let jt (Just t)) +(let n (Nothing (TypeOf jt))) + +(let world (Write! world res_sink (Key) (Contains jt (String 'dkey1)) '('('type)))) +(let world (Write! world res_sink (Key) (Contains jt (String 'dkeyx)) '('('type)))) +(let world (Write! world res_sink (Key) (Contains n (String 'dkey1)) '('('type)))) +(let world (Write! world res_sink (Key) (Contains n (String 'dkeyx)) '('('type)))) + +(let world (Write! world res_sink (Key) (Lookup jt (String 'dkey1)) '('('type)))) +(let world (Write! world res_sink (Key) (Lookup jt (String 'dkeyx)) '('('type)))) +(let world (Write! world res_sink (Key) (Lookup n (String 'dkey1)) '('('type)))) +(let world (Write! world res_sink (Key) (Lookup n (String 'dkeyx)) '('('type)))) + +(let world (Write! world res_sink (Key) (DictItems jt) '('('type)))) +(let world (Write! world res_sink (Key) (DictItems n) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/AggrMinMaxTuple.yql b/yql/essentials/tests/s-expressions/suites/InMem/AggrMinMaxTuple.yql new file mode 100644 index 0000000000..c84047a295 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/AggrMinMaxTuple.yql @@ -0,0 +1,35 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let write (lambda '(world x y) (block '( + (let world (Write! world res_sink (Key) (String '==============) '())) + (let world (Write! world res_sink (Key) (AggrMin x y) '('('type)))) + (let world (Write! world res_sink (Key) (AggrMax x y) '('('type)))) + (return world) +)))) + +(let world (Apply write world '() '())) +(let world (Apply write world (Just '()) (Just '()))) + +(let world (Apply write world '((Int64 '1)) '((Int64 '1)))) +(let world (Apply write world '((Int64 '1)) '((Int64 '2)))) +(let world (Apply write world '((Uint64 '3)) '((Uint64 '2)))) + +(let world (Apply write world '((Just (Int32 '1))) '((Just (Int32 '2))))) +(let world (Apply write world (Just '((Just (Int32 '1)))) (Just '((Just (Int32 '3)))))) + +(let world (Apply write world '((Int8 '1) (String 'a)) '((Int8 '1) (String 'a)))) +(let world (Apply write world '((Int8 '1) (String 'a)) '((Int8 '1) (String 'b)))) +(let world (Apply write world '((Int8 '1) (String 'b)) '((Int8 '1) (String 'a)))) +(let world (Apply write world '((Int8 '1) (String 'a)) '((Int8 '2) (String 'a)))) +(let world (Apply write world '((Int8 '2) (String 'a)) '((Int8 '1) (String 'b)))) +(let world (Apply write world '((Int8 '2) (String 'b)) '((Int8 '1) (String 'a)))) + +(let world (Commit! world res_sink)) +(return world) +) + diff --git a/yql/essentials/tests/s-expressions/suites/InMem/BitCore.yql b/yql/essentials/tests/s-expressions/suites/InMem/BitCore.yql new file mode 100644 index 0000000000..9cf4e53963 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/BitCore.yql @@ -0,0 +1,30 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import core_module '"/lib/yql/core.yql") +(let res_sink (DataSink 'result)) +(let test (lambda '(world data) (block '( + (let world (Write! world res_sink (Key) data '('('type)))) + (return world) +)))) + +(let world (Apply test world (Apply (bind core_module 'TestBit) (String '"\x05\x04") (Uint64 '0)))) +(let world (Apply test world (Apply (bind core_module 'TestBit) (String '"\x05\x04") (Uint64 '10)))) +(let world (Apply test world (Apply (bind core_module 'TestBit) (String '"\x05\x04") (Uint64 '11)))) +(let world (Apply test world (Apply (bind core_module 'TestBit) (String '"\x05\x04") (Uint64 '23)))) +(let world (Apply test world (Apply (bind core_module 'TestBit) (Just (String '"\x05\x04")) (Uint64 '0)))) +(let world (Apply test world (Apply (bind core_module 'TestBit) (Just (Utf8 '"\x05\x04")) (Uint64 '0)))) +(let world (Apply test world (Apply (bind core_module 'TestBit) (Uint8 '5) (Uint8 '0)))) +(let world (Apply test world (Apply (bind core_module 'TestBit) (Uint32 '5) (Uint8 '2)))) +(let world (Apply test world (Apply (bind core_module 'TestBit) (Uint64 '5) (Uint8 '1)))) +(let world (Apply test world (Apply (bind core_module 'TestBit) (Just (Uint8 '5)) (Uint8 '0)))) +(let world (Apply test world (Apply (bind core_module 'SetBit) (Uint32 '5) (Uint8 '1)))) +(let world (Apply test world (Apply (bind core_module 'SetBit) (Just (Uint32 '5)) (Uint8 '1)))) +(let world (Apply test world (Apply (bind core_module 'ClearBit) (Uint32 '5) (Uint8 '0)))) +(let world (Apply test world (Apply (bind core_module 'ClearBit) (Just (Uint32 '5)) (Uint8 '0)))) +(let world (Apply test world (Apply (bind core_module 'FlipBit) (Uint32 '5) (Uint8 '0)))) +(let world (Apply test world (Apply (bind core_module 'FlipBit) (Just (Uint32 '5)) (Uint8 '0)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/ByteAt.yql b/yql/essentials/tests/s-expressions/suites/InMem/ByteAt.yql new file mode 100644 index 0000000000..6be3f9bffc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/ByteAt.yql @@ -0,0 +1,15 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (ByteAt (String 'ab) (Uint32 '1)) '('('type)))) +(let world (Write! world res_sink (Key) (ByteAt (String 'ab) (Uint32 '2)) '('('type)))) +(let world (Write! world res_sink (Key) (ByteAt (Just (String 'ab)) (Uint32 '1)) '('('type)))) +(let world (Write! world res_sink (Key) (ByteAt (Just (String 'ab)) (Uint32 '2)) '('('type)))) +(let world (Write! world res_sink (Key) (ByteAt (Nothing (OptionalType (DataType 'String))) (Uint32 '1)) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Collect.yql b/yql/essentials/tests/s-expressions/suites/InMem/Collect.yql new file mode 100644 index 0000000000..e62000f1ee --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Collect.yql @@ -0,0 +1,12 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList (String 'aaa) (String 'bbb) (String 'ccc))) +(let world (Write! world res_sink (Key) (Collect (Iterator list)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Collect (LazyList (LazyList (Collect list))))) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/CompareNulls.yql b/yql/essentials/tests/s-expressions/suites/InMem/CompareNulls.yql new file mode 100644 index 0000000000..1e399b48cc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/CompareNulls.yql @@ -0,0 +1,24 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let write (lambda '(world x y) (block '( + (let world (Write! world res_sink (Key) (String '==============) '())) + (let world (Write! world res_sink (Key) (== x y) '('('type)))) + (return world) +)))) + +(let world (Apply write world (Null) (Null))) +(let world (Apply write world (Null) (Nothing (OptionalType (DataType 'String))))) +(let world (Apply write world (Int32 '0) (Null))) +(let world (Apply write world '((Null)) '((Null)))) +(let world (Apply write world '((Int32 '1) (Null)) '((Int32 '1) (Null)))) +(let world (Apply write world '((Int32 '1) (Nothing (OptionalType (DataType 'String)))) '((Int32 '1) (Nothing (OptionalType (DataType 'String)))))) + + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/CompareStruct.yql b/yql/essentials/tests/s-expressions/suites/InMem/CompareStruct.yql new file mode 100644 index 0000000000..112fc7f534 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/CompareStruct.yql @@ -0,0 +1,39 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let write (lambda '(world x y) (block '( + (let world (Write! world res_sink (Key) (String '==============) '())) + (let world (Write! world res_sink (Key) (== x y) '('('type)))) + (let world (Write! world res_sink (Key) (!= x y) '('('type)))) + (return world) +)))) + +(let world (Apply write world (AsStruct) (AsStruct))) +(let world (Apply write world (Just (AsStruct)) (AsStruct))) +(let world (Apply write world (AsStruct) (Just (AsStruct)))) +(let world (Apply write world (Just (AsStruct)) (Just (AsStruct)))) + +(let world (Apply write world (AsStruct '('x (Int32 '1))) (AsStruct '('x (Uint64 '1))))) +(let world (Apply write world (AsStruct '('x (Int32 '1))) (AsStruct '('x (Uint64 '2))))) +(let world (Apply write world (AsStruct '('x (Int32 '3))) (AsStruct '('x (Uint64 '2))))) + +(let world (Apply write world (Just (AsStruct '('x (Int32 '1)))) (AsStruct '('x (Uint64 '1))))) +(let world (Apply write world (AsStruct '('x (Int32 '1))) (Just (AsStruct '('x (Uint64 '1)))))) +(let world (Apply write world (AsStruct '('x (Just (Int32 '1)))) (AsStruct '('x (Uint64 '1))))) +(let world (Apply write world (AsStruct '('x (Int32 '1))) (AsStruct '('x (Just (Uint64 '1)))))) +(let world (Apply write world (Just (AsStruct '('x (Just (Int32 '1))))) (AsStruct '('x (Uint64 '1))))) +(let world (Apply write world (Just (AsStruct '('x (Just (Int32 '1))))) (AsStruct '('x (Just (Uint64 '1)))))) +(let world (Apply write world (Just (AsStruct '('x (Just (Int32 '1))))) (Just (AsStruct '('x (Just (Uint64 '1))))))) + +(let world (Apply write world (AsStruct '('x (Int32 '1)) '('y (String 'a))) (AsStruct '('x (Uint64 '1)) '('y (String 'a))))) +(let world (Apply write world (AsStruct '('x (Int32 '1)) '('y (String 'a))) (AsStruct '('x (Uint64 '1)) '('y (String 'b))))) +(let world (Apply write world (AsStruct '('x (Int32 '1)) '('y (String 'b))) (AsStruct '('x (Uint64 '1)) '('y (String 'a))))) +(let world (Apply write world (AsStruct '('x (Int32 '1)) '('y (String 'a))) (AsStruct '('x (Uint64 '2)) '('y (String 'a))))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/CompareStruct2.yql b/yql/essentials/tests/s-expressions/suites/InMem/CompareStruct2.yql new file mode 100644 index 0000000000..5d9ca77381 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/CompareStruct2.yql @@ -0,0 +1,21 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let write (lambda '(world x y) (block '( + (let world (Write! world res_sink (Key) (String '==============) '())) + (let world (Write! world res_sink (Key) (== x y) '('('type)))) + (let world (Write! world res_sink (Key) (!= x y) '('('type)))) + (return world) +)))) + +(let world (Apply write world (AsStruct '('x (Int32 '1)) '('y (String 'a))) (AsStruct '('y (String 'a)) '('z (Int64 '1))))) +(let world (Apply write world (AsStruct '('x (Int32 '1)) '('y (Just (String 'a)))) (AsStruct '('y (String 'a)) '('z (Int64 '1))))) +(let world (Apply write world (AsStruct) (AsStruct '('y (String 'a)) '('z (Int64 '1))))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/CompareTuple.yql b/yql/essentials/tests/s-expressions/suites/InMem/CompareTuple.yql new file mode 100644 index 0000000000..b51f864573 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/CompareTuple.yql @@ -0,0 +1,45 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let write (lambda '(world x y) (block '( + (let world (Write! world res_sink (Key) (String '==============) '())) + (let world (Write! world res_sink (Key) (== x y) '('('type)))) + (let world (Write! world res_sink (Key) (!= x y) '('('type)))) + (let world (Write! world res_sink (Key) (< x y) '('('type)))) + (let world (Write! world res_sink (Key) (<= x y) '('('type)))) + (let world (Write! world res_sink (Key) (> x y) '('('type)))) + (let world (Write! world res_sink (Key) (>= x y) '('('type)))) + (return world) +)))) + +(let world (Apply write world '() '())) +(let world (Apply write world (Just '()) '())) +(let world (Apply write world '() (Just '()))) +(let world (Apply write world (Just '()) (Just '()))) + +(let world (Apply write world '((Int32 '1)) '((Uint64 '1)))) +(let world (Apply write world '((Int32 '1)) '((Uint64 '2)))) +(let world (Apply write world '((Int32 '3)) '((Uint64 '2)))) + +(let world (Apply write world (Just '((Int32 '1))) '((Uint64 '1)))) +(let world (Apply write world '((Int32 '1)) (Just '((Uint64 '1))))) +(let world (Apply write world '((Just (Int32 '1))) '((Uint64 '1)))) +(let world (Apply write world '((Int32 '1)) '((Just (Uint64 '1))))) +(let world (Apply write world (Just '((Just (Int32 '1)))) '((Uint64 '1)))) +(let world (Apply write world (Just '((Just (Int32 '1)))) '((Just (Uint64 '1))))) +(let world (Apply write world (Just '((Just (Int32 '1)))) (Just '((Just (Uint64 '1)))))) + +(let world (Apply write world '((Int32 '1) (String 'a)) '((Uint64 '1) (String 'a)))) +(let world (Apply write world '((Int32 '1) (String 'a)) '((Uint64 '1) (String 'b)))) +(let world (Apply write world '((Int32 '1) (String 'b)) '((Uint64 '1) (String 'a)))) +(let world (Apply write world '((Int32 '1) (String 'a)) '((Uint64 '2) (String 'a)))) +(let world (Apply write world '((Int32 '2) (String 'a)) '((Uint64 '1) (String 'b)))) +(let world (Apply write world '((Int32 '2) (String 'b)) '((Uint64 '1) (String 'a)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/ConcatOpt.sql b/yql/essentials/tests/s-expressions/suites/InMem/ConcatOpt.sql new file mode 100644 index 0000000000..d916034abc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/ConcatOpt.sql @@ -0,0 +1,36 @@ +$es = YQL::Nothing(YQL::OptionalType(YQL::DataType(AsAtom("String")))); +$eu = YQL::Nothing(YQL::OptionalType(YQL::DataType(AsAtom("Utf8")))); +$u1 = YQL::Unwrap(cast("a" as utf8)); +$u2 = YQL::Unwrap(cast("b" as utf8)); +---------- +select YQL::Concat("a", "b"); +select YQL::Concat(YQL::Just("a"), "b"); +select YQL::Concat("a", YQL::Just("b")); +select YQL::Concat(YQL::Just("a"), "b"); +select YQL::Concat($es, "b"); +select YQL::Concat("a", $es); +select YQL::Concat($es, $es); +---------- +select YQL::Concat("a", $u2); +select YQL::Concat(YQL::Just("a"), $u2); +select YQL::Concat("a", YQL::Just($u2)); +select YQL::Concat(YQL::Just("a"), $u2); +select YQL::Concat($es, $u2); +select YQL::Concat("a", $eu); +select YQL::Concat($es, $eu); +---------- +select YQL::Concat($u1, "b"); +select YQL::Concat(YQL::Just($u1), "b"); +select YQL::Concat($u1, YQL::Just("b")); +select YQL::Concat(YQL::Just($u1), "b"); +select YQL::Concat($eu, "b"); +select YQL::Concat($u1, $es); +select YQL::Concat($eu, $es); +---------- +select YQL::Concat($u1, $u2); +select YQL::Concat(YQL::Just($u1), $u2); +select YQL::Concat($u1, YQL::Just($u2)); +select YQL::Concat(YQL::Just($u1), $u2); +select YQL::Concat($eu, $u2); +select YQL::Concat($u1, $eu); +select YQL::Concat($eu, $eu); diff --git a/yql/essentials/tests/s-expressions/suites/InMem/ConcatOpt.yql b/yql/essentials/tests/s-expressions/suites/InMem/ConcatOpt.yql new file mode 100644 index 0000000000..a20d1188dc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/ConcatOpt.yql @@ -0,0 +1,572 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(import core_module '"/lib/yql/core.yql") +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" (String '"a") (String '"b"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Just" (String '"a")) (String '"b"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" (String '"a") ("Just" (String '"b")))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Just" (String '"a")) (String '"b"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Nothing" ("OptionalType" ("DataType" '"String"))) (String '"b"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" (String '"a") ("Nothing" ("OptionalType" ("DataType" '"String"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Nothing" ("OptionalType" ("DataType" '"String"))) ("Nothing" ("OptionalType" ("DataType" '"String"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" (String '"a") ("Unwrap" (Cast (String '"b") 'Utf8)))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Just" (String '"a")) ("Unwrap" (Cast (String '"b") 'Utf8)))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" (String '"a") ("Just" ("Unwrap" (Cast (String '"b") 'Utf8))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Just" (String '"a")) ("Unwrap" (Cast (String '"b") 'Utf8)))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Nothing" ("OptionalType" ("DataType" '"String"))) ("Unwrap" (Cast (String '"b") 'Utf8)))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" (String '"a") ("Nothing" ("OptionalType" ("DataType" '"Utf8"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Nothing" ("OptionalType" ("DataType" '"String"))) ("Nothing" ("OptionalType" ("DataType" '"Utf8"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Unwrap" (Cast (String '"a") 'Utf8)) (String '"b"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Just" ("Unwrap" (Cast (String '"a") 'Utf8))) (String '"b"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Unwrap" (Cast (String '"a") 'Utf8)) ("Just" (String '"b")))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Just" ("Unwrap" (Cast (String '"a") 'Utf8))) (String '"b"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Nothing" ("OptionalType" ("DataType" '"Utf8"))) (String '"b"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Unwrap" (Cast (String '"a") 'Utf8)) ("Nothing" ("OptionalType" ("DataType" '"String"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Nothing" ("OptionalType" ("DataType" '"Utf8"))) ("Nothing" ("OptionalType" ("DataType" '"String"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Unwrap" (Cast (String '"a") 'Utf8)) ("Unwrap" (Cast (String '"b") 'Utf8)))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Just" ("Unwrap" (Cast (String '"a") 'Utf8))) ("Unwrap" (Cast (String '"b") 'Utf8)))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Unwrap" (Cast (String '"a") 'Utf8)) ("Just" ("Unwrap" (Cast (String '"b") 'Utf8))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Just" ("Unwrap" (Cast (String '"a") 'Utf8))) ("Unwrap" (Cast (String '"b") 'Utf8)))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Nothing" ("OptionalType" ("DataType" '"Utf8"))) ("Unwrap" (Cast (String '"b") 'Utf8)))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Unwrap" (Cast (String '"a") 'Utf8)) ("Nothing" ("OptionalType" ("DataType" '"Utf8"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Concat" ("Nothing" ("OptionalType" ("DataType" '"Utf8"))) ("Nothing" ("OptionalType" ("DataType" '"Utf8"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/CountBits.yql b/yql/essentials/tests/s-expressions/suites/InMem/CountBits.yql new file mode 100644 index 0000000000..5f688a5075 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/CountBits.yql @@ -0,0 +1,18 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (CountBits (Int8 '-1)) '('('type)))) +(let world (Write! world res_sink (Key) (CountBits (Uint8 '7)) '('('type)))) +(let world (Write! world res_sink (Key) (CountBits (Int16 '-1)) '('('type)))) +(let world (Write! world res_sink (Key) (CountBits (Uint16 '16)) '('('type)))) +(let world (Write! world res_sink (Key) (CountBits (Int32 '1)) '('('type)))) +(let world (Write! world res_sink (Key) (CountBits (Uint32 '0)) '('('type)))) +(let world (Write! world res_sink (Key) (CountBits (Int64 '-7)) '('('type)))) +(let world (Write! world res_sink (Key) (CountBits (Uint64 '7)) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Default.yql b/yql/essentials/tests/s-expressions/suites/InMem/Default.yql new file mode 100644 index 0000000000..a7f8667067 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Default.yql @@ -0,0 +1,38 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let test (lambda '(world type) (block '( + (let world (Write! world res_sink (Key) (Default (DataType type)) '('('type)))) + (let world (Write! world res_sink (Key) (Default (OptionalType (DataType type))) '('('type)))) + (return world) +)))) + +(let world (Apply test world 'Bool)) +(let world (Apply test world 'Int8)) +(let world (Apply test world 'Uint8)) +(let world (Apply test world 'Int16)) +(let world (Apply test world 'Uint16)) +(let world (Apply test world 'Int32)) +(let world (Apply test world 'Uint32)) +(let world (Apply test world 'Int64)) +(let world (Apply test world 'Uint64)) +(let world (Apply test world 'Float)) +(let world (Apply test world 'Double)) +(let world (Apply test world 'String)) +(let world (Apply test world 'Utf8)) +# yson & json don't have a default value +(let world (Apply test world 'Date)) +(let world (Apply test world 'Datetime)) +(let world (Apply test world 'Timestamp)) +(let world (Apply test world 'Interval)) +(let world (Apply test world 'TzDate)) +(let world (Apply test world 'TzDatetime)) +(let world (Apply test world 'TzTimestamp)) +(let world (Apply test world 'Uuid)) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Demux.yql b/yql/essentials/tests/s-expressions/suites/InMem/Demux.yql new file mode 100644 index 0000000000..6fd4b3f3cd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Demux.yql @@ -0,0 +1,44 @@ +( +#comment +(let res_sink (DataSink 'result)) +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let varTuple (VariantType (TupleType (DataType 'String) (DataType 'Bool) (DataType 'Uint32)))) + +(let varList (AsList + (Variant (String 'a1) '0 varTuple) + (Variant (Uint32 '3) '2 varTuple) + (Variant (String 'a2) '0 varTuple) + (Variant (Bool 'false) '1 varTuple) + (Variant (Uint32 '1) '2 varTuple) + (Variant (String 'a3) '0 varTuple) + (Variant (Uint32 '2) '2 varTuple) + (Variant (Bool 'true) '1 varTuple) + (Variant (Uint32 '4) '2 varTuple) +)) + +(let data (Demux varList)) +(let world (Write! world res_sink (Key) data '('('type)))) + +(let varStruct (VariantType (StructType '('s (DataType 'String)) '('b (DataType 'Bool)) '('u (DataType 'Uint32))))) + +(let varList (AsList + (Variant (String 'a1) 's varStruct) + (Variant (Uint32 '3) 'u varStruct) + (Variant (String 'a2) 's varStruct) + (Variant (Bool 'false) 'b varStruct) + (Variant (Uint32 '1) 'u varStruct) + (Variant (String 'a3) 's varStruct) + (Variant (Uint32 '2) 'u varStruct) + (Variant (Bool 'true) 'b varStruct) + (Variant (Uint32 '4) 'u varStruct) +)) + +(let data (Demux varList)) +(let world (Write! world res_sink (Key) data '('('type)))) + +(let world (Commit! world res_sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/DictOpt.yql b/yql/essentials/tests/s-expressions/suites/InMem/DictOpt.yql new file mode 100644 index 0000000000..b12be636c8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/DictOpt.yql @@ -0,0 +1,33 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let t1 (OptionalType (DataType 'Uint32))) +(let t2 (DataType 'String)) +(let d1 (DictType t1 t2)) +(let d2 (Dict d1 + '((Just (Uint32 '4)) (String 'aaa)) + '((Just (Uint32 '4)) (String 'zzz)) + '((Nothing (OptionalType (DataType 'Uint32))) (String 'bbb))) +) + +(let world (Write! world res_sink (Key) d2 '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Uint32 '4))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Nothing (OptionalType (DataType 'Uint32)))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Uint32 '5))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Just (Uint32 '5)))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Just (Uint32 '4)))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Nothing (OptionalType (DataType 'Uint32))))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Nothing (OptionalType (OptionalType (DataType 'Uint32))))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Uint32 '4))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Nothing (OptionalType (DataType 'Uint32)))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Uint32 '5))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Just (Uint32 '4)))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Just (Uint32 '5)))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Nothing (OptionalType (DataType 'Uint32))))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Nothing (OptionalType (OptionalType (DataType 'Uint32))))) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/DictOptTuple.yql b/yql/essentials/tests/s-expressions/suites/InMem/DictOptTuple.yql new file mode 100644 index 0000000000..4c9e5b46d5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/DictOptTuple.yql @@ -0,0 +1,30 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let t1 (TupleType (OptionalType (DataType 'Uint32)) (DataType 'String))) +(let t2 (DataType 'String)) +(let d1 (DictType t1 t2)) +(let d2 (Dict d1 + '('((Just (Uint32 '4)) (String 'ggg)) (String 'aaa)) + '('((Just (Uint32 '4)) (String 'hhh)) (String 'bbb)) + '('((Just (Uint32 '4)) (String 'ggg)) (String 'ccc)) + '('((Nothing (OptionalType (DataType 'Uint32))) (String 'rrr)) (String 'ddd)) +)) + +(let world (Write! world res_sink (Key) (Contains d2 '((Just (Uint32 '4)) (String 'ggg))) '())) +(let world (Write! world res_sink (Key) (Contains d2 '((Just (Uint32 '5)) (String 'ggg))) '())) +(let world (Write! world res_sink (Key) (Contains d2 '((Just (Uint32 '4)) (String 'sss))) '())) +(let world (Write! world res_sink (Key) (Contains d2 '((Nothing (OptionalType (DataType 'Uint32))) (String 'rrr))) '())) +(let world (Write! world res_sink (Key) (Contains d2 '((Nothing (OptionalType (DataType 'Uint32))) (String 'qqq))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 '((Just (Uint32 '4)) (String 'ggg))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 '((Just (Uint32 '5)) (String 'ggg))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 '((Just (Uint32 '4)) (String 'sss))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 '((Nothing (OptionalType (DataType 'Uint32))) (String 'rrr))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 '((Nothing (OptionalType (DataType 'Uint32))) (String 'qqq))) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/DiffKeyTypeContains.yql b/yql/essentials/tests/s-expressions/suites/InMem/DiffKeyTypeContains.yql new file mode 100644 index 0000000000..25e92e7eff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/DiffKeyTypeContains.yql @@ -0,0 +1,81 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let t1 (DataType 'Uint32)) +(let t2 (DataType 'String)) +(let dt (DictType t1 t2)) +(let d (Dict dt '((Uint32 '4) (String 'aaa)) '((Uint32 '5) (String 'bbb))) ) +(let jd (Just d)) +(let n (Nothing (TypeOf jd))) + +(let nu (Nothing (OptionalType (DataType 'Uint32)))) +(let t3 (OptionalType (DataType 'Uint32))) +(let t4 (OptionalType (DataType 'String))) +(let dt2 (DictType t3 t4)) +(let d2 (Dict dt2 +'((Just (Uint32 '4)) (Just (String 'aaa))) +'((Just (Uint32 '5)) (Just (String 'bbb))) +'(nu (Just (String 'ccc))) +)) +(let jd2 (Just d2)) +(let n2 (Nothing (TypeOf jd2))) + +(let world (Write! world res_sink (Key) (Contains d (Uint32 '4)) '())) +(let world (Write! world res_sink (Key) (Contains d (Uint8 '4)) '())) +(let world (Write! world res_sink (Key) (Contains d (Int64 '4)) '())) +(let world (Write! world res_sink (Key) (Contains d (Int64 '-4)) '())) +(let world (Write! world res_sink (Key) (Contains d (Uint64 '4)) '())) + +(let world (Write! world res_sink (Key) (Contains jd (Uint32 '4)) '())) +(let world (Write! world res_sink (Key) (Contains jd (Uint8 '4)) '())) +(let world (Write! world res_sink (Key) (Contains jd (Int64 '4)) '())) +(let world (Write! world res_sink (Key) (Contains jd (Int64 '-4)) '())) +(let world (Write! world res_sink (Key) (Contains jd (Uint64 '4)) '())) + +(let world (Write! world res_sink (Key) (Contains n (Uint32 '4)) '())) +(let world (Write! world res_sink (Key) (Contains n (Uint8 '4)) '())) +(let world (Write! world res_sink (Key) (Contains n (Int64 '4)) '())) +(let world (Write! world res_sink (Key) (Contains n (Int64 '-4)) '())) +(let world (Write! world res_sink (Key) (Contains n (Uint64 '4)) '())) + +(let world (Write! world res_sink (Key) (Contains d nu) '())) +(let world (Write! world res_sink (Key) (Contains d (Just (Uint32 '4))) '())) +(let world (Write! world res_sink (Key) (Contains d (Just (Uint8 '4))) '())) +(let world (Write! world res_sink (Key) (Contains d (Just (Int64 '4))) '())) +(let world (Write! world res_sink (Key) (Contains d (Just (Int64 '-4))) '())) +(let world (Write! world res_sink (Key) (Contains d (Just (Uint64 '4))) '())) + +(let world (Write! world res_sink (Key) (Contains d2 (Uint8 '4)) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Int32 '4)) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Uint32 '4)) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Int64 '4)) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Int64 '-4)) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Uint64 '4)) '())) + +(let world (Write! world res_sink (Key) (Contains d2 (Just (Uint8 '4))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Int32 '4))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Uint32 '4))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Int64 '4))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Int64 '-4))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Uint64 '4))) '())) + +(let world (Write! world res_sink (Key) (Contains d2 (Nothing (OptionalType (DataType 'Uint8)))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Nothing (OptionalType (DataType 'Int32)))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Nothing (OptionalType (DataType 'Uint32)))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Nothing (OptionalType (DataType 'Int64)))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Nothing (OptionalType (DataType 'Uint64)))) '())) + +(let world (Write! world res_sink (Key) (Contains d2 (Just (Just (Uint8 '4)))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Just (Int32 '4)))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Just (Uint32 '4)))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Just (Int64 '4)))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Just (Int64 '-4)))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Just (Uint64 '4)))) '())) +(let world (Write! world res_sink (Key) (Contains d2 (Just (Nothing (OptionalType (DataType 'Int64))))) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/DiffKeyTypeLookup.yql b/yql/essentials/tests/s-expressions/suites/InMem/DiffKeyTypeLookup.yql new file mode 100644 index 0000000000..d7c81831cb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/DiffKeyTypeLookup.yql @@ -0,0 +1,81 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let t1 (DataType 'Uint32)) +(let t2 (DataType 'String)) +(let dt (DictType t1 t2)) +(let d (Dict dt '((Uint32 '4) (String 'aaa)) '((Uint32 '5) (String 'bbb))) ) +(let jd (Just d)) +(let n (Nothing (TypeOf jd))) + +(let nu (Nothing (OptionalType (DataType 'Uint32)))) +(let t3 (OptionalType (DataType 'Uint32))) +(let t4 (OptionalType (DataType 'String))) +(let dt2 (DictType t3 t4)) +(let d2 (Dict dt2 +'((Just (Uint32 '4)) (Just (String 'aaa))) +'((Just (Uint32 '5)) (Just (String 'bbb))) +'(nu (Just (String 'ccc))) +)) +(let jd2 (Just d2)) +(let n2 (Nothing (TypeOf jd2))) + +(let world (Write! world res_sink (Key) (Lookup d (Uint32 '4)) '())) +(let world (Write! world res_sink (Key) (Lookup d (Uint8 '4)) '())) +(let world (Write! world res_sink (Key) (Lookup d (Int64 '4)) '())) +(let world (Write! world res_sink (Key) (Lookup d (Int64 '-4)) '())) +(let world (Write! world res_sink (Key) (Lookup d (Uint64 '4)) '())) + +(let world (Write! world res_sink (Key) (Lookup jd (Uint32 '4)) '())) +(let world (Write! world res_sink (Key) (Lookup jd (Uint8 '4)) '())) +(let world (Write! world res_sink (Key) (Lookup jd (Int64 '4)) '())) +(let world (Write! world res_sink (Key) (Lookup jd (Int64 '-4)) '())) +(let world (Write! world res_sink (Key) (Lookup jd (Uint64 '4)) '())) + +(let world (Write! world res_sink (Key) (Lookup n (Uint32 '4)) '())) +(let world (Write! world res_sink (Key) (Lookup n (Uint8 '4)) '())) +(let world (Write! world res_sink (Key) (Lookup n (Int64 '4)) '())) +(let world (Write! world res_sink (Key) (Lookup n (Int64 '-4)) '())) +(let world (Write! world res_sink (Key) (Lookup n (Uint64 '4)) '())) + +(let world (Write! world res_sink (Key) (Lookup d nu) '())) +(let world (Write! world res_sink (Key) (Lookup d (Just (Uint32 '4))) '())) +(let world (Write! world res_sink (Key) (Lookup d (Just (Uint8 '4))) '())) +(let world (Write! world res_sink (Key) (Lookup d (Just (Int64 '4))) '())) +(let world (Write! world res_sink (Key) (Lookup d (Just (Int64 '-4))) '())) +(let world (Write! world res_sink (Key) (Lookup d (Just (Uint64 '4))) '())) + +(let world (Write! world res_sink (Key) (Lookup d2 (Uint8 '4)) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Int32 '4)) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Uint32 '4)) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Int64 '4)) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Int64 '-4)) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Uint64 '4)) '())) + +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Uint8 '4))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Int32 '4))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Uint32 '4))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Int64 '4))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Int64 '-4))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Uint64 '4))) '())) + +(let world (Write! world res_sink (Key) (Lookup d2 (Nothing (OptionalType (DataType 'Uint8)))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Nothing (OptionalType (DataType 'Int32)))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Nothing (OptionalType (DataType 'Uint32)))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Nothing (OptionalType (DataType 'Int64)))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Nothing (OptionalType (DataType 'Uint64)))) '())) + +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Just (Uint8 '4)))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Just (Int32 '4)))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Just (Uint32 '4)))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Just (Int64 '4)))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Just (Int64 '-4)))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Just (Uint64 '4)))) '())) +(let world (Write! world res_sink (Key) (Lookup d2 (Just (Nothing (OptionalType (DataType 'Int64))))) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/ExtractMembers.yql b/yql/essentials/tests/s-expressions/suites/InMem/ExtractMembers.yql new file mode 100644 index 0000000000..ed1ea53868 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/ExtractMembers.yql @@ -0,0 +1,15 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let str1 (AsStruct '('a (Uint32 '1)) '('b (String 'a)) '('c (Bool 'true)))) +(let str2 (AsStruct '('a (Uint32 '2)) '('b (String 'b)) '('c (Bool 'false)))) +(let list1 (AsList str1 str2)) +(let world (Write! world res_sink (Key) (ExtractMembers list1 '('a)) '('('type)))) +(let world (Write! world res_sink (Key) (ExtractMembers (Collect (Iterator list1)) '()) '('('type)))) +(let world (Write! world res_sink (Key) (ExtractMembers (Just str1) '('a 'c)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/FilterNullMembers.yql b/yql/essentials/tests/s-expressions/suites/InMem/FilterNullMembers.yql new file mode 100644 index 0000000000..6d14f0d268 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/FilterNullMembers.yql @@ -0,0 +1,15 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList + (AsStruct '('key (Just (Uint32 '1))) '('value (String 'a))) + (AsStruct '('key (Nothing (OptionalType (DataType 'Uint32)))) '('value (String 'a))) +)) + +(let world (Write! world res_sink (Key) (FilterNullMembers list '('key)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/FilterWithLimit.yql b/yql/essentials/tests/s-expressions/suites/InMem/FilterWithLimit.yql new file mode 100644 index 0000000000..ee25f707f1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/FilterWithLimit.yql @@ -0,0 +1,16 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList (Int32 '1) (Int32 '2) (Int32 '3) (Int32 '4) (Int32 '5) (Int32 '6) (Int32 '7) (Int32 '8) (Int32 '9))) +(let world (Write! world res_sink (Key) (OrderedFilter list + (lambda '(x) (AggrLess x (Int32 '6))) (Int32 '2)) '('('type)))) +(let world (Write! world res_sink (Key) (Filter (LazyList list) + (lambda '(x) (AggrGreater x (Int32 '4))) (Uint64 '3)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Filter (ToFlow list) + (lambda '(x) (AggrGreaterOrEqual x (Int32 '3))) (Int16 '4))) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/FlatMapFiltersSortedList.yql b/yql/essentials/tests/s-expressions/suites/InMem/FlatMapFiltersSortedList.yql new file mode 100644 index 0000000000..306f073803 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/FlatMapFiltersSortedList.yql @@ -0,0 +1,22 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +(AsStruct '('a (Int32 '7)) '('b (String 'two))) +(AsStruct '('a (Int32 '1)) '('b (String 'one))) +(AsStruct '('a (Int32 '3)) '('b (String 'two))) +(AsStruct '('a (Int32 '5)) '('b (String 'one))) +(AsStruct '('a (Int32 '5)) '('b (String 'two))) +)) + +(let keyExtractor (lambda '(x) '((Member x 'a)(Member x 'b)))) +(let data (ListSort list '((Bool 'true) (Bool 'false)) keyExtractor)) +(let mapped (ListFlatMap data (lambda '(x) (ListIf (Greater (Member x 'a) (Uint64 '2)) x) ))) + +(let world (Write! world res_sink (Key) mapped '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/FloatsIncDec.yql b/yql/essentials/tests/s-expressions/suites/InMem/FloatsIncDec.yql new file mode 100644 index 0000000000..02b70ad22b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/FloatsIncDec.yql @@ -0,0 +1,14 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Inc (Double '3.3)) '('('type)))) +(let world (Write! world res_sink (Key) (Inc (Float '-7.5)) '('('type)))) +(let world (Write! world res_sink (Key) (Dec (Double '-0.3)) '('('type)))) +(let world (Write! world res_sink (Key) (Dec (Float '4.75)) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/InMem/FloatsMod.yql b/yql/essentials/tests/s-expressions/suites/InMem/FloatsMod.yql new file mode 100644 index 0000000000..efa89ba44c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/FloatsMod.yql @@ -0,0 +1,14 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Mod (Double '3.3) (Double '1.7)) '('('type)))) +(let world (Write! world res_sink (Key) (Mod (Float '-7.5) (Double '0.7)) '('('type)))) +(let world (Write! world res_sink (Key) (Mod (Double '-0.3) (Float '-3.8)) '('('type)))) +(let world (Write! world res_sink (Key) (Mod (Float '4.75) (Float '-2.5)) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Fold.yql b/yql/essentials/tests/s-expressions/suites/InMem/Fold.yql new file mode 100644 index 0000000000..9f4ce156f3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Fold.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let doFold (lambda '(list) (Fold list (List (TypeOf list)) (lambda '(item state) (Append state item))))) +(let world (Write! world res_sink (Key) (Apply doFold (AsList (String '"1") (String '"2") (String '"3") (String '"4"))) '('('type)))) +(let world (Write! world res_sink (Key) (Apply doFold (AsList '((String '"1") (String '"a")) '((String '"2") (String '"b")))) '('('type)))) +(let world (Write! world res_sink (Key) (Apply doFold (AsList (AsStruct '('"x" (String '"1"))) (AsStruct '('"x" (String '"2"))))) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Fold1Map.yql b/yql/essentials/tests/s-expressions/suites/InMem/Fold1Map.yql new file mode 100644 index 0000000000..751de45375 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Fold1Map.yql @@ -0,0 +1,42 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Uint32 '1) (String 'r)) +'((Uint32 '1) (String 'a)) +'((Uint32 '2) (String 'b)) +'((Uint32 '3) (String 'b)) +'((Uint32 '5) (String 'i)) +'((Uint32 '8) (String 't)))) + +(let init (lambda '(item) (block '( + (let key (Nth item '0)) + (let val (Nth item '1)) + (let skey key) + (let sval val) + (let new_item '(key val skey sval)) + (let new_state '(skey sval)) + (return '(new_item new_state) +))))) + +(let update (lambda '(item state) (block '( + (let key (Nth item '0)) + (let val (Nth item '1)) + (let skey (Nth state '0)) + (let sval (Nth state '1)) + (let skey (+ skey key)) + (let sval (Concat sval val)) + (let new_item '(key val skey sval)) + (let new_state '(skey sval)) + (return '(new_item new_state) +))))) + +(let result (Fold1Map list init update)) + +(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/InMem/Fold1MapOverPreservedStream.yql b/yql/essentials/tests/s-expressions/suites/InMem/Fold1MapOverPreservedStream.yql new file mode 100644 index 0000000000..1a3aad97c9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Fold1MapOverPreservedStream.yql @@ -0,0 +1,63 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList + '((Uint32 '1) (String 'r)) + '((Uint32 '1) (String 'a)) + '((Uint32 '2) (String 'b)) + '((Uint32 '3) (String 'b)) + '((Uint32 '5) (String 'i)) + '((Uint32 '8) (String 't)) +)) +(let base_stream (Iterator list)) + +(let queue (QueueCreate (ListItemType (TypeOf list)) (Uint64 '5) (Uint64 '0))) +#(let queue (QueueCreate (TupleType (DataType 'Uint32) (DataType 'String)) (Uint64 '5) (Uint64 '0))) +(let stream (PreserveStream base_stream queue (Uint64 '2))) + +(let init (lambda '(item) (block '( + (let key (Nth item '0)) + (let val (Nth item '1)) + (let next (QueuePeek queue (Uint64 '1) (DependsOn item))) + (let over (QueuePeek queue (Uint64 '2) (DependsOn item))) + (let nkey (Nth next '0)) + (let nval (Nth next '1)) + (let okey (Nth over '0)) + (let oval (Nth over '1)) + (let skey key) + (let sval val) + (let validate (== (+ key (Coalesce nkey (Uint32 '0))) (Coalesce okey (Uint32 '0)))) + (let words (Concat (Concat val (Coalesce nval (String '""))) (Coalesce oval (String '"")))) + (let new_item '(key val skey sval validate words)) + (let new_state '(skey sval)) + (return '(new_item new_state) +))))) + +(let update (lambda '(item state) (block '( + (let key (Nth item '0)) + (let val (Nth item '1)) + (let next (QueuePeek queue (Uint64 '1) (DependsOn item))) + (let over (QueuePeek queue (Uint64 '2) (DependsOn item))) + (let nkey (Nth next '0)) + (let nval (Nth next '1)) + (let okey (Nth over '0)) + (let oval (Nth over '1)) + (let skey (Nth state '0)) + (let sval (Nth state '1)) + (let skey (+ skey key)) + (let sval (Concat sval val)) + (let validate (== (+ key (Coalesce nkey (Uint32 '0))) (Coalesce okey (Uint32 '0)))) + (let words (Concat (Concat val (Coalesce nval (String '""))) (Coalesce oval (String '"")))) + (let new_item '(key val skey sval validate words)) + (let new_state '(skey sval)) + (return '(new_item new_state) +))))) + +(let result (Fold1Map stream init update)) + +(let world (Write! world res_sink (Key) (Collect result) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Fold1MapOverUnboundedPreservedStream.yql b/yql/essentials/tests/s-expressions/suites/InMem/Fold1MapOverUnboundedPreservedStream.yql new file mode 100644 index 0000000000..c555c6df02 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Fold1MapOverUnboundedPreservedStream.yql @@ -0,0 +1,63 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList + '((Uint32 '1) (String 'r)) + '((Uint32 '1) (String 'a)) + '((Uint32 '2) (String 'b)) + '((Uint32 '3) (String 'b)) + '((Uint32 '5) (String 'i)) + '((Uint32 '8) (String 't)) +)) +(let base_stream (Iterator list)) + +(let queue (QueueCreate (ListItemType (TypeOf list)) (Void) (Uint64 '0))) +#(let queue (QueueCreate (TupleType (DataType 'Uint32) (DataType 'String)) (Uint64 '5) (Uint64 '0))) +(let stream (PreserveStream base_stream queue (Uint64 '1000000))) + +(let init (lambda '(item) (block '( + (let key (Nth item '0)) + (let val (Nth item '1)) + (let next (QueuePeek queue (Uint64 '1) (DependsOn item))) + (let over (QueuePeek queue (Uint64 '2) (DependsOn item))) + (let nkey (Nth next '0)) + (let nval (Nth next '1)) + (let okey (Nth over '0)) + (let oval (Nth over '1)) + (let skey key) + (let sval val) + (let validate (== (+ key (Coalesce nkey (Uint32 '0))) (Coalesce okey (Uint32 '0)))) + (let words (Concat (Concat val (Coalesce nval (String '""))) (Coalesce oval (String '"")))) + (let new_item '(key val skey sval validate words)) + (let new_state '(skey sval)) + (return '(new_item new_state) +))))) + +(let update (lambda '(item state) (block '( + (let key (Nth item '0)) + (let val (Nth item '1)) + (let next (QueuePeek queue (Uint64 '1) (DependsOn item))) + (let over (QueuePeek queue (Uint64 '2) (DependsOn item))) + (let nkey (Nth next '0)) + (let nval (Nth next '1)) + (let okey (Nth over '0)) + (let oval (Nth over '1)) + (let skey (Nth state '0)) + (let sval (Nth state '1)) + (let skey (+ skey key)) + (let sval (Concat sval val)) + (let validate (== (+ key (Coalesce nkey (Uint32 '0))) (Coalesce okey (Uint32 '0)))) + (let words (Concat (Concat val (Coalesce nval (String '""))) (Coalesce oval (String '"")))) + (let new_item '(key val skey sval validate words)) + (let new_state '(skey sval)) + (return '(new_item new_state) +))))) + +(let result (Fold1Map stream init update)) + +(let world (Write! world res_sink (Key) (Collect result) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/FoldMap.yql b/yql/essentials/tests/s-expressions/suites/InMem/FoldMap.yql new file mode 100644 index 0000000000..fde736a37c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/FoldMap.yql @@ -0,0 +1,32 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Uint32 '1) (String 'b)) +'((Uint32 '2) (String 'o)) +'((Uint32 '1) (String 'm)) +'((Uint32 '3) (String 'b)))) + +(let init_state '((Uint32 '0) (String '""))) + +(let update (lambda '(item state) (block '( + (let key (Nth item '0)) + (let val (Nth item '1)) + (let skey (Nth state '0)) + (let sval (Nth state '1)) + (let skey (+ skey key)) + (let sval (Concat sval val)) + (let new_item '(key val skey sval)) + (let new_state '(skey sval)) + (return '(new_item new_state) +))))) + +(let result (FoldMap list init_state update)) + +(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/InMem/ForwardList.yql b/yql/essentials/tests/s-expressions/suites/InMem/ForwardList.yql new file mode 100644 index 0000000000..dfec8da682 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/ForwardList.yql @@ -0,0 +1,14 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList (String 'aaa) (String 'bbb) (String 'ccc))) +(let world (Write! world res_sink (Key) (ForwardList (Iterator list (DependsOn (Uint32 '0)))) '())) +(let world (Write! world res_sink (Key) (Length (ForwardList (Iterator list (DependsOn (Uint32 '1))))) '())) +(let world (Write! world res_sink (Key) (Skip (ForwardList (Iterator list (DependsOn (Uint32 '2)))) (Uint64 '2)) '())) +(let world (Write! world res_sink (Key) (Take (ForwardList (Iterator list (DependsOn (Uint32 '3)))) (Uint64 '2)) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/GroupOpt.yql b/yql/essentials/tests/s-expressions/suites/InMem/GroupOpt.yql new file mode 100644 index 0000000000..30fcbac0b5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/GroupOpt.yql @@ -0,0 +1,23 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Just (Uint32 '2)) (Just (String 'D))) +'((Nothing (OptionalType (DataType 'Uint32))) (Just (String 'E))) +'((Just (Uint32 '3)) (Just (String 'A))) +'((Just (Uint32 '3)) (Nothing (OptionalType (DataType 'String)))) +'((Just (Uint32 '2)) (Just (String 'B))) +'((Just (Uint32 '3)) (Just (String 'A))) +)) + +(let keyExtractor (lambda '(x) (Nth x '0))) +(let handler (lambda '(key list) (Just '(key list)))) +(let data (GroupByKey list keyExtractor handler)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/GroupOptTuple.yql b/yql/essentials/tests/s-expressions/suites/InMem/GroupOptTuple.yql new file mode 100644 index 0000000000..c21c6b07d3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/GroupOptTuple.yql @@ -0,0 +1,23 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Just (Uint32 '2)) (Just (String 'D))) +'((Nothing (OptionalType (DataType 'Uint32))) (Just (String 'E))) +'((Just (Uint32 '3)) (Just (String 'A))) +'((Just (Uint32 '3)) (Nothing (OptionalType (DataType 'String)))) +'((Just (Uint32 '2)) (Just (String 'B))) +'((Just (Uint32 '3)) (Just (String 'A))) +)) + +(let keyExtractor (lambda '(x) x)) +(let handler (lambda '(key list) (Just '(key list)))) +(let data (GroupByKey list keyExtractor handler)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Guess.cfg b/yql/essentials/tests/s-expressions/suites/InMem/Guess.cfg new file mode 100644 index 0000000000..e41deb15c5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Guess.cfg @@ -0,0 +1,2 @@ +res result.txt +mount ..\mounts.txt diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Guess.yql b/yql/essentials/tests/s-expressions/suites/InMem/Guess.yql new file mode 100644 index 0000000000..256b5de592 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Guess.yql @@ -0,0 +1,54 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import id_module '"/lib/yql/id.yql") +(let id (bind id_module 'id)) + +(let res_sink (DataSink 'result)) +(let vt (VariantType (TupleType (DataType 'Int32) (DataType 'String)))) +(let v1 (Variant (Int32 '34) '0 vt)) +(let v2 (Variant (String 'qwe) '1 vt)) +(let jv1 (Just v1)) +(let jv2 (Just v2)) +(let n (Nothing (TypeOf jv1))) + +(let world (Write! world res_sink (Key) (Guess v1 '0) '('('type)))) +(let world (Write! world res_sink (Key) (Guess v2 '1) '('('type)))) +(let world (Write! world res_sink (Key) (Guess jv1 '0) '('('type)))) +(let world (Write! world res_sink (Key) (Guess jv2 '1) '('('type)))) +(let world (Write! world res_sink (Key) (Guess n '0) '('('type)))) +(let world (Write! world res_sink (Key) (Guess n '1) '('('type)))) + +(let world (Write! world res_sink (Key) (Guess (Apply id v1) '0) '('('type)))) +(let world (Write! world res_sink (Key) (Guess (Apply id v2) '1) '('('type)))) +(let world (Write! world res_sink (Key) (Guess (Apply id jv1) '0) '('('type)))) +(let world (Write! world res_sink (Key) (Guess (Apply id jv2) '1) '('('type)))) +(let world (Write! world res_sink (Key) (Guess (Apply id n) '0) '('('type)))) +(let world (Write! world res_sink (Key) (Guess (Apply id n) '1) '('('type)))) + +(let vt (VariantType (StructType '('a (DataType 'Int32)) '('b (DataType 'String))))) +(let v1 (Variant (Int32 '34) 'a vt)) +(let v2 (Variant (String 'qwe) 'b vt)) +(let jv1 (Just v1)) +(let jv2 (Just v2)) +(let n (Nothing (TypeOf jv1))) + +(let world (Write! world res_sink (Key) (Guess v1 'a) '('('type)))) +(let world (Write! world res_sink (Key) (Guess v2 'b) '('('type)))) +(let world (Write! world res_sink (Key) (Guess jv1 'a) '('('type)))) +(let world (Write! world res_sink (Key) (Guess jv2 'b) '('('type)))) +(let world (Write! world res_sink (Key) (Guess n 'a) '('('type)))) +(let world (Write! world res_sink (Key) (Guess n 'b) '('('type)))) + +(let world (Write! world res_sink (Key) (Guess (Apply id v1) 'a) '('('type)))) +(let world (Write! world res_sink (Key) (Guess (Apply id v2) 'b) '('('type)))) +(let world (Write! world res_sink (Key) (Guess (Apply id jv1) 'a) '('('type)))) +(let world (Write! world res_sink (Key) (Guess (Apply id jv2) 'b) '('('type)))) +(let world (Write! world res_sink (Key) (Guess (Apply id n) 'a) '('('type)))) +(let world (Write! world res_sink (Key) (Guess (Apply id n) 'b) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Hopping.yql b/yql/essentials/tests/s-expressions/suites/InMem/Hopping.yql new file mode 100644 index 0000000000..0ae29c3594 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Hopping.yql @@ -0,0 +1,51 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let timeExtractor (lambda '(item) (Just (Member item 'time)))) + +(let init (lambda '(item) + (AsStruct + '('sum (Member item 'sum)) + '('max (Member item 'max)) +))) +(let update (lambda '(item state) + (AsStruct + '('sum (AggrAdd (Member item 'sum) (Member state 'sum))) + '('max (AggrMax (Member item 'max) (Member state 'max))) +))) +(let merge (lambda '(state1 state2) + (AsStruct + '('sum (AggrAdd (Member state1 'sum) (Member state2 'sum))) + '('max (AggrMax (Member state1 'max) (Member state2 'max))) +))) +(let save (lambda '(state) state)) +(let load (lambda '(state) state)) +(let finish (lambda '(state time) (AddMember state '_yql_time time))) + +(let stream (Iterator (AsList +(AsStruct '('time (Timestamp '1)) '('sum (Uint32 '2)) '('max (String 'f))) +(AsStruct '('time (Timestamp '2)) '('sum (Uint32 '3)) '('max (String 'a))) +(AsStruct '('time (Timestamp '15)) '('sum (Uint32 '4)) '('max (String 'e))) +(AsStruct '('time (Timestamp '23)) '('sum (Uint32 '6)) '('max (String 'h))) +(AsStruct '('time (Timestamp '24)) '('sum (Uint32 '5)) '('max (String 'd))) +(AsStruct '('time (Timestamp '25)) '('sum (Uint32 '7)) '('max (String 's))) +(AsStruct '('time (Timestamp '40)) '('sum (Uint32 '2)) '('max (String 'j))) +(AsStruct '('time (Timestamp '47)) '('sum (Uint32 '1)) '('max (String 't))) +(AsStruct '('time (Timestamp '51)) '('sum (Uint32 '6)) '('max (String 'b))) +(AsStruct '('time (Timestamp '59)) '('sum (Uint32 '2)) '('max (String 'c))) +(AsStruct '('time (Timestamp '85)) '('sum (Uint32 '8)) '('max (String 'g))) +(AsStruct '('time (Timestamp '55)) '('sum (Uint32 '1000)) '('max (String 'z))) +(AsStruct '('time (Timestamp '200)) '('sum (Uint32 '0)) '('max (String 'a))) +))) + +# row with time 55 should be excluded from aggregation due to delay + +(let itemType (StructType '('time (DataType 'Timestamp)) '('sum (DataType 'Uint32)) '('max (DataType 'String)))) +(let res (HoppingCore stream timeExtractor (Interval '10) (Interval '30) (Interval '20) init update save load merge finish)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Collect res) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/IndexDictOpt.yql b/yql/essentials/tests/s-expressions/suites/InMem/IndexDictOpt.yql new file mode 100644 index 0000000000..b551ccbad0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/IndexDictOpt.yql @@ -0,0 +1,20 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let t (AsList + (String 'a) + (String 'b) +)) + +(let jt (Just t)) +(let n (Nothing (TypeOf jt))) + +(let world (Write! world res_sink (Key) (ToIndexDict jt) '('('type)))) +(let world (Write! world res_sink (Key) (ToIndexDict n) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Iterator.yql b/yql/essentials/tests/s-expressions/suites/InMem/Iterator.yql new file mode 100644 index 0000000000..0cba17d6ea --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Iterator.yql @@ -0,0 +1,18 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList (String 'aaa) (String 'bbb) (String 'ccc))) +(let world (Write! world res_sink (Key) (Collect (Iterator list (DependsOn (Uint32 '0)))) '())) +(let world (Write! world res_sink (Key) (Collect (Iterator (Just list))) '())) +(let world (Write! world res_sink (Key) (Collect (Iterator (Nothing (OptionalType (TypeOf list))))) '())) +(let world (Write! world res_sink (Key) (Collect (EmptyIterator (StreamType (DataType 'Double)))) '())) +(let world (Write! world res_sink (Key) (Collect (ToStream (Just (Uint32 '123)) (DependsOn (Uint32 '1)))) '())) +(let world (Write! world res_sink (Key) (Collect (ToStream (Nothing (OptionalType (DataType 'Double))))) '())) +(let world (Write! world res_sink (Key) (Collect (ToStream (EmptyIterator (StreamType (DataType 'String))))) '())) +(let world (Write! world res_sink (Key) (Collect (ToStream list (DependsOn (Uint32 '2)))) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/LMap.yql b/yql/essentials/tests/s-expressions/suites/InMem/LMap.yql new file mode 100644 index 0000000000..12ad41b0a7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/LMap.yql @@ -0,0 +1,21 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Uint32 '1) (String 'a)) +'((Uint32 '2) (String 'b)) +'((Uint32 '1) (String 'c)))) + +(let handler (lambda '(stream) (block '( + (return (Map stream (lambda '(x) (Nth x '1)))) +)))) + +(let data (LMap list handler)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/ListExtendMany.yql b/yql/essentials/tests/s-expressions/suites/InMem/ListExtendMany.yql new file mode 100644 index 0000000000..6c3403e7d4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/ListExtendMany.yql @@ -0,0 +1,22 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let test (lambda '(world data) (block '( + (let world (Write! world res_sink (Key) data '('('type)))) + (return world) +)))) + +(let world (Apply test world (Extend (AsList (String 'a))))) +(let world (Apply test world (Extend (AsList (String 'a)) (AsList (String 'b))))) +(let world (Apply test world (Extend (AsList (String 'a)) (AsList (String 'b)) (AsList (String 'c))))) +(let world (Apply test world (Extend + (Extend (Take (AsList (String 'a)) (Uint64 '1)) (AsList (String 'b))) + (Extend (Take (AsList (String 'c)) (Uint64 '1)) (AsList (String 'd))) + ))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/ListFromRangeForDates.yql b/yql/essentials/tests/s-expressions/suites/InMem/ListFromRangeForDates.yql new file mode 100644 index 0000000000..7bf690187b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/ListFromRangeForDates.yql @@ -0,0 +1,16 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let intervalOneSec (Interval '"1000000")) + +(let FirstList (ListFromRange (SafeCast (CurrentUtcDate) (DataType 'Datetime)) (Unwrap (- (CurrentUtcDatetime) (Interval '"63995000000"))) intervalOneSec)) +(let SecondList (ListFromRange (CurrentUtcDate) (Unwrap (+ (CurrentUtcDate) (Interval '"432000000000"))) (Interval '"86400000000"))) +(let ThirdList (ListFromRange (CurrentUtcDatetime) (Unwrap (+ (CurrentUtcDatetime) (Interval '"5000000"))) intervalOneSec)) +(let FourthList (ListFromRange (CurrentUtcTimestamp) (Unwrap (+ (CurrentUtcTimestamp) (Interval '"5"))) (Interval '"1"))) +(let Columns '('"column0" '"column1" '"column2" '"column3")) +(let Col '('('type) '('autoref) '('columns Columns))) +(let world (Write! world res_sink (Key) (AsList (AsStruct '('"column0" FirstList) '('"column1" SecondList) '('"column2" ThirdList) '('"column3" FourthList))) Col)) +(return (Commit! world res_sink)) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/MemberOpt.yql b/yql/essentials/tests/s-expressions/suites/InMem/MemberOpt.yql new file mode 100644 index 0000000000..fafe8bee40 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/MemberOpt.yql @@ -0,0 +1,25 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let s (AsStruct + '('a (String 'aaa)) + '('b (Just (Uint32 '4))) + '('c (Nothing (OptionalType (DataType 'Uint32))))) +) + +(let js (Just s)) +(let n (Nothing (TypeOf js))) + +(let world (Write! world res_sink (Key) (Member s 'a) '())) +(let world (Write! world res_sink (Key) (Member js 'a) '())) +(let world (Write! world res_sink (Key) (Member js 'b) '())) +(let world (Write! world res_sink (Key) (Member js 'c) '())) +(let world (Write! world res_sink (Key) (Member n 'a) '())) +(let world (Write! world res_sink (Key) (Member n 'c) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Merge.yql b/yql/essentials/tests/s-expressions/suites/InMem/Merge.yql new file mode 100644 index 0000000000..3e91e821c6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Merge.yql @@ -0,0 +1,47 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list1 (AsList + (AsStruct '('a (Uint32 '4)) '('b (String 'c))) + (AsStruct '('a (Uint32 '1)) '('b (String 'd))) + (AsStruct '('a (Uint32 '3)) '('b (String 'b))) +)) +(let list2 (AsList + (AsStruct '('a (Uint32 '2)) '('b (String 'a))) + (AsStruct '('a (Uint32 '5)) '('b (String 'y))) + (AsStruct '('a (Uint32 '1)) '('b (String 'z))) +)) +(let world (Write! world res_sink (Key) + (Merge + list1 + list2 + ) +'('('type)))) + +(let world (Write! world res_sink (Key) + (Merge + (Sort list1 (Bool 'True) (lambda '(item) (Member item 'a))) + (Sort list2 (Bool 'True) (lambda '(item) (Member item 'a))) + ) +'('('type)))) + +(let world (Write! world res_sink (Key) + (Merge + (Sort list1 (Bool 'False) (lambda '(item) (Member item 'a))) + (Sort list2 (Bool 'False) (lambda '(item) (Member item 'a))) + ) +'('('type)))) + +(let world (Write! world res_sink (Key) + (Merge + (Sort list1 '((Bool 'True) (Bool 'True)) (lambda '(item) '((Member item 'a) (Member item 'b)))) + (Sort list2 '((Bool 'True) (Bool 'True)) (lambda '(item) '((Member item 'a) (Member item 'b)))) + ) +'('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/MultiMap.yql b/yql/essentials/tests/s-expressions/suites/InMem/MultiMap.yql new file mode 100644 index 0000000000..7a39c20b0a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/MultiMap.yql @@ -0,0 +1,16 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList (Int32 '1) (Int32 '2) (Int32 '3))) +(let world (Write! world res_sink (Key) (OrderedMultiMap list + (lambda '(x) x (+ x (Int32 '10)) x)) '('('type)))) +(let world (Write! world res_sink (Key) (MultiMap (LazyList list) + (lambda '(x) x (- (Int32 '7) x) (* x x))) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (MultiMap (ToFlow list) + (lambda '(x) x (+ x (Int32 '-3)) (Int32 '0)))) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Mux.yql b/yql/essentials/tests/s-expressions/suites/InMem/Mux.yql new file mode 100644 index 0000000000..2a226541f3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Mux.yql @@ -0,0 +1,20 @@ +( +#comment +(let res_sink (DataSink 'result)) +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList (String 'a1) (String 'a2) (String 'a3))) +(let list2 (AsList (Bool 'true) (Bool 'false))) +(let list3 (AsList (Uint32 '1) (Uint32 '2) (Uint32 '3) (Uint32 '4))) + +(let data (Mux '(list1 list2 list3))) +(let world (Write! world res_sink (Key) data '('('type)))) + +(let data (Mux (AsStruct '('a list1) '('b list2) '('c list3)))) +(let world (Write! world res_sink (Key) data '('('type)))) + +(let world (Commit! world res_sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/NthOpt.yql b/yql/essentials/tests/s-expressions/suites/InMem/NthOpt.yql new file mode 100644 index 0000000000..428da2f45f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/NthOpt.yql @@ -0,0 +1,25 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let t '( + (String 'aaa) + (Just (Uint32 '4)) + (Nothing (OptionalType (DataType 'Uint32))) +)) + +(let jt (Just t)) +(let n (Nothing (TypeOf jt))) + +(let world (Write! world res_sink (Key) (Nth t '0) '())) +(let world (Write! world res_sink (Key) (Nth jt '0) '())) +(let world (Write! world res_sink (Key) (Nth jt '1) '())) +(let world (Write! world res_sink (Key) (Nth jt '2) '())) +(let world (Write! world res_sink (Key) (Nth n '0) '())) +(let world (Write! world res_sink (Key) (Nth n '2) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/PartitionByKey.yql b/yql/essentials/tests/s-expressions/suites/InMem/PartitionByKey.yql new file mode 100644 index 0000000000..af112ea360 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/PartitionByKey.yql @@ -0,0 +1,27 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Uint32 '1) (String 'a)) +'((Uint32 '2) (String 'b)) +'((Uint32 '1) (String 'c)))) + +(let keyExtractor (lambda '(x) (Nth x '0))) +(let handler (lambda '(groups) (block '( + (return (Map groups (lambda '(pair) (block '( + (let key (Nth pair '0)) + (let stream (Nth pair '1)) + (let state (Concat (String '"key:") (ToString key))) + (let state (Condense stream state (lambda '(row state) (Bool 'False)) (lambda '(row state) (Concat (Concat state (String '" ")) (Nth row '1))))) + (return (Collect state)) + ))))) +)))) +(let data (PartitionByKey list keyExtractor (Void) (Void) handler)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/PartitionByKeySorted.yql b/yql/essentials/tests/s-expressions/suites/InMem/PartitionByKeySorted.yql new file mode 100644 index 0000000000..a5c99fd3ee --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/PartitionByKeySorted.yql @@ -0,0 +1,28 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Uint32 '1) (String 'a)) +'((Uint32 '2) (String 'b)) +'((Uint32 '1) (String 'c)))) + +(let keyExtractor (lambda '(x) (Nth x '0))) +(let subkeyExtractor (lambda '(x) (Nth x '1))) +(let handler (lambda '(groups) (block '( + (return (Map groups (lambda '(pair) (block '( + (let key (Nth pair '0)) + (let stream (Nth pair '1)) + (let state (Concat (String '"key:") (ToString key))) + (let state (Condense stream state (lambda '(row state) (Bool 'False)) (lambda '(row state) (Concat (Concat state (String '" ")) (Nth row '1))))) + (return (Collect state)) + ))))) +)))) +(let data (PartitionByKey list keyExtractor (Bool 'false) subkeyExtractor handler)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/PartitionsByKeys.yql b/yql/essentials/tests/s-expressions/suites/InMem/PartitionsByKeys.yql new file mode 100644 index 0000000000..81326641f1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/PartitionsByKeys.yql @@ -0,0 +1,24 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Uint32 '1) (String 'a)) +'((Uint32 '2) (String 'b)) +'((Uint32 '1) (String 'c)))) + +(let keyExtractor (lambda '(x) (Nth x '0))) +(let handler (lambda '(x) (Condense1 x + (lambda '(row) '((Nth row '0) (Concat (String '"values:") (ToString (Nth row '1))))) + (lambda '(row state) (AggrNotEquals (Nth row '0) (Nth state '0))) + (lambda '(row state) '((Nth state '0) (Concat (Concat (Nth state '1) (String '" ")) (Nth row '1)))) +))) +(let data (PartitionsByKeys (Iterator list) keyExtractor (Void) (Void) handler)) +(let data (Collect data)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/PartitionsByKeysSorted.yql b/yql/essentials/tests/s-expressions/suites/InMem/PartitionsByKeysSorted.yql new file mode 100644 index 0000000000..73f3a3f970 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/PartitionsByKeysSorted.yql @@ -0,0 +1,25 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Uint32 '1) (String 'a)) +'((Uint32 '2) (String 'b)) +'((Uint32 '1) (String 'c)))) + +(let keyExtractor (lambda '(x) (Nth x '0))) +(let subkeyExtractor (lambda '(x) (Nth x '1))) +(let handler (lambda '(x) (Condense1 x + (lambda '(row) '((Nth row '0) (Concat (String '"values:") (ToString (Nth row '1))))) + (lambda '(row state) (AggrNotEquals (Nth row '0) (Nth state '0))) + (lambda '(row state) '((Nth state '0) (Concat (Concat (Nth state '1) (String '" ")) (Nth row '1)))) +))) +(let data (PartitionsByKeys (Iterator list) keyExtractor (Bool 'false) subkeyExtractor handler)) +(let data (Collect data)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Queue.yql b/yql/essentials/tests/s-expressions/suites/InMem/Queue.yql new file mode 100644 index 0000000000..2589942a60 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Queue.yql @@ -0,0 +1,25 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let queue (QueueCreate (DataType 'Uint32) (Uint64 '4) (Uint64 '2))) + +(let queue (QueuePush queue (Int32 '1))) +(let queue (QueuePush queue (Int32 '2))) + +(let result '((QueuePeek queue (Uint64 '0)) (QueuePeek queue (Uint64 '1)) (QueuePeek queue (Uint64 '2)) (QueuePeek queue (Uint64 '3)))) +(let world (Write! world res_sink (Key) result '('('type)))) + +(let queue (QueuePop queue)) +(let queue (QueuePop queue)) +(let queue (QueuePush queue (Int32 '3))) + +(let result '((QueuePeek queue (Uint64 '0)) (QueuePeek queue (Uint64 '1)) (QueuePeek queue (Uint64 '2)) (QueuePeek queue (Uint64 '3)))) +(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/InMem/QueueCheckDependent.yql b/yql/essentials/tests/s-expressions/suites/InMem/QueueCheckDependent.yql new file mode 100644 index 0000000000..5bf3868fcc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/QueueCheckDependent.yql @@ -0,0 +1,33 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let qrs1 (QueueCreate (DataType 'String) (Uint64 '6) (Uint64 '0) (DependsOn (Uint64 '0)))) +(let qrs2 (QueueCreate (DataType 'String) (Uint64 '6) (Uint64 '0) (DependsOn (Uint64 '1)))) +(let qrs2 (QueuePush qrs2 (String '"It"))) +(let qrs1 (QueuePush qrs1 (String '"Look!"))) +(let qrs2 (QueuePush qrs2 (String '"is"))) +(let qrs1 (QueuePush qrs1 (String '"It"))) +(let qrs2 (QueuePush qrs2 (String '"a"))) +(let qrs1 (QueuePush qrs1 (String '"funny"))) +(let qrs2 (QueuePop qrs2)) +(let qrs2 (QueuePush qrs2 (String '"good"))) +(let qrs1 (QueuePop qrs1)) +(let qrs2 (QueuePush qrs2 (String '"day"))) +(let qrs2 (QueuePop qrs2)) +(let qrs2 (QueuePush qrs2 (String '"to"))) +(let qrs1 (QueuePush qrs1 (String '"bunny"))) +(let qrs2 (QueuePush qrs2 (String '"die"))) +(let qrs1 (QueuePop qrs1)) + +(let resultString1 '((QueuePeek qrs1 (Minus (Uint64 '1))) (QueuePeek qrs1 (Uint64 '0)) (QueuePeek qrs1 (Uint64 '1)) (QueuePeek qrs1 (Uint64 '2)))) +(let resultString2 '((QueuePeek qrs2 (Minus (Uint64 '1))) (QueuePeek qrs2 (Uint64 '0)) (QueuePeek qrs2 (Uint64 '1)) (QueuePeek qrs2 (Uint64 '2)))) + +(let result '(resultString1 resultString2)) + +(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/InMem/QueueMixedTypes.yql b/yql/essentials/tests/s-expressions/suites/InMem/QueueMixedTypes.yql new file mode 100644 index 0000000000..55e36075f5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/QueueMixedTypes.yql @@ -0,0 +1,30 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let qrs (QueueCreate (DataType 'String) (Uint64 '5) (Uint64 '0))) +(let qri (QueueCreate (DataType 'Int32) (Uint64 '5) (Uint64 '0))) +(let qri (QueuePush qri (Int32 '-5))) +(let qrs (QueuePush qrs (String '"It"))) +(let qri (QueuePush qri (Int32 '5))) +(let qrs (QueuePush qrs (String '"is"))) +(let qri (QueuePush qri (Int64 '-33))) +(let qrs (QueuePush qrs (String '"funny"))) +(let qri (QueuePop qri)) +(let qrs (QueuePop qrs)) +(let qri (QueuePush qri (Int32 '42))) +(let qri (QueuePop qri)) +(let qrs (QueuePush qrs (String '"bunny"))) +(let qrs (QueuePop qrs)) + +(let resultInt '((QueuePeek qri (Minus (Uint64 '1))) (QueuePeek qri (Uint64 '0)) (QueuePeek qri (Uint64 '1)) (QueuePeek qri (Uint64 '2)))) +(let resultString '((QueuePeek qrs (Minus (Uint64 '1))) (QueuePeek qrs (Uint64 '0)) (QueuePeek qrs (Uint64 '1)) (QueuePeek qrs (Uint64 '2)))) + +(let result '(resultInt resultString)) + +(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/InMem/QueueRangeWithPreservedStream.yql b/yql/essentials/tests/s-expressions/suites/InMem/QueueRangeWithPreservedStream.yql new file mode 100644 index 0000000000..3a0c673d27 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/QueueRangeWithPreservedStream.yql @@ -0,0 +1,32 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let list (AsList + (Uint32 '1) + (Uint32 '1) + (Uint32 '2) + (Uint32 '3) + (Uint32 '5) + (Uint32 '8) +)) + +(let base_stream (Iterator list)) + +(let queue (QueueCreate (ListItemType (TypeOf list)) (Void) (Uint64 '0))) + +(let stream (PreserveStream base_stream queue (Uint64 '100500))) + +(let update (lambda '(item state) (block '( + (let cumulative_sum (+ item state)) + (let queue_content (Collect (QueueRange queue (Uint64 '0) (Uint64 '100500) (DependsOn item)))) + (return '('(item cumulative_sum queue_content) cumulative_sum)) +)))) + +(let result (FoldMap stream (Uint32 '0) update)) + +(let world (Write! world res_sink (Key) (Collect result) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/QueueSimpleStrings.yql b/yql/essentials/tests/s-expressions/suites/InMem/QueueSimpleStrings.yql new file mode 100644 index 0000000000..e7c8c1d029 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/QueueSimpleStrings.yql @@ -0,0 +1,19 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let qr (QueueCreate (OptionalType (DataType 'String)) (Uint64 '5) (Uint64 '0))) +(let qr (QueuePush qr (String '"It"))) +(let qr (QueuePush qr (Just (String '"is")))) +(let qr (QueuePush qr (String '"funny"))) +(let qr (QueuePop qr)) +(let qr (QueuePush qr (Just (String '"bunny")))) +(let qr (QueuePop qr)) +(let result '((QueuePeek qr (Minus (Uint64 '1))) (QueuePeek qr (Uint64 '0)) (QueuePeek qr (Uint64 '1)) (QueuePeek qr (Uint64 '2)))) + +(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/InMem/ReplaceMember.yql b/yql/essentials/tests/s-expressions/suites/InMem/ReplaceMember.yql new file mode 100644 index 0000000000..bb7203c502 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/ReplaceMember.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let s (AsStruct '('a (String 'ccc)) '('b (Double '3.5)))) +(let world (Write! world res_sink (Key) (ReplaceMember s 'a (Int32 '7)) '('('type)))) +(let world (Write! world res_sink (Key) (ReplaceMember s 'b (String 'aaa)) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Seq.yql b/yql/essentials/tests/s-expressions/suites/InMem/Seq.yql new file mode 100644 index 0000000000..ea9eec4131 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Seq.yql @@ -0,0 +1,31 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let v1 (String 'test1)) +(let q1 (QueueCreate (TypeOf v1) (Uint64 '1) (Uint64 '1) (DependsOn v1))) +(let new_q1 (QueuePush (QueuePop q1) v1)) +(let q1_item (QueuePeek q1 (Uint64 '0) (DependsOn v1))) +(let new_q1_item (QueuePeek new_q1 (Uint64 '0) (DependsOn v1))) + +# will be (test1, test1) +(let result '(new_q1_item q1_item)) +(let world (Write! world res_sink (Key) result '('('type)))) + + +(let v2 (String 'test2)) +(let q2 (QueueCreate (TypeOf v2) (Uint64 '1) (Uint64 '1) (DependsOn v2))) +(let new_q2 (QueuePush (QueuePop q2) v2)) +(let q2_item (QueuePeek q2 (Uint64 '0) (DependsOn v2))) +(let new_q2_item (QueuePeek new_q2 (Uint64 '0) (DependsOn v2))) + +# enforce q2_item to be calculated first +(let result '((Seq q2_item new_q2_item) q2_item)) +(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/InMem/SkipNullMembers.yql b/yql/essentials/tests/s-expressions/suites/InMem/SkipNullMembers.yql new file mode 100644 index 0000000000..8da7e768fd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/SkipNullMembers.yql @@ -0,0 +1,15 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList + (AsStruct '('key (Just (Uint32 '1))) '('value (String 'a))) + (AsStruct '('key (Nothing (OptionalType (DataType 'Uint32)))) '('value (String 'a))) +)) + +(let world (Write! world res_sink (Key) (SkipNullMembers list '('key)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/SortOpt.yql b/yql/essentials/tests/s-expressions/suites/InMem/SortOpt.yql new file mode 100644 index 0000000000..3ef2f4081b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/SortOpt.yql @@ -0,0 +1,21 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Just (Uint32 '2)) (Just (String 'D))) +'((Nothing (OptionalType (DataType 'Uint32))) (Just (String 'E))) +'((Just (Uint32 '3)) (Just (String 'A))) +'((Just (Uint32 '3)) (Nothing (OptionalType (DataType 'String)))) +'((Just (Uint32 '2)) (Just (String 'B))) +)) + +(let keyExtractor (lambda '(x) (Nth x '0))) +(let data (Sort list (Bool 'true) keyExtractor)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/SortOptTuple.yql b/yql/essentials/tests/s-expressions/suites/InMem/SortOptTuple.yql new file mode 100644 index 0000000000..ddfb0a7e16 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/SortOptTuple.yql @@ -0,0 +1,21 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Just (Uint32 '2)) (Just (String 'D))) +'((Nothing (OptionalType (DataType 'Uint32))) (Just (String 'E))) +'((Just (Uint32 '3)) (Just (String 'A))) +'((Just (Uint32 '3)) (Nothing (OptionalType (DataType 'String)))) +'((Just (Uint32 '2)) (Just (String 'B))) +)) + +(let keyExtractor (lambda '(x) x)) +(let data (Sort list '((Bool 'false) (Bool 'false)) keyExtractor)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/SqlAccess.yql b/yql/essentials/tests/s-expressions/suites/InMem/SqlAccess.yql new file mode 100644 index 0000000000..9ad041b115 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/SqlAccess.yql @@ -0,0 +1,74 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let t '((Int32 '34) (String 'qwe))) +(let l (AsList (Int32 '34) (Int32 '56))) +(let s (AsStruct '('a (String 'ccc)) '('b (Double '3.5)))) +(let d (AsDict + '((Just (Uint32 '4)) (String 'aaa)) + '((Nothing (OptionalType (DataType 'Uint32))) (String 'bbb))) +) + +(let vt1 (VariantType (TupleType (DataType 'Int32) (DataType 'String)))) +(let v1 (Variant (Int32 '34) '0 vt1)) + +(let vt2 (VariantType (StructType '('a (DataType 'Int32)) '('b (DataType 'String))))) +(let v2 (Variant (Int32 '34) 'a vt2)) + +(let world (Write! world res_sink (Key) (SqlAccess 'tuple t '0) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'tuple t '1) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'tuple v1 '0) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'tuple v1 '1) '('('type)))) + +(let world (Write! world res_sink (Key) (SqlAccess 'tuple (Just t) '0) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'tuple (Just t) '1) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'tuple (Just v1) '0) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'tuple (Just v1) '1) '('('type)))) + +(let world (Write! world res_sink (Key) (SqlAccess 'tuple (Nothing (OptionalType (TypeOf t))) '0) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'tuple (Nothing (OptionalType (TypeOf t))) '1) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'tuple (Nothing (OptionalType (TypeOf v1))) '0) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'tuple (Nothing (OptionalType (TypeOf v1))) '1) '('('type)))) + +(let world (Write! world res_sink (Key) (SqlAccess 'struct s 'a) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'struct s 'b) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'struct v2 'a) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'struct v2 'b) '('('type)))) + +(let world (Write! world res_sink (Key) (SqlAccess 'struct (Just s) 'a) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'struct (Just s) 'b) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'struct (Just v2) 'a) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'struct (Just v2) 'b) '('('type)))) + +(let world (Write! world res_sink (Key) (SqlAccess 'struct (Nothing (OptionalType (TypeOf s))) 'a) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'struct (Nothing (OptionalType (TypeOf s))) 'b) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'struct (Nothing (OptionalType (TypeOf v2))) 'a) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'struct (Nothing (OptionalType (TypeOf v2))) 'b) '('('type)))) + +(let world (Write! world res_sink (Key) (SqlAccess 'dict l (Uint64 '0)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict l (Uint64 '1)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict l (Uint64 '2)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict d (Uint32 '4)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict d (Uint32 '5)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict d (Nothing (OptionalType (DataType 'Uint32)))) '('('type)))) + +(let world (Write! world res_sink (Key) (SqlAccess 'dict (Just l) (Uint64 '0)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict (Just l) (Uint64 '1)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict (Just l) (Uint64 '2)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict (Just d) (Uint32 '4)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict (Just d) (Uint32 '5)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict (Just d) (Nothing (OptionalType (DataType 'Uint32)))) '('('type)))) + +(let world (Write! world res_sink (Key) (SqlAccess 'dict (Nothing (OptionalType (TypeOf l))) (Uint64 '0)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict (Nothing (OptionalType (TypeOf l))) (Uint64 '1)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict (Nothing (OptionalType (TypeOf l))) (Uint64 '2)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict (Nothing (OptionalType (TypeOf d))) (Uint32 '4)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict (Nothing (OptionalType (TypeOf d))) (Uint32 '5)) '('('type)))) +(let world (Write! world res_sink (Key) (SqlAccess 'dict (Nothing (OptionalType (TypeOf d))) (Nothing (OptionalType (DataType 'Uint32)))) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/StaticMap.yql b/yql/essentials/tests/s-expressions/suites/InMem/StaticMap.yql new file mode 100644 index 0000000000..c4c247d675 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/StaticMap.yql @@ -0,0 +1,18 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let default (lambda '(x) (block '( + (return (Coalesce x (Default (OptionalItemType (TypeOf x))))) +)))) + +(let tuple '((Just (Uint32 '1)) (Just (String 'X)))) +(let struct (AsStruct '('a (Nothing (OptionalType (DataType 'Uint32)))) '('b (Just (String 'Y))))) + +(let world (Write! world res_sink (Key) (StaticMap tuple default) '('('type)))) +(let world (Write! world res_sink (Key) (StaticMap struct default) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/StreamDiscard.yql b/yql/essentials/tests/s-expressions/suites/InMem/StreamDiscard.yql new file mode 100644 index 0000000000..adf904774d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/StreamDiscard.yql @@ -0,0 +1,11 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list1 (AsList (Uint32 '1) (Uint32 '2) (Uint32 '3))) +(let world (Write! world res_sink (Key) (Collect (Discard (Iterator list1))) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/StreamExtend.yql b/yql/essentials/tests/s-expressions/suites/InMem/StreamExtend.yql new file mode 100644 index 0000000000..0e04475199 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/StreamExtend.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list1 (AsList (Uint32 '1) (Uint32 '2) (Uint32 '3))) +(let list2 (AsList (Uint32 '4) (Uint32 '5) (Uint32 '6))) +(let list3 (AsList (Uint32 '7) (Uint32 '8) (Uint32 '9))) +(let world (Write! world res_sink (Key) (Collect (Extend (Iterator list1) (Iterator list2) (Iterator list3))) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/StreamFilter.yql b/yql/essentials/tests/s-expressions/suites/InMem/StreamFilter.yql new file mode 100644 index 0000000000..ce40b9f8a9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/StreamFilter.yql @@ -0,0 +1,12 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList (Uint32 '1) (Uint32 '2) (Uint32 '3))) +(let world (Write! world res_sink (Key) (Collect (Filter (Iterator list) + (lambda '(x) (!= (Uint32 '0) (BitAnd x (Uint32 '1)))))) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/StreamFlatMap.yql b/yql/essentials/tests/s-expressions/suites/InMem/StreamFlatMap.yql new file mode 100644 index 0000000000..9a23a4d591 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/StreamFlatMap.yql @@ -0,0 +1,21 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList (Int32 '1) (Int32 '2) (Int32 '3))) +(let world (Write! world res_sink (Key) (Collect (FlatMap (Iterator list (DependsOn (String 'A))) + (lambda '(x) (AsList x x)))) '('('type)))) +(let add (lambda '(y) (+ y (Int32 '10)))) +(let world (Write! world res_sink (Key) (Collect (FlatMap (Iterator list (DependsOn (String 'B))) + (lambda '(x) (Map (/ (Int32 '5) (- (Int32 '2) x)) add)))) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (FlatMap (Iterator list (DependsOn (String 'C))) + (lambda '(x) (Iterator (AsList x x))))) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (FlatMap list + (lambda '(x) (Iterator (AsList x x))))) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (FlatMap (/ (Int32 '3) (Int32 '1)) + (lambda '(x) (Iterator (AsList x x))))) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/StreamFold1Map.yql b/yql/essentials/tests/s-expressions/suites/InMem/StreamFold1Map.yql new file mode 100644 index 0000000000..5acfe5d46d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/StreamFold1Map.yql @@ -0,0 +1,42 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Uint32 '1) (String 'r)) +'((Uint32 '1) (String 'a)) +'((Uint32 '2) (String 'b)) +'((Uint32 '3) (String 'b)) +'((Uint32 '5) (String 'i)) +'((Uint32 '8) (String 't)))) + +(let init (lambda '(item) (block '( + (let key (Nth item '0)) + (let val (Nth item '1)) + (let skey key) + (let sval val) + (let new_item '(key val skey sval)) + (let new_state '(skey sval)) + (return '(new_item new_state) +))))) + +(let update (lambda '(item state) (block '( + (let key (Nth item '0)) + (let val (Nth item '1)) + (let skey (Nth state '0)) + (let sval (Nth state '1)) + (let skey (+ skey key)) + (let sval (Concat sval val)) + (let new_item '(key val skey sval)) + (let new_state '(skey sval)) + (return '(new_item new_state) +))))) + +(let result (Fold1Map (Iterator list) init update)) + +(let world (Write! world res_sink (Key) (Collect result) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/StreamFoldMap.yql b/yql/essentials/tests/s-expressions/suites/InMem/StreamFoldMap.yql new file mode 100644 index 0000000000..78557d82b8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/StreamFoldMap.yql @@ -0,0 +1,32 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Uint32 '1) (String 'b)) +'((Uint32 '2) (String 'o)) +'((Uint32 '1) (String 'm)) +'((Uint32 '3) (String 'b)))) + +(let init_state '((Uint32 '0) (String '""))) + +(let update (lambda '(item state) (block '( + (let key (Nth item '0)) + (let val (Nth item '1)) + (let skey (Nth state '0)) + (let sval (Nth state '1)) + (let skey (+ skey key)) + (let sval (Concat sval val)) + (let new_item '(key val skey sval)) + (let new_state '(skey sval)) + (return '(new_item new_state) +))))) + +(let result (FoldMap (Iterator list) init_state update)) + +(let world (Write! world res_sink (Key) (Collect result) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/StreamInCombineByKey.yql b/yql/essentials/tests/s-expressions/suites/InMem/StreamInCombineByKey.yql new file mode 100644 index 0000000000..e58ebc251e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/StreamInCombineByKey.yql @@ -0,0 +1,16 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList '((Uint32 '1) (String 'a)) '((Uint32 '1) (String 'b)) '((Uint32 '2) (String 'c)))) +(let premap (lambda '(x) (Iterator (AsList x)))) +(let keyExtractor (lambda '(x) (Nth x '0))) +(let handlerInit (lambda '(key item) (Nth item '1))) +(let handlerUpdate (lambda '(key item state) (Concat (Nth item '1) state))) +(let handlerFinish (lambda '(key state) (Iterator (AsList '(key state))))) +(let world (Write! world res_sink (Key) (CombineByKey list premap keyExtractor handlerInit handlerUpdate handlerFinish) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/StreamInGroupByKey.yql b/yql/essentials/tests/s-expressions/suites/InMem/StreamInGroupByKey.yql new file mode 100644 index 0000000000..5eae4467ff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/StreamInGroupByKey.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList '((Uint32 '1) (String 'a)) '((Uint32 '1) (String 'b)) '((Uint32 '2) (String 'c)))) +(let keyExtractor (lambda '(x) (Nth x '0))) +(let handler (lambda '(key list) (Iterator (AsList key key)))) +(let world (Write! world res_sink (Key) (GroupByKey list keyExtractor handler) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/StreamMap.yql b/yql/essentials/tests/s-expressions/suites/InMem/StreamMap.yql new file mode 100644 index 0000000000..cb48729c8f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/StreamMap.yql @@ -0,0 +1,12 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList (Uint32 '1) (Uint32 '2) (Uint32 '3))) +(let world (Write! world res_sink (Key) (Collect (Map (Iterator list) + (lambda '(x) (+ (Uint32 '10) x)))) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/StreamSkip.yql b/yql/essentials/tests/s-expressions/suites/InMem/StreamSkip.yql new file mode 100644 index 0000000000..3d553a2b36 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/StreamSkip.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list1 (AsList (Uint32 '1) (Uint32 '2) (Uint32 '3))) +(let list2 (AsList (Uint32 '4) (Uint32 '5) (Uint32 '6))) +(let world (Write! world res_sink (Key) (Collect (Skip (Iterator list1) (Uint64 '2))) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Skip (Iterator list2) (Uint64 '0))) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/StreamTake.yql b/yql/essentials/tests/s-expressions/suites/InMem/StreamTake.yql new file mode 100644 index 0000000000..0870b1aac3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/StreamTake.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list1 (AsList (Uint32 '1) (Uint32 '2) (Uint32 '3))) +(let list2 (AsList (Uint32 '4) (Uint32 '5) (Uint32 '6))) +(let world (Write! world res_sink (Key) (Collect (Take (Iterator list1) (Uint64 '2))) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Take (Iterator list2) (Uint64 '0))) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/StringContains.yql b/yql/essentials/tests/s-expressions/suites/InMem/StringContains.yql new file mode 100644 index 0000000000..9d5e42e3cf --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/StringContains.yql @@ -0,0 +1,19 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let world (Write! world res_sink (Key) (StringContains (Utf8 '12345) (String '"")) '('('type)))) +(let world (Write! world res_sink (Key) (StringContains (Just (String '12345)) (String '346)) '('('type)))) +(let world (Write! world res_sink (Key) (StringContains (String '12345) (Just (String '012345))) '('('type)))) +(let world (Write! world res_sink (Key) (StringContains (Just (String '567)) (Just (Utf8 '67))) '('('type)))) +(let world (Write! world res_sink (Key) (StringContains (Utf8 'abcad) (String 'bc)) '('('type)))) +(let world (Write! world res_sink (Key) (StringContains (Utf8 'xyz) (Utf8 'xyz)) '('('type)))) +(let world (Write! world res_sink (Key) (StringContains (Utf8 'one) (Null)) '('('type)))) +(let world (Write! world res_sink (Key) (StringContains (Null) (Utf8 'two)) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/StringWith.yql b/yql/essentials/tests/s-expressions/suites/InMem/StringWith.yql new file mode 100644 index 0000000000..c6b3b3de2d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/StringWith.yql @@ -0,0 +1,28 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let world (Write! world res_sink (Key) (StartsWith (Utf8 '12345) (String '"")) '('('type)))) +(let world (Write! world res_sink (Key) (StartsWith (Just (String '12345)) (String '124)) '('('type)))) +(let world (Write! world res_sink (Key) (StartsWith (String '12345) (Just (String '123456))) '('('type)))) +(let world (Write! world res_sink (Key) (StartsWith (Just (String '567)) (Just (Utf8 '56))) '('('type)))) +(let world (Write! world res_sink (Key) (StartsWith (Utf8 'abcad) (String 'ab)) '('('type)))) +(let world (Write! world res_sink (Key) (StartsWith (Utf8 'xyz) (Utf8 'xyz)) '('('type)))) +(let world (Write! world res_sink (Key) (StartsWith (Utf8 'one) (Null)) '('('type)))) +(let world (Write! world res_sink (Key) (StartsWith (Null) (Utf8 'two)) '('('type)))) + +(let world (Write! world res_sink (Key) (EndsWith (Utf8 '12345) (String '"")) '('('type)))) +(let world (Write! world res_sink (Key) (EndsWith (Just (String '12345)) (String '346)) '('('type)))) +(let world (Write! world res_sink (Key) (EndsWith (String '12345) (Just (String '012345))) '('('type)))) +(let world (Write! world res_sink (Key) (EndsWith (Just (String '567)) (Just (Utf8 '67))) '('('type)))) +(let world (Write! world res_sink (Key) (EndsWith (Utf8 'abcad) (String 'ad)) '('('type)))) +(let world (Write! world res_sink (Key) (EndsWith (Utf8 'xyz) (Utf8 'xyz)) '('('type)))) +(let world (Write! world res_sink (Key) (EndsWith (Utf8 'one) (Null)) '('('type)))) +(let world (Write! world res_sink (Key) (EndsWith (Null) (Utf8 'two)) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Switch.yql b/yql/essentials/tests/s-expressions/suites/InMem/Switch.yql new file mode 100644 index 0000000000..9c17ddd66e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Switch.yql @@ -0,0 +1,34 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList (String 'aaa) (String 'bbb) (String 'ccc))) +(let id (lambda '(x) x)) +# id +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator list (DependsOn (String 'A))) '1 '('0) id)) '('('type)))) +# clone +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator list (DependsOn (String 'B))) '1 '('0) id '('0) id)) '('('type)))) +# separate +(let tupleType (TupleType (DataType 'String) (DataType 'String))) +(let vt (VariantType tupleType)) +(let vlist (AsList (Variant (String 'aaa) '0 vt) (Variant (String 'bbb) '1 vt) (Variant (String 'ccc) '0 vt))) +(let handlerSplit1 (lambda '(x) (Map x (lambda '(s) (Concat (String '"#0: ") s))))) +(let handlerSplit2 (lambda '(x) (Map x (lambda '(s) (Concat (String '"#1: ") s))))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'D))) '1 '('1) handlerSplit2 '('0) handlerSplit1)) '('('type)))) +# reunion +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'E))) '1 '('0 '1) id)) '('('type)))) +# reunion and parts +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'F))) '1 '('0 '1) id '('1) handlerSplit2 '('0) handlerSplit1)) '('('type)))) +# multiple outputs +(let twice (lambda '(x) (FlatMap x (lambda '(s) (AsList + (Variant (Concat (String '"#0: ") s) '0 vt) + (Variant (Concat (String '"#1: ") s) '1 vt) + ))))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator list (DependsOn (String 'G))) '1 '('0) twice)) '('('type)))) +# split and multiple outputs +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator list (DependsOn (String 'H))) '1 '('0) twice '('0) twice)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/TimezoneIdName.yql b/yql/essentials/tests/s-expressions/suites/InMem/TimezoneIdName.yql new file mode 100644 index 0000000000..4ad7ec02d1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/TimezoneIdName.yql @@ -0,0 +1,10 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (TimezoneName (TimezoneId (String '"Europe/Moscow"))) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/ToBytes.yql b/yql/essentials/tests/s-expressions/suites/InMem/ToBytes.yql new file mode 100644 index 0000000000..aa9ed74d8f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/ToBytes.yql @@ -0,0 +1,82 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let test (lambda '(world data dataType) (block '( + (let world (Write! world res_sink (Key) (ToBytes data) '('('type)))) + (let world (Write! world res_sink (Key) (FromBytes (ToBytes data) dataType) '('('type)))) + (return world) +)))) + +(let testEmpty (lambda '(world dataType) (block '( + (let n (ToBytes (Nothing (OptionalType (DataType dataType))))) + (let world (Write! world res_sink (Key) n '('('type)))) + (let world (Write! world res_sink (Key) (FromBytes n dataType) '('('type)))) + (return world) +)))) + +(let testFail (lambda '(world bytes dataType) (block '( + (let world (Write! world res_sink (Key) (Exists (FromBytes bytes dataType)) '('('type)))) + (return world) +)))) + +(let world (Apply test world (Uint8 '7) 'Uint8)) +(let world (Apply test world (Bool 'True) 'Bool)) +(let world (Apply test world (Bool 'False) 'Bool)) +(let world (Apply test world (Int32 'x"abcdef12") 'Int32)) +(let world (Apply test world (Int64 'x"71717171abcdef12") 'Int64)) +(let world (Apply test world (Uint32 'x"abcdef12") 'Uint32)) +(let world (Apply test world (Uint64 'x"ddddddddabcdef12") 'Uint64)) +(let world (Apply test world (Float '2) 'Float)) +(let world (Apply test world (Double '2) 'Double)) +(let world (Apply test world (String '"abc") 'String)) +(let world (Apply test world (Utf8 '"яндекс") 'Utf8)) +(let world (Apply test world (Yson '"[1;2]") 'Yson)) +(let world (Apply test world (Json '@@{"id":1}@@) 'Json)) + +(let world (Apply test world (Just (Uint8 '7)) 'Uint8)) +(let world (Apply test world (Just (Bool 'True)) 'Bool)) +(let world (Apply test world (Just (Bool 'False)) 'Bool)) +(let world (Apply test world (Just (Int32 'x"abcdef12")) 'Int32)) +(let world (Apply test world (Just (Int64 'x"71717171abcdef12")) 'Int64)) +(let world (Apply test world (Just (Uint32 'x"abcdef12")) 'Uint32)) +(let world (Apply test world (Just (Uint64 'x"ddddddddabcdef12")) 'Uint64)) +(let world (Apply test world (Just (Float '2)) 'Float)) +(let world (Apply test world (Just (Double '2)) 'Double)) +(let world (Apply test world (Just (String '"abc")) 'String)) +(let world (Apply test world (Just (Utf8 '"яндекс")) 'Utf8)) +(let world (Apply test world (Just (Yson '"[1;2]")) 'Yson)) +(let world (Apply test world (Just (Json '@@{"id":1}@@)) 'Json)) + +(let world (Apply testEmpty world 'Uint8)) +(let world (Apply testEmpty world 'Bool)) +(let world (Apply testEmpty world 'Int32)) +(let world (Apply testEmpty world 'Int64)) +(let world (Apply testEmpty world 'Uint32)) +(let world (Apply testEmpty world 'Uint64)) +(let world (Apply testEmpty world 'Float)) +(let world (Apply testEmpty world 'Double)) +(let world (Apply testEmpty world 'String)) +(let world (Apply testEmpty world 'Utf8)) +(let world (Apply testEmpty world 'Yson)) +(let world (Apply testEmpty world 'Json)) + +(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Uint8)) +(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Bool)) +(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Int32)) +(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Int64)) +(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Uint32)) +(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Uint64)) +(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Float)) +(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'Double)) +(let world (Apply testFail world (Nothing (OptionalType (DataType 'String))) 'String)) +(let world (Apply testFail world (String 'x"ffff") 'Utf8)) +(let world (Apply testFail world (String '"][") 'Yson)) +(let world (Apply testFail world (String '"}{") 'Json)) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/ToDict.yql b/yql/essentials/tests/s-expressions/suites/InMem/ToDict.yql new file mode 100644 index 0000000000..c66f952fa6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/ToDict.yql @@ -0,0 +1,35 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Uint32 '1) (String 'a)) +'((Uint32 '2) (String 'b)) +'((Uint32 '1) (String 'c)))) + +(let macro (lambda '(world name flags) (block '( + +(let dict (ToDict list (lambda '(x) (Nth x '0)) (lambda '(x) (Nth x '1)) flags)) + +(let world (Write! world res_sink (Key) (String name) '())) +(let world (Write! world res_sink (Key) dict '('('type)))) +(let world (Write! world res_sink (Key) (Contains dict (Uint32 '1)) '())) +(let world (Write! world res_sink (Key) (Contains dict (Uint32 '2)) '())) +(let world (Write! world res_sink (Key) (Contains dict (Uint32 '3)) '())) +(let world (Write! world res_sink (Key) (Lookup dict (Uint32 '1)) '())) +(let world (Write! world res_sink (Key) (Lookup dict (Uint32 '2)) '())) +(let world (Write! world res_sink (Key) (Lookup dict (Uint32 '3)) '())) + +(return world) +)))) + +(let world (Apply macro world 'Sorted/One '('Sorted 'One))) +(let world (Apply macro world 'Sorted/Many '('Sorted 'Many))) +(let world (Apply macro world 'Hashed/One '('Hashed 'One))) +(let world (Apply macro world 'Hashed/Many '('Hashed 'Many))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/ToDictOpt.yql b/yql/essentials/tests/s-expressions/suites/InMem/ToDictOpt.yql new file mode 100644 index 0000000000..0a2fab711e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/ToDictOpt.yql @@ -0,0 +1,39 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Just (Uint32 '1)) (String 'a)) +'((Just (Uint32 '2)) (String 'b)) +'((Just (Uint32 '1)) (String 'c)) +'((Nothing (OptionalType (DataType 'Uint32))) (String 'd)) +)) + +(let macro (lambda '(world name flags) (block '( + +(let dict (ToDict list (lambda '(x) (Nth x '0)) (lambda '(x) (Nth x '1)) flags)) + +(let world (Write! world res_sink (Key) (String name) '())) +(let world (Write! world res_sink (Key) dict '('('type)))) +(let world (Write! world res_sink (Key) (Contains dict (Just (Uint32 '1))) '())) +(let world (Write! world res_sink (Key) (Contains dict (Just (Uint32 '2))) '())) +(let world (Write! world res_sink (Key) (Contains dict (Just (Uint32 '3))) '())) +(let world (Write! world res_sink (Key) (Contains dict (Nothing (OptionalType (DataType 'Uint32)))) '())) +(let world (Write! world res_sink (Key) (Lookup dict (Just (Uint32 '1))) '())) +(let world (Write! world res_sink (Key) (Lookup dict (Just (Uint32 '2))) '())) +(let world (Write! world res_sink (Key) (Lookup dict (Just (Uint32 '3))) '())) +(let world (Write! world res_sink (Key) (Lookup dict (Nothing (OptionalType (DataType 'Uint32)))) '())) + +(return world) +)))) + +(let world (Apply macro world 'Sorted/One '('Sorted 'One))) +(let world (Apply macro world 'Sorted/Many '('Sorted 'Many))) +(let world (Apply macro world 'Hashed/One '('Hashed 'One))) +(let world (Apply macro world 'Hashed/Many '('Hashed 'Many))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/ToDictOptTuple.yql b/yql/essentials/tests/s-expressions/suites/InMem/ToDictOptTuple.yql new file mode 100644 index 0000000000..a76f483330 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/ToDictOptTuple.yql @@ -0,0 +1,41 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'('((Just (Uint32 '1)) (String 'a)) (String 'eee)) +'('((Just (Uint32 '2)) (String 'b)) (String 'fff)) +'('((Just (Uint32 '1)) (String 'a)) (String 'ggg)) +'('((Nothing (OptionalType (DataType 'Uint32))) (String 'd)) (String 'hhh)) +)) + +(let macro (lambda '(world name flags) (block '( + +(let dict (ToDict list (lambda '(x) (Nth x '0)) (lambda '(x) (Nth x '1)) flags)) + +(let world (Write! world res_sink (Key) (String name) '())) +(let world (Write! world res_sink (Key) dict '('('type)))) +(let world (Write! world res_sink (Key) (Contains dict '((Just (Uint32 '1)) (String 'a))) '())) +(let world (Write! world res_sink (Key) (Contains dict '((Just (Uint32 '2)) (String 'b))) '())) +(let world (Write! world res_sink (Key) (Contains dict '((Just (Uint32 '1)) (String 'c))) '())) +(let world (Write! world res_sink (Key) (Contains dict '((Just (Uint32 '2)) (String 'a))) '())) +(let world (Write! world res_sink (Key) (Contains dict '((Nothing (OptionalType (DataType 'Uint32))) (String 'd))) '())) +(let world (Write! world res_sink (Key) (Lookup dict '((Just (Uint32 '1)) (String 'a))) '())) +(let world (Write! world res_sink (Key) (Lookup dict '((Just (Uint32 '2)) (String 'b))) '())) +(let world (Write! world res_sink (Key) (Lookup dict '((Just (Uint32 '1)) (String 'c))) '())) +(let world (Write! world res_sink (Key) (Lookup dict '((Just (Uint32 '2)) (String 'a))) '())) +(let world (Write! world res_sink (Key) (Lookup dict '((Nothing (OptionalType (DataType 'Uint32))) (String 'd))) '())) + +(return world) +)))) + +(let world (Apply macro world 'Sorted/One '('Sorted 'One))) +(let world (Apply macro world 'Sorted/Many '('Sorted 'Many))) +(let world (Apply macro world 'Hashed/One '('Hashed 'One))) +(let world (Apply macro world 'Hashed/Many '('Hashed 'Many))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/ToDictOverOptList.yql b/yql/essentials/tests/s-expressions/suites/InMem/ToDictOverOptList.yql new file mode 100644 index 0000000000..bbb90c5408 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/ToDictOverOptList.yql @@ -0,0 +1,35 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList +'((Uint32 '1) (String 'a)) +'((Uint32 '2) (String 'b)) +'((Uint32 '1) (String 'c)))) + +(let macro (lambda '(world name flags) (block '( + +(let dict (ToDict (Just list) (lambda '(x) (Nth x '0)) (lambda '(x) (Nth x '1)) flags)) + +(let world (Write! world res_sink (Key) (String name) '())) +(let world (Write! world res_sink (Key) dict '('('type)))) +(let world (Write! world res_sink (Key) (Contains dict (Uint32 '1)) '())) +(let world (Write! world res_sink (Key) (Contains dict (Uint32 '2)) '())) +(let world (Write! world res_sink (Key) (Contains dict (Uint32 '3)) '())) +(let world (Write! world res_sink (Key) (Lookup dict (Uint32 '1)) '())) +(let world (Write! world res_sink (Key) (Lookup dict (Uint32 '2)) '())) +(let world (Write! world res_sink (Key) (Lookup dict (Uint32 '3)) '())) + +(return world) +)))) + +(let world (Apply macro world 'Sorted/One '('Sorted 'One))) +(let world (Apply macro world 'Sorted/Many '('Sorted 'Many))) +(let world (Apply macro world 'Hashed/One '('Hashed 'One))) +(let world (Apply macro world 'Hashed/Many '('Hashed 'Many))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/ToOptional.yql b/yql/essentials/tests/s-expressions/suites/InMem/ToOptional.yql new file mode 100644 index 0000000000..b9e3d077ae --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/ToOptional.yql @@ -0,0 +1,29 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let test (lambda '(world data) (block '( + (let world (Write! world res_sink (Key) (ToOptional data) '('('type)))) + (return world) +)))) + +(let listType (ListType (DataType 'String))) +(let callableType (CallableType '() '(listType))) + +(let callable1 (Callable callableType (lambda '() (List listType)))) +(let callable2 (Callable callableType (lambda '() (List listType (String 'A))))) +(let callable3 (Callable callableType (lambda '() (List listType (String 'A) (String 'B))))) + +(let world (Apply test world (List listType))) +(let world (Apply test world (List listType (String 'a)))) +(let world (Apply test world (List listType (String 'a) (String 'b)))) + +(let world (Apply test world (Apply callable1))) +(let world (Apply test world (Apply callable2))) +(let world (Apply test world (Apply callable3))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Top.yql b/yql/essentials/tests/s-expressions/suites/InMem/Top.yql new file mode 100644 index 0000000000..0e8ab78955 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Top.yql @@ -0,0 +1,27 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList + (AsStruct '('a (Uint32 '4)) '('b (String 'c))) + (AsStruct '('a (Uint32 '1)) '('b (String 'd))) + (AsStruct '('a (Uint32 '3)) '('b (String 'b))) + (AsStruct '('a (Uint32 '2)) '('b (String 'a))) + (AsStruct '('a (Uint32 '5)) '('b (String 'y))) + (AsStruct '('a (Uint32 '1)) '('b (String 'z))) +)) +(let world (Write! world res_sink (Key) (Top list (Uint64 '3) (Bool 'True) (lambda '(item) (Member item 'b))) '('('type)))) +(let world (Write! world res_sink (Key) (Top list (Uint64 '3) (Bool 'False) (lambda '(item) (Member item 'b))) '('('type)))) +(let world (Write! world res_sink (Key) (Top list (Uint64 '3) '((Bool 'True) (Bool 'True)) (lambda '(item) '((Member item 'a) (Member item 'b)))) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Top (Iterator list (DependsOn (String 'a))) (Uint64 '3) (Bool 'True) (lambda '(item) (Member item 'b)))) '('('type)))) + +(let world (Write! world res_sink (Key) (TopSort list (Uint64 '3) (Bool 'True) (lambda '(item) (Member item 'b))) '('('type)))) +(let world (Write! world res_sink (Key) (TopSort list (Uint64 '3) (Bool 'False) (lambda '(item) (Member item 'b))) '('('type)))) +(let world (Write! world res_sink (Key) (TopSort list (Uint64 '3) '((Bool 'True) (Bool 'True)) (lambda '(item) '((Member item 'a) (Member item 'b)))) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (TopSort (Iterator list (DependsOn (String 'b))) (Uint64 '3) (Bool 'True) (lambda '(item) (Member item 'b)))) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/VariantItem.yql b/yql/essentials/tests/s-expressions/suites/InMem/VariantItem.yql new file mode 100644 index 0000000000..5b2d4c3930 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/VariantItem.yql @@ -0,0 +1,50 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import id_module '"/lib/yql/id.yql") +(let id (bind id_module 'id)) + +(let res_sink (DataSink 'result)) +(let vt (VariantType (TupleType (DataType 'Int32) (DataType 'Int32)))) +(let v1 (Variant (Int32 '34) '0 vt)) +(let v2 (Variant (Int32 '42) '1 vt)) +(let jv1 (Just v1)) +(let jv2 (Just v2)) +(let n (Nothing (TypeOf jv1))) + +(let world (Write! world res_sink (Key) (VariantItem v1) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem v2) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem jv1) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem jv2) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem n) '('('type)))) + +(let world (Write! world res_sink (Key) (VariantItem (Apply id v1)) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem (Apply id v2)) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem (Apply id jv1)) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem (Apply id jv2)) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem (Apply id n)) '('('type)))) + +(let vt (VariantType (StructType '('a (DataType 'Int32)) '('b (DataType 'Int32))))) +(let v1 (Variant (Int32 '34) 'a vt)) +(let v2 (Variant (Int32 '42) 'b vt)) +(let jv1 (Just v1)) +(let jv2 (Just v2)) +(let n (Nothing (TypeOf jv1))) + +(let world (Write! world res_sink (Key) (VariantItem v1) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem v2) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem jv1) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem jv2) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem n) '('('type)))) + +(let world (Write! world res_sink (Key) (VariantItem (Apply id v1)) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem (Apply id v2)) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem (Apply id jv1)) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem (Apply id jv2)) '('('type)))) +(let world (Write! world res_sink (Key) (VariantItem (Apply id n)) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Visit.cfg b/yql/essentials/tests/s-expressions/suites/InMem/Visit.cfg new file mode 100644 index 0000000000..e41deb15c5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Visit.cfg @@ -0,0 +1,2 @@ +res result.txt +mount ..\mounts.txt diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Visit.yql b/yql/essentials/tests/s-expressions/suites/InMem/Visit.yql new file mode 100644 index 0000000000..0616a5100c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Visit.yql @@ -0,0 +1,59 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import id_module '"/lib/yql/id.yql") +(let id (bind id_module 'id)) + +#comment +(let res_sink (DataSink 'result)) +(let vt (VariantType (TupleType (DataType 'Int32) (DataType 'String)))) +(let v1 (Variant (Int32 '34) '0 vt)) +(let v2 (Variant (String 'qwe) '1 vt)) + +(let handler1 (lambda '(x) (Concat (String '"handler1:") (ToString (+ (Uint32 '100) x))))) +(let handler2 (lambda '(x) (Concat (String '"handler2:") x))) + +(let world (Write! world res_sink (Key) (Visit v1 '0 handler1 '1 handler2) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 '0 handler1 '1 handler2) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v1 '0 handler1 (String 'q1)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v1 '1 handler2 (String 'q2)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 '0 handler1 (String 'q3)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 '1 handler2 (String 'q4)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v1 (String 'q5)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 (String 'q6)) '('('type)))) + +(let world (Write! world res_sink (Key) (Visit (Apply id v1) '0 handler1 '1 handler2) '('('type)))) +(let world (Write! world res_sink (Key) (Visit (Apply id v2) '1 handler2 '0 handler1) '('('type)))) +(let world (Write! world res_sink (Key) (Visit (Apply id v1) '0 handler1 (String 'q1)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit (Apply id v1) '1 handler2 (String 'q2)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit (Apply id v2) '0 handler1 (String 'q3)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit (Apply id v2) '1 handler2 (String 'q4)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit (Apply id v1) (String 'q5)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit (Apply id v2) (String 'q6)) '('('type)))) + +(let vt (VariantType (StructType '('a (DataType 'Int32)) '('b (DataType 'String))))) +(let v1 (Variant (Int32 '34) 'a vt)) +(let v2 (Variant (String 'qwe) 'b vt)) + +(let world (Write! world res_sink (Key) (Visit v1 'a handler1 'b handler2) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 'b handler2 'a handler1) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v1 'a handler1 (String 'r1)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v1 'b handler2 (String 'r2)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 'a handler1 (String 'r3)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 'b handler2 (String 'r4)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v1 (String 'r5)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 (String 'r6)) '('('type)))) + +(let world (Write! world res_sink (Key) (Visit (Apply id v1) 'a handler1 'b handler2) '('('type)))) +(let world (Write! world res_sink (Key) (Visit (Apply id v2) 'a handler1 'b handler2) '('('type)))) +(let world (Write! world res_sink (Key) (Visit (Apply id v1) 'a handler1 (String 'r1)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit (Apply id v1) 'b handler2 (String 'r2)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit (Apply id v2) 'a handler1 (String 'r3)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit (Apply id v2) 'b handler2 (String 'r4)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit (Apply id v1) (String 'r5)) '('('type)))) +(let world (Write! world res_sink (Key) (Visit (Apply id v2) (String 'r6)) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Way.cfg b/yql/essentials/tests/s-expressions/suites/InMem/Way.cfg new file mode 100644 index 0000000000..e41deb15c5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Way.cfg @@ -0,0 +1,2 @@ +res result.txt +mount ..\mounts.txt diff --git a/yql/essentials/tests/s-expressions/suites/InMem/Way.yql b/yql/essentials/tests/s-expressions/suites/InMem/Way.yql new file mode 100644 index 0000000000..a1e2043ec3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/Way.yql @@ -0,0 +1,50 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import id_module '"/lib/yql/id.yql") +(let id (bind id_module 'id)) + +(let res_sink (DataSink 'result)) +(let vt (VariantType (TupleType (DataType 'Int32) (DataType 'String)))) +(let v1 (Variant (Int32 '34) '0 vt)) +(let v2 (Variant (String 'qwe) '1 vt)) +(let jv1 (Just v1)) +(let jv2 (Just v2)) +(let n (Nothing (TypeOf jv1))) + +(let world (Write! world res_sink (Key) (Way v1) '('('type)))) +(let world (Write! world res_sink (Key) (Way v2) '('('type)))) +(let world (Write! world res_sink (Key) (Way jv1) '('('type)))) +(let world (Write! world res_sink (Key) (Way jv2) '('('type)))) +(let world (Write! world res_sink (Key) (Way n) '('('type)))) + +(let world (Write! world res_sink (Key) (Way (Apply id v1)) '('('type)))) +(let world (Write! world res_sink (Key) (Way (Apply id v2)) '('('type)))) +(let world (Write! world res_sink (Key) (Way (Apply id jv1)) '('('type)))) +(let world (Write! world res_sink (Key) (Way (Apply id jv2)) '('('type)))) +(let world (Write! world res_sink (Key) (Way (Apply id n)) '('('type)))) + +(let vt (VariantType (StructType '('a (DataType 'Int32)) '('b (DataType 'String))))) +(let v1 (Variant (Int32 '34) 'a vt)) +(let v2 (Variant (String 'qwe) 'b vt)) +(let jv1 (Just v1)) +(let jv2 (Just v2)) +(let n (Nothing (TypeOf jv1))) + +(let world (Write! world res_sink (Key) (Way v1) '('('type)))) +(let world (Write! world res_sink (Key) (Way v2) '('('type)))) +(let world (Write! world res_sink (Key) (Way jv1) '('('type)))) +(let world (Write! world res_sink (Key) (Way jv2) '('('type)))) +(let world (Write! world res_sink (Key) (Way n) '('('type)))) + +(let world (Write! world res_sink (Key) (Way (Apply id v1)) '('('type)))) +(let world (Write! world res_sink (Key) (Way (Apply id v2)) '('('type)))) +(let world (Write! world res_sink (Key) (Way (Apply id jv1)) '('('type)))) +(let world (Write! world res_sink (Key) (Way (Apply id jv2)) '('('type)))) +(let world (Write! world res_sink (Key) (Way (Apply id n)) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/InMem/default.cfg b/yql/essentials/tests/s-expressions/suites/InMem/default.cfg new file mode 100644 index 0000000000..00dec6c3f8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/InMem/default.cfg @@ -0,0 +1 @@ +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCore.yql b/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCore.yql new file mode 100644 index 0000000000..8bf51c75d5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCore.yql @@ -0,0 +1,53 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let emptyInt32 (Nothing (OptionalType (DataType 'Int32)))) +(let emptyString (Nothing (OptionalType (DataType 'String)))) +(let list1 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'B))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let list2 (AsList + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'X))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'Y))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let list12 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'X))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'B))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'Y))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let writeRes (lambda '(world list) (block '( +(let joinInner (CommonJoinCore (Iterator list (DependsOn (String 'Inner))) 'Inner '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinLeft (CommonJoinCore (Iterator list (DependsOn (String 'Left))) 'Left '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinRight (CommonJoinCore (Iterator list (DependsOn (String 'Right))) 'Right '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinFull (CommonJoinCore (Iterator list (DependsOn (String 'Full))) 'Full '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinLeftOnly (CommonJoinCore (Iterator list (DependsOn (String 'LeftOnly))) 'LeftOnly '('key1 'value1) '() '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinLeftSemi (CommonJoinCore (Iterator list (DependsOn (String 'LeftSemi))) 'LeftSemi '('key1 'value1) '() '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinRightOnly (CommonJoinCore (Iterator list (DependsOn (String 'RightOnly))) 'RightOnly '() '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinRightSemi (CommonJoinCore (Iterator list (DependsOn (String 'RightSemi))) 'RightSemi '() '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinExclusion (CommonJoinCore (Iterator list (DependsOn (String 'Exclusion))) 'Exclusion '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinCross (CommonJoinCore (Iterator list (DependsOn (String 'Cross))) 'Cross '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Collect joinInner) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeft) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRight) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinFull) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRightOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRightSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinExclusion) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinCross) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)))) + +(let world (Apply writeRes world list1)) +(let world (Apply writeRes world list2)) +(let world (Apply writeRes world list12)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCoreSortedLeft.yql b/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCoreSortedLeft.yql new file mode 100644 index 0000000000..3d7aacb4dc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCoreSortedLeft.yql @@ -0,0 +1,54 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let emptyInt32 (Nothing (OptionalType (DataType 'Int32)))) +(let emptyString (Nothing (OptionalType (DataType 'String)))) + +(let list1 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'B))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let list2 (AsList + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'X))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'Y))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let list12 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'X))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'B))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'Y))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let writeRes (lambda '(world list) (block '( +(let joinInner (CommonJoinCore (Iterator list (DependsOn (String 'Inner))) 'Inner '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinLeft (CommonJoinCore (Iterator list (DependsOn (String 'Left))) 'Left '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinRight (CommonJoinCore (Iterator list (DependsOn (String 'Right))) 'Right '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinFull (CommonJoinCore (Iterator list (DependsOn (String 'Full))) 'Full '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinLeftOnly (CommonJoinCore (Iterator list (DependsOn (String 'LeftOnly))) 'LeftOnly '('key1 'value1) '() '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinLeftSemi (CommonJoinCore (Iterator list (DependsOn (String 'LeftSemi))) 'LeftSemi '('key1 'value1) '() '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinRightOnly (CommonJoinCore (Iterator list (DependsOn (String 'RightOnly))) 'RightOnly '() '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinRightSemi (CommonJoinCore (Iterator list (DependsOn (String 'RightSemi))) 'RightSemi '() '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinExclusion (CommonJoinCore (Iterator list (DependsOn (String 'Exclusion))) 'Exclusion '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinCross (CommonJoinCore (Iterator list (DependsOn (String 'Cross))) 'Cross '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Collect joinInner) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeft) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRight) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinFull) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRightOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRightSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinExclusion) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinCross) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)))) + +(let world (Apply writeRes world list1)) +(let world (Apply writeRes world list2)) +(let world (Apply writeRes world list12)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCoreSortedLeft_Flow.yql b/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCoreSortedLeft_Flow.yql new file mode 100644 index 0000000000..5d4048a4ab --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCoreSortedLeft_Flow.yql @@ -0,0 +1,54 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let emptyInt32 (Nothing (OptionalType (DataType 'Int32)))) +(let emptyString (Nothing (OptionalType (DataType 'String)))) + +(let list1 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'B))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let list2 (AsList + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'X))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'Y))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let list12 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'X))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'B))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'Y))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let writeRes (lambda '(world list) (block '( +(let joinInner (CommonJoinCore (ToFlow list) 'Inner '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinLeft (CommonJoinCore (ToFlow list) 'Left '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinRight (CommonJoinCore (ToFlow list) 'Right '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinFull (CommonJoinCore (ToFlow list) 'Full '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinLeftOnly (CommonJoinCore (ToFlow list) 'LeftOnly '('key1 'value1) '() '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinLeftSemi (CommonJoinCore (ToFlow list) 'LeftSemi '('key1 'value1) '() '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinRightOnly (CommonJoinCore (ToFlow list) 'RightOnly '() '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinRightSemi (CommonJoinCore (ToFlow list) 'RightSemi '() '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinExclusion (CommonJoinCore (ToFlow list) 'Exclusion '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) +(let joinCross (CommonJoinCore (ToFlow list) 'Cross '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'left)) '_yql_table_index)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Collect joinInner) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeft) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRight) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinFull) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRightOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRightSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinExclusion) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinCross) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)))) + +(let world (Apply writeRes world list1)) +(let world (Apply writeRes world list2)) +(let world (Apply writeRes world list12)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCoreSortedRight.yql b/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCoreSortedRight.yql new file mode 100644 index 0000000000..64425dd37b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCoreSortedRight.yql @@ -0,0 +1,54 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let emptyInt32 (Nothing (OptionalType (DataType 'Int32)))) +(let emptyString (Nothing (OptionalType (DataType 'String)))) + +(let list1 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'B))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let list2 (AsList + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'X))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'Y))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let list12 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'X))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'B))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'Y))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let writeRes (lambda '(world list) (block '( +(let joinInner (CommonJoinCore (Iterator list (DependsOn (String 'Inner))) 'Inner '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinLeft (CommonJoinCore (Iterator list (DependsOn (String 'Left))) 'Left '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinRight (CommonJoinCore (Iterator list (DependsOn (String 'Right))) 'Right '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinFull (CommonJoinCore (Iterator list (DependsOn (String 'Full))) 'Full '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinLeftOnly (CommonJoinCore (Iterator list (DependsOn (String 'LeftOnly))) 'LeftOnly '('key1 'value1) '() '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinLeftSemi (CommonJoinCore (Iterator list (DependsOn (String 'LeftSemi))) 'LeftSemi '('key1 'value1) '() '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinRightOnly (CommonJoinCore (Iterator list (DependsOn (String 'RightOnly))) 'RightOnly '() '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinRightSemi (CommonJoinCore (Iterator list (DependsOn (String 'RightSemi))) 'RightSemi '() '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinExclusion (CommonJoinCore (Iterator list (DependsOn (String 'Exclusion))) 'Exclusion '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinCross (CommonJoinCore (Iterator list (DependsOn (String 'Cross))) 'Cross '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Collect joinInner) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeft) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRight) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinFull) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRightOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRightSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinExclusion) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinCross) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)))) + +(let world (Apply writeRes world list1)) +(let world (Apply writeRes world list2)) +(let world (Apply writeRes world list12)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCoreSortedRight_Flow.yql b/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCoreSortedRight_Flow.yql new file mode 100644 index 0000000000..a3d9b47ecf --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCoreSortedRight_Flow.yql @@ -0,0 +1,54 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let emptyInt32 (Nothing (OptionalType (DataType 'Int32)))) +(let emptyString (Nothing (OptionalType (DataType 'String)))) + +(let list1 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'B))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let list2 (AsList + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'X))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'Y))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let list12 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'X))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'B))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'Y))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let writeRes (lambda '(world list) (block '( +(let joinInner (CommonJoinCore (ToFlow list) 'Inner '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinLeft (CommonJoinCore (ToFlow list) 'Left '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinRight (CommonJoinCore (ToFlow list) 'Right '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinFull (CommonJoinCore (ToFlow list) 'Full '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinLeftOnly (CommonJoinCore (ToFlow list) 'LeftOnly '('key1 'value1) '() '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinLeftSemi (CommonJoinCore (ToFlow list) 'LeftSemi '('key1 'value1) '() '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinRightOnly (CommonJoinCore (ToFlow list) 'RightOnly '() '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinRightSemi (CommonJoinCore (ToFlow list) 'RightSemi '() '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinExclusion (CommonJoinCore (ToFlow list) 'Exclusion '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) +(let joinCross (CommonJoinCore (ToFlow list) 'Cross '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '('('sorted 'right)) '_yql_table_index)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Collect joinInner) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeft) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRight) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinFull) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRightOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRightSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinExclusion) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinCross) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)))) + +(let world (Apply writeRes world list1)) +(let world (Apply writeRes world list2)) +(let world (Apply writeRes world list12)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCore_Flow.yql b/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCore_Flow.yql new file mode 100644 index 0000000000..10b5abc6e7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCore_Flow.yql @@ -0,0 +1,53 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let emptyInt32 (Nothing (OptionalType (DataType 'Int32)))) +(let emptyString (Nothing (OptionalType (DataType 'String)))) +(let list1 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'B))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let list2 (AsList + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'X))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'Y))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let list12 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'A))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'X))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (Just (String 'B))) '('key2 emptyInt32) '('value2 emptyString) '('_yql_table_index (Uint32 '0)) '('_yql_join_column_0 (Just (Int32 '1)))) + (AsStruct '('key1 emptyInt32) '('value1 emptyString) '('key2 (Just (Int32 '1))) '('value2 (Just (String 'Y))) '('_yql_table_index (Uint32 '1)) '('_yql_join_column_0 (Just (Int32 '1)))) +)) + +(let writeRes (lambda '(world list) (block '( +(let joinInner (CommonJoinCore (ToFlow list) 'Inner '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinLeft (CommonJoinCore (ToFlow list) 'Left '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinRight (CommonJoinCore (ToFlow list) 'Right '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinFull (CommonJoinCore (ToFlow list) 'Full '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinLeftOnly (CommonJoinCore (ToFlow list) 'LeftOnly '('key1 'value1) '() '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinLeftSemi (CommonJoinCore (ToFlow list) 'LeftSemi '('key1 'value1) '() '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinRightOnly (CommonJoinCore (ToFlow list) 'RightOnly '() '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinRightSemi (CommonJoinCore (ToFlow list) 'RightSemi '() '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinExclusion (CommonJoinCore (ToFlow list) 'Exclusion '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) +(let joinCross (CommonJoinCore (ToFlow list) 'Cross '('key1 'value1) '('key2 'value2) '() '('_yql_join_column_0) '() '_yql_table_index)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Collect joinInner) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeft) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRight) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinFull) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRightOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRightSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinExclusion) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinCross) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)))) + +(let world (Apply writeRes world list1)) +(let world (Apply writeRes world list2)) +(let world (Apply writeRes world list12)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCore_FlowOfTuples.yql b/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCore_FlowOfTuples.yql new file mode 100644 index 0000000000..bb15c6f634 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/CommonJoinCore_FlowOfTuples.yql @@ -0,0 +1,54 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let emptyInt32 (Nothing (OptionalType (DataType 'Int32)))) +(let emptyString (Nothing (OptionalType (DataType 'String)))) +(let list1 (AsList + '((Just (Int32 '1)) (Just (String 'A)) emptyInt32 emptyString (Uint32 '0) (Just (Int32 '1))) + '((Just (Int32 '1)) (Just (String 'B)) emptyInt32 emptyString (Uint32 '0) (Just (Int32 '1))) +)) + +(let list2 (AsList + '(emptyInt32 emptyString (Just (Int32 '1)) (Just (String 'X)) (Uint32 '1) (Just (Int32 '1))) + '(emptyInt32 emptyString (Just (Int32 '1)) (Just (String 'Y)) (Uint32 '1) (Just (Int32 '1))) +)) + +(let list12 (AsList + '((Just (Int32 '1)) (Just (String 'A)) emptyInt32 emptyString (Uint32 '0) (Just (Int32 '1))) + '(emptyInt32 emptyString (Just (Int32 '1)) (Just (String 'X)) (Uint32 '1) (Just (Int32 '1))) + '((Just (Int32 '1)) (Just (String 'B)) emptyInt32 emptyString (Uint32 '0) (Just (Int32 '1))) + '(emptyInt32 emptyString (Just (Int32 '1)) (Just (String 'Y)) (Uint32 '1) (Just (Int32 '1))) +)) + +(let writeRes (lambda '(world list) (block '( +(let joinInner (CommonJoinCore (ToFlow list) 'Inner '('0 '1) '('2 '3) '() '('5) '() '4)) +(let joinLeft (CommonJoinCore (ToFlow list) 'Left '('0 '1) '('2 '3) '() '('5) '() '4)) +(let joinRight (CommonJoinCore (ToFlow list) 'Right '('0 '1) '('2 '3) '() '('5) '() '4)) +(let joinFull (CommonJoinCore (ToFlow list) 'Full '('0 '1) '('2 '3) '() '('5) '() '4)) +(let joinLeftOnly (CommonJoinCore (ToFlow list) 'LeftOnly '('0 '1) '() '() '('5) '() '4)) +(let joinLeftSemi (CommonJoinCore (ToFlow list) 'LeftSemi '('0 '1) '() '() '('5) '() '4)) +(let joinRightOnly (CommonJoinCore (ToFlow list) 'RightOnly '() '('2 '3) '() '('5) '() '4)) +(let joinRightSemi (CommonJoinCore (ToFlow list) 'RightSemi '() '('2 '3) '() '('5) '() '4)) +(let joinExclusion (CommonJoinCore (ToFlow list) 'Exclusion '('0 '1) '('2 '3) '() '('5) '() '4)) +(let joinCross (CommonJoinCore (ToFlow list) 'Cross '('0 '1) '('2 '3) '() '('5) '() '4)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Collect joinInner) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeft) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRight) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinFull) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRightOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinRightSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinExclusion) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinCross) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)))) + +(let world (Apply writeRes world list1)) +(let world (Apply writeRes world list2)) +(let world (Apply writeRes world list12)) +(return world) +) + diff --git a/yql/essentials/tests/s-expressions/suites/Join/EmptyLeftJoin.yql b/yql/essentials/tests/s-expressions/suites/Join/EmptyLeftJoin.yql new file mode 100644 index 0000000000..78c4cbd20f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/EmptyLeftJoin.yql @@ -0,0 +1,23 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let list1 (AsList + (AsStruct '('key1 (Just (String '1))) '('value1 (Just (String 'A)))) +)) + +(let list2 (AsList + (AsStruct '('key2 (String '1)) '('value2 (Nothing (OptionalType (DataType 'String))))) +)) + +(let keyExtractor (lambda '(x) (Member x 'key2))) +(let payloadExtractor (lambda '(x) x)) + +(let dictOne (ToDict list2 keyExtractor payloadExtractor '('Hashed 'One 'Compact))) +(let dictMany (ToDict list2 keyExtractor payloadExtractor '('Hashed 'Many 'Compact))) +(let joinLeft (MapJoinCore (Iterator list1 (DependsOn (String 'Left))) dictMany 'Left '('key1) '('key2) '('key1 'a.key1) '('key2 'b.key2 'value2 'b.value2) '() '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Collect joinLeft) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Join/InputSelf.txt b/yql/essentials/tests/s-expressions/suites/Join/InputSelf.txt new file mode 100644 index 0000000000..8ed0317c19 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/InputSelf.txt @@ -0,0 +1,8 @@ +{"key"="075";"subkey"=".";"value"="abc"}; +{"key"="911";"subkey"=".";"value"="kkk"}; +{"key"="023";"subkey"=".";"value"="075"}; +{"key"="527";"subkey"=".";"value"="bbb"}; +{"key"="037";"subkey"=".";"value"="ddd"}; +{"key"="761";"subkey"=".";"value"="023"}; +{"key"="200";"subkey"=".";"value"="qqq"}; +{"key"="150";"subkey"=".";"value"="zzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/Join/InputSelf.txt.attr b/yql/essentials/tests/s-expressions/suites/Join/InputSelf.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/InputSelf.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/Join/JoinInMem.yql b/yql/essentials/tests/s-expressions/suites/Join/JoinInMem.yql new file mode 100644 index 0000000000..aecec9aba2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/JoinInMem.yql @@ -0,0 +1,34 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList + '((Int32 '1) (String 'A)) + '((Int32 '7) (String 'B)) + '((Int32 '4) (String 'C)) + '((Int32 '4) (String 'D)) +)) + +(let list2 (AsList + '((Int32 '9) (String 'Z)) + '((Int32 '4) (String 'Y)) + '((Int32 '3) (String 'X)) + '((Int32 '4) (String 'W)) + '((Int32 '8) (String 'V)) +)) + +(let keyExtractor (lambda '(item) (Nth item '0))) +(let joinInner (Join list1 list2 keyExtractor keyExtractor 'Inner)) +(let joinLeft (Join list1 list2 keyExtractor keyExtractor 'Left)) +(let joinRight (Join list1 list2 keyExtractor keyExtractor 'Right)) +(let joinFull (Join list1 list2 keyExtractor keyExtractor 'Full)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) joinInner '())) +(let world (Write! world res_sink (Key) joinLeft '())) +(let world (Write! world res_sink (Key) joinRight '())) +(let world (Write! world res_sink (Key) joinFull '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Join/JoinTypes.yql b/yql/essentials/tests/s-expressions/suites/Join/JoinTypes.yql new file mode 100644 index 0000000000..dff7b4a5f8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/JoinTypes.yql @@ -0,0 +1,30 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source + (Key '('table (String 'Input1))) + '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let table2 (Map table1 (lambda '(item) (block '( + (return (AsStruct + '('value (Member item 'key)) + '('subkey (Member item 'subkey)) + '('key (Member item 'value))))) +)))) + +(let keyExtractor (lambda '(item) (Member item 'key))) +(let joinInner (Join table1 table2 keyExtractor keyExtractor 'Inner)) +(let joinLeft (Join table1 table2 keyExtractor keyExtractor 'Left)) +(let joinRight (Join table1 table2 keyExtractor keyExtractor 'Right)) +(let joinFull (Join table1 table2 keyExtractor keyExtractor 'Full)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf joinInner)) '())) +(let world (Write! world res_sink (Key) (FormatType (TypeOf joinLeft)) '())) +(let world (Write! world res_sink (Key) (FormatType (TypeOf joinRight)) '())) +(let world (Write! world res_sink (Key) (FormatType (TypeOf joinFull)) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Join/MapJoinCore.yql b/yql/essentials/tests/s-expressions/suites/Join/MapJoinCore.yql new file mode 100644 index 0000000000..3111328024 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/MapJoinCore.yql @@ -0,0 +1,41 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let list1 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (String 'A))) + (AsStruct '('key1 (Just (Int32 '7))) '('value1 (String 'B))) + (AsStruct '('key1 (Nothing (OptionalType (DataType 'Int32)))) '('value1 (String 'C))) + (AsStruct '('key1 (Just (Int32 '4))) '('value1 (String 'D))) + (AsStruct '('key1 (Just (Int32 '4))) '('value1 (String 'E))) +)) + +(let list2 (AsList + (AsStruct '('key2 (Int64 '9)) '('value2 (String 'Z))) + (AsStruct '('key2 (Int64 '4)) '('value2 (String 'Y))) + (AsStruct '('key2 (Int64 '3)) '('value2 (String 'X))) + (AsStruct '('key2 (Int64 '4)) '('value2 (String 'W))) + (AsStruct '('key2 (Int64 '8)) '('value2 (String 'V))) +)) + +(let keyExtractor (lambda '(x) (Member x 'key2))) +(let payloadExtractor (lambda '(x) x)) + +(let dictOne (ToDict list2 keyExtractor payloadExtractor '('Hashed 'One 'Compact))) +(let dictMany (ToDict list2 keyExtractor payloadExtractor '('Hashed 'Many 'Compact))) +(let joinLeftSemi (MapJoinCore (Iterator list1 (DependsOn (String 'LeftSemi))) dictOne 'LeftSemi '('key1) '('key2) '('key1 'a.key1 'value1 'a.value1) '() '() '())) +(let joinLeftOnly (MapJoinCore (Iterator list1 (DependsOn (String 'LeftOnly))) dictOne 'LeftOnly '('key1) '('key2) '('key1 'a.key1 'key1 'another_key 'key1 'yet_another_key) '() '() '())) +(let joinInnerUnique (MapJoinCore (Iterator list1 (DependsOn (String 'InnerU))) dictOne 'Inner '('key1) '('key2) '('key1 'a.key1 'value1 'a.value1) '('value2 'b.value2) '() '())) +(let joinLeftUnique (MapJoinCore (Iterator list1 (DependsOn (String 'LeftU))) dictOne 'Left '('key1) '('key2) '('key1 'a.key1) '('key2 'b.key2 'value2 'b.value2) '() '())) +(let joinInner (MapJoinCore (Iterator list1 (DependsOn (String 'Inner))) dictMany 'Inner '('key1) '('key2) '('key1 'a.key1 'value1 'a.value1) '('key2 'b.key2) '() '())) +(let joinLeft (MapJoinCore (Iterator list1 (DependsOn (String 'Left))) dictMany 'Left '('key1) '('key2) '('key1 'a.key1) '('key2 'b.key2 'value2 'b.value2) '() '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Collect joinLeftSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinInnerUnique) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftUnique) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinInner) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeft) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Join/MapJoinCoreOnStrings.yql b/yql/essentials/tests/s-expressions/suites/Join/MapJoinCoreOnStrings.yql new file mode 100644 index 0000000000..663bde4955 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/MapJoinCoreOnStrings.yql @@ -0,0 +1,41 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let list1 (AsList + (AsStruct '('key1 (Just (String '0123456789QWRTYUIOP1))) '('value1 (String 'A))) + (AsStruct '('key1 (Just (String '0123456789QWRTYUIOP7))) '('value1 (String 'B))) + (AsStruct '('key1 (Nothing (OptionalType (DataType 'String)))) '('value1 (String 'C))) + (AsStruct '('key1 (Just (String '0123456789QWRTYUIOP4))) '('value1 (String 'D))) + (AsStruct '('key1 (Just (String '0123456789QWRTYUIOP4))) '('value1 (String 'E))) +)) + +(let list2 (AsList + (AsStruct '('key2 (String '0123456789QWRTYUIOP9)) '('value2 (String 'Z))) + (AsStruct '('key2 (String '0123456789QWRTYUIOP4)) '('value2 (String 'Y))) + (AsStruct '('key2 (String '0123456789QWRTYUIOP3)) '('value2 (String 'X))) + (AsStruct '('key2 (String '0123456789QWRTYUIOP4)) '('value2 (String 'W))) + (AsStruct '('key2 (String '0123456789QWRTYUIOP8)) '('value2 (String 'V))) +)) + +(let keyExtractor (lambda '(x) (Member x 'key2))) +(let payloadExtractor (lambda '(x) x)) + +(let dictOne (ToDict list2 keyExtractor payloadExtractor '('Hashed 'One 'Compact))) +(let dictMany (ToDict list2 keyExtractor payloadExtractor '('Hashed 'Many 'Compact))) +(let joinLeftSemi (MapJoinCore (Iterator list1 (DependsOn (String 'LeftSemi))) dictOne 'LeftSemi '('key1) '('key2) '('key1 'a.key1 'value1 'a.value1) '() '() '())) +(let joinLeftOnly (MapJoinCore (Iterator list1 (DependsOn (String 'LeftOnly))) dictOne 'LeftOnly '('key1) '('key2) '('key1 'a.key1 'key1 'another_key 'key1 'yet_another_key) '() '() '())) +(let joinInnerUnique (MapJoinCore (Iterator list1 (DependsOn (String 'InnerU))) dictOne 'Inner '('key1) '('key2) '('key1 'a.key1 'value1 'a.value1) '('value2 'b.value2) '() '())) +(let joinLeftUnique (MapJoinCore (Iterator list1 (DependsOn (String 'LeftU))) dictOne 'Left '('key1) '('key2) '('key1 'a.key1) '('key2 'b.key2 'value2 'b.value2) '() '())) +(let joinInner (MapJoinCore (Iterator list1 (DependsOn (String 'Inner))) dictMany 'Inner '('key1) '('key2) '('key1 'a.key1 'value1 'a.value1) '('key2 'b.key2) '() '())) +(let joinLeft (MapJoinCore (Iterator list1 (DependsOn (String 'Left))) dictMany 'Left '('key1) '('key2) '('key1 'a.key1) '('key2 'b.key2 'value2 'b.value2) '() '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Collect joinLeftSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinInnerUnique) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftUnique) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinInner) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeft) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Join/MapJoinCoreOnStrings_Flow.yql b/yql/essentials/tests/s-expressions/suites/Join/MapJoinCoreOnStrings_Flow.yql new file mode 100644 index 0000000000..9c1ef15dfe --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/MapJoinCoreOnStrings_Flow.yql @@ -0,0 +1,41 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let list1 (AsList + (AsStruct '('key1 (Just (String '0123456789QWRTYUIOP1))) '('value1 (String 'A))) + (AsStruct '('key1 (Just (String '0123456789QWRTYUIOP7))) '('value1 (String 'B))) + (AsStruct '('key1 (Nothing (OptionalType (DataType 'String)))) '('value1 (String 'C))) + (AsStruct '('key1 (Just (String '0123456789QWRTYUIOP4))) '('value1 (String 'D))) + (AsStruct '('key1 (Just (String '0123456789QWRTYUIOP4))) '('value1 (String 'E))) +)) + +(let list2 (AsList + (AsStruct '('key2 (String '0123456789QWRTYUIOP9)) '('value2 (String 'Z))) + (AsStruct '('key2 (String '0123456789QWRTYUIOP4)) '('value2 (String 'Y))) + (AsStruct '('key2 (String '0123456789QWRTYUIOP3)) '('value2 (String 'X))) + (AsStruct '('key2 (String '0123456789QWRTYUIOP4)) '('value2 (String 'W))) + (AsStruct '('key2 (String '0123456789QWRTYUIOP8)) '('value2 (String 'V))) +)) + +(let keyExtractor (lambda '(x) (Member x 'key2))) +(let payloadExtractor (lambda '(x) x)) + +(let dictOne (ToDict list2 keyExtractor payloadExtractor '('Hashed 'One 'Compact))) +(let dictMany (ToDict list2 keyExtractor payloadExtractor '('Hashed 'Many 'Compact))) +(let joinLeftSemi (MapJoinCore (ToFlow list1) dictOne 'LeftSemi '('key1) '('key2) '('key1 'a.key1 'value1 'a.value1) '() '() '())) +(let joinLeftOnly (MapJoinCore (ToFlow list1) dictOne 'LeftOnly '('key1) '('key2) '('key1 'a.key1 'key1 'another_key 'key1 'yet_another_key) '() '() '())) +(let joinInnerUnique (MapJoinCore (ToFlow list1) dictOne 'Inner '('key1) '('key2) '('key1 'a.key1 'value1 'a.value1) '('value2 'b.value2) '() '())) +(let joinLeftUnique (MapJoinCore (ToFlow list1) dictOne 'Left '('key1) '('key2) '('key1 'a.key1) '('key2 'b.key2 'value2 'b.value2) '() '())) +(let joinInner (MapJoinCore (ToFlow list1) dictMany 'Inner '('key1) '('key2) '('key1 'a.key1 'value1 'a.value1) '('key2 'b.key2) '() '())) +(let joinLeft (MapJoinCore (ToFlow list1) dictMany 'Left '('key1) '('key2) '('key1 'a.key1) '('key2 'b.key2 'value2 'b.value2) '() '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Collect joinLeftSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinInnerUnique) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftUnique) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinInner) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeft) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Join/MapJoinCore_Flow.yql b/yql/essentials/tests/s-expressions/suites/Join/MapJoinCore_Flow.yql new file mode 100644 index 0000000000..61b150f5f8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/MapJoinCore_Flow.yql @@ -0,0 +1,41 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let list1 (AsList + (AsStruct '('key1 (Just (Int32 '1))) '('value1 (String 'A))) + (AsStruct '('key1 (Just (Int32 '7))) '('value1 (String 'B))) + (AsStruct '('key1 (Nothing (OptionalType (DataType 'Int32)))) '('value1 (String 'C))) + (AsStruct '('key1 (Just (Int32 '4))) '('value1 (String 'D))) + (AsStruct '('key1 (Just (Int32 '4))) '('value1 (String 'E))) +)) + +(let list2 (AsList + (AsStruct '('key2 (Int64 '9)) '('value2 (String 'Z))) + (AsStruct '('key2 (Int64 '4)) '('value2 (String 'Y))) + (AsStruct '('key2 (Int64 '3)) '('value2 (String 'X))) + (AsStruct '('key2 (Int64 '4)) '('value2 (String 'W))) + (AsStruct '('key2 (Int64 '8)) '('value2 (String 'V))) +)) + +(let keyExtractor (lambda '(x) (Member x 'key2))) +(let payloadExtractor (lambda '(x) x)) + +(let dictOne (ToDict list2 keyExtractor payloadExtractor '('Hashed 'One 'Compact))) +(let dictMany (ToDict list2 keyExtractor payloadExtractor '('Hashed 'Many 'Compact))) +(let joinLeftSemi (MapJoinCore (ToFlow list1) dictOne 'LeftSemi '('key1) '('key2) '('key1 'a.key1 'value1 'a.value1) '() '() '())) +(let joinLeftOnly (MapJoinCore (ToFlow list1) dictOne 'LeftOnly '('key1) '('key2) '('key1 'a.key1 'key1 'another_key 'key1 'yet_another_key) '() '() '())) +(let joinInnerUnique (MapJoinCore (ToFlow list1) dictOne 'Inner '('key1) '('key2) '('key1 'a.key1 'value1 'a.value1) '('value2 'b.value2) '() '())) +(let joinLeftUnique (MapJoinCore (ToFlow list1) dictOne 'Left '('key1) '('key2) '('key1 'a.key1) '('key2 'b.key2 'value2 'b.value2) '() '())) +(let joinInner (MapJoinCore (ToFlow list1) dictMany 'Inner '('key1) '('key2) '('key1 'a.key1 'value1 'a.value1) '('key2 'b.key2) '() '())) +(let joinLeft (MapJoinCore (ToFlow list1) dictMany 'Left '('key1) '('key2) '('key1 'a.key1) '('key2 'b.key2 'value2 'b.value2) '() '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Collect joinLeftSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinInnerUnique) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftUnique) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinInner) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeft) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Join/MapJoinCore_FlowOfTuples.yql b/yql/essentials/tests/s-expressions/suites/Join/MapJoinCore_FlowOfTuples.yql new file mode 100644 index 0000000000..dbd0d1712d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/MapJoinCore_FlowOfTuples.yql @@ -0,0 +1,41 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let list1 (AsList + '((Just (Int32 '1)) (String 'A)) + '((Just (Int32 '7)) (String 'B)) + '((Nothing (OptionalType (DataType 'Int32))) (String 'C)) + '((Just (Int32 '4)) (String 'D)) + '((Just (Int32 '4)) (String 'E)) +)) + +(let list2 (AsList + '((Int64 '9) (String 'Z)) + '((Int64 '4) (String 'Y)) + '((Int64 '3) (String 'X)) + '((Int64 '4) (String 'W)) + '((Int64 '8) (String 'V)) +)) + +(let keyExtractor (lambda '(x) (Nth x '0))) +(let payloadExtractor (lambda '(x) x)) + +(let dictOne (ToDict list2 keyExtractor payloadExtractor '('Hashed 'One 'Compact))) +(let dictMany (ToDict list2 keyExtractor payloadExtractor '('Hashed 'Many 'Compact))) +(let joinLeftSemi (MapJoinCore (ToFlow list1) dictOne 'LeftSemi '('0) '('0) '('0 '0 '1 '1) '() '() '())) +(let joinLeftOnly (MapJoinCore (ToFlow list1) dictOne 'LeftOnly '('0) '('0) '('0 '0 '0 '1 '0 '2) '() '() '())) +(let joinInnerUnique (MapJoinCore (ToFlow list1) dictOne 'Inner '('0) '('0) '('0 '2 '1 '1) '('1 '0) '() '())) +(let joinLeftUnique (MapJoinCore (ToFlow list1) dictOne 'Left '('0) '('0) '('0 '0) '('0 '1 '1 '2) '() '())) +(let joinInner (MapJoinCore (ToFlow list1) dictMany 'Inner '('0) '('0) '('0 '0 '1 '1) '('0 '2) '() '())) +(let joinLeft (MapJoinCore (ToFlow list1) dictMany 'Left '('0) '('0) '('0 '2) '('0 '1 '1 '0) '() '())) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Collect joinLeftSemi) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftOnly) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinInnerUnique) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeftUnique) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinInner) '('('type)))) +(let world (Write! world res_sink (Key) (Collect joinLeft) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Join/default.cfg b/yql/essentials/tests/s-expressions/suites/Join/default.cfg new file mode 100644 index 0000000000..db91b7fd18 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/default.cfg @@ -0,0 +1,5 @@ +res result.txt +in InputSelf InputSelf.txt +in Input1 input1.txt +in Input2 input2.txt +in Input3 input3.txt diff --git a/yql/essentials/tests/s-expressions/suites/Join/input1.txt b/yql/essentials/tests/s-expressions/suites/Join/input1.txt new file mode 100644 index 0000000000..f53757c309 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/input1.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="800";"subkey"="1";"value"="ddd"}; +{"key"="020";"subkey"="1";"value"="q"}; +{"key"="150";"subkey"="1";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/Join/input1.txt.attr b/yql/essentials/tests/s-expressions/suites/Join/input1.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/input1.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/Join/input2.txt b/yql/essentials/tests/s-expressions/suites/Join/input2.txt new file mode 100644 index 0000000000..07af3b4647 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/input2.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="2";"value"="abc"}; +{"key"="800";"subkey"="2";"value"="ddd"}; +{"key"="020";"subkey"="2";"value"="q"}; +{"key"="150";"subkey"="2";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/Join/input2.txt.attr b/yql/essentials/tests/s-expressions/suites/Join/input2.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/input2.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/Join/input3.txt b/yql/essentials/tests/s-expressions/suites/Join/input3.txt new file mode 100644 index 0000000000..1dc1bcc60b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/input3.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="3";"value"="abd"}; +{"key"="800";"subkey"="3";"value"="ddd"}; +{"key"="021";"subkey"="3";"value"="q"}; +{"key"="151";"subkey"="3";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/Join/input3.txt.attr b/yql/essentials/tests/s-expressions/suites/Join/input3.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Join/input3.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/Lib/Agg_Avg.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Avg.yql new file mode 100644 index 0000000000..3a918b3c81 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Avg.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '1))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '9))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '7))) +)) +(let avg_traits (Apply (bind agg_module 'avg_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('avg_value avg_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Avg_If.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Avg_If.yql new file mode 100755 index 0000000000..3b90e99391 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Avg_If.yql @@ -0,0 +1,22 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '2)) '('pred (Bool '1)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '1)) '('pred (Bool '1)) '('value (Uint32 '17))) +(AsStruct '('key (Uint32 '2)) '('pred (Bool '0)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '1)) '('pred (Bool '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('pred (Bool '0)) '('value (Uint32 '1))) +(AsStruct '('key (Uint32 '2)) '('pred (Bool '0)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '2)) '('pred (Bool '1)) '('value (Uint32 '9))) +)) +(let avg_traits (Apply (bind agg_module 'avg_if_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (lambda '(row) (Member row 'pred)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('avg_value avg_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Avg_If_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Avg_If_Opt.yql new file mode 100755 index 0000000000..830f163e5f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Avg_If_Opt.yql @@ -0,0 +1,22 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '2)) '('pred (Bool '1)) '('value (Just (Uint32 '5)))) +(AsStruct '('key (Uint32 '1)) '('pred (Bool '1)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('pred (Bool '0)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '1)) '('pred (Bool '1)) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Uint32 '3)) '('pred (Bool '0)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('pred (Bool '0)) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Uint32 '2)) '('pred (Bool '1)) '('value (Just (Uint32 '9)))) +)) +(let avg_traits (Apply (bind agg_module 'avg_if_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (lambda '(row) (Member row 'pred)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('avg_value avg_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Avg_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Avg_Opt.yql new file mode 100644 index 0000000000..1862c9703d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Avg_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '9)))) +)) +(let avg_traits (Apply (bind agg_module 'avg_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('avg_value avg_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bit_And.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bit_And.yql new file mode 100644 index 0000000000..75cbff2731 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bit_And.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '1))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '9))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let and_traits (Apply (bind agg_module 'bit_and_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('and_value and_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bit_Or.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bit_Or.yql new file mode 100644 index 0000000000..37cd22a4ed --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bit_Or.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '1))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '9))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let or_traits (Apply (bind agg_module 'bit_or_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('or_value or_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bit_Xor.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bit_Xor.yql new file mode 100644 index 0000000000..b4cb8e8f5a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bit_Xor.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '1))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '9))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let xor_traits (Apply (bind agg_module 'bit_xor_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('xor_value xor_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bool_And_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bool_And_Opt.yql new file mode 100644 index 0000000000..3f57941811 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bool_And_Opt.yql @@ -0,0 +1,28 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '0)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '0)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Bool))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Bool))))) +(AsStruct '('key (Uint32 '4)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '4)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '5)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '5)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '5)) '('value (Nothing (OptionalType (DataType 'Bool))))) +)) +(let and_traits (Apply (bind agg_module 'and_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('and_value and_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bool_Or_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bool_Or_Opt.yql new file mode 100644 index 0000000000..32ab9bdf8e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bool_Or_Opt.yql @@ -0,0 +1,28 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '0)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '0)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Bool))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Bool))))) +(AsStruct '('key (Uint32 '4)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '4)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '5)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '5)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '5)) '('value (Nothing (OptionalType (DataType 'Bool))))) +)) +(let or_traits (Apply (bind agg_module 'or_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('or_value or_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bool_Xor_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bool_Xor_Opt.yql new file mode 100644 index 0000000000..7463add10f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Bool_Xor_Opt.yql @@ -0,0 +1,28 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '0)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '0)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Bool))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Bool))))) +(AsStruct '('key (Uint32 '4)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '4)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '5)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '5)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '5)) '('value (Nothing (OptionalType (DataType 'Bool))))) +)) +(let xor_traits (Apply (bind agg_module 'xor_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('xor_value xor_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Compare_By_Opts.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Compare_By_Opts.yql new file mode 100644 index 0000000000..f00b6365aa --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Compare_By_Opts.yql @@ -0,0 +1,24 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Just (Uint32 '7))) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Just (Uint32 '2))) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Just (Uint32 '1))) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Just (Uint32 '3))) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Nothing (OptionalType (DataType 'Uint32)))) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Just (Uint32 '2))) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Just (Uint32 '6))) '('value (Just (Uint32 '6)))) +(AsStruct '('key (Just (Uint32 '5))) '('value (Just (Uint32 '9)))) +)) +(let min (Apply (bind agg_module 'min_by_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (lambda '(row) (Member row 'key)) (Void))) +(let max (Apply (bind agg_module 'max_by_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (lambda '(row) (Member row 'key)) (Void))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '() '('('min min) '('max max)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count.yql new file mode 100644 index 0000000000..70c1586820 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '10))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let count_traits (Apply (bind agg_module 'count_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('count_value count_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_All.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_All.yql new file mode 100644 index 0000000000..4e21b049d6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_All.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '10))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let count_traits (Apply (bind agg_module 'count_all_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('count_value count_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_All_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_All_Opt.yql new file mode 100644 index 0000000000..2bbd4d8aee --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_All_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +)) +(let count_traits (Apply (bind agg_module 'count_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('count_value count_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_If.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_If.yql new file mode 100644 index 0000000000..05fc3411ee --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_If.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Bool '0))) +(AsStruct '('key (Uint32 '2)) '('value (Bool '1))) +(AsStruct '('key (Uint32 '1)) '('value (Bool '0))) +(AsStruct '('key (Uint32 '3)) '('value (Bool '1))) +(AsStruct '('key (Uint32 '2)) '('value (Bool '1))) +(AsStruct '('key (Uint32 '2)) '('value (Bool '0))) +)) +(let count_traits (Apply (bind agg_module 'count_if_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('count_value count_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_If_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_If_Opt.yql new file mode 100644 index 0000000000..562b296e54 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_If_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Bool))))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Bool))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Bool '1)))) +)) +(let count_traits (Apply (bind agg_module 'count_if_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('count_value count_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_Opt.yql new file mode 100644 index 0000000000..1c622b7dc4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Count_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +)) +(let count_traits (Apply (bind agg_module 'count_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('count_value count_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count.yql new file mode 100644 index 0000000000..4164df0baf --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '10))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let count_traits (Apply (bind agg_module 'count_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('count_value count_traits 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_All.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_All.yql new file mode 100644 index 0000000000..f0aa559269 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_All.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '10))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let count_traits (Apply (bind agg_module 'count_all_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('count_value count_traits 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_All_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_All_Opt.yql new file mode 100644 index 0000000000..35b9f5ff52 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_All_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +)) +(let count_traits (Apply (bind agg_module 'count_all_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('count_value count_traits 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_If.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_If.yql new file mode 100644 index 0000000000..2f803d033c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_If.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Bool '0))) +(AsStruct '('key (Uint32 '2)) '('value (Bool '1))) +(AsStruct '('key (Uint32 '1)) '('value (Bool '0))) +(AsStruct '('key (Uint32 '3)) '('value (Bool '1))) +(AsStruct '('key (Uint32 '2)) '('value (Bool '0))) +(AsStruct '('key (Uint32 '2)) '('value (Bool '1))) +)) +(let count_traits (Apply (bind agg_module 'count_if_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('count_value count_traits 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_If_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_If_Opt.yql new file mode 100644 index 0000000000..23fc8348fd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_If_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Just (Bool '0)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Bool))))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Bool))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Bool '1)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Bool '1)))) +)) +(let count_traits (Apply (bind agg_module 'count_if_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('count_value count_traits 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_Opt.yql new file mode 100644 index 0000000000..b8d6f537a6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Count_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +)) +(let count_traits (Apply (bind agg_module 'count_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('count_value count_traits 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Max.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Max.yql new file mode 100644 index 0000000000..5ecf5b1435 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Max.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '10))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let max_traits (Apply (bind agg_module 'max_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('max_value max_traits 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Max_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Max_Opt.yql new file mode 100644 index 0000000000..9eeab95381 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Max_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +)) +(let max_traits (Apply (bind agg_module 'max_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('max_value max_traits 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Min.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Min.yql new file mode 100644 index 0000000000..b31163c9ed --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Min.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '10))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let min_traits (Apply (bind agg_module 'min_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('min_value min_traits 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Min_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Min_Opt.yql new file mode 100644 index 0000000000..2f6803c9ce --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Min_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +)) +(let min_traits (Apply (bind agg_module 'min_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('min_value min_traits 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Some.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Some.yql new file mode 100644 index 0000000000..f765ed07b9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Some.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '9))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '0))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '1))) +)) +(let some_traits (Apply (bind agg_module 'some_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('some_value some_traits 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Some_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Some_Opt.yql new file mode 100644 index 0000000000..7194f87bdc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Some_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '1)))) +)) +(let some_traits (Apply (bind agg_module 'some_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('some_value some_traits 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Sum.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Sum.yql new file mode 100644 index 0000000000..6aaa8a231a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Sum.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '10))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let sum_traits (Apply (bind agg_module 'sum_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('sum_value sum_traits 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Sum_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Sum_Opt.yql new file mode 100644 index 0000000000..4c19ad9f29 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Distinct_Sum_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +)) +(let sum_traits (Apply (bind agg_module 'sum_traits_factory) (ListType (StructMemberType (ListItemType (TypeOf list)) 'value)) (lambda '(v) v))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('sum_value sum_traits 'value)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_List.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List.yql new file mode 100644 index 0000000000..61ed0f2179 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '1))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '9))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '7))) +)) +(let list_traits (Apply (bind agg_module 'list_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (Uint64 '0))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('list_value list_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Compare_By_Opts.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Compare_By_Opts.yql new file mode 100644 index 0000000000..6fc7177662 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Compare_By_Opts.yql @@ -0,0 +1,29 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Just (Uint32 '7))) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Just (Uint32 '7))) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Just (Uint32 '2))) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Just (Uint32 '1))) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Just (Uint32 '0))) '('value (Just (Uint32 '9)))) +(AsStruct '('key (Just (Uint32 '1))) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Just (Uint32 '1))) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Just (Uint32 '3))) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Nothing (OptionalType (DataType 'Uint32)))) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Just (Uint32 '2))) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Just (Uint32 '6))) '('value (Just (Uint32 '6)))) +(AsStruct '('key (Just (Uint32 '5))) '('value (Just (Uint32 '9)))) +(AsStruct '('key (Nothing (OptionalType (DataType 'Uint32)))) '('value (Just (Uint32 '9)))) +)) +(let min (Apply (bind agg_module 'min_by_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (lambda '(row) (Member row 'key)) (Uint64 '3))) +(let max (Apply (bind agg_module 'max_by_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (lambda '(row) (Member row 'key)) (Uint64 '3))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '() '('('min min) '('max max)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Limit.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Limit.yql new file mode 100644 index 0000000000..ab1302c752 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Limit.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '1))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '9))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '7))) +)) +(let list_traits (Apply (bind agg_module 'list_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (Uint64 '1))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('list_value list_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Max_By.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Max_By.yql new file mode 100644 index 0000000000..0572dfb448 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Max_By.yql @@ -0,0 +1,23 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '1))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '1))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '7))) +)) +(let traits (Apply (bind agg_module 'max_by_traits_factory) (TypeOf list) (lambda '(row) (Member row 'key)) (lambda '(row) (Member row 'value)) (Uint64 '3))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '() '('('result traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Max_By_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Max_By_Opt.yql new file mode 100644 index 0000000000..d2ec207c91 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Max_By_Opt.yql @@ -0,0 +1,22 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '9)))) +(AsStruct '('key (Uint32 '0)) '('value (Just (Uint32 '9)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +)) +(let traits (Apply (bind agg_module 'max_by_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (lambda '(row) (Member row 'key)) (Uint64 '3))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '() '('('result traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Min_By.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Min_By.yql new file mode 100644 index 0000000000..e29fb2715c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Min_By.yql @@ -0,0 +1,23 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '8))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '1))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '1))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '8))) +)) +(let traits (Apply (bind agg_module 'min_by_traits_factory) (TypeOf list) (lambda '(row) (Member row 'key)) (lambda '(row) (Member row 'value)) (Uint64 '7))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '() '('('result traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Min_By_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Min_By_Opt.yql new file mode 100644 index 0000000000..96e85e97c4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Min_By_Opt.yql @@ -0,0 +1,23 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '7)) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Uint32 '9)) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '0)) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +)) +(let traits (Apply (bind agg_module 'min_by_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (lambda '(row) (Member row 'key)) (Uint64 '3))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '() '('('result traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Opt.yql new file mode 100644 index 0000000000..a22f743db3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_List_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '9)))) +)) +(let list_traits (Apply (bind agg_module 'list_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (Uint64 '0))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('list_value list_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Max.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Max.yql new file mode 100644 index 0000000000..8bf97f958c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Max.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '10))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let max_traits (Apply (bind agg_module 'max_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('max_value max_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Max_By.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Max_By.yql new file mode 100644 index 0000000000..e28d35900c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Max_By.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '1))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let traits (Apply (bind agg_module 'max_by_traits_factory) (TypeOf list) (lambda '(row) (Member row 'key)) (lambda '(row) (Member row 'value)) (Void))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '() '('('result traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Max_By_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Max_By_Opt.yql new file mode 100644 index 0000000000..95168e3143 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Max_By_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '0)) '('value (Just (Uint32 '9)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +)) +(let traits (Apply (bind agg_module 'max_by_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (lambda '(row) (Member row 'key)) (Void))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '() '('('result traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Max_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Max_Opt.yql new file mode 100644 index 0000000000..6e41241625 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Max_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +)) +(let max_traits (Apply (bind agg_module 'max_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('max_value max_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Min.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Min.yql new file mode 100644 index 0000000000..35ecccd09e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Min.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '10))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let min_traits (Apply (bind agg_module 'min_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('min_value min_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Min_By.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Min_By.yql new file mode 100644 index 0000000000..3ad67c8e7f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Min_By.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '1))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '0)) '('value (Uint32 '7))) +)) +(let traits (Apply (bind agg_module 'min_by_traits_factory) (TypeOf list) (lambda '(row) (Member row 'key)) (lambda '(row) (Member row 'value)) (Void))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '() '('('result traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Min_By_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Min_By_Opt.yql new file mode 100644 index 0000000000..7e48591609 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Min_By_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '7)) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +)) +(let traits (Apply (bind agg_module 'min_by_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (lambda '(row) (Member row 'key)) (Void))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '() '('('result traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Min_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Min_Opt.yql new file mode 100644 index 0000000000..648369b4d3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Min_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '2)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +)) +(let min_traits (Apply (bind agg_module 'min_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('min_value min_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Some.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Some.yql new file mode 100644 index 0000000000..629a3cea33 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Some.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '9))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '8))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let some_traits (Apply (bind agg_module 'some_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('some_value some_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Some_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Some_Opt.yql new file mode 100644 index 0000000000..34ec224a58 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Some_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '7)))) +)) +(let some_traits (Apply (bind agg_module 'some_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('some_value some_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Sum.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Sum.yql new file mode 100644 index 0000000000..2a943f1234 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Sum.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('value (Uint32 '10))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '2)) '('value (Uint32 '5))) +)) +(let sum_traits (Apply (bind agg_module 'sum_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('sum_value sum_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Sum_If.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Sum_If.yql new file mode 100755 index 0000000000..c229026827 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Sum_If.yql @@ -0,0 +1,22 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '2)) '('pred (Bool '1)) '('value (Uint32 '5))) +(AsStruct '('key (Uint32 '1)) '('pred (Bool '1)) '('value (Uint32 '17))) +(AsStruct '('key (Uint32 '2)) '('pred (Bool '0)) '('value (Uint32 '2))) +(AsStruct '('key (Uint32 '1)) '('pred (Bool '1)) '('value (Uint32 '4))) +(AsStruct '('key (Uint32 '3)) '('pred (Bool '0)) '('value (Uint32 '1))) +(AsStruct '('key (Uint32 '2)) '('pred (Bool '0)) '('value (Uint32 '3))) +(AsStruct '('key (Uint32 '2)) '('pred (Bool '1)) '('value (Uint32 '9))) +)) +(let sum_traits (Apply (bind agg_module 'sum_if_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (lambda '(row) (Member row 'pred)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('sum_value sum_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Sum_If_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Sum_If_Opt.yql new file mode 100755 index 0000000000..51e667e8d3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Sum_If_Opt.yql @@ -0,0 +1,22 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '2)) '('pred (Bool '1)) '('value (Just (Uint32 '5)))) +(AsStruct '('key (Uint32 '1)) '('pred (Bool '1)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('pred (Bool '0)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '1)) '('pred (Bool '1)) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Uint32 '3)) '('pred (Bool '0)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('pred (Bool '0)) '('value (Just (Uint32 '3)))) +(AsStruct '('key (Uint32 '2)) '('pred (Bool '1)) '('value (Just (Uint32 '9)))) +)) +(let sum_traits (Apply (bind agg_module 'sum_if_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (lambda '(row) (Member row 'pred)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('sum_value sum_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Agg_Sum_Opt.yql b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Sum_Opt.yql new file mode 100644 index 0000000000..a50b4f93a9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Agg_Sum_Opt.yql @@ -0,0 +1,21 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Uint32 '1)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '1)) '('value (Just (Uint32 '4)))) +(AsStruct '('key (Uint32 '3)) '('value (Nothing (OptionalType (DataType 'Uint32))))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +(AsStruct '('key (Uint32 '2)) '('value (Just (Uint32 '5)))) +)) +(let sum_traits (Apply (bind agg_module 'sum_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)))) +(let res_sink (DataSink 'result)) +(let resKey (Aggregate list '('key) '('('sum_value sum_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Decode.sql b/yql/essentials/tests/s-expressions/suites/Lib/Decode.sql new file mode 100644 index 0000000000..d56651c52b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Decode.sql @@ -0,0 +1,4 @@ +SELECT Core::Decode("key1",AsList("key1","value1","key2","value2"),"default"); +SELECT Core::Decode("key2",AsList("key1","value1","key2","value2"),"default"); +SELECT Core::Decode("keyZ",AsList("key1","value1","key2","value2"),"default"); + diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Decode.yql b/yql/essentials/tests/s-expressions/suites/Lib/Decode.yql new file mode 100644 index 0000000000..25d3e102c6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Decode.yql @@ -0,0 +1,72 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(import core_module '"/lib/yql/core.yql") +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Apply" ("bind" core_module '"Decode") (String '"key1") ("AsList" (String '"key1") (String '"value1") (String '"key2") (String '"value2")) (String '"default"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Apply" ("bind" core_module '"Decode") (String '"key2") ("AsList" (String '"key1") (String '"value1") (String '"key2") (String '"value2")) (String '"default"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Apply" ("bind" core_module '"Decode") (String '"keyZ") ("AsList" (String '"key1") (String '"value1") (String '"key2") (String '"value2")) (String '"default"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/Sqr.yql b/yql/essentials/tests/s-expressions/suites/Lib/Sqr.yql new file mode 100644 index 0000000000..431c462e10 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/Sqr.yql @@ -0,0 +1,12 @@ +# program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import sqr_module '"/lib/yql/sqr.yql") +(let mySqr (bind sqr_module 'sqr)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Apply mySqr (Uint32 '4)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Lib/default.cfg b/yql/essentials/tests/s-expressions/suites/Lib/default.cfg new file mode 100644 index 0000000000..e41deb15c5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Lib/default.cfg @@ -0,0 +1,2 @@ +res result.txt +mount ..\mounts.txt diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/BadUnionButUnusedFieldProject.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/BadUnionButUnusedFieldProject.yql new file mode 100644 index 0000000000..55b38fb1b9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/BadUnionButUnusedFieldProject.yql @@ -0,0 +1,59 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input1"))) '('"key") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input2"))) '('"key") '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (UnionAll (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"A" (String '"1"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + )) (block '( + (let core table1) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"A" (Int64 '"1"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + )))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"column1" ("Concat" (Member row '"key") (String '"AAA")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"key" '"column1"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/BadUnionButUnusedFieldRead.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/BadUnionButUnusedFieldRead.yql new file mode 100644 index 0000000000..67becd3ffb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/BadUnionButUnusedFieldRead.yql @@ -0,0 +1,58 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input1"))) '('"key") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input2"))) '('"key") '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (UnionAll (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"A" (String '"1"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + )) (block '( + (let core table1) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"A" (Int64 '"1"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + )))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"key"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/CompactPlan.cfg b/yql/essentials/tests/s-expressions/suites/ManyInputTables/CompactPlan.cfg new file mode 100644 index 0000000000..e5e19ca2fb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/CompactPlan.cfg @@ -0,0 +1,16 @@ +in Input1 input1.txt +in Input2 input1.txt +in Input3 input1.txt +in Input4 input1.txt +in Input5 input1.txt +in Input6 input1.txt +in Input7 input1.txt +in Input8 input1.txt +in Input9 input1.txt +in Input10 input1.txt +in Input11 input1.txt +in Input12 input1.txt +in Input13 input1.txt +in Input14 input1.txt +in Input15 input1.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/CompactPlan.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/CompactPlan.yql new file mode 100644 index 0000000000..89b7fd5a76 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/CompactPlan.yql @@ -0,0 +1,58 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input4))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table4 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input5))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table5 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input6))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table6 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input7))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table7 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input8))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table8 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input9))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table9 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input10))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table10 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input11))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table11 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input12))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table12 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input13))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table13 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input14))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table14 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input15))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table15 (Right! x)) +(let lens (AsList + (Length table1) (Length table2) (Length table3) (Length table4) (Length table5) + (Length table6) (Length table7) (Length table8) (Length table9) (Length table10) + (Length table11) (Length table12) (Length table13) (Length table14) (Length table15))) +(let result (Fold lens (Uint64 '0) (lambda '(x y) (+ x y)))) +(let res_sink (DataSink '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/ManyInputTables/ConcatSortedAndNonSorted.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/ConcatSortedAndNonSorted.yql new file mode 100644 index 0000000000..a16749b54f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/ConcatSortedAndNonSorted.yql @@ -0,0 +1,12 @@ +( +(let source (DataSource 'yt 'plato)) +(let x (Read! world source (Key '('table (String 'Input1))) '('key 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let sorted (Sort table (Bool 'true) (lambda '(item) (Member item 'value)))) +(let result (Extend table sorted)) +(let sink (DataSink 'yt 'plato)) +(let world (Write! world sink (Key '('table (String 'Output))) result '())) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/DupAndSort.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/DupAndSort.yql new file mode 100644 index 0000000000..08089395f7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/DupAndSort.yql @@ -0,0 +1,21 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let offset (Uint64 '5)) +(let result (Extend table1 table1)) +(let result (Sort result (Bool 'true) (lambda '(row) (block '( + (let res (Member row 'key)) + (return res) +) +)))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) result '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/DupByExtend.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/DupByExtend.yql new file mode 100644 index 0000000000..0089378d22 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/DupByExtend.yql @@ -0,0 +1,16 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let offset (Uint64 '5)) +(let result (Extend table1 table1)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) result '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/ExtendBetweenSorts.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/ExtendBetweenSorts.yql new file mode 100644 index 0000000000..110b0a004a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/ExtendBetweenSorts.yql @@ -0,0 +1,29 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let result1 (Sort table1 (Bool 'true) (lambda '(row) (block '( + (let res (Member row 'value)) + (return res) +) +)))) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let offset (Uint64 '5)) +(let result2 (Extend result1 table2)) +(let result2 (Sort result2 '((Bool 'true) (Bool 'true)) (lambda '(row) (block '( + (let res '((Member row 'key) (Member row 'subkey))) + (return res) +) +)))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) result2 '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result2 '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/FilterAfterExtend.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/FilterAfterExtend.yql new file mode 100644 index 0000000000..1c7045232c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/FilterAfterExtend.yql @@ -0,0 +1,19 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let tresh (String '100)) +(let result (Filter (Extend table1 table2) (lambda '(item) (< (Member item 'key) tresh)))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) result '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/FilterBeforeExtend.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/FilterBeforeExtend.yql new file mode 100644 index 0000000000..2f2f487eca --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/FilterBeforeExtend.yql @@ -0,0 +1,17 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let tresh (String '100)) +(let result (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let result (Extend result table2)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) result '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/GroupAfterWeakConcat.cfg b/yql/essentials/tests/s-expressions/suites/ManyInputTables/GroupAfterWeakConcat.cfg new file mode 100644 index 0000000000..656c5e8480 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/GroupAfterWeakConcat.cfg @@ -0,0 +1,5 @@ +in Input1 non_ksv_input1.txt +in Input2 non_ksv_input2.txt +out Output output.txt +res result.txt +mount ..\mounts.txt diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/GroupAfterWeakConcat.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/GroupAfterWeakConcat.yql new file mode 100644 index 0000000000..1afa2e265e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/GroupAfterWeakConcat.yql @@ -0,0 +1,13 @@ +( +#comment +(import aggregate_module '"/lib/yql/aggregate.yql") +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (MrTableConcat (Key '('table (String 'Input1))) (Key '('table (String 'Input2)))) (Void) '())) +(let world (Left! x)) +(let core (Right! x)) +(let core (Aggregate core '('"age") '('('cnt (Apply (bind aggregate_module '"count_traits_factory") (TypeOf core) (lambda '(row) (Void))))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) core '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/GroupAfterWeakConcatOther.cfg b/yql/essentials/tests/s-expressions/suites/ManyInputTables/GroupAfterWeakConcatOther.cfg new file mode 100644 index 0000000000..31a57e15ff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/GroupAfterWeakConcatOther.cfg @@ -0,0 +1,9 @@ +in Input1 non_ksv_input1.txt +in Input2 non_ksv_input3.txt +in Input3 non_ksv_input1.txt +in Input4 non_ksv_input3.txt +in Input5 non_ksv_input1.txt +in Input6 non_ksv_input3.txt +out Output output.txt +res result.txt +mount ..\mounts.txt diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/GroupAfterWeakConcatOther.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/GroupAfterWeakConcatOther.yql new file mode 100644 index 0000000000..2215cc2428 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/GroupAfterWeakConcatOther.yql @@ -0,0 +1,57 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(import core_module '"/lib/yql/core.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat + (Key '('table (String '"Input1"))) + (Key '('table (String '"Input2"))) + (Key '('table (String '"Input3"))) + (Key '('table (String '"Input4"))) + (Key '('table (String '"Input5"))) + (Key '('table (String '"Input6"))) + ) (Void) '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"age" (Coalesce + (TryMember row '"age" (Nothing (OptionalType (DataType 'Int64)))) + (FromYsonSimpleType (SqlAccess 'dict (TryMember row '"_other" (Just (Dict (DictType (DataType '"String") (DataType '"String"))))) (String '"age")) 'Int64) + )))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (Aggregate core '('"age") '('('Count1 (Apply (bind aggregate_module '"count_traits_factory") (TypeOf core) (lambda '(row) (Void))))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" (Member row 'Count1)) '('"age" (Member row '"age")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let output (Sort output '((Bool 'true) (Bool 'true)) (lambda '(item) '((Member item 'column0) (Member item 'age))))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0" '"age"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/LengthOfTableRange.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/LengthOfTableRange.yql new file mode 100644 index 0000000000..40cb4dc92c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/LengthOfTableRange.yql @@ -0,0 +1,16 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let filter (lambda '(name) (And (>= name (String '"Input1")) (<= name (String '"Input3"))))) +(let x (Read! world mr_source (Key '('table (MrTableRange '"" filter))) (Void) '())) +(let world (Left! x)) +(let tables (Right! x)) +(let length (Length tables)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) (Just (AsStruct '('value length))) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) length '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/LengthOfTableStrictRange.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/LengthOfTableStrictRange.yql new file mode 100644 index 0000000000..b52191ad74 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/LengthOfTableStrictRange.yql @@ -0,0 +1,16 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let filter (lambda '(name) (And (>= name (String '"Input1")) (<= name (String '"Input3"))))) +(let x (Read! world mr_source (Key '('table (MrTableRangeStrict '"" filter))) (Void) '())) +(let world (Left! x)) +(let tables (Right! x)) +(let length (Length tables)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) (Just (AsStruct '('value length))) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) length '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/LengthOfTwoTables.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/LengthOfTwoTables.yql new file mode 100644 index 0000000000..6855885d32 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/LengthOfTwoTables.yql @@ -0,0 +1,15 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source '((Key '('table (String 'Input1))) (Key '('table (String 'Input2)))) (Void) '())) +(let world (Left! x)) +(let tables (Right! x)) +(let length (Length tables)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) (Just (AsStruct '('value length))) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) length '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/LengthOfWeakConcatTables.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/LengthOfWeakConcatTables.yql new file mode 100644 index 0000000000..b103b4e66e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/LengthOfWeakConcatTables.yql @@ -0,0 +1,15 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (MrTableConcat (Key '('table (String 'Input1))) (Key '('table (String 'Input2)))) (Void) '())) +(let world (Left! x)) +(let tables (Right! x)) +(let length (Length tables)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) (Just (AsStruct '('value length))) '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) length '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/ManyTableRange.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/ManyTableRange.yql new file mode 100644 index 0000000000..f5612e30a0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/ManyTableRange.yql @@ -0,0 +1,20 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let filter1 (lambda '(name) (And (>= name (String '"Input1")) (<= name (String '"Input1"))))) +(let filter3 (lambda '(name) (And (>= name (String '"Input3")) (<= name (String '"Input3"))))) +(let x (Read! world mr_source '( + (Key '('table (MrTableRange '"" filter1))) + (Key '('table (MrTableRange '"" filter3)))) + (Void) '())) +(let world (Left! x)) +(let tables (Right! x)) +(let tables (Sort tables '((Bool 'true) (Bool 'true)) (lambda '(item) '((Member item 'key) (Member item 'subkey))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) tables '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) tables '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/MapThreeTables.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/MapThreeTables.yql new file mode 100644 index 0000000000..506868f4a8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/MapThreeTables.yql @@ -0,0 +1,28 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) +(let tresh (Int32 '100)) +(let result (FlatMap (Extend table1 (Extend table2 table3)) (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let ret (FlatMap intValueOpt (lambda '(item2) (block '( + (return (ListIf (< item2 tresh) item)) + ))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) result '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/MapTwoTables.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/MapTwoTables.yql new file mode 100644 index 0000000000..aca48ae0c8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/MapTwoTables.yql @@ -0,0 +1,25 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let tresh (Int32 '100)) +(let result (FlatMap (Extend table1 table2) (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let ret (FlatMap intValueOpt (lambda '(item2) (block '( + (return (ListIf (< item2 tresh) item)) + ))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) result '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/Skip.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/Skip.yql new file mode 100644 index 0000000000..1995fa124f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/Skip.yql @@ -0,0 +1,19 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let offset (Uint64 '5)) +(let result (Skip (Extend table1 table2) offset)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) result '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/SkipTakeThenMapTreeTables.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/SkipTakeThenMapTreeTables.yql new file mode 100644 index 0000000000..a4b1c5f1c6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/SkipTakeThenMapTreeTables.yql @@ -0,0 +1,28 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input3))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table3 (Right! x)) +(let e (Extend table1 (Extend table2 table3))) +(let e (Skip e (Uint64 '5))) +(let e (Take e (Uint64 '6))) +(let table1map (Map e (lambda '(item) (block '( + (let value (Member item 'value)) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '""))) + (let s (AddMember s 'value value)) + (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/ManyInputTables/SortTwoTables.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/SortTwoTables.yql new file mode 100644 index 0000000000..799d9cb488 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/SortTwoTables.yql @@ -0,0 +1,24 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let offset (Uint64 '5)) +(let result (Extend table1 table2)) +(let result (Sort result '((Bool 'true) (Bool 'true)) (lambda '(row) (block '( + (let res '((Member row 'key) (Member row 'subkey))) + (return res) +) +)))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) result '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/SplitTableRange.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/SplitTableRange.yql new file mode 100644 index 0000000000..8793b592e7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/SplitTableRange.yql @@ -0,0 +1,16 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"maxinputtables" '"2")) +(let x (Read! world mr_source (Key '('table (MrTableRange '"" (lambda '($i) (And (>= $i (String '"Input1")) (<= $i (String '"Input~")))) '""))) (Void) '())) +(let world (Left! x)) +(let tables (Right! x)) +(let tables (Sort tables '((Bool 'true) (Bool 'true)) (lambda '(item) '((Member item 'key) (Member item 'subkey))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) tables '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) tables '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/TableRange.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/TableRange.yql new file mode 100644 index 0000000000..5e16c9166d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/TableRange.yql @@ -0,0 +1,16 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let filter (lambda '(name) (And (>= name (String '"Input1")) (<= name (String '"Input3"))))) +(let x (Read! world mr_source (Key '('table (MrTableRange '"" filter))) (Void) '())) +(let world (Left! x)) +(let tables (Right! x)) +(let tables (Sort tables '((Bool 'true) (Bool 'true)) (lambda '(item) '((Member item 'key) (Member item 'subkey))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) tables '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) tables '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/TableRangeStrict.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/TableRangeStrict.yql new file mode 100644 index 0000000000..80647dd661 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/TableRangeStrict.yql @@ -0,0 +1,16 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let filter (lambda '(name) (And (>= name (String '"Input1")) (<= name (String '"Input3"))))) +(let x (Read! world mr_source (Key '('table (MrTableRangeStrict '"" filter))) (Void) '())) +(let world (Left! x)) +(let tables (Right! x)) +(let tables (Sort tables '((Bool 'true) (Bool 'true)) (lambda '(item) '((Member item 'key) (Member item 'subkey))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) tables '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) tables '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatOverStrictTableRange.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatOverStrictTableRange.yql new file mode 100644 index 0000000000..3cca68b2ab --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatOverStrictTableRange.yql @@ -0,0 +1,20 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let filter1 (lambda '(name) (And (>= name (String '"Input1")) (<= name (String '"Input1"))))) +(let filter3 (lambda '(name) (And (>= name (String '"Input3")) (<= name (String '"Input3"))))) +(let x (Read! world mr_source (MrTableConcat + (Key '('table (MrTableRangeStrict '"" filter1))) + (Key '('table (MrTableRangeStrict '"" filter3)))) + (Void) '())) +(let world (Left! x)) +(let tables (Right! x)) +(let tables (Sort tables '((Bool 'true) (Bool 'true)) (lambda '(item) '((Member item 'key) (Member item 'subkey))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) tables '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) tables '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatOverTableRange.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatOverTableRange.yql new file mode 100644 index 0000000000..b43c3f66d4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatOverTableRange.yql @@ -0,0 +1,20 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let filter1 (lambda '(name) (And (>= name (String '"Input1")) (<= name (String '"Input1"))))) +(let filter3 (lambda '(name) (And (>= name (String '"Input3")) (<= name (String '"Input3"))))) +(let x (Read! world mr_source (MrTableConcat + (Key '('table (MrTableRange '"" filter1))) + (Key '('table (MrTableRange '"" filter3)))) + (Void) '())) +(let world (Left! x)) +(let tables (Right! x)) +(let tables (Sort tables '((Bool 'true) (Bool 'true)) (lambda '(item) '((Member item 'key) (Member item 'subkey))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) tables '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) tables '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatTables.cfg b/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatTables.cfg new file mode 100644 index 0000000000..a87e460b09 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatTables.cfg @@ -0,0 +1,4 @@ +in Input1 non_ksv_input1.txt +in Input2 non_ksv_input2.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatTables.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatTables.yql new file mode 100644 index 0000000000..a9ac514a99 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatTables.yql @@ -0,0 +1,15 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (MrTableConcat (Key '('table (String 'Input1))) (Key '('table (String 'Input2)))) (Void) '())) +(let world (Left! x)) +(let tables (Right! x)) +(let tables (Sort tables '((Bool 'true) (Bool 'true)) (lambda '(row) '((Member row 'name) (Member row 'name2))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) tables '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) tables '('('type)))) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatTablesBadUnusedColumn.cfg b/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatTablesBadUnusedColumn.cfg new file mode 100644 index 0000000000..d7ef0e0048 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatTablesBadUnusedColumn.cfg @@ -0,0 +1,4 @@ +in Input1 non_ksv_input1_bad.txt +in Input2 non_ksv_input2_bad.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatTablesBadUnusedColumn.yql b/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatTablesBadUnusedColumn.yql new file mode 100644 index 0000000000..da7c64aa5d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/WeakConcatTablesBadUnusedColumn.yql @@ -0,0 +1,15 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (MrTableConcat (Key '('table (String 'Input1))) (Key '('table (String 'Input2)))) '('name 'name2) '())) +(let world (Left! x)) +(let tables (Right! x)) +(let tables (Sort tables '((Bool 'true) (Bool 'true)) (lambda '(row) '((Member row 'name) (Member row 'name2))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) tables '())) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) tables '('('type)))) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/default.cfg b/yql/essentials/tests/s-expressions/suites/ManyInputTables/default.cfg new file mode 100644 index 0000000000..5cdd7ddbf6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/default.cfg @@ -0,0 +1,5 @@ +in Input1 input1.txt +in Input2 input2.txt +in Input3 input3.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/input1.txt b/yql/essentials/tests/s-expressions/suites/ManyInputTables/input1.txt new file mode 100644 index 0000000000..f53757c309 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/input1.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="800";"subkey"="1";"value"="ddd"}; +{"key"="020";"subkey"="1";"value"="q"}; +{"key"="150";"subkey"="1";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/input1.txt.attr b/yql/essentials/tests/s-expressions/suites/ManyInputTables/input1.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/input1.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/ManyInputTables/input2.txt b/yql/essentials/tests/s-expressions/suites/ManyInputTables/input2.txt new file mode 100644 index 0000000000..07af3b4647 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/input2.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="2";"value"="abc"}; +{"key"="800";"subkey"="2";"value"="ddd"}; +{"key"="020";"subkey"="2";"value"="q"}; +{"key"="150";"subkey"="2";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/input2.txt.attr b/yql/essentials/tests/s-expressions/suites/ManyInputTables/input2.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/input2.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/ManyInputTables/input3.txt b/yql/essentials/tests/s-expressions/suites/ManyInputTables/input3.txt new file mode 100644 index 0000000000..7a155c91b8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/input3.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="3";"value"="abc"}; +{"key"="800";"subkey"="3";"value"="ddd"}; +{"key"="020";"subkey"="3";"value"="q"}; +{"key"="150";"subkey"="3";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/input3.txt.attr b/yql/essentials/tests/s-expressions/suites/ManyInputTables/input3.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/input3.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/ManyInputTables/non_ksv_input1.txt b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input1.txt new file mode 100644 index 0000000000..dd7dace4b5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input1.txt @@ -0,0 +1,6 @@ +{"age"=30;"name"="bob"}; +{"age"=16;"name"="alice"}; +{"age"=55;"name"="jone"}; +{"age"=45;"name"="silver"}; +{"age"=45;"name"="smith"}; +{"age"=90;"name"="stive"}; diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input1.txt.attr b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input1.txt.attr new file mode 100644 index 0000000000..984ced0f70 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input1.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"Type"=["StructType";[["age";["DataType";"Int64"]];["name";["DataType";"String"]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input1_bad.txt b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input1_bad.txt new file mode 100644 index 0000000000..dd7dace4b5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input1_bad.txt @@ -0,0 +1,6 @@ +{"age"=30;"name"="bob"}; +{"age"=16;"name"="alice"}; +{"age"=55;"name"="jone"}; +{"age"=45;"name"="silver"}; +{"age"=45;"name"="smith"}; +{"age"=90;"name"="stive"}; diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input1_bad.txt.attr b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input1_bad.txt.attr new file mode 100644 index 0000000000..1ceba168e8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input1_bad.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"Type"=["StructType";[["age";["DataType";"Int32"]];["name";["DataType";"String"]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input2.txt b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input2.txt new file mode 100644 index 0000000000..72d5cb8767 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input2.txt @@ -0,0 +1,6 @@ +{"age"=30u;"name2"="bob"}; +{"age"=16u;"name2"="alice"}; +{"age"=55u;"name2"="jone"}; +{"age"=45u;"name2"="silver"}; +{"age"=45u;"name2"="smith"}; +{"age"=90u;"name2"="stive"}; diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input2.txt.attr b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input2.txt.attr new file mode 100644 index 0000000000..f6fe260020 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input2.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"Type"=["StructType";[["age";["DataType";"Uint32"]];["name2";["DataType";"String"]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input2_bad.txt b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input2_bad.txt new file mode 100644 index 0000000000..72d5cb8767 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input2_bad.txt @@ -0,0 +1,6 @@ +{"age"=30u;"name2"="bob"}; +{"age"=16u;"name2"="alice"}; +{"age"=55u;"name2"="jone"}; +{"age"=45u;"name2"="silver"}; +{"age"=45u;"name2"="smith"}; +{"age"=90u;"name2"="stive"}; diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input2_bad.txt.attr b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input2_bad.txt.attr new file mode 100644 index 0000000000..e74a1cdc27 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input2_bad.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"Type"=["StructType";[["age";["OptionalType";["DataType";"Uint32"]]];["name2";["DataType";"String"]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input3.txt b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input3.txt new file mode 100644 index 0000000000..dfe71abfe7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input3.txt @@ -0,0 +1,6 @@ +{"age"=30;"name2"="bob"}; +{"age"=16;"name2"="alice"}; +{"age"=55;"name2"="jone"}; +{"age"=45;"name2"="silver"}; +{"age"=45;"name2"="smith"}; +{"age"=90;"name2"="stive"}; diff --git a/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input3.txt.attr b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input3.txt.attr new file mode 100644 index 0000000000..1c447d3475 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyInputTables/non_ksv_input3.txt.attr @@ -0,0 +1,10 @@ +{ + "schema" = < + "strict" = %false; + "unique_keys" = %false + > + [{ + "name" = "missing"; + "type" = "string" + }]; +} diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465.cfg b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465.cfg new file mode 100644 index 0000000000..ac8f608e62 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465.cfg @@ -0,0 +1,6 @@ +in hits Bug1465_hits.txt +out out1 out1.txt +out out2 out2.txt +res result.txt +udf url_udf +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465.sql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465.sql new file mode 100644 index 0000000000..f8488fb2e1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465.sql @@ -0,0 +1,181 @@ +USE hahn; + +$minus_date = Python::minus_date( + @@(String?,String?)->Int64@@, + @@ +from datetime import datetime, timedelta +def minus_date(date1, date2): + return (datetime.strptime(date1, "%Y-%m-%d") - datetime.strptime(date2, "%Y-%m-%d")).days + @@ +); + +$normalize_list = Python::normalize_list( + @@(List<Tuple<Int64,Int64?>>)->List<Tuple<Int64,Int64>>@@, + @@ +def normalize_list(values): + return sorted((x, y) for x, y in values if y) + @@ +); + +$urls = ( +FROM hits +SELECT url AS Url, "2016-10-25" AS Date +GROUP BY url +); + +$flatten_factors = ( +FROM $urls AS target +INNER JOIN hits AS history +ON target.Url == history.url +SELECT + target.Url AS Url, + target.Date AS Date, + history.* +); + +INSERT INTO [Out1] WITH TRUNCATE FROM $flatten_factors SELECT *; +COMMIT; + +$pool = ( +FROM [Out1] +SELECT + Url, + Date, + Url::GetHost(Url) AS Host +/* $normalize_list(LIST(($minus_date(Date, [history.date]), [history.metrika_all_total]))) AS metrika_all_total +/* $normalize_list(LIST(($minus_date(Date, [history.date]), [history.yabro_mobile_unique]))) AS yabro_mobile_unique, + $normalize_list(LIST(($minus_date(Date, [history.date]), [history.metrika_counter_count]))) AS metrika_counter_count, + $normalize_list(LIST(($minus_date(Date, [history.date]), [history.metrika_yabro_desktop_total]))) AS metrika_yabro_desktop_total, + $normalize_list(LIST(($minus_date(Date, [history.date]), [history.metrika_yabro_desktop_unique]))) AS metrika_yabro_desktop_unique, + $normalize_list(LIST(($minus_date(Date, [history.date]), [history.metrika_all_unique]))) AS metrika_all_unique, + $normalize_list(LIST(($minus_date(Date, [history.date]), [history.metrika_yabro_mobile_unique]))) AS metrika_yabro_mobile_unique, + $normalize_list(LIST(($minus_date(Date, [history.date]), [history.yabro_desktop_total]))) AS yabro_desktop_total, + $normalize_list(LIST(($minus_date(Date, [history.date]), [history.yabro_desktop_unique]))) AS yabro_desktop_unique, + $normalize_list(LIST(($minus_date(Date, [history.date]), [history.yabro_mobile_total]))) AS yabro_mobile_total, + $normalize_list(LIST(($minus_date(Date, [history.date]), [history.metrika_yabro_mobile_total]))) AS metrika_yabro_mobile_total, + $normalize_list(LIST(($minus_date(Date, [history.date]), [history.cs_clicks]))) AS cs_clicks, + $normalize_list(LIST(($minus_date(Date, [history.date]), [history.cs_shows]))) AS cs_shows*/ +GROUP BY Url, Date +); + +$hosts = ( +FROM $pool +SELECT Host, "2016-10-25" AS Date +GROUP BY Host +); + +$host_features = ( +FROM $hosts AS hosts +LEFT JOIN hits AS all_hits +ON hosts.Host == Url::GetHost(all_hits.url) +SELECT + hosts.Host AS Host, + hosts.Date AS Date, +/* SUM(all_hits.metrika_all_total) AS metrika_all_total_sum7, +/* MAX(all_hits.metrika_all_total) AS metrika_all_total_max7, +-- STDDEV(all_hits.metrika_all_total) AS metrika_all_total_stddev7, + MEDIAN(all_hits.metrika_all_total) AS metrika_all_total_median7, + PERCENTILE(all_hits.metrika_all_total, 0.25) AS metrika_all_total_25perc7, + PERCENTILE(all_hits.metrika_all_total, 0.75) AS metrika_all_total_75perc7, + COUNT_IF(all_hits.metrika_all_total > 0) AS metrika_all_total_nonzero7, + SUM(all_hits.yabro_mobile_unique) AS yabro_mobile_unique_sum7, + MAX(all_hits.yabro_mobile_unique) AS yabro_mobile_unique_max7, +-- STDDEV(all_hits.yabro_mobile_unique) AS yabro_mobile_unique_stddev7, + MEDIAN(all_hits.yabro_mobile_unique) AS yabro_mobile_unique_median7, + PERCENTILE(all_hits.yabro_mobile_unique, 0.25) AS yabro_mobile_unique_25perc7, + PERCENTILE(all_hits.yabro_mobile_unique, 0.75) AS yabro_mobile_unique_75perc7, + COUNT_IF(all_hits.yabro_mobile_unique > 0) AS yabro_mobile_unique_nonzero7, + SUM(all_hits.metrika_counter_count) AS metrika_counter_count_sum7, + MAX(all_hits.metrika_counter_count) AS metrika_counter_count_max7, +-- STDDEV(all_hits.metrika_counter_count) AS metrika_counter_count_stddev7, + MEDIAN(all_hits.metrika_counter_count) AS metrika_counter_count_median7, + PERCENTILE(all_hits.metrika_counter_count, 0.25) AS metrika_counter_count_25perc7, + PERCENTILE(all_hits.metrika_counter_count, 0.75) AS metrika_counter_count_75perc7, + COUNT_IF(all_hits.metrika_counter_count > 0) AS metrika_counter_count_nonzero7, + SUM(all_hits.metrika_yabro_desktop_total) AS metrika_yabro_desktop_total_sum7, + MAX(all_hits.metrika_yabro_desktop_total) AS metrika_yabro_desktop_total_max7, +-- STDDEV(all_hits.metrika_yabro_desktop_total) AS metrika_yabro_desktop_total_stddev7, + MEDIAN(all_hits.metrika_yabro_desktop_total) AS metrika_yabro_desktop_total_median7, + PERCENTILE(all_hits.metrika_yabro_desktop_total, 0.25) AS metrika_yabro_desktop_total_25perc7, + PERCENTILE(all_hits.metrika_yabro_desktop_total, 0.75) AS metrika_yabro_desktop_total_75perc7, + COUNT_IF(all_hits.metrika_yabro_desktop_total > 0) AS metrika_yabro_desktop_total_nonzero7, + SUM(all_hits.metrika_yabro_desktop_unique) AS metrika_yabro_desktop_unique_sum7, + MAX(all_hits.metrika_yabro_desktop_unique) AS metrika_yabro_desktop_unique_max7, +-- STDDEV(all_hits.metrika_yabro_desktop_unique) AS metrika_yabro_desktop_unique_stddev7, + MEDIAN(all_hits.metrika_yabro_desktop_unique) AS metrika_yabro_desktop_unique_median7, + PERCENTILE(all_hits.metrika_yabro_desktop_unique, 0.25) AS metrika_yabro_desktop_unique_25perc7, + PERCENTILE(all_hits.metrika_yabro_desktop_unique, 0.75) AS metrika_yabro_desktop_unique_75perc7, + COUNT_IF(all_hits.metrika_yabro_desktop_unique > 0) AS metrika_yabro_desktop_unique_nonzero7, + SUM(all_hits.metrika_all_unique) AS metrika_all_unique_sum7, + MAX(all_hits.metrika_all_unique) AS metrika_all_unique_max7, +-- STDDEV(all_hits.metrika_all_unique) AS metrika_all_unique_stddev7, + MEDIAN(all_hits.metrika_all_unique) AS metrika_all_unique_median7, + PERCENTILE(all_hits.metrika_all_unique, 0.25) AS metrika_all_unique_25perc7, + PERCENTILE(all_hits.metrika_all_unique, 0.75) AS metrika_all_unique_75perc7, + COUNT_IF(all_hits.metrika_all_unique > 0) AS metrika_all_unique_nonzero7, + SUM(all_hits.metrika_yabro_mobile_unique) AS metrika_yabro_mobile_unique_sum7, + MAX(all_hits.metrika_yabro_mobile_unique) AS metrika_yabro_mobile_unique_max7, +-- STDDEV(all_hits.metrika_yabro_mobile_unique) AS metrika_yabro_mobile_unique_stddev7, + MEDIAN(all_hits.metrika_yabro_mobile_unique) AS metrika_yabro_mobile_unique_median7, + PERCENTILE(all_hits.metrika_yabro_mobile_unique, 0.25) AS metrika_yabro_mobile_unique_25perc7, + PERCENTILE(all_hits.metrika_yabro_mobile_unique, 0.75) AS metrika_yabro_mobile_unique_75perc7, + COUNT_IF(all_hits.metrika_yabro_mobile_unique > 0) AS metrika_yabro_mobile_unique_nonzero7, + SUM(all_hits.yabro_desktop_total) AS yabro_desktop_total_sum7, + MAX(all_hits.yabro_desktop_total) AS yabro_desktop_total_max7, +-- STDDEV(all_hits.yabro_desktop_total) AS yabro_desktop_total_stddev7, + MEDIAN(all_hits.yabro_desktop_total) AS yabro_desktop_total_median7, + PERCENTILE(all_hits.yabro_desktop_total, 0.25) AS yabro_desktop_total_25perc7, + PERCENTILE(all_hits.yabro_desktop_total, 0.75) AS yabro_desktop_total_75perc7, + COUNT_IF(all_hits.yabro_desktop_total > 0) AS yabro_desktop_total_nonzero7, + SUM(all_hits.yabro_desktop_unique) AS yabro_desktop_unique_sum7, + MAX(all_hits.yabro_desktop_unique) AS yabro_desktop_unique_max7, +-- STDDEV(all_hits.yabro_desktop_unique) AS yabro_desktop_unique_stddev7, + MEDIAN(all_hits.yabro_desktop_unique) AS yabro_desktop_unique_median7, + PERCENTILE(all_hits.yabro_desktop_unique, 0.25) AS yabro_desktop_unique_25perc7, + PERCENTILE(all_hits.yabro_desktop_unique, 0.75) AS yabro_desktop_unique_75perc7, + COUNT_IF(all_hits.yabro_desktop_unique > 0) AS yabro_desktop_unique_nonzero7, + SUM(all_hits.yabro_mobile_total) AS yabro_mobile_total_sum7, + MAX(all_hits.yabro_mobile_total) AS yabro_mobile_total_max7, +-- STDDEV(all_hits.yabro_mobile_total) AS yabro_mobile_total_stddev7, + MEDIAN(all_hits.yabro_mobile_total) AS yabro_mobile_total_median7, + PERCENTILE(all_hits.yabro_mobile_total, 0.25) AS yabro_mobile_total_25perc7, + PERCENTILE(all_hits.yabro_mobile_total, 0.75) AS yabro_mobile_total_75perc7, + COUNT_IF(all_hits.yabro_mobile_total > 0) AS yabro_mobile_total_nonzero7, + SUM(all_hits.metrika_yabro_mobile_total) AS metrika_yabro_mobile_total_sum7, + MAX(all_hits.metrika_yabro_mobile_total) AS metrika_yabro_mobile_total_max7, +-- STDDEV(all_hits.metrika_yabro_mobile_total) AS metrika_yabro_mobile_total_stddev7, + MEDIAN(all_hits.metrika_yabro_mobile_total) AS metrika_yabro_mobile_total_median7, + PERCENTILE(all_hits.metrika_yabro_mobile_total, 0.25) AS metrika_yabro_mobile_total_25perc7, + PERCENTILE(all_hits.metrika_yabro_mobile_total, 0.75) AS metrika_yabro_mobile_total_75perc7, + COUNT_IF(all_hits.metrika_yabro_mobile_total > 0) AS metrika_yabro_mobile_total_nonzero7,*/ + COUNT(*) AS url_day_count, + COUNT(DISTINCT(all_hits.url)) AS url_count +GROUP BY hosts.Host, hosts.Date +); + +INSERT INTO [Out2] WITH TRUNCATE +FROM $pool AS pool +LEFT JOIN $host_features AS host +ON Url::GetHost(pool.Url) == host.Host AND pool.Date == host.Date +SELECT *; +/* pool.Date AS Date, + pool.yabro_mobile_unique AS yabro_mobile_unique, + pool.Url AS Url, + pool.cs_clicks AS cs_clicks, + pool.cs_shows AS cs_shows, + pool.metrika_all_total AS metrika_all_total, + pool.metrika_all_unique AS metrika_all_unique, + pool.Host AS Host, + pool.metrika_yabro_desktop_total AS metrika_yabro_desktop_total, + pool.metrika_yabro_desktop_unique AS metrika_yabro_desktop_unique, + pool.metrika_yabro_mobile_total AS metrika_yabro_mobile_total, + pool.metrika_yabro_mobile_unique AS metrika_yabro_mobile_unique, + pool.yabro_desktop_total AS yabro_desktop_total, + pool.yabro_desktop_unique AS yabro_desktop_unique, + pool.yabro_mobile_total AS yabro_mobile_total, + pool.metrika_counter_count AS metrika_counter_count, + host.*;*/ + +COMMIT; +DROP TABLE [Out1]; + diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465.yql new file mode 100644 index 0000000000..eaa0d95edb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465.yql @@ -0,0 +1,192 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"hits"))) (Void) '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let values (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core (EquiJoin '((block '( + (let select (block '( + (let core table0) + (let core (block '( + (return (Aggregate core '('"url") '())) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"Url" (Member row '"url"))) + (let res (AddMember res '"Date" (String '"2016-10-25"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"target") '(table0 '"history") '('Inner '"target" '"history" '('"target" '"Url") '('"history" '"url") '()) '())) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (SelectMembers row '('"history."))) + (let res (AddMember res '"Url" (Member row '"target.Url"))) + (let res (AddMember res '"Date" (Member row '"target.Date"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"out1"))) values '('('mode 'renew)))) + (return world) + ))) + (return world) +))) +(let world (block '( + (let hahn_sink (DataSink '"yt" '"plato")) + (let world (Commit! world hahn_sink)) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"out1"))) '('"Url" '"Date") '())) + (let world (Left! x)) + (let table3 (Right! x)) + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"hits"))) '('"url") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let values (block '( + (let select (block '( + (let core (Map (EquiJoin '((Map (block '( + (let select (block '( + (let core table3) + (let core (block '( + (return (Aggregate core '('"Date" '"Url") '())) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"Url" (Member row '"Url"))) + (let res (AddMember res '"Date" (Member row '"Date"))) + (let res (AddMember res '"Host" ("Apply" ("Udf" '"Url.GetHost") (Member row '"Url")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) (lambda '(row) (block '( + (let row (AddMember row '"_equijoin_column_0" ("Apply" ("Udf" '"Url.GetHost") (Member row '"Url")))) + (return row) + )))) '"pool") '((block '( + (let select (block '( + (let core (Map (EquiJoin '((block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table3) + (let core (block '( + (return (Aggregate core '('"Date" '"Url") '())) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"Url" (Member row '"Url"))) + (let res (AddMember res '"Date" (Member row '"Date"))) + (let res (AddMember res '"Host" ("Apply" ("Udf" '"Url.GetHost") (Member row '"Url")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (return (Aggregate core '('"Host") '())) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"Host" (Member row '"Host"))) + (let res (AddMember res '"Date" (String '"2016-10-25"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"hosts") '((Map table0 (lambda '(row) (block '( + (let row (AddMember row '"_equijoin_column_0" ("Apply" ("Udf" '"Url.GetHost") (Member row '"url")))) + (return row) + )))) '"all_hits") '('Left '"hosts" '"all_hits" '('"hosts" '"Host") '('"all_hits" '"_equijoin_column_0") '()) '()) (lambda '(row) (block '( + (let row (ForceRemoveMember row '"all_hits._equijoin_column_0")) + (return row) + ))))) + (let core (block '( + (let Count4_create (lambda '(row) (Uint64 '1))) + (let Count4_update (lambda '(row state) (OptionalReduce state (Uint64 '1) (lambda '(a b) (+ a b))))) + (let Count4_save (lambda '(state) state)) + (let Count4_load (lambda '(item) item)) + (let Count4_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Count4_finish (lambda '(state) state)) + (let Count5_create (lambda '(row) (Convert (Exists row) 'Uint64))) + (let Count5_update (lambda '(row state) (OptionalReduce state (Convert (Exists row) 'Uint64) (lambda '(a b) (+ a b))))) + (let Count5_save (lambda '(state) state)) + (let Count5_load (lambda '(item) item)) + (let Count5_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Count5_finish (lambda '(state) state)) + (return (Aggregate core '('"hosts.Date" '"hosts.Host") '('('Count4 (AggregationTraits (ListItemType (TypeOf core)) Count4_create Count4_update Count4_save Count4_load Count4_merge Count4_finish (Uint64 '0))) '('Count5 (AggregationTraits (StructMemberType (ListItemType (TypeOf core)) '"all_hits.url") Count5_create Count5_update Count5_save Count5_load Count5_merge Count5_finish (Uint64 '0)) '"all_hits.url")))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"Host" (Member row '"hosts.Host"))) + (let res (AddMember res '"Date" (Member row '"hosts.Date"))) + (let res (AddMember res '"url_day_count" (Member row 'Count4))) + (let res (AddMember res '"url_count" (Member row 'Count5))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"host") '('Left '"pool" '"host" '('"pool" '"_equijoin_column_0" '"pool" '"Date") '('"host" '"Host" '"host" '"Date") '()) '()) (lambda '(row) (block '( + (let row (ForceRemoveMember row '"pool._equijoin_column_0")) + (return row) + ))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"out2"))) values '('('mode 'renew)))) + (return world) + ))) + (return world) +))) +(let world (block '( + (let hahn_sink (DataSink '"yt" '"plato")) + (let world (Commit! world hahn_sink)) + (return world) +))) +(let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"out1"))) (Void) '('('mode 'drop)))) + (return world) +))) +(let world (block '( + (let hahn_sink (DataSink '"yt" '"plato")) + (let world (Commit! world hahn_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465_hits.txt b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465_hits.txt new file mode 100644 index 0000000000..d122076744 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465_hits.txt @@ -0,0 +1 @@ +{"history.date"="20016-01-01";"url"="http://ya.ru"}; diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465_hits.txt.attr b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465_hits.txt.attr new file mode 100644 index 0000000000..56aac6ba29 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1465_hits.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"Type"=["StructType";[["url";["OptionalType";["DataType";"String"]]];["history.date";["OptionalType";["DataType";"String"]]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1941.sql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1941.sql new file mode 100644 index 0000000000..c5ed4796d9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1941.sql @@ -0,0 +1,5 @@ +USE plato; + +SELECT sum(count) from ( +select count(*) as count from Input WHERE key < "100" +); diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1941.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1941.yql new file mode 100644 index 0000000000..a8908a0100 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/Bug1941.yql @@ -0,0 +1,47 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) '('"key") '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table1) + (let core (Filter core (lambda '(row) (Coalesce ("<" (Member row '"key") (String '"100")) (Bool 'false))))) + (let core (Just (AsStruct '('Count0 (Length core))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"count" (Member row 'Count0)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (Aggregate core '() '('('Sum2 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"count"))))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" (Member row 'Sum2)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/CombineThenGroup.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/CombineThenGroup.yql new file mode 100644 index 0000000000..5a39b90887 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/CombineThenGroup.yql @@ -0,0 +1,39 @@ +( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key" '"subkey" '"value") '())) + (let world (Left! x)) + (let table0 (Right! x)) + + (let preMap (lambda '(item) (Just item))) + (let keyExtractor (lambda '(item) (Member item 'key))) + (let init (lambda '(key item) (Member item 'value))) + (let update (lambda '(key item state) (Concat state (Member item 'value)))) + (let finish (lambda '(key state) (block '( + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value state)) + (return (Just s)) + )))) + (let combine (CombineByKey table0 preMap keyExtractor init update finish)) + + (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 value (Fold1 list + (lambda '(item) (Member item 'value)) + (lambda '(item state) (Concat state (Member item 'value))) + )) + (let s (AddMember s 'value (Coalesce value (String '"")))) + (let ret (AsList s)) + (return ret) + )))))) + (let reducedTable (PartitionByKey combine keyExtractor (Void) (Void) 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/ManyYamrOperations/CombineThenSort.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/CombineThenSort.yql new file mode 100644 index 0000000000..c9f35934d8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/CombineThenSort.yql @@ -0,0 +1,30 @@ +( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key" '"subkey" '"value") '())) + (let world (Left! x)) + (let table0 (Right! x)) + + (let map (FlatMap table0 (lambda '(row) (block '( + (let key (MatchType (Member row '"key") 'Optional (lambda '(item) (Coalesce (Map item (lambda '(val) (IfType val (DataType 'String) (lambda '(item) (FromString item '"Int64")) (lambda '(item) (Just (Convert item '"Int64")))))) (Nothing (OptionalType (DataType '"Int64"))))) (lambda '(item) (IfType item (DataType 'String) (lambda '(item) (FromString item '"Int64")) (lambda '(item) (Convert item '"Int64")))))) + (let res (Struct)) + (let res (AddMember res '"Avg1" '(key (Convert (Exists key) 'Uint64)))) + (let res (AsList res)) + (return res) + ))))) + (let combine (CombineByKey map (lambda '(row) (Just row)) (lambda '(row) (Uint64 '0)) (lambda '(key row) row) (lambda '(key row state) state) (lambda '(key state) (Just state)))) + (let result (FlatMap combine (lambda '(row) (block '( + (let p0 (Nth (Member row 'Avg1) '0)) + (let p1 (Nth (Member row 'Avg1) '1)) + (let res (Struct)) + (let res (AddMember res '"keyAvg" ( + FlatMap p0 (lambda '(value) (Just (Coalesce (Div (Convert value 'Double) (Convert p1 'Double)) (Double '0)))) + ))) + (let res (AsList res)) + (return res) + ))))) + (let sortAfterCombine (Sort result (Bool 'false) (lambda '(x) (Member x 'keyAvg) ))) + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) sortAfterCombine '('('type) '('autoref)))) + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return (Commit! world result_sink)) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/MapCombineMap.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/MapCombineMap.yql new file mode 100644 index 0000000000..fd5d2eb0e7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/MapCombineMap.yql @@ -0,0 +1,29 @@ +( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key" '"subkey" '"value") '())) + (let world (Left! x)) + (let table0 (Right! x)) + + (let map (FlatMap table0 (lambda '(row) (block '( + (let key (MatchType (Member row '"key") 'Optional (lambda '(item) (Coalesce (Map item (lambda '(val) (IfType val (DataType 'String) (lambda '(item) (FromString item '"Int64")) (lambda '(item) (Just (Convert item '"Int64")))))) (Nothing (OptionalType (DataType '"Int64"))))) (lambda '(item) (IfType item (DataType 'String) (lambda '(item) (FromString item '"Int64")) (lambda '(item) (Convert item '"Int64")))))) + (let res (Struct)) + (let res (AddMember res '"Avg1" '(key (Convert (Exists key) 'Uint64)))) + (let res (AsList res)) + (return res) + ))))) + (let combine (CombineByKey map (lambda '(row) (Just row)) (lambda '(row) (Uint64 '0)) (lambda '(key row) row) (lambda '(key row state) state) (lambda '(key state) (Just state)))) + (let result (FlatMap combine (lambda '(row) (block '( + (let p0 (Nth (Member row 'Avg1) '0)) + (let p1 (Nth (Member row 'Avg1) '1)) + (let res (Struct)) + (let res (AddMember res '"keyAvg" ( + FlatMap p0 (lambda '(value) (Just (Coalesce (Div (Convert value 'Double) (Convert p1 'Double)) (Double '0)))) + ))) + (let res (AsList res)) + (return res) + ))))) + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) result '('('type) '('autoref)))) + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return (Commit! world result_sink)) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/MapThenExtend.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/MapThenExtend.yql new file mode 100644 index 0000000000..d8c639d055 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/MapThenExtend.yql @@ -0,0 +1,18 @@ +( +#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 s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '1))) + (let s (AddMember s 'value (String 'v))) + (return s) +))))) +(let mr_sink (DataSink 'yt 'plato)) +(let world (Write! world mr_sink (Key '('table (String 'Output))) (Extend table1map table1map) '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/MapThenGroup.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/MapThenGroup.yql new file mode 100644 index 0000000000..6248b7416e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/MapThenGroup.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 tresh (Int32 'x"64000000")) +(let table1low (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let ret (FlatMap intValueOpt (lambda '(item2) (block '( + (let s (ListIf (< item2 tresh) item)) + (return s) + ))))) + (return ret) +))))) +(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 table1low keySelector (Void) (Void) 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/ManyYamrOperations/MapThenSort.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/MapThenSort.yql new file mode 100644 index 0000000000..fd736cacf2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/MapThenSort.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 tresh (Int32 'x"64000000")) +(let table1low (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let ret (FlatMap intValueOpt (lambda '(item2) (block '( + (let s (ListIf (< item2 tresh) item)) + (return s) + ))))) + (return ret) +))))) +(let table1sorted (Sort table1low (Bool 'true) (lambda '(item) (Member item 'key)))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1sorted '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/MapWithReadTable.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/MapWithReadTable.yql new file mode 100644 index 0000000000..c276a9e835 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/MapWithReadTable.yql @@ -0,0 +1,53 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key") '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let output (block '( + (let select (block '( + (let core table1) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"column0" ("Concat" (Member row '"key") ("Coalesce" (Member (MatchType (block '( + (let select (block '( + (let core table1) + (let core (block '( + (let Min0_create (lambda '(row) (Member row '"key"))) + (let Min0_update (lambda '(row state) (OptionalReduce state (Member row '"key") (lambda '(a b) (Min a b))))) + (let Min0_save (lambda '(state) state)) + (let Min0_load (lambda '(item) item)) + (let Min0_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (Min a b))))) + (let Min0_finish (lambda '(state) state)) + (return (Aggregate core '() '('('Min0 (AggregationTraits (ListItemType (TypeOf core)) Min0_create Min0_update Min0_save Min0_load Min0_merge Min0_finish (Null)))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row 'Min0))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) 'Dict (lambda '(dict) (Lookup dict (Int64 '"0"))) (lambda '(list) (Lookup (ToIndexDict list) (Int64 '"0")))) '"key") (String '""))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/ReduceThenMap.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/ReduceThenMap.yql new file mode 100644 index 0000000000..df91ac7aab --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/ReduceThenMap.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 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 (Void) (Void) listHandler)) +(let filterAfterReduce (Filter reducedTable (lambda '(x) (block '( + (return (> (Member x 'value) (String '1))) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) filterAfterReduce '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/ReduceThenSort.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/ReduceThenSort.yql new file mode 100644 index 0000000000..420d463be3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/ReduceThenSort.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 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 (Concat (ToString (Length list)) key))) + (let ret (AsList s)) + (return ret) +)))))) +(let reducedTable (PartitionByKey table1 keySelector (Void) (Void) listHandler)) +(let sortAfterReduce (Sort reducedTable (Bool 'false) (lambda '(x) (Member x 'value) ))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) sortAfterReduce '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/TakeThenMap.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/TakeThenMap.yql new file mode 100644 index 0000000000..f1dfaf4ca4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/TakeThenMap.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 tresh (Int32 'x"64000000")) +(let table1low (FlatMap (Take table1 (Uint64 '3)) (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let ret (FlatMap intValueOpt (lambda '(item2) (block '( + (let s (ListIf (< item2 tresh) item)) + (return s) + ))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/YQL-1733_1.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/YQL-1733_1.yql new file mode 100644 index 0000000000..5e6aec09e8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/YQL-1733_1.yql @@ -0,0 +1,85 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) '('"key" '"value") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"subkey" (String '""))) + (let res (AddMember res '"value" ("Concat" (String '"value:") (Member row '"value")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (let select (Sort select (Bool 'true) (lambda '(row) (Member row '"key")))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (let select (Take select (Int32 '"2"))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) '('"key" '"value") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let values (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"subkey" (String '""))) + (let res (AddMember res '"value" ("Concat" (String '"value:") (Member row '"value")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (let select (Sort select (Bool 'true) (lambda '(row) (Member row '"key")))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"Output"))) values '('('mode 'append)))) + (return world) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/YQL-1733_2.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/YQL-1733_2.yql new file mode 100644 index 0000000000..6c2634f9ad --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/YQL-1733_2.yql @@ -0,0 +1,86 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) '('"key" '"value") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"subkey" (String '""))) + (let res (AddMember res '"value" ("Concat" (String '"value:") (Member row '"value")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (let select (Sort select (Bool 'true) (lambda '(row) (Member row '"key")))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (let select (Take select (Int32 '"2"))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) '('"key" '"value") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let values (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"subkey" (String '""))) + (let res (AddMember res '"value" ("Concat" (String '"value:") (Member row '"value")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (let select (Sort select (Bool 'true) (lambda '(row) (Member row '"key")))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (let select (Take select (Int32 '"3"))) + (return select) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"Output"))) values '('('mode 'append)))) + (return world) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/default.cfg b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/default.cfg new file mode 100644 index 0000000000..fe2b19a9ff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/default.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/ManyYamrOperations/input.txt b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/input.txt new file mode 100644 index 0000000000..d77d384ae6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/input.txt @@ -0,0 +1,5 @@ +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="075";"subkey"="2";"value"="qqqw"}; +{"key"="800";"subkey"="3";"value"="ddd"}; +{"key"="020";"subkey"="4";"value"="q"}; +{"key"="150";"subkey"="5";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/input.txt.attr b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrOperations/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/ManyYamrTransactions/default.cfg b/yql/essentials/tests/s-expressions/suites/ManyYamrTransactions/default.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrTransactions/default.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrTransactions/input.txt b/yql/essentials/tests/s-expressions/suites/ManyYamrTransactions/input.txt new file mode 100644 index 0000000000..65949ea745 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrTransactions/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/ManyYamrTransactions/input.txt.attr b/yql/essentials/tests/s-expressions/suites/ManyYamrTransactions/input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrTransactions/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/ManyYamrTransactions/program1.cfg b/yql/essentials/tests/s-expressions/suites/ManyYamrTransactions/program1.cfg new file mode 100644 index 0000000000..5baea08e78 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrTransactions/program1.cfg @@ -0,0 +1,3 @@ +in Input input.txt +out Output output.txt +out Output2 output2.txt diff --git a/yql/essentials/tests/s-expressions/suites/ManyYamrTransactions/program1.yql b/yql/essentials/tests/s-expressions/suites/ManyYamrTransactions/program1.yql new file mode 100644 index 0000000000..8ebe956e7c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/ManyYamrTransactions/program1.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 tresh (Int32 'x"64000000")) +(let table1low (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let ret (FlatMap intValueOpt (lambda '(item2) (block '( + (return (ListIf (< item2 tresh) item)) + ))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('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 world (Write! world mr_sink (Key '('table (String 'Output2))) table2 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/LMapWithMultiIn.yql b/yql/essentials/tests/s-expressions/suites/MultiIO/LMapWithMultiIn.yql new file mode 100644 index 0000000000..261a85c931 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/LMapWithMultiIn.yql @@ -0,0 +1,42 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) + +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let data1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let data2 (Right! x)) + +(let data (Mux '(data1 data2))) + +(let data (LMap data (lambda '(stream) (block '( + (return (FlatMap stream (lambda '(item) (block '( + (let res (Visit item + '0 (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '0))) + (let s (AddMember s 'value (Member item 'value))) + (return s) + ))) + '1 (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '1))) + (let s (AddMember s 'value (Member item 'value))) + (return s) + ))) + )) + (return (Just res)) + ))))) +))))) + +(let world (Write! world mr_sink (Key '('table (String 'Output1))) data '('('mode 'renew)))) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/LMapWithMultiOut.yql b/yql/essentials/tests/s-expressions/suites/MultiIO/LMapWithMultiOut.yql new file mode 100644 index 0000000000..aeefafd75f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/LMapWithMultiOut.yql @@ -0,0 +1,43 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) + +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let data (Right! x)) + +(let varTuple (VariantType (TupleType + (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) + ) + (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) + ) +))) + +(let data (LMap data (lambda '(stream) (block '( + (return (FlatMap stream (lambda '(item) (block '( + (let intValue (FromString (Member item 'key) 'Int32)) + (let res + (If (Coalesce (Equal (% intValue (Int32 '2)) (Int32 '0)) (Bool 'false)) + (Variant item '0 varTuple) + (Variant item '1 varTuple) + ) + ) + (return (Just res)) + ))))) +))))) + +(let dataTuple (Demux data)) + +(let world (Write! world mr_sink (Key '('table (String 'Output1))) (Nth dataTuple '0) '('('mode 'renew)))) +(let world (Write! world mr_sink (Key '('table (String 'Output2))) (Nth dataTuple '1) '('('mode 'renew)))) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/MapOverDemux.yql b/yql/essentials/tests/s-expressions/suites/MultiIO/MapOverDemux.yql new file mode 100644 index 0000000000..4697cb40ba --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/MapOverDemux.yql @@ -0,0 +1,45 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) + +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let data (Right! x)) + +(let varTuple (VariantType (TupleType + (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) + ) + (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) + ) +))) + +(let data (Map data (lambda '(item) (block '( + (let intValue (FromString (Member item 'key) 'Int32)) + (let res + (If (Coalesce (Equal (% intValue (Int32 '2)) (Int32 '0)) (Bool 'false)) + (Variant item '0 varTuple) + (Variant item '1 varTuple) + ) + ) + (return res) +))))) + +(let dataTuple (Demux data)) + +(let data1 (Nth dataTuple '0)) +(let data2 (Nth dataTuple '1)) + +(let data1 (Filter data1 (lambda '(item) (Less (Member item 'key) (String '200))))) + +(let world (Write! world mr_sink (Key '('table (String 'Output1))) data1 '('('mode 'renew)))) +(let world (Write! world mr_sink (Key '('table (String 'Output2))) data2 '('('mode 'renew)))) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/MuxOverMap.yql b/yql/essentials/tests/s-expressions/suites/MultiIO/MuxOverMap.yql new file mode 100644 index 0000000000..bbceddd5da --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/MuxOverMap.yql @@ -0,0 +1,35 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) + +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let data (Right! x)) + +(let data1 (Filter data (lambda '(item) (block '( + (let intValue (FromString (Member item 'key) 'Int32)) + (let res (Coalesce (Equal (% intValue (Int32 '2)) (Int32 '0)) (Bool 'false))) + (return res) +))))) + +(let data2 (Filter data (lambda '(item) (block '( + (let intValue (FromString (Member item 'key) 'Int32)) + (let res (Coalesce (Equal (% intValue (Int32 '2)) (Int32 '1)) (Bool 'false))) + (return res) +))))) + +(let data (Mux '(data1 data2))) + +(let data (Map data (lambda '(item) (block '( + (let res (Visit item + '0 (lambda '(x) x) + '1 (lambda '(x) x) + )) + (return res) +))))) + +(let world (Write! world mr_sink (Key '('table (String 'Output1))) data '('('mode 'renew)))) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/MuxOverMixed.yql b/yql/essentials/tests/s-expressions/suites/MultiIO/MuxOverMixed.yql new file mode 100644 index 0000000000..77f51cfd2b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/MuxOverMixed.yql @@ -0,0 +1,35 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) + +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let data (Right! x)) + +(let data1 (Filter data (lambda '(item) (block '( + (let intValue (FromString (Member item 'key) 'Int32)) + (let res (Coalesce (Equal (% intValue (Int32 '2)) (Int32 '0)) (Bool 'false))) + (return res) +))))) + +(let data2 (AsList + (AsStruct '('key (String 'k1)) '('subkey (String 's1)) '('value (String 'v1))) + (AsStruct '('key (String 'k2)) '('subkey (String 's2)) '('value (String 'v2))) + (AsStruct '('key (String 'k3)) '('subkey (String 's3)) '('value (String 'v3))) +)) + +(let data (Mux '(data1 data2))) + +(let data (Map data (lambda '(item) (block '( + (let res (Visit item + '0 (lambda '(x) x) + '1 (lambda '(x) x) + )) + (return res) +))))) + +(let world (Write! world mr_sink (Key '('table (String 'Output1))) data '('('mode 'renew)))) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/MuxOverRead.yql b/yql/essentials/tests/s-expressions/suites/MultiIO/MuxOverRead.yql new file mode 100644 index 0000000000..08c7c997bc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/MuxOverRead.yql @@ -0,0 +1,27 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) + +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let data1 (Right! x)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let data2 (Right! x)) + +(let data (Mux '(data1 data2))) + +(let data (Map data (lambda '(item) (block '( + (let res (Visit item + '0 (lambda '(x) x) + '1 (lambda '(x) x) + )) + (return res) +))))) + +(let world (Write! world mr_sink (Key '('table (String 'Output1))) data '('('mode 'renew)))) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/OrderedPartitionByKeyWithMultiOut.yql b/yql/essentials/tests/s-expressions/suites/MultiIO/OrderedPartitionByKeyWithMultiOut.yql new file mode 100644 index 0000000000..56ef61571a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/OrderedPartitionByKeyWithMultiOut.yql @@ -0,0 +1,56 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) + +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let data (Right! x)) + +(let varTuple (VariantType (TupleType + (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) + ) + (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) + ) +))) + +(let keySelector (lambda '(x) (Member x 'key))) +(let listHandler (lambda '(groups) (block '( + (return (Map groups (lambda '(group) (block '( + (let key (Nth group '0)) + (let stream (Nth group '1)) + + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (ToString (Length (ForwardList stream))))) + + (let intValue (FromString key 'Int32)) + (let res + (If (Coalesce (Equal (% intValue (Int32 '2)) (Int32 '0)) (Bool 'false)) + (Variant s '0 varTuple) + (Variant s '1 varTuple) + ) + ) + (return res) + ))))) +)))) +(let data (PartitionByKey data keySelector (Void) (Void) listHandler)) + +(let dataTuple (Demux data)) + +(let data1 (Nth dataTuple '0)) +(let data2 (Nth dataTuple '1)) + +(let world (Write! world mr_sink (Key '('table (String 'Output1))) data1 '('('mode 'renew)))) +(let world (Write! world mr_sink (Key '('table (String 'Output2))) data2 '('('mode 'renew)))) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/PartitionByKeyWithMultiOut.yql b/yql/essentials/tests/s-expressions/suites/MultiIO/PartitionByKeyWithMultiOut.yql new file mode 100644 index 0000000000..bcb27c7be3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/PartitionByKeyWithMultiOut.yql @@ -0,0 +1,56 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) + +(let x (Read! world mr_source (Key '('table (String 'Input2))) (Void) '())) +(let world (Left! x)) +(let data (Right! x)) + +(let varTuple (VariantType (TupleType + (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) + ) + (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) + ) +))) + +(let keySelector (lambda '(x) (Member x 'key))) +(let listHandler (lambda '(groups) (block '( + (return (Map groups (lambda '(group) (block '( + (let key (Nth group '0)) + (let stream (Nth group '1)) + + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (ToString (Length (ForwardList stream))))) + + (let intValue (FromString key 'Int32)) + (let res + (If (Coalesce (Equal (% intValue (Int32 '2)) (Int32 '0)) (Bool 'false)) + (Variant s '0 varTuple) + (Variant s '1 varTuple) + ) + ) + (return res) + ))))) +)))) +(let data (PartitionByKey data keySelector (Void) (Void) listHandler)) + +(let dataTuple (Demux data)) + +(let data1 (Nth dataTuple '0)) +(let data2 (Nth dataTuple '1)) + +(let world (Write! world mr_sink (Key '('table (String 'Output1))) data1 '('('mode 'renew)))) +(let world (Write! world mr_sink (Key '('table (String 'Output2))) data2 '('('mode 'renew)))) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/SuppressOuts1.yql b/yql/essentials/tests/s-expressions/suites/MultiIO/SuppressOuts1.yql new file mode 100644 index 0000000000..30fefdd2f4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/SuppressOuts1.yql @@ -0,0 +1,39 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) + +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let data (Right! x)) + +(let varTuple (VariantType (TupleType + (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) + ) + (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) + ) +))) + +(let data (Map data (lambda '(item) (block '( + (let intValue (FromString (Member item 'key) 'Int32)) + (let res + (If (Coalesce (Equal (% intValue (Int32 '2)) (Int32 '0)) (Bool 'false)) + (Variant item '0 varTuple) + (Variant item '1 varTuple) + ) + ) + (return res) +))))) + +(let dataTuple (Demux data)) + +(let world (Write! world mr_sink (Key '('table (String 'Output2))) (Nth dataTuple '1) '('('mode 'renew)))) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/SuppressOuts2.yql b/yql/essentials/tests/s-expressions/suites/MultiIO/SuppressOuts2.yql new file mode 100644 index 0000000000..5d0c493a3d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/SuppressOuts2.yql @@ -0,0 +1,39 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) + +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let data (Right! x)) + +(let structType (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) +)) + +(let varTuple (VariantType (TupleType structType structType structType))) + +(let data (Map data (lambda '(item) (block '( + (let intValue (FromString (Member item 'key) 'Int32)) + (let mod (Coalesce (% intValue (Int32 '3)) (Int32 '0))) + (let res + (If (Equal mod (Int32 '0)) + (Variant item '0 varTuple) + (If (Equal mod (Int32 '1)) + (Variant item '1 varTuple) + (Variant item '2 varTuple) + ) + ) + ) + (return res) +))))) + +(let dataTuple (Demux data)) + +(let world (Write! world mr_sink (Key '('table (String 'Output1))) (Nth dataTuple '0) '('('mode 'renew)))) +(let world (Write! world mr_sink (Key '('table (String 'Output2))) (Nth dataTuple '2) '('('mode 'renew)))) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/SuppressOuts3.yql b/yql/essentials/tests/s-expressions/suites/MultiIO/SuppressOuts3.yql new file mode 100644 index 0000000000..683fca64b4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/SuppressOuts3.yql @@ -0,0 +1,43 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) + +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let data (Right! x)) + +(let structType (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) +)) + +(let varTuple (VariantType (TupleType structType structType structType))) + +(let data (Map data (lambda '(item) (block '( + (let intValue (FromString (Member item 'key) 'Int32)) + (let res + (If (Coalesce (Equal (% intValue (Int32 '2)) (Int32 '0)) (Bool 'false)) + (Variant item '0 varTuple) + (Variant item '1 varTuple) + ) + ) + (let res + (If (Coalesce (Equal (% intValue (Int32 '3)) (Int32 '0)) (Bool 'false)) + (Variant item '2 varTuple) + res + ) + ) + (return res) +))))) + +(let dataTuple (Demux data)) + +(let res (UnionAll (Nth dataTuple '0) (Nth dataTuple '1))) + + +(let world (Write! world mr_sink (Key '('table (String 'Output1))) res '('('mode 'renew)))) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/WriteOverDemux.yql b/yql/essentials/tests/s-expressions/suites/MultiIO/WriteOverDemux.yql new file mode 100644 index 0000000000..ddf986949c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/WriteOverDemux.yql @@ -0,0 +1,40 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) + +(let x (Read! world mr_source (Key '('table (String 'Input1))) (Void) '())) +(let world (Left! x)) +(let data (Right! x)) + +(let varTuple (VariantType (TupleType + (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) + ) + (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) + ) +))) + +(let data (Map data (lambda '(item) (block '( + (let intValue (FromString (Member item 'key) 'Int32)) + (let res + (If (Coalesce (Equal (% intValue (Int32 '2)) (Int32 '0)) (Bool 'false)) + (Variant item '0 varTuple) + (Variant item '1 varTuple) + ) + ) + (return res) +))))) + +(let dataTuple (Demux data)) + +(let world (Write! world mr_sink (Key '('table (String 'Output1))) (Nth dataTuple '0) '('('mode 'renew)))) +(let world (Write! world mr_sink (Key '('table (String 'Output2))) (Nth dataTuple '1) '('('mode 'renew)))) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/default.cfg b/yql/essentials/tests/s-expressions/suites/MultiIO/default.cfg new file mode 100644 index 0000000000..d01d69e755 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/default.cfg @@ -0,0 +1,5 @@ +in Input1 input1.txt +in Input2 input2.txt +out Output1 output1.txt +out Output2 output2.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/input1.txt b/yql/essentials/tests/s-expressions/suites/MultiIO/input1.txt new file mode 100644 index 0000000000..b214aab0d9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/input1.txt @@ -0,0 +1,10 @@ +{"key"="023";"subkey"="3";"value"="aaa"}; +{"key"="037";"subkey"="5";"value"="ddd"}; +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="150";"subkey"="1";"value"="aaa"}; +{"key"="150";"subkey"="3";"value"="iii"}; +{"key"="150";"subkey"="8";"value"="zzz"}; +{"key"="200";"subkey"="7";"value"="qqq"}; +{"key"="527";"subkey"="4";"value"="bbb"}; +{"key"="761";"subkey"="6";"value"="ccc"}; +{"key"="911";"subkey"="2";"value"="kkk"}; diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/input1.txt.attr b/yql/essentials/tests/s-expressions/suites/MultiIO/input1.txt.attr new file mode 100644 index 0000000000..ed13e20223 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/input1.txt.attr @@ -0,0 +1,11 @@ +{"_yql_row_spec"={ + "Type"=["StructType";[ + ["key";["DataType";"String"]]; + ["subkey";["DataType";"String"]]; + ["value";["DataType";"String"]] + ]]; + "SortDirections"=[1;1;]; + "SortedBy"=["key";"subkey";]; + "SortedByTypes"=[["DataType";"String";];["DataType";"String";];]; + "SortMembers"=["key";"subkey";]; +}} diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/input2.txt b/yql/essentials/tests/s-expressions/suites/MultiIO/input2.txt new file mode 100644 index 0000000000..07af3b4647 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/input2.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="2";"value"="abc"}; +{"key"="800";"subkey"="2";"value"="ddd"}; +{"key"="020";"subkey"="2";"value"="q"}; +{"key"="150";"subkey"="2";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/MultiIO/input2.txt.attr b/yql/essentials/tests/s-expressions/suites/MultiIO/input2.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/MultiIO/input2.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/Optimizers/AggregateAfterUnion.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/AggregateAfterUnion.cfg new file mode 100644 index 0000000000..27b6ab6bec --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/AggregateAfterUnion.cfg @@ -0,0 +1,3 @@ +in Input1 inputUnion1.txt +in Input2 inputUnion2.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/AggregateAfterUnion.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/AggregateAfterUnion.yql new file mode 100644 index 0000000000..f3d4e5db52 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/AggregateAfterUnion.yql @@ -0,0 +1,26 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input1"))) (Void) '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input2"))) (Void) '())) + (let world (Left! x)) + (let table2 (Right! x)) + (let u (UnionAll table1 table2)) + (let output (Aggregate u '() '('('Min0 (Apply (bind aggregate_module '"min_traits_factory") (TypeOf u) (lambda '(row) (Member row '"age"))))))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/AvoidDuplicationOfJoinsBeforeAggr.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/AvoidDuplicationOfJoinsBeforeAggr.cfg new file mode 100644 index 0000000000..6f99339756 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/AvoidDuplicationOfJoinsBeforeAggr.cfg @@ -0,0 +1,2 @@ +in Input input.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/AvoidDuplicationOfJoinsBeforeAggr.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/AvoidDuplicationOfJoinsBeforeAggr.yql new file mode 100644 index 0000000000..0886d5c7a9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/AvoidDuplicationOfJoinsBeforeAggr.yql @@ -0,0 +1,111 @@ +#USE plato; +# +#$sample = (SELECT a.key as key, a.value as value FROM Input as a Join Input as b ON a.key = b.key); +# +#select key, count(*) from $sample group by key; +#select value, count(*) from $sample group by value; + +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key" '"value") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core (EquiJoin '(table0 '"a") '(table0 '"b") '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key") '()) '())) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"a.key"))) + (let res (AddMember res '"value" (Member row '"a.value"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (let Count2_create (lambda '(row) (Uint64 '1))) + (let Count2_update (lambda '(row state) (OptionalReduce state (Uint64 '1) (lambda '(a b) (+ a b))))) + (let Count2_save (lambda '(state) state)) + (let Count2_load (lambda '(item) item)) + (let Count2_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Count2_finish (lambda '(state) state)) + (return (Aggregate core '('"key") '('('Count2 (AggregationTraits (ListItemType (TypeOf core)) Count2_create Count2_update Count2_save Count2_load Count2_merge Count2_finish (Uint64 '0)))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AddMember res '"column1" (Member row 'Count2))) + (let res (AsList res)) + (return res) + ))))) + (let core (Sort core (Bool 'true) (lambda '(row) (Member row '"key")))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"key" '"column1"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key" '"value") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core (EquiJoin '(table0 '"a") '(table0 '"b") '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key") '()) '())) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"a.key"))) + (let res (AddMember res '"value" (Member row '"a.value"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (let Count4_create (lambda '(row) (Uint64 '1))) + (let Count4_update (lambda '(row state) (OptionalReduce state (Uint64 '1) (lambda '(a b) (+ a b))))) + (let Count4_save (lambda '(state) state)) + (let Count4_load (lambda '(item) item)) + (let Count4_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Count4_finish (lambda '(state) state)) + (return (Aggregate core '('"value") '('('Count4 (AggregationTraits (ListItemType (TypeOf core)) Count4_create Count4_update Count4_save Count4_load Count4_merge Count4_finish (Uint64 '0)))))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"value" (Member row '"value"))) + (let res (AddMember res '"column1" (Member row 'Count4))) + (let res (AsList res)) + (return res) + ))))) + (let core (Sort core (Bool 'true) (lambda '(row) (Member row '"value")))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"value" '"column1"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/AvoidFuseOfSameJoins.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/AvoidFuseOfSameJoins.cfg new file mode 100644 index 0000000000..6f99339756 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/AvoidFuseOfSameJoins.cfg @@ -0,0 +1,2 @@ +in Input input.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/AvoidFuseOfSameJoins.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/AvoidFuseOfSameJoins.yql new file mode 100644 index 0000000000..9918cc7770 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/AvoidFuseOfSameJoins.yql @@ -0,0 +1,87 @@ +#USE plato; +# +#$sample = (SELECT a.key as key, a.value as value FROM Input as a Join Input as b ON a.key = b.key); +# +#select * from $sample as x left join Input as y using (key); +#select * from $sample as x right join Input as y using (value); + +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) (Void) '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (EquiJoin '((block '( + (let select (block '( + (let core (EquiJoin '(table0 '"a") '(table0 '"b") '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key") '()) '())) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"a.key"))) + (let res (AddMember res '"value" (Member row '"a.value"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"x") '(table0 '"y") '('Left '"x" '"y" '('"x" '"key") '('"y" '"key") '()) '())) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (let select (Sort select '((Bool 'true) (Bool 'true) (Bool 'true)) (lambda '(row) '((Member row '"x.key") (Member row '"x.value") (Member row '"y.key"))))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) (Void) '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (EquiJoin '((block '( + (let select (block '( + (let core (EquiJoin '(table0 '"a") '(table0 '"b") '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key") '()) '())) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"a.key"))) + (let res (AddMember res '"value" (Member row '"a.value"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"x") '(table0 '"y") '('Right '"x" '"y" '('"x" '"value") '('"y" '"value") '()) '())) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (let select (Sort select '((Bool 'true) (Bool 'true) (Bool 'true)) (lambda '(row) '((Member row '"x.key") (Member row '"x.value") (Member row '"y.key"))))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/BinaryDataLiterals.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/BinaryDataLiterals.yql new file mode 100644 index 0000000000..fe707cfe07 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/BinaryDataLiterals.yql @@ -0,0 +1,25 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let data (Bool 'x"00")) +(let world (Write! world res_sink (Key) data '())) + +(let data (Int16 'x"FEFF")) +(let world (Write! world res_sink (Key) data '())) + +(let data (Double 'x"722078DC7BF042D3")) +(let world (Write! world res_sink (Key) data '())) + +(let data (Date 'x"0100")) +(let world (Write! world res_sink (Key) data '())) + +(let data (TzTimestamp 'x"0000F9BCF768AC000001")) +(let world (Write! world res_sink (Key) data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ChopperUseOnlyKeyInHandler.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/ChopperUseOnlyKeyInHandler.cfg new file mode 100644 index 0000000000..de97bde764 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ChopperUseOnlyKeyInHandler.cfg @@ -0,0 +1,4 @@ +in Input input4.txt +out Output output.txt +res result.txt + diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ChopperUseOnlyKeyInHandler.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ChopperUseOnlyKeyInHandler.yql new file mode 100644 index 0000000000..7c3615fa7f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ChopperUseOnlyKeyInHandler.yql @@ -0,0 +1,15 @@ +( +#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 keySwitch (lambda '(key item) (IsKeySwitch key item (lambda '(k) k) keySelector))) +(let listHandler (lambda '(key stream) (ToStream (Just (AsStruct '('KEY key)))))) +(let reducedTable (Chopper (ToStream table1) keySelector keySwitch 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/Optimizers/CloneStructure.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/CloneStructure.yql new file mode 100644 index 0000000000..e2e95e299b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/CloneStructure.yql @@ -0,0 +1,23 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source + (Key '('table (String 'Input))) + (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let table2 (Map table1 (lambda '(x) (block '( + (let s (Struct)) + (let s (AddMember s 'value (Member x 'value))) + (let s (AddMember s 'subkey (Member x 'subkey))) + (let s (AddMember s 'key (Member x 'key))) + (return s) +))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + table2 '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceOverJust.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceOverJust.yql new file mode 100644 index 0000000000..5d034dfec2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceOverJust.yql @@ -0,0 +1,12 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (Coalesce (Just (Int32 '1)) (Int32 '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (Coalesce (Just (Int32 '1)) (Just (Int32 '2)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceOverNothing.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceOverNothing.yql new file mode 100644 index 0000000000..efbc67ef1b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceOverNothing.yql @@ -0,0 +1,14 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (Coalesce (Nothing (OptionalType (DataType 'Int32))) (Int32 '2))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (Coalesce (Nothing (OptionalType (DataType 'Int32))) (Just (Int32 '2)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (Coalesce (Nothing (OptionalType (DataType 'Int32))) (Just (Int32 '2)) (Int32 '3))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceWithBoolOverAnd.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceWithBoolOverAnd.yql new file mode 100644 index 0000000000..1d290a7ef7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceWithBoolOverAnd.yql @@ -0,0 +1,12 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let optBool1 (== (Int32 '0) (/ (Int32 '1) (Int32 '2)))) +(let optBool2 (== (Int32 '0) (/ (Int32 '4) (Int32 '5)))) +(let data (Coalesce (And optBool1 optBool2) (Bool 'false))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceWithBoolOverNot.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceWithBoolOverNot.yql new file mode 100644 index 0000000000..1d48368834 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceWithBoolOverNot.yql @@ -0,0 +1,11 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let optBool (SafeCast (/ (Int32 '1) (Int32 '0)) (OptionalType (DataType 'Bool)))) +(let data (Coalesce (Not optBool) (Bool 'false))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceWithBoolOverOr.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceWithBoolOverOr.yql new file mode 100644 index 0000000000..9e382837fc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/CoalesceWithBoolOverOr.yql @@ -0,0 +1,12 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let optBool1 (== (Int32 '0) (/ (Int32 '3) (Int32 '2)))) +(let optBool2 (== (Int32 '0) (/ (Int32 '4) (Int32 '5)))) +(let data (Coalesce (Or optBool1 optBool2) (Bool 'false))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/Condense1OneItemStruct.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/Condense1OneItemStruct.yql new file mode 100644 index 0000000000..ef949a7afb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/Condense1OneItemStruct.yql @@ -0,0 +1,25 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Condense1 list + (lambda '(item) + (AddMember + (Struct) + 'z + item)) + (lambda '(item state) (Bool 'false)) + (lambda '(item state) + (AddMember + (Struct) + 'z + (Concat (Member state 'z) item))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/Condense1OneItemTuple.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/Condense1OneItemTuple.yql new file mode 100644 index 0000000000..1044367186 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/Condense1OneItemTuple.yql @@ -0,0 +1,20 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Condense1 list + (lambda '(item) + '(item)) + (lambda '(item state) (Bool 'false)) + (lambda '(item state) (block '( + (let x (Concat (Nth state '0) item)) + (return '(x))))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/CondenseOneItemStruct.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/CondenseOneItemStruct.yql new file mode 100644 index 0000000000..1d24deecd5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/CondenseOneItemStruct.yql @@ -0,0 +1,20 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Condense list (AddMember (Struct) 'z (String '"")) + (lambda '(item state) (Bool 'false)) + (lambda '(item state) + (AddMember + (Struct) + 'z + (Concat (Member state 'z) item))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/CondenseOneItemTuple.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/CondenseOneItemTuple.yql new file mode 100644 index 0000000000..d638ca1fef --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/CondenseOneItemTuple.yql @@ -0,0 +1,19 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let s (String '"")) +(let data (Condense list '(s) + (lambda '(item state) (Bool 'false)) + (lambda '(item state) (block '( + (let state (Concat (Nth state '0) item)) + (return '(state))))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ConstMapThenCondense.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ConstMapThenCondense.yql new file mode 100644 index 0000000000..ca92c5573e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ConstMapThenCondense.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list1 (AsList (String 'a) (String 'b) (String 'c))) +(let map (Map list1 (lambda '(x) (Uint32 '2)))) +(let data (Condense map (Uint32 '1) (lambda '(item state) (Bool 'false)) (lambda '(item state) (* item state)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ConstMapThenCondense1.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ConstMapThenCondense1.yql new file mode 100644 index 0000000000..5d213f0f5a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ConstMapThenCondense1.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list1 (AsList (String 'a) (String 'b) (String 'c))) +(let map (Map list1 (lambda '(x) (Uint32 '2)))) +(let data (Condense1 map (lambda '(item) item) (lambda '(item state) (Bool 'false)) (lambda '(item state) (* item state)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ConstMapThenFold.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ConstMapThenFold.yql new file mode 100644 index 0000000000..06d8d1ee2e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ConstMapThenFold.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list1 (AsList (String 'a) (String 'b) (String 'c))) +(let map (Map list1 (lambda '(x) (Uint32 '1)))) +(let data (Fold map (Uint32 '0) (lambda '(item state) (+ item state)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ConstMapThenFold1.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ConstMapThenFold1.yql new file mode 100644 index 0000000000..dbb25f37ee --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ConstMapThenFold1.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list1 (AsList (String 'a) (String 'b) (String 'c))) +(let map (Map list1 (lambda '(x) (Uint32 '1)))) +(let data (Fold1 map (lambda '(item) item) (lambda '(item state) (+ item state)))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ConsumeOrMoveForwardList.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ConsumeOrMoveForwardList.yql new file mode 100644 index 0000000000..37b6fe207e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ConsumeOrMoveForwardList.yql @@ -0,0 +1,30 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import id_module '"/lib/yql/id.yql") +(let id (bind id_module 'id)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (ForwardList (Iterator list (DependsOn (Int32 '0)))) '('('type)))) +(let world (Write! world res_sink (Key) (ForwardList (Apply id (Iterator list (DependsOn (Int32 '1))))) '('('type)))) +(let world (Write! world res_sink (Key) (Fold (ForwardList (Apply id (Iterator list (DependsOn (Int32 '2))))) (String '"") + (lambda '(item state) (Concat item state))) '('('type)))) +(let world (Write! world res_sink (Key) (Fold1 (ForwardList (Apply id (Iterator list (DependsOn (Int32 '3))))) + (lambda '(item) item) + (lambda '(item state) (Concat item state))) '('('type)))) +(let world (Write! world res_sink (Key) (FlatMap (ForwardList (Apply id (Iterator list (DependsOn (Int32 '4))))) + (lambda '(item) (AsList item item))) '('('type)))) +(let world (Write! world res_sink (Key) (FoldMap (ForwardList (Apply id (Iterator list (DependsOn (Int32 '5))))) (String '"") + (lambda '(item state) '((Concat item state) (Concat item state)))) '('('type)))) + +(let world (Write! world res_sink (Key) (Fold1Map (ForwardList (Apply id (Iterator list (DependsOn (Int32 '6))))) + (lambda '(item) '(item item)) + (lambda '(item state) '((Concat item state) (Concat item state)))) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/CountDistinct.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/CountDistinct.cfg new file mode 100644 index 0000000000..96364ca2c5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/CountDistinct.cfg @@ -0,0 +1,3 @@ +in Input inputDistinctKey.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/CountDistinct.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/CountDistinct.yql new file mode 100644 index 0000000000..6d0405e562 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/CountDistinct.yql @@ -0,0 +1,41 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key") '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let output (block '( + (let select (block '( + (let core table1) + (let core (block '( + (let Count0_create (lambda '(row) (AggrCountInit row))) + (let Count0_update (lambda '(row state) (AggrCountUpdate row state))) + (let Count0_save (lambda '(state) state)) + (let Count0_load (lambda '(item) item)) + (let Count0_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Count0_finish (lambda '(state) state)) + (return (Aggregate core '() '('('Count0 (AggregationTraits (StructMemberType (ListItemType (TypeOf core)) '"key") Count0_create Count0_update Count0_save Count0_load Count0_merge Count0_finish (Uint64 '0)) '"key")))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"column0" (Member row 'Count0))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/CountDistinctOpt.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/CountDistinctOpt.cfg new file mode 100644 index 0000000000..96364ca2c5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/CountDistinctOpt.cfg @@ -0,0 +1,3 @@ +in Input inputDistinctKey.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/CountDistinctOpt.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/CountDistinctOpt.yql new file mode 100644 index 0000000000..ebd34f15ed --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/CountDistinctOpt.yql @@ -0,0 +1,53 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Cast (Member row '"key") 'Int32))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (block '( + (let Count1_create (lambda '(row) (AggrCountInit row))) + (let Count1_update (lambda '(row state) (AggrCountUpdate row state))) + (let Count1_save (lambda '(state) state)) + (let Count1_load (lambda '(item) item)) + (let Count1_merge (lambda '(a b) (OptionalReduce a b (lambda '(a b) (+ a b))))) + (let Count1_finish (lambda '(state) state)) + (return (Aggregate core '() '('('Count1 (AggregationTraits (StructMemberType (ListItemType (TypeOf core)) '"key") Count1_create Count1_update Count1_save Count1_load Count1_merge Count1_finish (Uint64 '0)) '"key")))) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"column0" (Member row 'Count1))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/DedupAndWithCommonPartsUnderOr.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/DedupAndWithCommonPartsUnderOr.cfg new file mode 100644 index 0000000000..b8c8b850ac --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/DedupAndWithCommonPartsUnderOr.cfg @@ -0,0 +1,3 @@ +in Input input4.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/DedupAndWithCommonPartsUnderOr.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/DedupAndWithCommonPartsUnderOr.yql new file mode 100644 index 0000000000..d1a2b6f1e2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/DedupAndWithCommonPartsUnderOr.yql @@ -0,0 +1,16 @@ +( +(let $1 (DataSink 'result)) +(let $2 (Write! world $1 (Key) (Unordered (EnsurePersistable (OrderedFlatMap (OrderedFilter (Right! (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) (Void) '())) (lambda '($3) (Coalesce + (Or + (Or + (And (== (Member $3 '"key") (String '"911")) (== (Member $3 '"value") (String '"kkk"))) + (And (And (== (String '"911") (Member $3 '"key")) (== (String '"xyz") (Member $3 '"value"))) (== (Member $3 '"subkey") (String '"3"))) + ) + (Or + (And (== (String '"911") (Member $3 '"key")) (== (String '"xyz") (Member $3 '"value"))) + (And (== (String '"911") (Member $3 '"key")) (== (String '"aaa") (Member $3 '"value"))) + ) + ) +(Bool 'false)))) (lambda '($4) (AsList $4))))) '('('type) '('autoref)))) +(return (CommitAll! (Commit! $2 $1))) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/DedupOrWithCommonPartsUnderAnd.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/DedupOrWithCommonPartsUnderAnd.cfg new file mode 100644 index 0000000000..b8c8b850ac --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/DedupOrWithCommonPartsUnderAnd.cfg @@ -0,0 +1,3 @@ +in Input input4.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/DedupOrWithCommonPartsUnderAnd.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/DedupOrWithCommonPartsUnderAnd.yql new file mode 100644 index 0000000000..0271673f55 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/DedupOrWithCommonPartsUnderAnd.yql @@ -0,0 +1,16 @@ +( +(let $1 (DataSink 'result)) +(let $2 (Write! world $1 (Key) (Unordered (EnsurePersistable (OrderedFlatMap (OrderedFilter (Right! (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) (Void) '())) (lambda '($3) (Coalesce + (And + (And + (Or (== (Member $3 '"key") (String '"075")) (== (Member $3 '"subkey") (String '"4"))) + (Or (== (String '"075") (Member $3 '"key")) (== (String '"xyz") (Member $3 '"value"))) + ) + (Or + (Or (== (String '"075") (Member $3 '"key")) (== (Member $3 '"value") (String '"xyz"))) + (== (Member $3 '"key") (String '"200")) + ) + ) +(Bool 'false)))) (lambda '($4) (AsList $4))))) '('('type) '('autoref)))) +(return (CommitAll! (Commit! $2 $1))) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/DemuxOverExtend.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/DemuxOverExtend.yql new file mode 100644 index 0000000000..b8eba4c967 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/DemuxOverExtend.yql @@ -0,0 +1,57 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) + +(let x (Read! world mr_source (Key '('table (String 'Input))) (Void) '())) +(let world (Left! x)) +(let data (Right! x)) + +(let varTuple (VariantType (TupleType + (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) + ) + (StructType + '('key (DataType 'String)) + '('subkey (DataType 'String)) + '('value (DataType 'String)) + ) +))) + +(let varData1 (Map data (lambda '(item) (block '( + (let intValue (FromString (Member item 'key) 'Int32)) + (let res + (If (Coalesce (Equal (% intValue (Int32 '2)) (Int32 '0)) (Bool 'false)) + (Variant item '0 varTuple) + (Variant item '1 varTuple) + ) + ) + (return res) +))))) + +(let varData2 (Map data (lambda '(item) (block '( + (let intValue (FromString (Member item 'key) 'Int32)) + (let intValue (+ intValue (Int32 '1))) + (let res + (If (Coalesce (Equal (% intValue (Int32 '2)) (Int32 '0)) (Bool 'false)) + (Variant item '0 varTuple) + (Variant item '1 varTuple) + ) + ) + (return res) +))))) + +(let dataTuple (Demux (Extend varData1 varData2))) + +(let data1 (Nth dataTuple '0)) +(let data2 (Nth dataTuple '1)) + +(let data1 (Filter data1 (lambda '(item) (Less (Member item 'key) (String '200))))) + +(let world (Write! world mr_sink (Key '('table (String 'Output))) data1 '('('mode 'renew)))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) data2 '('('mode 'append)))) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/DoubleSort.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/DoubleSort.yql new file mode 100644 index 0000000000..cd9fa2787f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/DoubleSort.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (String 'c) (String 'e) (String 'a))) +(let data (Sort data (Bool 'true) (lambda '(x) x))) +(let data (Sort data (Bool 'true) (lambda '(x) x))) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/EquivInsideNestedLambdaOuterDiffLevel.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/EquivInsideNestedLambdaOuterDiffLevel.yql new file mode 100644 index 0000000000..d78e05c61f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/EquivInsideNestedLambdaOuterDiffLevel.yql @@ -0,0 +1,35 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +#comment +(let res_sink (DataSink 'result)) +(let outLambda1 (lambda '(sep) (block '( + (let data (AsList (String 'a) (String 'b))) + (let data1 (Map data (lambda '(x) (Concat x sep)))) + (let res data1) + (return res) +)))) + +(let outLambda2 (lambda '(sep) (block '( + (let data (AsList (String 'a) (String 'b))) + (let data1 (Map data (lambda '(x) (Concat x sep)))) + (let res data1) + (return res) +)))) + +(let anotherLambda (lambda '(sep) (block '( + (let seps (AsList (Concat (String 'z) sep) (Concat (String 'y) sep))) + (let res1 (FlatMap seps outLambda1)) + (let res2 (FlatMap seps outLambda2)) + (return (Extend res1 res2)) +)))) + +(let predicate (== (Int32 '1) (Int32 '2))) +(let sep (If predicate (Just (String '_)) (Just (String '+)))) +(let data1 (IfPresent sep outLambda1 (AsList (String 'none)))) +(let data2 (IfPresent sep anotherLambda (AsList (String 'none)))) +(let world (Write! world res_sink (Key) '(data1 data2) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/EquivLambda.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/EquivLambda.yql new file mode 100644 index 0000000000..792976bc37 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/EquivLambda.yql @@ -0,0 +1,14 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (String 'a) (String 'a))) +(let data1 (Map data (lambda '(x) (Concat x (Concat (String '_) (String '_)))))) +(let data2 (Map data (lambda '(y) (Concat y (Concat (String '_) (String '_)))))) +(let data (Extend data1 data2)) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNestedLambdaOneLevel.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNestedLambdaOneLevel.yql new file mode 100644 index 0000000000..2c5734f703 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNestedLambdaOneLevel.yql @@ -0,0 +1,20 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let outLambda (lambda '(sep) (block '( + (let data (AsList (String 'a) (String 'b))) + (let data1 (Map data (lambda '(x) (Concat x sep)))) + (let data2 (Map data (lambda '(y) (Concat y sep)))) + (let res (Extend data1 data2)) + (return res) +)))) +(let predicate (== (Int32 '1) (Int32 '2))) +(let sep (If predicate (Just (String '_)) (Just (String '+)))) +(let data (IfPresent sep outLambda (AsList (String 'none)))) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNestedLambdaOuterDiffLevel.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNestedLambdaOuterDiffLevel.yql new file mode 100644 index 0000000000..caa3cca763 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNestedLambdaOuterDiffLevel.yql @@ -0,0 +1,34 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let outLambda1 (lambda '(sep) (block '( + (let data (AsList (String 'a) (String 'b))) + (let data1 (Map data (lambda '(x) (Concat x sep)))) + (let res data1) + (return res) +)))) + +(let outLambda2 (lambda '(sep) (block '( + (let data (AsList (String 'a) (String 'b))) + (let data1 (Map data (lambda '(x) (Concat x sep)))) + (let res data1) + (return res) +)))) + +(let anotherLambda (lambda '(sep) (block '( + (let seps (AsList (Concat (String 'z) sep) (Concat (String 'y) sep))) + (let res (FlatMap seps outLambda2)) + (return res) +)))) + +(let predicate (== (Int32 '1) (Int32 '2))) +(let sep (If predicate (Just (String '_)) (Just (String '+)))) +(let data1 (IfPresent sep outLambda1 (AsList (String 'none)))) +(let data2 (IfPresent sep anotherLambda (AsList (String 'none)))) +(let world (Write! world res_sink (Key) '(data1 data2) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNestedLambdaOuterSameLevel.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNestedLambdaOuterSameLevel.yql new file mode 100644 index 0000000000..810324b0dd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNestedLambdaOuterSameLevel.yql @@ -0,0 +1,28 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let outLambda1 (lambda '(sep) (block '( + (let data (AsList (String 'a) (String 'b))) + (let data1 (Map data (lambda '(x) (Concat x sep)))) + (let res data1) + (return res) +)))) + +(let outLambda2 (lambda '(sep) (block '( + (let data (AsList (String 'a) (String 'b))) + (let data1 (Map data (lambda '(x) (Concat x sep)))) + (let res data1) + (return res) +)))) + +(let predicate (== (Int32 '1) (Int32 '2))) +(let sep (If predicate (Just (String '_)) (Just (String '+)))) +(let data1 (IfPresent sep outLambda1 (AsList (String 'none)))) +(let data2 (IfPresent sep outLambda2 (AsList (String 'none)))) +(let world (Write! world res_sink (Key) '(data1 data2) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNodeInNestedLambda.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNodeInNestedLambda.yql new file mode 100644 index 0000000000..5da1b36ee1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNodeInNestedLambda.yql @@ -0,0 +1,18 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let predicate (== (Int32 '1) (Int32 '2))) +(let outLambda (lambda '(sep) (block '( + (let data (AsList (String 'a) (String 'b))) + (let data1 (Map data (lambda '(x) (Concat (Concat x sep) (ToString (Int32 '1)))))) + (return data1) +)))) +(let sep (If predicate (Just (String '_)) (Just (String '+)))) +(let data (IfPresent sep outLambda (AsList (String 'none)))) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNodesInLambdas.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNodesInLambdas.yql new file mode 100644 index 0000000000..3f76dd440f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/EquivNodesInLambdas.yql @@ -0,0 +1,14 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (String 'a) (String 'a))) +(let data1 (Map data (lambda '(x) (Concat x (Concat (String 'l1) (String 'l2)))))) +(let data2 (Map data (lambda '(y) (Concat y (Concat (String 'l2) (String 'l1)))))) +(let data (Extend data1 data2)) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExpandAddRemoveMember.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ExpandAddRemoveMember.yql new file mode 100644 index 0000000000..69ede42271 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExpandAddRemoveMember.yql @@ -0,0 +1,17 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let func (lambda '() (AsStruct '('a (String '1)) '('b (Int32 '2))))) +(let type (CallableType '() '((StructType '('a (DataType 'String)) '('b (DataType 'Int32)))))) +(let call (Callable type func)) +(let data (Apply call)) +(let data1 (AddMember data 'd (Bool 'True))) +(let data2 (ForceRemoveMember data 'a)) +(let data2 (ForceRemoveMember data2 'x)) +(let world (Write! world res_sink (Key) '(data1 data2) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendAndFlatmapExchange.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendAndFlatmapExchange.yql new file mode 100644 index 0000000000..0ff086d5c7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendAndFlatmapExchange.yql @@ -0,0 +1,29 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) (Void) '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let table2 (Skip table1 (Uint32 '1))) + (let duplicate (lambda '(row) (block '( + (let res (Struct)) + (let res (AsList row row)) + (return res) + )))) + (let ttable1 (FlatMap table1 duplicate)) + (let ttable2 (FlatMap table2 duplicate)) + (let extend (Extend ttable1 ttable2)) + (let output (Filter extend (lambda '(row) (< (Member row '"key") (String '500))))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendAndFlatmapOptimizeTablePath.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendAndFlatmapOptimizeTablePath.yql new file mode 100644 index 0000000000..ac8743eeca --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendAndFlatmapOptimizeTablePath.yql @@ -0,0 +1,16 @@ +( +(let mr_sync (DataSink 'result)) +(let mr_source (DataSource '"yt" '"plato")) +(let lambda (lambda '(item) (block '( + (return (AsList (AsStruct '('"path" (TablePath (DependsOn item)))))) +)))) +(let res (Extend + (FlatMap (Right! (Read! world mr_source (Key '('table (String '"Input"))) '() '())) lambda) + (FlatMap (Right! (Read! world mr_source (Key '('table (String '"Input"))) '() '())) lambda) + (FlatMap (Extend + (Right! (Read! world mr_source (Key '('table (String '"Input"))) '() '()))) (lambda '(item) (block '( + (return (AsList (AsStruct '('"path" (String '"Special"))))) +)))))) +(let world (ResWrite! world mr_sync (Key) res '('('type) '('autoref) '('columns '('"path"))))) +(return (Commit! (Commit! world mr_sync) (DataSink '"yt" '"plato"))) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendTableWithLiteral.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendTableWithLiteral.yql new file mode 100644 index 0000000000..296bdafd03 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendTableWithLiteral.yql @@ -0,0 +1,80 @@ +#use plato; +# +#SELECT * FROM Input +#UNION ALL +#SELECT 2 AS y; +# +#SELECT 1 AS x +#UNION ALL +#SELECT * FROM Input; + +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) (Void) '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (UnionAll (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + )) (block '( + (let core (AsList (Void))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"y" (Int64 '"2"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + )))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) (Void) '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (UnionAll (block '( + (let core (AsList (Void))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"x" (Int64 '"1"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + )) (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + )))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithFill.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithFill.cfg new file mode 100644 index 0000000000..80d5638bff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithFill.cfg @@ -0,0 +1,3 @@ +in Input SomeKeys.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithFill.sql b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithFill.sql new file mode 100644 index 0000000000..371846c584 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithFill.sql @@ -0,0 +1,13 @@ +USE plato; + +-- Should not generate single MrFill for all content +INSERT INTO Output +SELECT * from( + select key, sum(cast(subkey as Uint32)) as value + from Input group by key + + union all + + select "" as key, sum(cast(subkey as Uint32)) as value + from Input-- group by key +); diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithFill.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithFill.yql new file mode 100644 index 0000000000..2e266ddca2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithFill.yql @@ -0,0 +1,56 @@ +( +# Should not generate single MrFill for all content +(import aggregate_module '"/lib/yql/aggregate.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) (Void) '())) + (let world (Left! x)) + (let table2 (Right! x)) + (let values (block '( + (let select (block '( + (let core (UnionAll (block '( + (let select (block '( + (let core table2) + (let core (Aggregate core '('"key") '('('Sum0 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Cast (Member row '"subkey") 'Uint32))))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"key" (Member row '"key")) '('"value" (Member row 'Sum0)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) (block '( + (let select (block '( + (let core table2) + (let core (Aggregate core '() '('('Sum1 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Cast (Member row '"subkey") 'Uint32))))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"key" (String '"")) '('"value" (Member row 'Sum1)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"Output"))) values '('('mode 'append)))) + (return world) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithTablePath.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithTablePath.cfg new file mode 100644 index 0000000000..807ada95e2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithTablePath.cfg @@ -0,0 +1,3 @@ +in Input1 input.txt +in Input2 input2.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithTablePath.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithTablePath.yql new file mode 100644 index 0000000000..a61e2d4d2f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtendWithTablePath.yql @@ -0,0 +1,48 @@ +#USE plato; +#select table, count(*) from +# (select TablePath() as table from CONCAT([Input],[Input])) group by table; + +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input1"))) (Key '('table (String '"Input2")))) '() '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"table" (TablePath (DependsOn row))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (Aggregate core '('"table") '('('Count1 (Apply (bind aggregate_module '"count_traits_factory") (TypeOf core) (lambda '(row) (Void))))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"table" (Member row '"table")) '('"column1" (Member row 'Count1)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"table" '"column1"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOnMultiInput.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOnMultiInput.cfg new file mode 100644 index 0000000000..807ada95e2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOnMultiInput.cfg @@ -0,0 +1,3 @@ +in Input1 input.txt +in Input2 input2.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOnMultiInput.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOnMultiInput.yql new file mode 100644 index 0000000000..d775d38829 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOnMultiInput.yql @@ -0,0 +1,22 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x1 (Read! world mr_source (Key '('table (String 'Input1))) '('key 'subkey 'value) '())) +(let x2 (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x1)) +(let table1 (RemoveSystemMembers (Right! x1))) +(let table2 (RemoveSystemMembers (Right! x2))) + +(let joinType '('LeftOnly '"t" '"d" '('"t" '"key") '('"d" '"key") '())) +(let $67 '('"rename" '"t.key" '"key")) +(let $68 '('"rename" '"t.subkey" '"subkey")) +(let $69 '('"rename" '"t.value" '"value")) +(let rename '($67 $68 $69)) + +(let join (EquiJoin '(table1 '"t") '((FlatMap (Extend (ExtractMembers table1 '('"key")) (ExtractMembers table2 '('"key"))) (lambda '($159) (Just (AsStruct '('"key" (Member $159 '"key")))))) '"d") joinType rename)) +(let out (Extend table1 table2 join)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) out '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOverEquiJoin.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOverEquiJoin.cfg new file mode 100644 index 0000000000..6f99339756 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOverEquiJoin.cfg @@ -0,0 +1,2 @@ +in Input input.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOverEquiJoin.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOverEquiJoin.yql new file mode 100644 index 0000000000..08083fbc54 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOverEquiJoin.yql @@ -0,0 +1,12 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let join (EquiJoin '(table 'a) '(table 'b) '('Inner '"a" '"b" '('"a" '"key") '('"b" '"value" ) '()) '())) +(let join (ExtractMembers join '('a.key 'b.value))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) join '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOverRead.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOverRead.yql new file mode 100644 index 0000000000..e5bccc409e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractMembersOverRead.yql @@ -0,0 +1,17 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source + (Key '('table (String 'Input))) + (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let table1 (ExtractMembers table1 '('key 'value))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + table1 '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractPredicateFromFlatmapOverListIf.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractPredicateFromFlatmapOverListIf.yql new file mode 100644 index 0000000000..0a63ce0c2c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ExtractPredicateFromFlatmapOverListIf.yql @@ -0,0 +1,37 @@ +( +# read data from Input table +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let str1 (AsStruct '('a (Uint32 '1)) '('b (String 'a)))) +(let str2 (AsStruct '('a (Uint32 '2)) '('b (String 'b)))) +(let str3 (AsStruct '('a (Uint32 '3)) '('b (String 'c)))) +(let list1 (AsList str1 str2)) +(let list2 (AsList str2 str1)) +(let list3 (AsList str1 str3)) + +(let cond (>= (RandomNumber) (Uint64 '0))) + +(let res (FlatMap (OptionalIf cond str1) (lambda '(r) (OptionalIf (>= (Member r 'b) (String 'a)) r)))) +(let world (Write! world res_sink (Key) res '())) + +(let res (FlatMap (OptionalIf cond str1) (lambda '(r) (AsList r r)))) +(let world (Write! world res_sink (Key) res '())) + +(let res (FlatMap (OptionalIf cond str1) (lambda '(r) (ToStream (Just r) (DependsOn r))))) +(let world (Write! world res_sink (Key) (ForwardList res) '())) + +(let res (FlatMap (ListIf cond str1) (lambda '(r) (OptionalIf (>= (Member r 'b) (String 'a)) r)))) +(let world (Write! world res_sink (Key) res '())) + +(let res (FlatMap (ListIf cond str1) (lambda '(r) (AsList r r)))) +(let world (Write! world res_sink (Key) res '())) + +(let res (FlatMap (ListIf cond str1) (lambda '(r) (ToStream (Just r) (DependsOn r))))) +(let world (Write! world res_sink (Key) res '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FalattenByColumns.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/FalattenByColumns.cfg new file mode 100644 index 0000000000..fa5e600b39 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FalattenByColumns.cfg @@ -0,0 +1,2 @@ +in Input typed_table.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FalattenByColumns.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FalattenByColumns.yql new file mode 100644 index 0000000000..4a52d5d457 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FalattenByColumns.yql @@ -0,0 +1,38 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")) '('view (String '"opt_struct")))) '('"b") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (FlattenByColumns row '('b 'bb))) + (return res) + ))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"bb" (Member row '"bb"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"bb"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FlatMapAfterCombineByKey.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FlatMapAfterCombineByKey.yql new file mode 100644 index 0000000000..abfdcb837a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FlatMapAfterCombineByKey.yql @@ -0,0 +1,19 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (String 'a) (String 'a) (String 'b))) +(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 data preMap keyExtractor init update finish)) +(let map (Map combined (lambda '(x) (Nth x '1)))) +(let result (Sort map (Bool 'true) (lambda '(x) x))) +(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/Optimizers/FlatMapAfterFilterNullMembers.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FlatMapAfterFilterNullMembers.yql new file mode 100644 index 0000000000..62ab06b3ec --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FlatMapAfterFilterNullMembers.yql @@ -0,0 +1,18 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList + (AsStruct '('data (Just (String 'a)))) + (AsStruct '('data (Nothing (OptionalType (DataType 'String))))) + (AsStruct '('data (Just (String 'b)))) +)) +(let filtered (FilterNullMembers data '('data))) +(let map (Map filtered (lambda '(x) '(x x)))) +(let result (Sort map (Bool 'true) (lambda '(x) (Member (Nth x '0) 'data)))) +(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/Optimizers/FlatMapBeforeCombineByKey.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FlatMapBeforeCombineByKey.yql new file mode 100644 index 0000000000..aa7b1d874a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FlatMapBeforeCombineByKey.yql @@ -0,0 +1,19 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (String 'a) (String 'a) (String 'b) (String 'c))) +(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 map (Filter data (lambda '(x) (< x (String 'c))))) +(let combined (CombineByKey map preMap keyExtractor init update finish)) +(let result (Sort combined (Bool 'true) (lambda '(x) (Nth x '0)))) +(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/Optimizers/FlatMapToExtractMembers.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FlatMapToExtractMembers.yql new file mode 100644 index 0000000000..b0dfbcde05 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FlatMapToExtractMembers.yql @@ -0,0 +1,30 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let str1 (AsStruct '('a (Uint32 '1)) '('b (String 'a)) '('c (Bool 'true)))) +(let str2 (AsStruct '('a (Uint32 '2)) '('b (String 'b)) '('c (Bool 'false)))) +(let list1 (AsList str1 str2)) + +(let res1 (FlatMap list1 (lambda '(item) (block '( + (let ret (Just (AsStruct '('a (Member item 'a)) '('c (Member item 'c))))) + (return ret) +))))) + +(let res2 (FlatMap list1 (lambda '(item) (block '( + (let ret (Just (AsStruct '('b (Member item 'b)) '('k (Member item 'c))))) + (return ret) +))))) + +(let res3 (FlatMap list1 (lambda '(item) (block '( + (let ret (Just (AsStruct))) + (return ret) +))))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) res1 '('('type)))) +(let world (Write! world res_sink (Key) res2 '('('type)))) +(let world (Write! world res_sink (Key) res3 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FlatMapWithVariantItemAfterSwitch.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FlatMapWithVariantItemAfterSwitch.yql new file mode 100644 index 0000000000..855ec4454f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FlatMapWithVariantItemAfterSwitch.yql @@ -0,0 +1,25 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let structType (StructType '('key (DataType 'String)) '('value (DataType 'String)))) +(let tupleType (TupleType structType structType structType)) +(let vt (VariantType tupleType)) +(let vlist (AsList + (Variant (AsStruct '('key (String 'aaa)) '('value (String '0))) '0 vt) + (Variant (AsStruct '('key (String 'bbb)) '('value (String '1))) '1 vt) + (Variant (AsStruct '('key (String 'ccc)) '('value (String '2))) '2 vt) +)) + +(let takeHandler (lambda '(x) (Take x (Uint64 '42)))) + +(let world (Write! world res_sink (Key) (Collect (Map (Switch (ToFlow vlist) '1 '('0) takeHandler '('1 '2) takeHandler) (lambda '(s) (VariantItem s)))) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Map (Switch (ToFlow vlist) '1 '('1) takeHandler '('2) takeHandler) (lambda '(s) (VariantItem s)))) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Map (Switch (ToFlow vlist) '1 '('0 '1) takeHandler '('1 '2) takeHandler) (lambda '(s) (VariantItem s)))) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (OrderedMap (Switch (ToFlow vlist) '1 '('0 '1 '2) takeHandler) (lambda '(s) (VariantItem s)))) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1ConstMax.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1ConstMax.yql new file mode 100644 index 0000000000..a32571a772 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1ConstMax.yql @@ -0,0 +1,16 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Fold1 list + (lambda '(item) (String 'z)) + (lambda '(item state) (Max state (String 'y))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1ConstMin.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1ConstMin.yql new file mode 100644 index 0000000000..f173ae96ab --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1ConstMin.yql @@ -0,0 +1,16 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Fold1 list + (lambda '(item) (String 'z)) + (lambda '(item state) (Min state (String 'y))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1EmptyStruct.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1EmptyStruct.yql new file mode 100644 index 0000000000..a9b8d1e1ee --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1EmptyStruct.yql @@ -0,0 +1,14 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Fold1 list (lambda '(item) (Struct)) (lambda '(item state) state))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1EmptyTuple.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1EmptyTuple.yql new file mode 100644 index 0000000000..e6be656d48 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1EmptyTuple.yql @@ -0,0 +1,14 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Fold1 list (lambda '(item) '()) (lambda '(item state) state))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1IncrementAsLength.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1IncrementAsLength.yql new file mode 100644 index 0000000000..47cda00536 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1IncrementAsLength.yql @@ -0,0 +1,16 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Fold1 list + (lambda '(item) (Uint32 '1)) + (lambda '(item state) (+ state (Uint32 '1))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1OneItemStruct.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1OneItemStruct.yql new file mode 100644 index 0000000000..5077ac27e4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1OneItemStruct.yql @@ -0,0 +1,24 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Fold1 list + (lambda '(item) + (AddMember + (Struct) + 'z + item)) + (lambda '(item state) + (AddMember + (Struct) + 'z + (Concat (Member state 'z) item))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1OneItemTuple.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1OneItemTuple.yql new file mode 100644 index 0000000000..0f6615de39 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1OneItemTuple.yql @@ -0,0 +1,19 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Fold1 list + (lambda '(item) + '(item)) + (lambda '(item state) (block '( + (let x (Concat (Nth state '0) item)) + (return '(x))))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1OverOptional.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1OverOptional.yql new file mode 100644 index 0000000000..c4ac775064 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/Fold1OverOptional.yql @@ -0,0 +1,16 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (Just (String 'a))) +(let data (Fold1 list +(lambda '(item) (Concat item (String 'b))) +(lambda '(item state) (Concat item state)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FoldConstMax.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FoldConstMax.yql new file mode 100644 index 0000000000..cc2d3f5d62 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FoldConstMax.yql @@ -0,0 +1,16 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Fold list + (String 'z) + (lambda '(item state) (Max state (String 'y))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FoldConstMin.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FoldConstMin.yql new file mode 100644 index 0000000000..d7f3bc98b5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FoldConstMin.yql @@ -0,0 +1,16 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Fold list + (String 'z) + (lambda '(item state) (Min state (String 'y))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FoldEmptyStruct.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FoldEmptyStruct.yql new file mode 100644 index 0000000000..c170ea2fc0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FoldEmptyStruct.yql @@ -0,0 +1,14 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Fold list (Struct) (lambda '(item state) state))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FoldEmptyTuple.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FoldEmptyTuple.yql new file mode 100644 index 0000000000..73ac847631 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FoldEmptyTuple.yql @@ -0,0 +1,14 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Fold list '() (lambda '(item state) state))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FoldIncrementAsLength.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FoldIncrementAsLength.yql new file mode 100644 index 0000000000..758cd43bf4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FoldIncrementAsLength.yql @@ -0,0 +1,14 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Fold list (Uint32 '0) (lambda '(item state) (+ state (Uint32 '1))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FoldOneItemStruct.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FoldOneItemStruct.yql new file mode 100644 index 0000000000..12014ead02 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FoldOneItemStruct.yql @@ -0,0 +1,19 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let data (Fold list (AddMember (Struct) 'z (String '"")) + (lambda '(item state) + (AddMember + (Struct) + 'z + (Concat (Member state 'z) item))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FoldOneItemTuple.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FoldOneItemTuple.yql new file mode 100644 index 0000000000..ccada97695 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FoldOneItemTuple.yql @@ -0,0 +1,18 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let s (String '"")) +(let data (Fold list '(s) + (lambda '(item state) (block '( + (let state (Concat (Nth state '0) item)) + (return '(state))))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseExtractMembers.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseExtractMembers.yql new file mode 100644 index 0000000000..8d267ce890 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseExtractMembers.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let str1 (AsStruct '('a (Uint32 '1)) '('b (String 'a)) '('c (Bool 'true)))) +(let str2 (AsStruct '('a (Uint32 '2)) '('b (String 'b)) '('c (Bool 'false)))) +(let list1 (AsList str1 str2)) +(let world (Write! world res_sink (Key) (ExtractMembers (ExtractMembers list1 '('a 'c)) '('a)) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatMapWithExtractMembers.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatMapWithExtractMembers.yql new file mode 100644 index 0000000000..57c81db622 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatMapWithExtractMembers.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let str1 (AsStruct '('a (Uint32 '1)) '('b (String 'a)) '('c (Bool 'true)))) +(let str2 (AsStruct '('a (Uint32 '2)) '('b (String 'b)) '('c (Bool 'false)))) +(let list1 (AsList str1 str2)) +(let world (Write! world res_sink (Key) (Map (ExtractMembers list1 '('a 'c)) (lambda '(row) '((+ (Member row 'a) (Uint32 '10)) (Member row 'c)))) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatMapWithStreamLambda.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatMapWithStreamLambda.yql new file mode 100644 index 0000000000..c4585070bf --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatMapWithStreamLambda.yql @@ -0,0 +1,15 @@ +( +(let res_sink (DataSink 'result)) + +(let singleList (AsList (Int32 '1))) +(let optional (/ (Int32 '1) (Int32 '0))) +(let streamLambda (lambda '(x) (Iterator (AsList (Int32 '1) (Int32 '2))))) + +(let map1 (Unordered (FlatMap singleList streamLambda))) +(let map2 (Unordered (FlatMap (ToList optional) streamLambda))) + +(let world (Write! world res_sink (Key) map1 '('('type)))) +(let world (Write! world res_sink (Key) map2 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatMapsWithDependsOn.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatMapsWithDependsOn.yql new file mode 100644 index 0000000000..0553caa8fd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatMapsWithDependsOn.yql @@ -0,0 +1,35 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let res_sink (DataSink 'result)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) + +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) + +(let inner1 (FlatMap table (lambda '(row) (OptionalIf (> (Member row 'key) (String '100)) (AsStruct '('key1 (Member row 'key))))))) + +(let inner2 (FlatMap table (lambda '(row) (Just (AsStruct '('key1 (Member row 'key))))))) + +(let outer (lambda '(input) (FlatMap input (lambda '(row) + (Just + (AsStruct + '('key (Member row 'key1)) + '('value (ToOptional (Collect (Condense + (Iterator list (DependsOn row)) + (String '"") + (lambda '(item state) (Bool 'False)) + (lambda '(item state) (Concat state item)) + )))) + ) + ) +)))) + + +(let world (Write! world res_sink (Key) (Apply outer inner1) '('('type)))) +(let world (Write! world res_sink (Key) (Apply outer inner2) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatmapsWithInnerVisit.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatmapsWithInnerVisit.yql new file mode 100644 index 0000000000..9a0a42e1f3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatmapsWithInnerVisit.yql @@ -0,0 +1,59 @@ +( +#comment +(let config (DataSource 'config)) +(let res_sink (DataSink 'result)) + +(let world (Configure! world config 'PureDataSource 'yt)) + +(let vt (VariantType (TupleType (DataType 'String) (DataType 'String) (DataType 'String)))) +(let v0 (Variant (String 'aaa) '0 vt)) +(let v1 (Variant (String 'bbb) '1 vt)) +(let v2 (Variant (String 'ccc) '2 vt)) +(let list (AsList v0 v1 v2)) + + +(let inner (lambda '(list) + (FlatMap list (lambda '(item) + (Visit item + '0 (lambda '(x) (OptionalIf (== x (String 'aaa)) (Variant (Concat (String '0-) x) '0 vt))) + '1 (lambda '(x) (Just (Variant (Concat (String '1-) x) '1 vt))) + (Just (Variant (String '2-) '2 vt)) + ) + )) +)) + +(let res (FlatMap (Apply inner (Iterator list (DependsOn (String 'a)))) (lambda '(item) + (Just (VariantItem item)) +))) +(let world (Write! world res_sink (Key) (Collect res) '('('type)))) + +(let res (FlatMap (Apply inner (Iterator list (DependsOn (String 'b)))) (lambda '(item) + (Just (Visit item + '0 (lambda '(x) (Variant x '0 vt)) + '1 (lambda '(x) (Variant x '1 vt)) + '2 (lambda '(x) (Variant x '1 vt)) + )) +))) +(let world (Write! world res_sink (Key) (Collect res) '('('type)))) + +(let res (FlatMap + (FlatMap list (lambda '(item) + (Visit item + '0 (lambda '(x) (ListIf (== x (String 'aaa)) (Variant (Concat (String '0-) x) '0 vt))) + '1 (lambda '(x) (AsList (Variant (Concat (String '1-) x) '1 vt) (Variant (Concat (String '2-) x) '2 vt))) + (AsList (Variant (String '2-) '2 vt)) + ) + )) + (lambda '(item) + (Just (Visit item + '0 (lambda '(x) (Variant x '0 vt)) + '1 (lambda '(x) (Variant x '1 vt)) + '2 (lambda '(x) (Variant x '1 vt)) + )) + ) +)) +(let world (Write! world res_sink (Key) (Collect res) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatmapsWithOptionalIf.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatmapsWithOptionalIf.yql new file mode 100644 index 0000000000..3a7375371f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseFlatmapsWithOptionalIf.yql @@ -0,0 +1,32 @@ +( +# read data from Input table +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let str1 (AsStruct '('a (Uint32 '1)) '('b (String 'a)))) +(let str2 (AsStruct '('a (Uint32 '2)) '('b (String 'b)))) +(let list (AsList str1 str2)) + +(let res (FlatMap (FlatMap (Iterator list (DependsOn (String '1))) (lambda '(r) (OptionalIf (> (Member r 'a) (Uint32 '0)) r))) (lambda '(r) (ToStream (Just r))))) +(let world (Write! world res_sink (Key) (ForwardList res) '())) + +(let res (FlatMap (FlatMap (Iterator list (DependsOn (String '2))) (lambda '(r) (OptionalIf (> (Member r 'a) (Uint32 '0)) r))) (lambda '(r) (AsList r r)))) +(let world (Write! world res_sink (Key) (ForwardList res) '())) + +(let res (FlatMap (FlatMap (Iterator list (DependsOn (String '3))) (lambda '(r) (OptionalIf (> (Member r 'a) (Uint32 '0)) r))) (lambda '(r) (OptionalIf (> (Member r 'b) (String 'a)) r)))) +(let world (Write! world res_sink (Key) (ForwardList res) '())) + +(let res (FlatMap (FlatMap (Iterator list (DependsOn (String '4))) (lambda '(r) (ListIf (> (Member r 'a) (Uint32 '0)) r))) (lambda '(r) (ToStream (Just r))))) +(let world (Write! world res_sink (Key) (ForwardList res) '())) + +(let res (FlatMap (FlatMap (Iterator list (DependsOn (String '5))) (lambda '(r) (ListIf (> (Member r 'a) (Uint32 '0)) r))) (lambda '(r) (AsList r r)))) +(let world (Write! world res_sink (Key) (ForwardList res) '())) + +(let res (FlatMap (FlatMap (Iterator list (DependsOn (String '6))) (lambda '(r) (ListIf (> (Member r 'a) (Uint32 '0)) r))) (lambda '(r) (OptionalIf (> (Member r 'b) (String 'a)) r)))) +(let world (Write! world res_sink (Key) (ForwardList res) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterLReduce.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterLReduce.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterLReduce.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterLReduce.sql b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterLReduce.sql new file mode 100644 index 0000000000..0f5cd0b0c6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterLReduce.sql @@ -0,0 +1,31 @@ +USE plato; + +$a = (SELECT + skey,count(*) as cnt +FROM Input +GROUP BY Length(key) as skey); + +$udfScript = @@ +def f(input,x): + for i in list(input): + d = i.__dict__ + d["pass"] = x + yield d +@@; + +$udf = Python::f(@@ +(Stream<Struct<skey:Uint32,cnt:Uint64>>,Int32) +-> +Stream<Struct<skey:Uint32,cnt:Uint64,pass:Int32>> +@@, $udfScript); + +$udf2 = Python::f(@@ +(Stream<Struct<skey:Uint32,cnt:Uint64,pass:Int32>>,Int32) +-> +Stream<Struct<skey:Uint32,cnt:Uint64,pass:Int32>> +@@, $udfScript); + + +$b = (PROCESS $a USING $udf($ROWS,1)); + +PROCESS $b USING $udf2($ROWS,2); diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterLReduce.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterLReduce.yql new file mode 100644 index 0000000000..cc5b60392b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterLReduce.yql @@ -0,0 +1,82 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(import core_module '"/lib/yql/core.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) '('"key") '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let output (block '( + (let select (block '( + (let inputRowsList (block '( + (let select (block '( + (let inputRowsList (block '( + (let select (block '( + (let core table1) + (let core (FlatMap core (lambda '(row) (AsList (AsStruct '('"key" (Member row '"key")) '('"skey" ("Size" (Member row '"key")))))))) + (let core (Aggregate core '('"skey") '('('Count0 (Apply (bind aggregate_module '"count_traits_factory") (TypeOf core) (lambda '(row) (Void))))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"skey" (Member row '"skey")) '('"cnt" (Member row 'Count0)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (LMap inputRowsList (lambda '(x) (block '( + (let inputType (CallableArgumentType (TypeOf (ScriptUdf 'Python '"f" (CallableType '() '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"pass" (DataType 'Int32)) '('"skey" (DataType 'Uint32))))) '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"skey" (DataType 'Uint32))))) '((DataType 'Int32))) (String '@@ +def f(input,x): + for i in list(input): + d = i.__dict__ + d["pass"] = x + yield d +@@))) '0)) + (let inputRowsList (MatchType inputType 'List (lambda '(y) (ForwardList x)) (lambda '(y) "x"))) + (return (Apply (ScriptUdf 'Python '"f" (CallableType '() '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"pass" (DataType 'Int32)) '('"skey" (DataType 'Uint32))))) '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"skey" (DataType 'Uint32))))) '((DataType 'Int32))) (String '@@ +def f(input,x): + for i in list(input): + d = i.__dict__ + d["pass"] = x + yield d +@@)) inputRowsList (Int32 '"1"))) + ))))) + (return core) + ))) + (return select) + ))) + (let core (LMap inputRowsList (lambda '(x) (block '( + (let inputType (CallableArgumentType (TypeOf (ScriptUdf 'Python '"f" (CallableType '() '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"pass" (DataType 'Int32)) '('"skey" (DataType 'Uint32))))) '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"pass" (DataType 'Int32)) '('"skey" (DataType 'Uint32))))) '((DataType 'Int32))) (String '@@ +def f(input,x): + for i in list(input): + d = i.__dict__ + d["pass"] = x + yield d +@@))) '0)) + (let inputRowsList (MatchType inputType 'List (lambda '(y) (ForwardList x)) (lambda '(y) "x"))) + (return (Apply (ScriptUdf 'Python '"f" (CallableType '() '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"pass" (DataType 'Int32)) '('"skey" (DataType 'Uint32))))) '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"pass" (DataType 'Int32)) '('"skey" (DataType 'Uint32))))) '((DataType 'Int32))) (String '@@ +def f(input,x): + for i in list(input): + d = i.__dict__ + d["pass"] = x + yield d +@@)) inputRowsList (Int32 '"2"))) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterReduce.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterReduce.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterReduce.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterReduce.sql b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterReduce.sql new file mode 100644 index 0000000000..f0bd1ff3ba --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterReduce.sql @@ -0,0 +1,23 @@ +USE plato; + +$a = (SELECT + skey,count(*) as cnt +FROM Input +GROUP BY Length(key) as skey); + +$udfScript = @@ +def f(input,x): + for i in list(input): + d = i.__dict__ + d["pass"] = x + yield d +@@; + +$udf = Python::f(@@ +(Stream<Struct<skey:Uint32,cnt:Uint64>>,Int32) +-> +Stream<Struct<skey:Uint32,cnt:Uint64,pass:Int32>> +@@, $udfScript); + + +PROCESS $a USING $udf($ROWS,1); diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterReduce.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterReduce.yql new file mode 100644 index 0000000000..1f806dc3a3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseLMapAfterReduce.yql @@ -0,0 +1,59 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(import core_module '"/lib/yql/core.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) '('"key") '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let output (block '( + (let select (block '( + (let inputRowsList (block '( + (let select (block '( + (let core table1) + (let core (FlatMap core (lambda '(row) (AsList (AsStruct '('"key" (Member row '"key")) '('"skey" ("Size" (Member row '"key")))))))) + (let core (Aggregate core '('"skey") '('('Count0 (Apply (bind aggregate_module '"count_traits_factory") (TypeOf core) (lambda '(row) (Void))))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"skey" (Member row '"skey")) '('"cnt" (Member row 'Count0)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (LMap inputRowsList (lambda '(x) (block '( + (let inputType (CallableArgumentType (TypeOf (ScriptUdf 'Python '"f" (CallableType '() '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"pass" (DataType 'Int32)) '('"skey" (DataType 'Uint32))))) '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"skey" (DataType 'Uint32))))) '((DataType 'Int32))) (String '@@ +def f(input,x): + for i in list(input): + d = i.__dict__ + d["pass"] = x + yield d +@@))) '0)) + (let inputRowsList (MatchType inputType 'List (lambda '(y) (ForwardList x)) (lambda '(y) "x"))) + (return (Apply (ScriptUdf 'Python '"f" (CallableType '() '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"pass" (DataType 'Int32)) '('"skey" (DataType 'Uint32))))) '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"skey" (DataType 'Uint32))))) '((DataType 'Int32))) (String '@@ +def f(input,x): + for i in list(input): + d = i.__dict__ + d["pass"] = x + yield d +@@)) inputRowsList (Int32 '"1"))) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseMapAfterLReduce.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseMapAfterLReduce.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseMapAfterLReduce.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseMapAfterLReduce.sql b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseMapAfterLReduce.sql new file mode 100644 index 0000000000..c87931cafd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseMapAfterLReduce.sql @@ -0,0 +1,32 @@ +USE plato; + +$a = (SELECT + skey,count(*) as cnt +FROM Input +GROUP BY Length(key) as skey); + +$udfScript = @@ +def f(input,x): + for i in list(input): + d = i.__dict__ + d["pass"] = x + yield d + +def f2(a,b,c): + return {"a":a,"b":b,"c":c} +@@; + +$udf = Python::f(@@ +(Stream<Struct<skey:Uint32,cnt:Uint64>>,Int32) +-> +Stream<Struct<skey:Uint32,cnt:Uint64,pass:Int32>> +@@, $udfScript); + +$udf2 = Python::f2(@@ +(skey:Uint32,cnt:Uint64,pass:Int32)->Struct<a:Uint32,b:Uint64,c:Int32> +@@, $udfScript); + + +$b = (PROCESS $a USING $udf($ROWS,1)); + +PROCESS $b USING $udf2(skey,cnt,pass); diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseMapAfterLReduce.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseMapAfterLReduce.yql new file mode 100644 index 0000000000..ea138e481a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseMapAfterLReduce.yql @@ -0,0 +1,85 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(import core_module '"/lib/yql/core.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) '('"key") '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let inputRowsList (block '( + (let select (block '( + (let core table1) + (let core (FlatMap core (lambda '(row) (AsList (AsStruct '('"key" (Member row '"key")) '('"skey" ("Size" (Member row '"key")))))))) + (let core (Aggregate core '('"skey") '('('Count0 (Apply (bind aggregate_module '"count_traits_factory") (TypeOf core) (lambda '(row) (Void))))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"skey" (Member row '"skey")) '('"cnt" (Member row 'Count0)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (LMap inputRowsList (lambda '(x) (block '( + (let inputType (CallableArgumentType (TypeOf (ScriptUdf 'Python '"f" (CallableType '() '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"pass" (DataType 'Int32)) '('"skey" (DataType 'Uint32))))) '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"skey" (DataType 'Uint32))))) '((DataType 'Int32))) (String '@@ +def f(input,x): + for i in list(input): + d = i.__dict__ + d["pass"] = x + yield d + +def f2(a,b,c): + return {"a":a,"b":b,"c":c} +@@))) '0)) + (let inputRowsList (MatchType inputType 'List (lambda '(y) (ForwardList x)) (lambda '(y) "x"))) + (return (Apply (ScriptUdf 'Python '"f" (CallableType '() '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"pass" (DataType 'Int32)) '('"skey" (DataType 'Uint32))))) '((StreamType (StructType '('"cnt" (DataType 'Uint64)) '('"skey" (DataType 'Uint32))))) '((DataType 'Int32))) (String '@@ +def f(input,x): + for i in list(input): + d = i.__dict__ + d["pass"] = x + yield d + +def f2(a,b,c): + return {"a":a,"b":b,"c":c} +@@)) inputRowsList (Int32 '"1"))) + ))))) + (return core) + ))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Apply (ScriptUdf 'Python '"f2" (CallableType '() '((StructType '('"a" (DataType 'Uint32)) '('"b" (DataType 'Uint64)) '('"c" (DataType 'Int32)))) '((DataType 'Uint32) 'skey) '((DataType 'Uint64) 'cnt) '((DataType 'Int32) 'pass)) (String '@@ +def f(input,x): + for i in list(input): + d = i.__dict__ + d["pass"] = x + yield d + +def f2(a,b,c): + return {"a":a,"b":b,"c":c} +@@)) (Member row '"skey") (Member row '"cnt") (Member row '"pass"))) + (let res (MatchType res 'Optional (lambda '(opt) (ToList opt)) (lambda '(val) (MatchType val 'List (lambda '(list) list) (lambda '(item) (AsList item)))))) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/FuseMultipliersFlatmaps.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseMultipliersFlatmaps.yql new file mode 100644 index 0000000000..6241a465a7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/FuseMultipliersFlatmaps.yql @@ -0,0 +1,20 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList + (AsStruct '('data (String 'a))) + (AsStruct '('data (String 'b))) + (AsStruct '('data (String 'c))) +)) + +(let one (OrderedFlatMap data (lambda '(x) (AsList x (AsStruct '('data (String 'z))))))) +(let two (OrderedFlatMap one (lambda '(x) (AsList (AsStruct '('data (String 'y))) x x)))) +(let three (OrderedFlatMap two (lambda '(x) (AsList x (AsStruct '('data (String 'x))) x)))) +(let world (Write! world res_sink (Key) three '())) +(let world (Commit! world res_sink)) +(return world) +) + diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/GroupBySingleKeyListUnused.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/GroupBySingleKeyListUnused.yql new file mode 100644 index 0000000000..877db04e8b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/GroupBySingleKeyListUnused.yql @@ -0,0 +1,16 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let keyExtractor (lambda '(x) (String '"@"))) +(let handler (lambda '(key list) (AsList (Uint32 '42)))) +(let data (GroupByKey list keyExtractor handler)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/GroupBySingleKeyListUsed.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/GroupBySingleKeyListUsed.yql new file mode 100644 index 0000000000..40045830d0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/GroupBySingleKeyListUsed.yql @@ -0,0 +1,16 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list (AsList (String 'a) (String 'b) (String 'c))) +(let keyExtractor (lambda '(x) (String '"@"))) +(let handler (lambda '(key list) (AsList '(key (Length list))))) +(let data (GroupByKey list keyExtractor handler)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/HasItemsAfterEnumerate.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/HasItemsAfterEnumerate.yql new file mode 100644 index 0000000000..eb78e634af --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/HasItemsAfterEnumerate.yql @@ -0,0 +1,12 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let data (HasItems (Enumerate (AsList (String 'a) (String 'b) (String 'c))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) data '())) + +(let world (Commit! world res_sink)) +(return world) +) + diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/IfOverNotPredicate.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/IfOverNotPredicate.yql new file mode 100644 index 0000000000..798f4b5825 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/IfOverNotPredicate.yql @@ -0,0 +1,11 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (If (Not (ListHas (AsList (Uint32 '1)) (Uint32 '1))) (String 'a) (String 'b))) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/InjectExtractMembersOverSort.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/InjectExtractMembersOverSort.yql new file mode 100644 index 0000000000..2346c6fbe8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/InjectExtractMembersOverSort.yql @@ -0,0 +1,14 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let str1 (AsStruct '('a (Uint32 '1)) '('b (String 'a)) '('c (Bool 'true)))) +(let str2 (AsStruct '('a (Uint32 '2)) '('b (String 'b)) '('c (Bool 'false)))) +(let list1 (AsList str1 str2)) +(let list1 (Sort list1 (Bool 'true) (lambda '(row) (Member row 'a)))) +(let list1 (ExtractMembers list1 '('b))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) list1 '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/InnerLambda.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/InnerLambda.yql new file mode 100644 index 0000000000..cefbe8d819 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/InnerLambda.yql @@ -0,0 +1,18 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list1 (AsList (String 'a) (String 'b))) +(let list2 (AsList (String 'c) (String 'd))) +(let data (FlatMap list1 (lambda '(x) (block '( + (let myList (Map list2 (lambda '(y) (block '( + (return (Concat x y))))))) + (return myList) +))))) + +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/InputUniq.txt b/yql/essentials/tests/s-expressions/suites/Optimizers/InputUniq.txt new file mode 100644 index 0000000000..95a39214c5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/InputUniq.txt @@ -0,0 +1,8 @@ +{"key"="023";"subkey"="3";"value"="aaa"}; +{"key"="037";"subkey"="5";"value"="ddd"}; +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="150";"subkey"="8";"value"="zzz"}; +{"key"="200";"subkey"="7";"value"="qqq"}; +{"key"="527";"subkey"="4";"value"="bbb"}; +{"key"="761";"subkey"="6";"value"="ccc"}; +{"key"="911";"subkey"="2";"value"="kkk"}; diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/InputUniq.txt.attr b/yql/essentials/tests/s-expressions/suites/Optimizers/InputUniq.txt.attr new file mode 100644 index 0000000000..b10bf7c075 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/InputUniq.txt.attr @@ -0,0 +1,10 @@ +{ + "_yql_row_spec"={ + "UniqueKeys"=%true; + "SortMembers"=["key"]; + "SortedBy"=["key"]; + "SortDirections"=[1]; + "SortedByTypes"=[["DataType";"String"]]; + "Type"=["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/LMapWithEmptyInput.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/LMapWithEmptyInput.cfg new file mode 100644 index 0000000000..9d65859cb9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/LMapWithEmptyInput.cfg @@ -0,0 +1,3 @@ +out Output output.txt +res result.txt +udf python3_udf diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/LMapWithEmptyInput.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/LMapWithEmptyInput.yql new file mode 100644 index 0000000000..5395d3e9f8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/LMapWithEmptyInput.yql @@ -0,0 +1,23 @@ +( +(let structType (StructType '('"key" (DataType 'String)) '('"subkey" (DataType 'String)) '('"value" (DataType 'String)))) +#comment +(let udfType (CallableType '() '((StreamType structType)) '((StreamType structType)))) +(let script '@@ +def f(input): + for i in input: + yield { + 'key': i.key, + 'subkey': i.subkey, + 'value': i.value + } +@@) +(let udf (ScriptUdf 'Python3 '"f" udfType (String script))) + +(let res (LMap (List (ListType structType)) (lambda '(stream) (block '( + (return (Apply udf stream)) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) res '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/LengthAfterAsList.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthAfterAsList.yql new file mode 100644 index 0000000000..1e36b20260 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthAfterAsList.yql @@ -0,0 +1,13 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let data (Length (AsList (String 'a) (String 'b)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/LengthAfterEnumerate.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthAfterEnumerate.yql new file mode 100644 index 0000000000..3926c6303f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthAfterEnumerate.yql @@ -0,0 +1,12 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let data (Length (Enumerate (AsList (String 'a) (String 'b) (String 'c))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) data '())) + +(let world (Commit! world res_sink)) +(return world) +) + diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/LengthAfterList.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthAfterList.yql new file mode 100644 index 0000000000..89e18df910 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthAfterList.yql @@ -0,0 +1,13 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let data (Length (List (ListType (DataType 'String)) (String 'a) (String 'b)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/LengthAfterMap.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthAfterMap.yql new file mode 100644 index 0000000000..90563d41a3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthAfterMap.yql @@ -0,0 +1,18 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source + (Key '('table (String 'Input))) + (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let table1 (Map table1 (lambda '(x) '(x (String 'qwe))))) +(let table1len (Length table1)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + table1len '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/LengthOverMrTableContent.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthOverMrTableContent.cfg new file mode 100644 index 0000000000..bf54cfd5be --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthOverMrTableContent.cfg @@ -0,0 +1,2 @@ +in Input input_tbl_content.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/LengthOverMrTableContent.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthOverMrTableContent.yql new file mode 100644 index 0000000000..1a1056aa00 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthOverMrTableContent.yql @@ -0,0 +1,16 @@ +( + #comment + (let mr_source (DataSource 'yt 'plato)) + (let r (Read! world mr_source (Key '('table (String 'Input))) (Void) '('('inline)))) + (let input (Right! r)) + (let out (FlatMap input (lambda '(item) (block '( + (let len (Length input)) + (let key (Member item 'key)) + (let key (Coalesce (Cast key 'Uint64) (Uint64 '0))) + (return (ListIf (> key len) item)) + ))))) + (let mr_sink (DataSink 'yt 'plato)) + (let world (Write! world mr_sink (Key '('table (String 'Output))) out '('('mode 'append)))) + (let world (Commit! world mr_sink)) + (return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/LengthOverMrTableContentInsideMap.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthOverMrTableContentInsideMap.cfg new file mode 100644 index 0000000000..bf54cfd5be --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthOverMrTableContentInsideMap.cfg @@ -0,0 +1,2 @@ +in Input input_tbl_content.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/LengthOverMrTableContentInsideMap.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthOverMrTableContentInsideMap.yql new file mode 100644 index 0000000000..ce4c782796 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/LengthOverMrTableContentInsideMap.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 r (Read! world mr_source (Key '('table (String 'Input))) (Void) '('('inline)))) + + (let out (FlatMap table1 (lambda '(item) (block '( + (let len (Length (Right! r))) + (let key (Member item 'key)) + (let key (Coalesce (Cast key 'Uint64) (Uint64 '0))) + (return (ListIf (> key len) item)) + ))))) + (let mr_sink (DataSink 'yt 'plato)) + (let world (Write! world mr_sink (Key '('table (String 'Output))) out '('('mode 'append)))) + (let world (Commit! world mr_sink)) + (return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MapNextWithUnusedNext.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/MapNextWithUnusedNext.yql new file mode 100644 index 0000000000..06f26563b3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MapNextWithUnusedNext.yql @@ -0,0 +1,14 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let lst (AsList (Int32 '0) (Int32 '1) (Int32 '2) (Int32 '3))) +(let lst (Iterator lst)) +(let lst (MapNext lst (lambda '(current next) (+ current (Int32 '1))))) +(let lst (ForwardList lst)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) lst '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MapThenSortWithLimit.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/MapThenSortWithLimit.cfg new file mode 100644 index 0000000000..a3547c5df6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MapThenSortWithLimit.cfg @@ -0,0 +1,3 @@ +in Input input2.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MapThenSortWithLimit.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/MapThenSortWithLimit.yql new file mode 100644 index 0000000000..800f3c5a9e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MapThenSortWithLimit.yql @@ -0,0 +1,37 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"value" '"key") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core table0) + (let core (Filter core (lambda '(row) (Coalesce ("<" (Member row '"value") (String '"f")) (Bool 'false))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"key" (Member row '"key"))) + (let res (AsList res)) + (return res) +) +)))) + (return core) +) +)) + (let select (Sort select (Bool 'true) (lambda '(row) (Member row '"key")))) + (let select (Take select (Uint64 '"2"))) + (return select) +) +)) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"key"))))) + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return (Commit! world result_sink)) +) +)) + (return world) +) +)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MemberOverFlattenMembers.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/MemberOverFlattenMembers.yql new file mode 100644 index 0000000000..6d4866a169 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MemberOverFlattenMembers.yql @@ -0,0 +1,17 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let myStruct1 (AsStruct '('a (String 'z)))) +(let myStruct2 (AsStruct '('b (String 'y)))) +(let flatten (FlattenMembers '('"first_" myStruct1) '('"second_" myStruct2))) +(let world (Write! world res_sink (Key) flatten '('('type)))) +(let world (Write! world res_sink (Key) (Member flatten 'first_a) '('('type)))) +(let add (AddMember flatten 'c (String 'x))) +(let world (Write! world res_sink (Key) add '('('type)))) +(let world (Write! world res_sink (Key) (Member add 'second_b) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MemberOverJustOrNothingWithNulls.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/MemberOverJustOrNothingWithNulls.yql new file mode 100644 index 0000000000..af913733b0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MemberOverJustOrNothingWithNulls.yql @@ -0,0 +1,13 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let myStruct (AsStruct '('a (String 'z)) '('b (Null)))) +(let typeOfMyStruct (TypeOf myStruct)) + +(let world (Write! world res_sink (Key) (Member (Just myStruct) 'b) '('('type)))) +(let world (Write! world res_sink (Key) (Member (Nothing (OptionalType typeOfMyStruct)) 'b) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverConstSort.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverConstSort.yql new file mode 100644 index 0000000000..94385fb383 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverConstSort.yql @@ -0,0 +1,14 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let str1 (AsStruct '('a (Uint32 '1)) '('b (String 'a)) '('c (Bool 'true)))) +(let str2 (AsStruct '('a (Uint32 '2)) '('b (String 'b)) '('c (Bool 'false)))) +(let list1 (AsList str1 str2)) +(let list1 (Sort list1 (Bool 'true) (lambda '(row) (String 'const_key)))) +(let list1 (ExtractMembers list1 '('c))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) list1 '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverExtend.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverExtend.yql new file mode 100644 index 0000000000..48bd5bd276 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverExtend.yql @@ -0,0 +1,17 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import id_module '"/lib/yql/id.yql") +(let id (bind id_module 'id)) + +(let str1 (AsStruct '('a (Uint32 '1)) '('b (String 'a)) '('c (Bool 'true)))) +(let str2 (AsStruct '('a (Uint32 '2)) '('b (String 'b)) '('c (Bool 'false)))) +(let list1 (Apply id (AsList str1 str2))) +(let list1 (Extend list1 list1)) +(let list1 (ExtractMembers list1 '('a))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) list1 '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverMapNext.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverMapNext.yql new file mode 100644 index 0000000000..72a41ec35c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverMapNext.yql @@ -0,0 +1,23 @@ +( +(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 table1 (Iterator table1)) +(let table1 (MapNext table1 (lambda '(current next) (AsStruct + '('ks '((Member current 'key) (Member next 'subkey))) + '('sv '((Member current 'subkey) (Member next 'value))) + )))) + +(let table1 (ForwardList table1)) + +(let table1 (OrderedMap table1 (lambda '(row) (AsStruct + '('sv (Member row 'sv)) + )))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverSkip.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverSkip.yql new file mode 100644 index 0000000000..5345f0b143 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverSkip.yql @@ -0,0 +1,14 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let str1 (AsStruct '('a (Uint32 '1)) '('b (String 'a)) '('c (Bool 'true)))) +(let str2 (AsStruct '('a (Uint32 '2)) '('b (String 'b)) '('c (Bool 'false)))) +(let list1 (AsList str1 str2)) +(let list1 (Skip list1 (Uint64 '1))) +(let list1 (ExtractMembers list1 '('a))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) list1 '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverSort.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverSort.yql new file mode 100644 index 0000000000..46aec084d2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverSort.yql @@ -0,0 +1,14 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let str1 (AsStruct '('a (Uint32 '1)) '('b (String 'a)) '('c (Bool 'true)))) +(let str2 (AsStruct '('a (Uint32 '2)) '('b (String 'b)) '('c (Bool 'false)))) +(let list1 (AsList str1 str2)) +(let list1 (Sort list1 (Bool 'true) (lambda '(row) (Member row 'a)))) +(let list1 (ExtractMembers list1 '('a))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) list1 '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverSort1.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverSort1.yql new file mode 100644 index 0000000000..a7c9bb7e78 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverSort1.yql @@ -0,0 +1,14 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let str1 (AsStruct '('a (Uint32 '1)) '('b (String 'a)) '('c (Bool 'true)))) +(let str2 (AsStruct '('a (Uint32 '2)) '('b (String 'b)) '('c (Bool 'false)))) +(let list1 (AsList str1 str2)) +(let list1 (Sort list1 (Bool 'true) (lambda '(row) (Member row 'b)))) +(let list1 (ExtractMembers list1 '('b))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) list1 '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverSort2.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverSort2.yql new file mode 100644 index 0000000000..d3988b8ebb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverSort2.yql @@ -0,0 +1,14 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let str1 (AsStruct '('a (Uint32 '1)) '('b (String 'a)) '('c (Bool 'true)))) +(let str2 (AsStruct '('a (Uint32 '2)) '('b (String 'b)) '('c (Bool 'false)))) +(let list1 (AsList str1 str2)) +(let list1 (Sort list1 (Bool 'true) (lambda '(row) (Member row 'b)))) +(let list1 (ExtractMembers list1 '('b 'c))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) list1 '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverTake.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverTake.yql new file mode 100644 index 0000000000..713a57a0fd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MoveExtractMembersOverTake.yql @@ -0,0 +1,14 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let str1 (AsStruct '('a (Uint32 '1)) '('b (String 'a)) '('c (Bool 'true)))) +(let str2 (AsStruct '('a (Uint32 '2)) '('b (String 'b)) '('c (Bool 'false)))) +(let list1 (AsList str1 str2)) +(let list1 (Take list1 (Uint64 '1))) +(let list1 (ExtractMembers list1 '('a))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) list1 '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MultiExtractMembersOverReadTable.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/MultiExtractMembersOverReadTable.cfg new file mode 100644 index 0000000000..64df516e6f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MultiExtractMembersOverReadTable.cfg @@ -0,0 +1,3 @@ +in Input1 input1.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MultiExtractMembersOverReadTable.sql b/yql/essentials/tests/s-expressions/suites/Optimizers/MultiExtractMembersOverReadTable.sql new file mode 100644 index 0000000000..3e7b24508a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MultiExtractMembersOverReadTable.sql @@ -0,0 +1,13 @@ +$aggregated = ( + SELECT Group, Name, SUM(Amount) AS TotalAmount + FROM plato.Input1 + GROUP BY Group, Name +); + +SELECT t.Comment, a.TotalAmount +FROM plato.Input1 AS t +INNER JOIN $aggregated AS a +ON t.Group == a.Group AND t.Name == a.Name +ORDER BY t.Comment, a.TotalAmount; + +SELECT TotalAmount FROM $aggregated ORDER BY TotalAmount; diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/MultiExtractMembersOverReadTable.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/MultiExtractMembersOverReadTable.yql new file mode 100644 index 0000000000..c744fafa76 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/MultiExtractMembersOverReadTable.yql @@ -0,0 +1,83 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(import core_module '"/lib/yql/core.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input1")))) (Void) '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let output (block '( + (let select (block '( + (let core (EquiJoin '(table1 '"t") '((block '( + (let select (block '( + (let core table1) + (let core (Aggregate core '('"Group" '"Name") '('('Sum0 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"Amount"))))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"Group" (Member row '"Group")) '('"Name" (Member row '"Name")) '('"TotalAmount" (Member row 'Sum0)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"a") '('Inner '"t" '"a" '('"t" '"Group" '"t" '"Name") '('"a" '"Group" '"a" '"Name") '()) '())) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"t.Comment" (SqlColumn row '"Comment" '"t")) '('"a.TotalAmount" (SqlColumn row '"TotalAmount" '"a")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (let select (Sort select '((Bool 'true) (Bool 'true)) (lambda '(row) '((Member row '"t.Comment") (Member row '"a.TotalAmount"))))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"t.Comment" '"a.TotalAmount"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input1")))) (Void) '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let output (block '( + (let select (block '( + (let core (block '( + (let select (block '( + (let core table1) + (let core (Aggregate core '('"Group" '"Name") '('('Sum0 (Apply (bind aggregate_module '"sum_traits_factory") (TypeOf core) (lambda '(row) (Member row '"Amount"))))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"Group" (Member row '"Group")) '('"Name" (Member row '"Name")) '('"TotalAmount" (Member row 'Sum0)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"TotalAmount" (Member row '"TotalAmount")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (let select (Sort select (Bool 'true) (lambda '(row) (Member row '"TotalAmount")))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"TotalAmount"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/NonEquivNestedLambdaOuterSameLevel.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/NonEquivNestedLambdaOuterSameLevel.yql new file mode 100644 index 0000000000..61f9307f1a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/NonEquivNestedLambdaOuterSameLevel.yql @@ -0,0 +1,28 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let outLambda1 (lambda '(sep) (block '( + (let data (AsList (String 'a) (String 'b))) + (let data1 (Map data (lambda '(x) (Concat x sep)))) + (let res data1) + (return res) +)))) + +(let outLambda2 (lambda '(sep) (block '( + (let data (AsList (String 'a) (String 'c))) + (let data1 (Map data (lambda '(x) (Concat x sep)))) + (let res data1) + (return res) +)))) + +(let predicate (== (Int32 '1) (Int32 '2))) +(let sep (If predicate (Just (String '_)) (Just (String '+)))) +(let data1 (IfPresent sep outLambda1 (AsList (String 'none)))) +(let data2 (IfPresent sep outLambda2 (AsList (String 'none)))) +(let world (Write! world res_sink (Key) '(data1 data2) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/PartitionByWithInnerSort.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/PartitionByWithInnerSort.cfg new file mode 100644 index 0000000000..bc0dfe8e18 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/PartitionByWithInnerSort.cfg @@ -0,0 +1,4 @@ +in Input SomeKeys.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/PartitionByWithInnerSort.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/PartitionByWithInnerSort.yql new file mode 100644 index 0000000000..a245de4f18 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/PartitionByWithInnerSort.yql @@ -0,0 +1,72 @@ +( + # prepare python udf + (let str (DataType 'String)) + (let tupleType (TupleType str str)) + (let udfType (CallableType '() '(tupleType) '(str) '(str))) + (let udfScript (String '@@ +def MyTuple(one, two): + return (one, two) + +@@)) + (let udf (ScriptUdf 'Python 'MyTuple udfType udfScript)) + + (let mr_source (DataSource 'yt 'plato)) + (let x (Read! world mr_source (Key '('table (String 'Input))) (Void) '())) + (let world (Left! x)) + (let table1 (Right! x)) + + (let singleKeySelector (lambda '(x) (Member x 'key))) + (let multiKeySelector (lambda '(x) '((Member x 'key) (Member x 'subkey)))) + (let tupleKeySelector (lambda '(x) (Apply udf (Member x 'key) (Member x 'subkey)))) + (let calcKeySelector (lambda '(x) (Concat (Member x 'key) (Member x 'subkey)))) + + (let singleDirAsc (Bool 'true)) + (let singleDirDesc (Bool 'false)) + (let multiDirAsc '((Bool 'true) (Bool 'true))) + (let multiDirDesc '((Bool 'false) (Bool 'false))) + + (let singleSortKeySelector (lambda '(item) (Member item 'subkey))) + (let multiSortKeySelector (lambda '(item) '((Member item 'subkey) (Member item 'value)))) + (let tupleSortKeySelector (lambda '(item) (Apply udf (Member item 'subkey) (Member item 'value)))) + (let calcSortKeySelector (lambda '(item) (Concat (Member item 'subkey) (Member item 'value)))) + + (let res_sink (DataSink 'result)) + + (let macro (lambda '(world keySelector sortDir sortKeySelector) (block '( + (let res (PartitionByKey table1 keySelector sortDir sortKeySelector (lambda '(stream) (FlatMap stream (lambda '(pair) (Nth pair '1)))))) + (let res (Sort res '((Bool 'true) (Bool 'true)) (lambda '(item) '((Member item 'key) (Member item 'subkey))))) + (let world (Write! world res_sink (Key) res '())) + (return world) + )))) + + (let world (Apply macro world singleKeySelector singleDirAsc singleSortKeySelector)) + (let world (Apply macro world singleKeySelector singleDirDesc singleSortKeySelector)) + (let world (Apply macro world singleKeySelector multiDirAsc multiSortKeySelector)) + (let world (Apply macro world singleKeySelector multiDirDesc multiSortKeySelector)) + (let world (Apply macro world singleKeySelector multiDirAsc tupleSortKeySelector)) + (let world (Apply macro world singleKeySelector singleDirAsc calcSortKeySelector)) + + (let world (Apply macro world multiKeySelector singleDirAsc singleSortKeySelector)) + (let world (Apply macro world multiKeySelector singleDirDesc singleSortKeySelector)) + (let world (Apply macro world multiKeySelector multiDirAsc multiSortKeySelector)) + (let world (Apply macro world multiKeySelector multiDirDesc multiSortKeySelector)) + (let world (Apply macro world multiKeySelector multiDirAsc tupleSortKeySelector)) + (let world (Apply macro world multiKeySelector singleDirAsc calcSortKeySelector)) + + (let world (Apply macro world tupleKeySelector singleDirAsc singleSortKeySelector)) + (let world (Apply macro world tupleKeySelector singleDirDesc singleSortKeySelector)) + (let world (Apply macro world tupleKeySelector multiDirAsc multiSortKeySelector)) + (let world (Apply macro world tupleKeySelector multiDirDesc multiSortKeySelector)) + (let world (Apply macro world tupleKeySelector multiDirAsc tupleSortKeySelector)) + (let world (Apply macro world tupleKeySelector singleDirAsc calcSortKeySelector)) + + (let world (Apply macro world calcKeySelector singleDirAsc singleSortKeySelector)) + (let world (Apply macro world calcKeySelector singleDirDesc singleSortKeySelector)) + (let world (Apply macro world calcKeySelector multiDirAsc multiSortKeySelector)) + (let world (Apply macro world calcKeySelector multiDirDesc multiSortKeySelector)) + (let world (Apply macro world calcKeySelector multiDirAsc tupleSortKeySelector)) + (let world (Apply macro world calcKeySelector singleDirAsc calcSortKeySelector)) + + (let world (Commit! world res_sink)) + (return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/PartitionsByWithInnerSort.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/PartitionsByWithInnerSort.cfg new file mode 100644 index 0000000000..bc0dfe8e18 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/PartitionsByWithInnerSort.cfg @@ -0,0 +1,4 @@ +in Input SomeKeys.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/PartitionsByWithInnerSort.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/PartitionsByWithInnerSort.yql new file mode 100644 index 0000000000..dda6bd8d62 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/PartitionsByWithInnerSort.yql @@ -0,0 +1,72 @@ +( + # prepare python udf + (let str (DataType 'String)) + (let tupleType (TupleType str str)) + (let udfType (CallableType '() '(tupleType) '(str) '(str))) + (let udfScript (String '@@ +def MyTuple(one, two): + return (one, two) + +@@)) + (let udf (ScriptUdf 'Python3 'MyTuple udfType udfScript)) + + (let mr_source (DataSource 'yt 'plato)) + (let x (Read! world mr_source (Key '('table (String 'Input))) (Void) '())) + (let world (Left! x)) + (let table1 (Right! x)) + + (let singleKeySelector (lambda '(x) (Member x 'key))) + (let multiKeySelector (lambda '(x) '((Member x 'key) (Member x 'subkey)))) + (let tupleKeySelector (lambda '(x) (Apply udf (Member x 'key) (Member x 'subkey)))) + (let calcKeySelector (lambda '(x) (Concat (Member x 'key) (Member x 'subkey)))) + + (let singleDirAsc (Bool 'true)) + (let singleDirDesc (Bool 'false)) + (let multiDirAsc '((Bool 'true) (Bool 'true))) + (let multiDirDesc '((Bool 'false) (Bool 'false))) + + (let singleSortKeySelector (lambda '(item) (Member item 'subkey))) + (let multiSortKeySelector (lambda '(item) '((Member item 'subkey) (Member item 'value)))) + (let tupleSortKeySelector (lambda '(item) (Apply udf (Member item 'subkey) (Member item 'value)))) + (let calcSortKeySelector (lambda '(item) (Concat (Member item 'subkey) (Member item 'value)))) + + (let res_sink (DataSink 'result)) + + (let macro (lambda '(world keySelector sortDir sortKeySelector) (block '( + (let res (PartitionsByKeys table1 keySelector sortDir sortKeySelector (lambda '(stream) stream))) + (let res (Sort res '((Bool 'true) (Bool 'true)) (lambda '(item) '((Member item 'key) (Member item 'subkey))))) + (let world (Write! world res_sink (Key) res '())) + (return world) + )))) + + (let world (Apply macro world singleKeySelector singleDirAsc singleSortKeySelector)) + (let world (Apply macro world singleKeySelector singleDirDesc singleSortKeySelector)) + (let world (Apply macro world singleKeySelector multiDirAsc multiSortKeySelector)) + (let world (Apply macro world singleKeySelector multiDirDesc multiSortKeySelector)) + (let world (Apply macro world singleKeySelector multiDirAsc tupleSortKeySelector)) + (let world (Apply macro world singleKeySelector singleDirAsc calcSortKeySelector)) + + (let world (Apply macro world multiKeySelector singleDirAsc singleSortKeySelector)) + (let world (Apply macro world multiKeySelector singleDirDesc singleSortKeySelector)) + (let world (Apply macro world multiKeySelector multiDirAsc multiSortKeySelector)) + (let world (Apply macro world multiKeySelector multiDirDesc multiSortKeySelector)) + (let world (Apply macro world multiKeySelector multiDirAsc tupleSortKeySelector)) + (let world (Apply macro world multiKeySelector singleDirAsc calcSortKeySelector)) + + (let world (Apply macro world tupleKeySelector singleDirAsc singleSortKeySelector)) + (let world (Apply macro world tupleKeySelector singleDirDesc singleSortKeySelector)) + (let world (Apply macro world tupleKeySelector multiDirAsc multiSortKeySelector)) + (let world (Apply macro world tupleKeySelector multiDirDesc multiSortKeySelector)) + (let world (Apply macro world tupleKeySelector multiDirAsc tupleSortKeySelector)) + (let world (Apply macro world tupleKeySelector singleDirAsc calcSortKeySelector)) + + (let world (Apply macro world calcKeySelector singleDirAsc singleSortKeySelector)) + (let world (Apply macro world calcKeySelector singleDirDesc singleSortKeySelector)) + (let world (Apply macro world calcKeySelector multiDirAsc multiSortKeySelector)) + (let world (Apply macro world calcKeySelector multiDirDesc multiSortKeySelector)) + (let world (Apply macro world calcKeySelector multiDirAsc tupleSortKeySelector)) + (let world (Apply macro world calcKeySelector singleDirAsc calcSortKeySelector)) + + (let world (Commit! world res_sink)) + (return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/PullLimitAfterFilter.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/PullLimitAfterFilter.yql new file mode 100644 index 0000000000..262c788d71 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/PullLimitAfterFilter.yql @@ -0,0 +1,18 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source + (Key '('table (String 'Input))) + (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +#(let table1 (AsList (AsStruct '('key (String '100))))) +(let table2 (Filter table1 (lambda '(x) (< (Member x 'key) (String '800))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + table2 '('('take '2)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/PullLimitAfterFilterRef.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/PullLimitAfterFilterRef.yql new file mode 100644 index 0000000000..a96ce7edcf --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/PullLimitAfterFilterRef.yql @@ -0,0 +1,18 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source + (Key '('table (String 'Input))) + (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +#(let table1 (AsList (AsStruct '('key (String '100))))) +(let table2 (Filter table1 (lambda '(x) (< (Member x 'key) (String '800))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + table2 '('('take '2) '('autoref)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/PushDownToFlow.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/PushDownToFlow.yql new file mode 100644 index 0000000000..cf614d25ca --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/PushDownToFlow.yql @@ -0,0 +1,17 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (String 'x) (String 'c) (String 'e) (String 'a) (String 'z) (String 'y) (String 'f))) +(let data (Reverse data)) +(let data (Skip data (Uint64 '2))) +(let data (Take data (Uint64 '3))) +(let data (OrderedMap data (lambda '(x) '(x x)))) +(let data (ToFlow data)) +(let data (Collect data)) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/ReverseAfterSort.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/ReverseAfterSort.yql new file mode 100644 index 0000000000..f4ca885270 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/ReverseAfterSort.yql @@ -0,0 +1,17 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (String 'c) (String 'e) (String 'a))) +(let data (Sort data (Bool 'true) (lambda '(x) x))) +(let data (Reverse data)) +(let world (Write! world res_sink (Key) data '())) +(let data (AsList '((Uint32 '1) (String 'c)) '((Uint32 '1) (String 's)) '((Uint32 '2) (String 'a)))) +(let data (Sort data '((Bool 'true) (Bool 'false)) (lambda '(x) x))) +(let data (Reverse data)) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SelectMembersOverOptStruct.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/SelectMembersOverOptStruct.yql new file mode 100644 index 0000000000..b9e3b2373c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SelectMembersOverOptStruct.yql @@ -0,0 +1,18 @@ +( +(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 table1 (Map ("/" (Int32 '42) (Int32 '1)) (lambda '(item) (AsStruct + '('magic (Just item)) + '('black_magic ("/" (Int32 '100) item)) + )))) + +(let table1 (SelectMembers table1 '('m))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersect.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersect.cfg new file mode 100644 index 0000000000..e6d9edcc5d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersect.cfg @@ -0,0 +1,2 @@ +in Input InputUniq.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersect.sql b/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersect.sql new file mode 100644 index 0000000000..127c25a4d5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersect.sql @@ -0,0 +1,5 @@ +USE plato; + +$a = (SELECT key,subkey || "a" as subkey from Input where value < "r"); +$b = (SELECT key,subkey || "b" as subkey from Input where value > "c"); +select a.key as k1,a.subkey,b.subkey from $a as a join $b as b using (key); diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersect.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersect.yql new file mode 100644 index 0000000000..3770df6de5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersect.yql @@ -0,0 +1,57 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) '('"value" '"key" '"subkey") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (EquiJoin '((block '( + (let select (block '( + (let core table0) + (let core (Filter core (lambda '(row) (Coalesce ("<" (Member row '"value") (String '"r")) (Bool 'false))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"key" (Member row '"key")) '('"subkey" ("Concat" (Member row '"subkey") (String '"a"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"a") '((block '( + (let select (block '( + (let core table0) + (let core (Filter core (lambda '(row) (Coalesce (">" (Member row '"value") (String '"c")) (Bool 'false))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"key" (Member row '"key")) '('"subkey" ("Concat" (Member row '"subkey") (String '"b"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"b") '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key") '()) '())) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"k1" (SqlColumn row '"key" '"a")) '('"a.subkey" (SqlColumn row '"subkey" '"a")) '('"b.subkey" (SqlColumn row '"subkey" '"b")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"k1" '"a.subkey" '"b.subkey"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersectTab1.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersectTab1.cfg new file mode 100644 index 0000000000..e6d9edcc5d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersectTab1.cfg @@ -0,0 +1,2 @@ +in Input InputUniq.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersectTab1.sql b/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersectTab1.sql new file mode 100644 index 0000000000..944f3c386f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersectTab1.sql @@ -0,0 +1,5 @@ +USE plato; + +$a = (SELECT key,subkey || "a" as subkey from Input where value < "r"); +$b = (SELECT key,subkey || "b" as subkey from Input); +select a.key as k1,a.subkey,b.subkey from Input as a join $b as b using (key); diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersectTab1.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersectTab1.yql new file mode 100644 index 0000000000..45e75bf7d7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SelfJoinIntersectTab1.yql @@ -0,0 +1,44 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) '('"key" '"subkey") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core (EquiJoin '(table0 '"a") '((block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"key" (Member row '"key")) '('"subkey" ("Concat" (Member row '"subkey") (String '"b"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + )) '"b") '('Inner '"a" '"b" '('"a" '"key") '('"b" '"key") '()) '())) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"k1" (SqlColumn row '"key" '"a")) '('"a.subkey" (SqlColumn row '"subkey" '"a")) '('"b.subkey" (SqlColumn row '"subkey" '"b")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"k1" '"a.subkey" '"b.subkey"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SkipAfterMap.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/SkipAfterMap.yql new file mode 100644 index 0000000000..fbc9dc1ba4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SkipAfterMap.yql @@ -0,0 +1,18 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source + (Key '('table (String 'Input))) + (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let table1 (Map table1 (lambda '(x) (AddMember x 'foo (String 'qwe))))) +(let table1 (Skip table1 (Uint64 '2))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + table1 '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SkipOverExtend.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/SkipOverExtend.yql new file mode 100644 index 0000000000..3ec439ddde --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SkipOverExtend.yql @@ -0,0 +1,18 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList (String 'a) (String 'b) (String 'c))) +(let list2 (AsList (String 'd) (String 'e) (String 'f))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + (Skip (Extend list1 list2) (Uint64 '1)) '())) + +(let world (Write! world res_sink + (Key) + (Skip (Extend list1 list2) (Uint64 '5)) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SkipTakeOverMrTableContent.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/SkipTakeOverMrTableContent.cfg new file mode 100644 index 0000000000..bf54cfd5be --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SkipTakeOverMrTableContent.cfg @@ -0,0 +1,2 @@ +in Input input_tbl_content.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SkipTakeOverMrTableContent.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/SkipTakeOverMrTableContent.yql new file mode 100644 index 0000000000..d51db8e508 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SkipTakeOverMrTableContent.yql @@ -0,0 +1,17 @@ +( + #comment + (let mr_source (DataSource 'yt 'plato)) + (let r (Read! world mr_source (Key '('table (String 'Input))) (Void) '('('inline)))) + (let table1 (Right! r)) + (let table1 (Skip table1 (Uint64 '5))) + (let table1 (Take table1 (Uint64 '3))) + (let tresh (String '300)) + (let table1low (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (Member item 'key)) + (return (ListIf (< intValueOpt tresh) item)) + ))))) + (let mr_sink (DataSink 'yt 'plato)) + (let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) + (let world (Commit! world mr_sink)) + (return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SkipTakeOverMrTableContentInsideMap.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/SkipTakeOverMrTableContentInsideMap.cfg new file mode 100644 index 0000000000..bf54cfd5be --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SkipTakeOverMrTableContentInsideMap.cfg @@ -0,0 +1,2 @@ +in Input input_tbl_content.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SkipTakeOverMrTableContentInsideMap.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/SkipTakeOverMrTableContentInsideMap.yql new file mode 100644 index 0000000000..5bfc63445e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SkipTakeOverMrTableContentInsideMap.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 r (Read! world mr_source (Key '('table (String 'Input))) (Void) '('('inline)))) + (let mrtc (Right! r)) + (let mrtc (Skip mrtc (Uint64 '5))) + (let mrtc (Take mrtc (Uint64 '3))) + (let mrtc (FlatMap mrtc (lambda '(item) (block '( + (let key (Member item 'key)) + (return (ListIf (> key (String '100)) item)) + ))))) + (let filter (ToDict mrtc (lambda '(x) (Member x 'key)) (lambda '(x) (Member x 'value)) '('Hashed 'One))) + + (let tresh (String '500)) + (let out (FlatMap table1 (lambda '(item) (block '( + (let key (Member item 'key)) + (return (ListIf (And (< key tresh) (Contains filter key)) item)) + ))))) + (let mr_sink (DataSink 'yt 'plato)) + (let world (Write! world mr_sink (Key '('table (String 'Output))) out '('('mode 'append)))) + (let world (Commit! world mr_sink)) + (return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SkipWhileOverLiterals.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/SkipWhileOverLiterals.yql new file mode 100644 index 0000000000..e661d70dde --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SkipWhileOverLiterals.yql @@ -0,0 +1,44 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let listVal (AsList (Int32 '0))) +(let listVal (Append listVal (Int32 '1))) + +(let emptyList (List (ListType (DataType 'Int32)))) +(let emptyStream (EmptyIterator (StreamType (DataType 'Int32)))) +(let emptyOptional (Nothing (OptionalType (DataType 'Int32)))) + +(let notOptLambda (lambda '(x) (< x (Int32 '1)))) + +# Skip while true: [] +(let res (SkipWhile listVal (lambda '(x) (Bool 'true)))) +(let world (Write! world res_sink (Key) res '('('type)))) + +# Skip while false: [0, 1] +(let res (SkipWhile listVal (lambda '(x) (Bool 'false)))) +(let world (Write! world res_sink (Key) res '('('type)))) + +# Skip from empty list: [] +(let res (SkipWhile emptyList notOptLambda)) +(let world (Write! world res_sink (Key) res '('('type)))) + +# Skip from empty stream: [] +(let res (SkipWhile emptyStream notOptLambda)) +(let res (Collect res)) +(let world (Write! world res_sink (Key) res '('('type)))) + +# Skip from empty optional: [] +(let res (SkipWhile emptyOptional notOptLambda)) +(let world (Write! world res_sink (Key) res '('('type)))) + +# General case: [1] +(let res (SkipWhile listVal notOptLambda)) +(let world (Write! world res_sink (Key) res '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SomeKeys.txt b/yql/essentials/tests/s-expressions/suites/Optimizers/SomeKeys.txt new file mode 100644 index 0000000000..6d0b5b4d40 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SomeKeys.txt @@ -0,0 +1,7 @@ +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="075";"subkey"="2";"value"="abc2"}; +{"key"="075";"subkey"="3";"value"="abc3"}; +{"key"="800";"subkey"="4";"value"="ddd"}; +{"key"="020";"subkey"="5";"value"="q"}; +{"key"="150";"subkey"="6";"value"="qzz"}; +{"key"="150";"subkey"="7";"value"="zz"}; diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SomeKeys.txt.attr b/yql/essentials/tests/s-expressions/suites/Optimizers/SomeKeys.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SomeKeys.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/Optimizers/SortAfterReverse.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/SortAfterReverse.yql new file mode 100644 index 0000000000..21570ead7b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SortAfterReverse.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (String 'c) (String 'e) (String 'a))) +(let data (Reverse data)) +(let data (Sort data (Bool 'true) (lambda '(x) x))) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SortOfSortedDesc.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/SortOfSortedDesc.yql new file mode 100644 index 0000000000..3fbb12f446 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SortOfSortedDesc.yql @@ -0,0 +1,24 @@ +( +(let source (DataSource 'yt 'plato)) +(let sink (DataSink 'yt 'plato)) +(let result (DataSink 'result)) + +(let r (Read! world source (MrTableConcat (Key '('table (String '"Input")))) (Void) '())) +(let input (Right! r)) +(let world (Left! r)) + +(let out (Sort (FlatMap input (lambda '(item) (AsList item))) (Bool 'false) (lambda '(item) (Member item '"key")))) +(let world (Write! world sink (Key '('table (String '"Output"))) out '('('mode 'renew)))) +(let world (Commit! world sink)) + +(let r (Read! world source (MrTableConcat (Key '('table (String '"Output")))) (Void) '())) +(let input (Right! r)) +(let world (Left! r)) + +(let out (Sort (FlatMap input (lambda '(item) (AsList item))) (Bool 'true) (lambda '(item) (Member item '"key")))) +(let world (Write! world result (Key) out '('('type) '('autoref)))) +(let world (Commit! world result)) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/SubsetOfFields.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/SubsetOfFields.yql new file mode 100644 index 0000000000..f4d4e775d8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SubsetOfFields.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 item (RemoveMember item 'value)) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '"s1"))) + (let s (AddMember s 'value (String '"v1"))) + (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 'Input))) '('key 'subkey 'value) '('('inline)))) +(let table1 (Right! x)) +(let table1map (Map table1 (lambda '(item) (block '( + (let item (RemoveMember item 'value)) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '"s2"))) + (let s (AddMember s 'value (String '"v2"))) + (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/Optimizers/SwitchToVisit.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/SwitchToVisit.yql new file mode 100644 index 0000000000..b703492435 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/SwitchToVisit.yql @@ -0,0 +1,73 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let list (AsList + (AsStruct '('key (String 'aaa)) '('value (String '0))) + (AsStruct '('key (String 'bbb)) '('value (String '1))) + (AsStruct '('key (String 'ccc)) '('value (String '2))) +)) + +(let structType (StructType '('key (DataType 'String)) '('value (DataType 'String)))) +(let tupleType (TupleType structType structType structType)) +(let vt (VariantType tupleType)) +(let vlist (AsList + (Variant (AsStruct '('key (String 'aaa)) '('value (String '0))) '0 vt) + (Variant (AsStruct '('key (String 'bbb)) '('value (String '1))) '1 vt) + (Variant (AsStruct '('key (String 'ccc)) '('value (String '2))) '2 vt) +)) + +(let trivialLambda (lambda '(x) x)) +(let justHandler1 (lambda '(x) (FlatMap x (lambda '(s) (Just (AsStruct '('key (Concat (String '"#0: ") (Member s 'key))) '('value (Member s 'value)))))))) +(let justHandler2 (lambda '(x) (FlatMap x (lambda '(s) (Just (AsStruct '('key (Concat (String '"#1: ") (Member s 'key))) '('value (Member s 'value)))))))) +(let justHandler3 (lambda '(x) (FlatMap x (lambda '(s) (Just (AsStruct '('key (Concat (String '"#3: ") (Member s 'key))) '('value (Member s 'value)))))))) +(let extractMembersHandler (lambda '(x) (FlatMap (ExtractMembers x '('key)) (lambda '(s) (Just (AsStruct '('key (Concat (String '"#3: ") (Member s 'key))))))))) +(let listHandler (lambda '(x) (FlatMap x (lambda '(s) (AsList s s))))) +(let streamHandler (lambda '(x) (FlatMap x (lambda '(s) (Iterator (AsList s s) (DependsOn s) (DependsOn (String '0))))))) +(let justVarHandler1 (lambda '(x) (FlatMap x (lambda '(s) (Just (Variant s '1 vt)))))) +(let justVarHandler2 (lambda '(x) (FlatMap x (lambda '(s) (Just (Variant s '2 vt)))))) + +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'A1))) '1 '('1) trivialLambda)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'A2))) '1 '('0) justHandler1)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'A3))) '1 '('0) listHandler)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'A4))) '1 '('0) streamHandler)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'A5))) '1 '('0) justVarHandler1)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'A6))) '1 '('0) extractMembersHandler)) '('('type)))) + +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'B1))) '1 '('0) justHandler1 '('1) justHandler2)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'B2))) '1 '('0) justHandler1 '('1) justHandler2 '('2) justHandler3)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'B3))) '1 '('0) justHandler1 '('1) trivialLambda)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'B4))) '1 '('0) justHandler1 '('1) extractMembersHandler)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'B5))) '1 '('0) justHandler1 '('1) justHandler2 '('1) justHandler3 '('2) justHandler3)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'B6))) '1 '('0) justHandler1 '('1) justHandler2 '('1) justHandler3)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'B7))) '1 '('0) justHandler1 '('0) justHandler2)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'B8))) '1 '('0) justHandler1 '('1) justHandler2 '('1) streamHandler)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'B9))) '1 '('0) justHandler1 '('1) extractMembersHandler '('1) streamHandler)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'B10))) '1 '('0) justHandler1 '('1) listHandler '('1) streamHandler)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'B11))) '1 '('0) justHandler1 '('1) listHandler '('1) trivialLambda)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'B12))) '1 '('0) justHandler1 '('1) trivialLambda '('1) trivialLambda)) '('('type)))) + +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'C1))) '1 '('0) justHandler1 '('1) listHandler '('2) trivialLambda)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'C2))) '1 '('0) streamHandler '('1) listHandler '('2) trivialLambda)) '('('type)))) + +# Shouldn't be optimized +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'D1))) '1 '('0) justVarHandler1 '('1) justVarHandler2)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator vlist (DependsOn (String 'D2))) '1 '('0) justHandler1 '('1) justVarHandler2)) '('('type)))) + +# Replicating Switch +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator list (DependsOn (String 'E1))) '1 '('0) trivialLambda)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator list (DependsOn (String 'E2))) '1 '('0) justVarHandler1)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator list (DependsOn (String 'E3))) '1 '('0) trivialLambda '('0) justHandler1 '('0) justHandler2)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator list (DependsOn (String 'E4))) '1 '('0) justHandler1 '('0) extractMembersHandler)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator list (DependsOn (String 'E5))) '1 '('0) trivialLambda '('0) justHandler1 '('0) listHandler)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator list (DependsOn (String 'E6))) '1 '('0) streamHandler '('0) listHandler)) '('('type)))) + +# Shouldn't be optimized +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator list (DependsOn (String 'F1))) '1 '('0) justVarHandler1 '('0) justVarHandler2)) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Switch (Iterator list (DependsOn (String 'F2))) '1 '('0) justHandler1 '('0) justVarHandler2)) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/TakeAfterMap.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeAfterMap.yql new file mode 100644 index 0000000000..41df996fee --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeAfterMap.yql @@ -0,0 +1,18 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source + (Key '('table (String 'Input))) + (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let table1 (Map table1 (lambda '(x) (AddMember x 'foo (String 'qwe))))) +(let table1 (Take table1 (Uint64 '2))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + table1 '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterCombine.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterCombine.cfg new file mode 100644 index 0000000000..80d5638bff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterCombine.cfg @@ -0,0 +1,3 @@ +in Input SomeKeys.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterCombine.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterCombine.yql new file mode 100644 index 0000000000..b263c72063 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterCombine.yql @@ -0,0 +1,30 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source + (Key '('table (String 'Input))) + (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let preMap (lambda '(item) (Just item))) +(let keyExtractor (lambda '(item) (Member item 'key))) +(let init (lambda '(key item) (FromString (Member item 'subkey) 'Uint32))) +(let update (lambda '(key item state) (+ state (FromString (Member item 'subkey) 'Uint32)))) +(let finish (lambda '(key state) (block '( + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Coalesce (Map state (lambda '(x) (ToString x))) (String '"")))) + (return (Just s)) +)))) + +(let table2 (CombineByKey table1 preMap keyExtractor init update finish)) +(let table2 (Take table2 (Uint64 '2))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + table2 '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterFilter.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterFilter.yql new file mode 100644 index 0000000000..e161a11ee5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterFilter.yql @@ -0,0 +1,23 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source + (Key '('table (String 'Input))) + (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let table1 (Filter table1 (lambda '(x) (< (Member x 'key) (String '800))))) +(let table2x (Skip (Take table1 (Uint64 '2)) (Uint64 '1))) +(let table2y (Take table1 (Uint64 '3))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + table2x '())) + +(let world (Write! world res_sink + (Key) + table2y '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterGroup.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterGroup.cfg new file mode 100644 index 0000000000..80d5638bff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterGroup.cfg @@ -0,0 +1,3 @@ +in Input SomeKeys.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterGroup.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterGroup.yql new file mode 100644 index 0000000000..d0fa6fb1dd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterGroup.yql @@ -0,0 +1,34 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source + (Key '('table (String 'Input))) + (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let keyExtractor (lambda '(item) (Member item 'key))) +(let handler (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 f (Fold list (Uint64 '0) (lambda '(item state) (block '( + (let value (Coalesce (FromString (Member item 'subkey) 'Uint64) (Uint64 '0))) + (return (+ value state)) + ))))) + (let s (AddMember s 'value (ToString f))) + (return (Just s)) +)))))) + +(let table2 (PartitionByKey table1 keyExtractor (Void) (Void) handler)) +(let table2 (Take table2 (Uint64 '4))) +(let table2 (Sort table2 (Bool 'true) (lambda '(item) (Member item 'value)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + table2 '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterSort.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterSort.yql new file mode 100644 index 0000000000..107a53b598 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeLimitAfterSort.yql @@ -0,0 +1,19 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source + (Key '('table (String 'Input))) + (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let keyExtractor (lambda '(item) (Member item 'key))) +(let table2 (Sort table1 (Bool 'true) keyExtractor)) +(let table2 (Take table2 (Uint64 '2))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + table2 '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/TakeOverExtend.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeOverExtend.yql new file mode 100644 index 0000000000..e7b12fc1c1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeOverExtend.yql @@ -0,0 +1,18 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let list1 (AsList (String 'a) (String 'b) (String 'c))) +(let list2 (AsList (String 'd) (String 'e) (String 'f))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + (Take (Extend list1 list2) (Uint64 '1)) '())) + +(let world (Write! world res_sink + (Key) + (Take (Extend list1 list2) (Uint64 '5)) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/TakeOverTop.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeOverTop.yql new file mode 100644 index 0000000000..ad245012d0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeOverTop.yql @@ -0,0 +1,14 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (String 'x) (String 'c) (String 'e) (String 'a) (String 'z) (String 'y) (String 'f))) +(let data (Top data (Uint64 '4) (Bool 'true) (lambda '(x) x))) +(let data (Take data (Uint64 '2))) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) + diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/TakeWhileOverLiterals.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeWhileOverLiterals.yql new file mode 100644 index 0000000000..bc2bdb9037 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/TakeWhileOverLiterals.yql @@ -0,0 +1,44 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) + +(let listVal (AsList (Int32 '0))) +(let listVal (Append listVal (Int32 '1))) + +(let emptyList (List (ListType (DataType 'Int32)))) +(let emptyStream (EmptyIterator (StreamType (DataType 'Int32)))) +(let emptyOptional (Nothing (OptionalType (DataType 'Int32)))) + +(let notOptLambda (lambda '(x) (< x (Int32 '1)))) + +# Take while true: [0, 1] +(let res (TakeWhile listVal (lambda '(x) (Bool 'true)))) +(let world (Write! world res_sink (Key) res '('('type)))) + +# Take while false: [] +(let res (TakeWhile listVal (lambda '(x) (Bool 'false)))) +(let world (Write! world res_sink (Key) res '('('type)))) + +# Take from empty list: [] +(let res (TakeWhile emptyList notOptLambda)) +(let world (Write! world res_sink (Key) res '('('type)))) + +# Take from empty stream: [] +(let res (TakeWhile emptyStream notOptLambda)) +(let res (Collect res)) +(let world (Write! world res_sink (Key) res '('('type)))) + +# Take from empty optional: [] +(let res (TakeWhile emptyOptional notOptLambda)) +(let world (Write! world res_sink (Key) res '('('type)))) + +# General case: [0] +(let res (TakeWhile listVal notOptLambda)) +(let world (Write! world res_sink (Key) res '('('type)))) + +(let world (Commit! world res_sink)) +(return world) + +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/Top.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/Top.yql new file mode 100644 index 0000000000..e0a2bab036 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/Top.yql @@ -0,0 +1,42 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let res_sink (DataSink 'result)) + +(let x (Read! world mr_source (Key '('table (String 'Input))) (Void) '())) +(let world (Left! x)) +(let table (Right! x)) + +(let list (AsList + (AsStruct '('a (Uint32 '4)) '('b (String 'c))) + (AsStruct '('a (Uint32 '1)) '('b (String 'd))) + (AsStruct '('a (Uint32 '3)) '('b (String 'b))) +)) + +# Top->Take +(let world (Write! world res_sink (Key) (Top table (Uint64 '3) '() (lambda '(item) '())) '('('type)))) +(let world (Write! world res_sink (Key) (TopSort table (Uint64 '3) '() (lambda '(item) '())) '('('type)))) + +# tuple with single item +(let world (Write! world res_sink (Key) (Top table (Uint64 '3) '((Bool 'True)) (lambda '(item) '((Member item 'key)))) '('('type)))) +(let world (Write! world res_sink (Key) (TopSort table (Uint64 '3) '((Bool 'True)) (lambda '(item) '((Member item 'key)))) '('('type)))) + +# zero count +(let world (Write! world res_sink (Key) (Top table (Uint64 '0) (Bool 'True) (lambda '(item) (Member item 'key))) '('('type)))) +(let world (Write! world res_sink (Key) (TopSort table (Uint64 '0) (Bool 'True) (lambda '(item) (Member item 'key))) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (Top (Iterator table (DependsOn (String 'a))) (Uint64 '0) (Bool 'True) (lambda '(item) (Member item 'key)))) '('('type)))) +(let world (Write! world res_sink (Key) (Collect (TopSort (Iterator table (DependsOn (String 'b))) (Uint64 '0) (Bool 'True) (lambda '(item) (Member item 'key)))) '('('type)))) + +# list <= N +(let world (Write! world res_sink (Key) (Top list (Uint64 '3) (Bool 'True) (lambda '(item) (Member item 'a))) '('('type)))) +(let world (Write! world res_sink (Key) (TopSort list (Uint64 '3) (Bool 'True) (lambda '(item) (Member item 'a))) '('('type)))) + +# ExtractMembers +(let world (Write! world res_sink (Key) (ExtractMembers (Top table (Uint64 '3) (Bool 'True) (lambda '(item) (Member item 'key))) '('key 'value)) '('('type)))) +(let world (Write! world res_sink (Key) (ExtractMembers (TopSort table (Uint64 '3) (Bool 'True) (lambda '(item) (Member item 'key))) '('key 'value)) '('('type)))) +(let world (Write! world res_sink (Key) (ExtractMembers (Top table (Uint64 '3) (Bool 'True) (lambda '(item) (Member item 'key))) '('value)) '('('type)))) +(let world (Write! world res_sink (Key) (ExtractMembers (TopSort table (Uint64 '3) (Bool 'True) (lambda '(item) (Member item 'key))) '('value)) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/UnionOfSortedDesc.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/UnionOfSortedDesc.yql new file mode 100644 index 0000000000..b1de8fceb1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/UnionOfSortedDesc.yql @@ -0,0 +1,20 @@ +( +(let source (DataSource 'yt 'plato)) +(let sink (DataSink 'yt 'plato)) + +(let r (Read! world source (MrTableConcat (Key '('table (String '"Input")))) (Void) '())) +(let input (Right! r)) +(let world (Left! r)) + +(let mapLambda (lambda '(item) (AsList (AsStruct '('"key" (Member item '"key")))))) +(let keyExtractLambda (lambda '(item) (Member item '"key"))) + +(let out1 (Sort (FlatMap input mapLambda) (Bool 'false) keyExtractLambda)) +(let out2 (Sort (FlatMap input mapLambda) (Bool 'false) keyExtractLambda)) +(let union (UnionAll (Take out1 (Int32 '"3")) (Take out2 (Int32 '"2")))) + +(let world (Write! world sink (Key '('table (String '"Output"))) union '('('mode 'renew)))) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/UnionOfSortedMix.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/UnionOfSortedMix.yql new file mode 100644 index 0000000000..cbe8c2bb5e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/UnionOfSortedMix.yql @@ -0,0 +1,20 @@ +( +(let source (DataSource 'yt 'plato)) +(let sink (DataSink 'yt 'plato)) + +(let r (Read! world source (MrTableConcat (Key '('table (String '"Input")))) (Void) '())) +(let input (Right! r)) +(let world (Left! r)) + +(let mapLambda (lambda '(item) (AsList (AsStruct '('"key" (Member item '"key")))))) +(let keyExtractLambda (lambda '(item) (Member item '"key"))) + +(let out1 (Sort (FlatMap input mapLambda) (Bool 'false) keyExtractLambda)) +(let out2 (Sort (FlatMap input mapLambda) (Bool 'true) keyExtractLambda)) +(let union (UnionAll (Take out1 (Int32 '"3")) (Take out2 (Int32 '"2")))) + +(let world (Write! world sink (Key '('table (String '"Output"))) union '('('mode 'renew)))) +(let world (Commit! world sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/UnusedColumnsAfterTake.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/UnusedColumnsAfterTake.yql new file mode 100644 index 0000000000..65f43e76db --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/UnusedColumnsAfterTake.yql @@ -0,0 +1,18 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source + (Key '('table (String 'Input))) + (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) + +(let table1 (Take table1 (Uint64 '2))) +(let table1 (Map table1 (lambda '(x) (AsStruct '('key (Member x 'key)))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + table1 '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/UseEmptyDict.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/UseEmptyDict.yql new file mode 100644 index 0000000000..6f5b78d34e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/UseEmptyDict.yql @@ -0,0 +1,20 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let ed (Dict (DictType (DataType 'Int32) (DataType 'String)))) +(let data (Lookup ed (Int32 '0))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (Contains ed (Int32 '0))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (DictItems ed)) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (DictKeys ed)) +(let world (Write! world res_sink (Key) data '('('type)))) +(let data (DictPayloads ed)) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/VariantItemOverVisit.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/VariantItemOverVisit.yql new file mode 100644 index 0000000000..76b605c271 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/VariantItemOverVisit.yql @@ -0,0 +1,23 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) + +(let vt (VariantType (TupleType (DataType 'String) (DataType 'String) (DataType 'String)))) +(let v0 (Variant (String 'aaa) '0 vt)) +(let v1 (Variant (String 'bbb) '1 vt)) +(let v2 (Variant (String 'ccc) '2 vt)) +(let list (AsList v0 v1 v2)) + +(let handler (lambda '(x) (Concat (String '0-) x))) + +(let remap (lambda '(x) (Visit x '0 (lambda '(x) (Variant x '1 vt)) '1 (lambda '(x) (Variant x '2 vt)) '2 (lambda '(x) (Variant x '0 vt))))) +(let def (lambda '(x) (Visit x '0 (lambda '(x) (Variant (Apply handler x) '0 vt)) v1))) + +(let world (Write! world res_sink (Key) (Map list (lambda '(x) (VariantItem (Apply remap x)))) '('('type)))) +(let world (Write! world res_sink (Key) (Map list (lambda '(x) (VariantItem (Apply def x)))) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/Visit1.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/Visit1.yql new file mode 100644 index 0000000000..8c8c4f7726 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/Visit1.yql @@ -0,0 +1,23 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let vt (VariantType (TupleType (DataType 'Int32)))) +(let v1 (Variant (Int32 '34) '0 vt)) + +(let handler (lambda '(x) (+ (Int32 '100) x))) + +(let world (Write! world res_sink (Key) (Visit v1 '0 handler) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v1 '0 handler (Int32 '999)) '('('type)))) + +(let vt (VariantType (StructType '('a (DataType 'Int32))))) +(let v1 (Variant (Int32 '34) 'a vt)) + +(let world (Write! world res_sink (Key) (Visit v1 'a handler) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v1 'a handler (Int32 '999)) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/VisitAllEqualLambdas.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/VisitAllEqualLambdas.yql new file mode 100644 index 0000000000..5f7b186e37 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/VisitAllEqualLambdas.yql @@ -0,0 +1,21 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let vt (VariantType (TupleType (DataType 'String) (DataType 'String) (DataType 'String)))) +(let v0 (Variant (String 'aaa) '0 vt)) +(let v1 (Variant (String 'bbb) '1 vt)) +(let v2 (Variant (String 'ccc) '2 vt)) +(let list (AsList v0 v1 v2)) + +(let handler0 (lambda '(x) (Concat (String '0-) x))) +(let handler1 (lambda '(x) (Concat (String '0-) x))) +(let handler2 (lambda '(x) (Concat (String '0-) x))) + +(let world (Write! world res_sink (Key) (Map list (lambda '(x) (Visit x '0 handler0 '1 handler1 '2 handler2))) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/VisitAsGuess.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/VisitAsGuess.yql new file mode 100644 index 0000000000..271b065f4a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/VisitAsGuess.yql @@ -0,0 +1,40 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let vt (VariantType (TupleType (DataType 'Int32) (DataType 'String)))) +(let v1 (Variant (Int32 '34) '0 vt)) +(let v2 (Variant (String 'qwe) '1 vt)) + +(let handler (lambda '(x) (Just x))) +(let listHandler (lambda '(x) (AsList x))) + +(let world (Write! world res_sink (Key) (Visit v1 '0 handler (Nothing (OptionalType (DataType 'Int32)))) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v1 '1 handler (Nothing (OptionalType (DataType 'String)))) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 '0 handler (Nothing (OptionalType (DataType 'Int32)))) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 '1 handler (Nothing (OptionalType (DataType 'String)))) '('('type)))) + +(let world (Write! world res_sink (Key) (Visit v1 '0 listHandler (List (ListType (DataType 'Int32)))) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v1 '1 listHandler (List (ListType (DataType 'String)))) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 '0 listHandler (List (ListType (DataType 'Int32)))) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 '1 listHandler (List (ListType (DataType 'String)))) '('('type)))) + +(let vt (VariantType (StructType '('a (DataType 'Int32)) '('b (DataType 'String))))) +(let v1 (Variant (Int32 '34) 'a vt)) +(let v2 (Variant (String 'qwe) 'b vt)) + +(let world (Write! world res_sink (Key) (Visit v1 'a handler (Nothing (OptionalType (DataType 'Int32)))) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v1 'b handler (Nothing (OptionalType (DataType 'String)))) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 'a handler (Nothing (OptionalType (DataType 'Int32)))) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 'b handler (Nothing (OptionalType (DataType 'String)))) '('('type)))) + +(let world (Write! world res_sink (Key) (Visit v1 'a listHandler (List (ListType (DataType 'Int32)))) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v1 'b listHandler (List (ListType (DataType 'String)))) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 'a listHandler (List (ListType (DataType 'Int32)))) '('('type)))) +(let world (Write! world res_sink (Key) (Visit v2 'b listHandler (List (ListType (DataType 'String)))) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/VisitOverVisit.yql b/yql/essentials/tests/s-expressions/suites/Optimizers/VisitOverVisit.yql new file mode 100644 index 0000000000..8a0197dd5e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/VisitOverVisit.yql @@ -0,0 +1,29 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let vt3 (VariantType (TupleType (DataType 'String) (DataType 'String) (DataType 'String)))) +(let vt2 (VariantType (TupleType (DataType 'String) (DataType 'String)))) +(let v0 (Variant (String 'aaa) '0 vt3)) +(let v1 (Variant (String 'bbb) '1 vt3)) +(let v2 (Variant (String 'ccc) '2 vt3)) +(let list (AsList v0 v1 v2)) + +(let handler0 (lambda '(x) (Concat (String '0-) x))) +(let handler1 (lambda '(x) (Concat (String '1-) x))) +(let handler2 (lambda '(x) (Concat (String '2-) x))) + +(let remap (lambda '(x) (Visit x '0 (lambda '(x) (Variant x '1 vt3)) '1 (lambda '(x) (Variant x '2 vt3)) '2 (lambda '(x) (Variant x '0 vt3))))) +(let def (lambda '(x) (Visit x '0 (lambda '(x) (Variant (Apply handler0 x) '0 vt3)) v1))) +(let reduce (lambda '(x) (Visit x '0 (lambda '(x) (Variant x '0 vt2)) '1 (lambda '(x) (Variant x '0 vt2)) '2 (lambda '(x) (Variant x '1 vt2))))) + +(let world (Write! world res_sink (Key) (Map list (lambda '(x) (Visit (Apply remap x) '0 handler0 '1 handler1 '2 handler2))) '('('type)))) +(let world (Write! world res_sink (Key) (Map list (lambda '(x) (Visit (Apply def x) '0 handler0 '1 handler1 (String 'def)))) '('('type)))) +(let world (Write! world res_sink (Key) (Map list (lambda '(x) (Visit (Apply def x) '0 handler0 (String 'def)))) '('('type)))) +(let world (Write! world res_sink (Key) (Map list (lambda '(x) (Visit (Apply reduce x) '0 handler0 '1 handler1))) '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/default.cfg b/yql/essentials/tests/s-expressions/suites/Optimizers/default.cfg new file mode 100644 index 0000000000..fe2b19a9ff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/default.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/Optimizers/input.txt b/yql/essentials/tests/s-expressions/suites/Optimizers/input.txt new file mode 100644 index 0000000000..65949ea745 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/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/Optimizers/input.txt.attr b/yql/essentials/tests/s-expressions/suites/Optimizers/input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/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/Optimizers/input1.txt b/yql/essentials/tests/s-expressions/suites/Optimizers/input1.txt new file mode 100644 index 0000000000..bd567557a0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/input1.txt @@ -0,0 +1,19 @@ +{"Amount"=100;"Comment"="Test1";"Group"=1u;"Name"="Name1"}; +{"Amount"=101;"Comment"="Test1";"Group"=1u;"Name"="Name2"}; +{"Amount"=102;"Comment"="Test1";"Group"=1u;"Name"="Name3"}; +{"Amount"=103;"Comment"="Test1";"Group"=2u;"Name"="Name1"}; +{"Amount"=104;"Comment"="Test1";"Group"=3u;"Name"="Name3"}; +{"Amount"=105;"Comment"="Test1";"Group"=4u;"Name"="Name1"}; +{"Amount"=106;"Comment"="Test1";"Group"=4u;"Name"="Name4"}; +{"Amount"=107;"Comment"="Test1";"Group"=5u;"Name"="Name5"}; +{"Amount"=108;"Comment"="Test1";"Group"=6u;"Name"="Name1"}; +{"Amount"=109;"Comment"="Test1";"Group"=6u;"Name"="Name2"}; +{"Amount"=100;"Comment"="Test3";"Group"=10u;"Name"="Name1"}; +{"Amount"=101;"Comment"="Test3";"Group"=10u;"Name"="Name2"}; +{"Amount"=102;"Comment"="Test3";"Group"=10u;"Name"="Name3"}; +{"Amount"=103;"Comment"="Test3";"Group"=10u;"Name"="Name4"}; +{"Amount"=104;"Comment"="Test3";"Group"=10u;"Name"="Name5"}; +{"Amount"=105;"Comment"="Test3";"Group"=10u;"Name"="Name6"}; +{"Amount"=100;"Comment"="Test2";"Group"=100001u;"Name"="Name1"}; +{"Amount"=102;"Comment"="Test2";"Group"=100002u;"Name"="Name2"}; +{"Amount"=103;"Comment"="Test2";"Group"=100003u;"Name"="Name1"}; diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/input1.txt.attr b/yql/essentials/tests/s-expressions/suites/Optimizers/input1.txt.attr new file mode 100644 index 0000000000..ffb9a19cab --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/input1.txt.attr @@ -0,0 +1,42 @@ +{ + "_yql_row_spec" = { + "UniqueKeys"=%true; + "SortMembers"=["Group"; "Name"]; + "SortedBy"=["Group"; "Name"]; + "SortDirections"=[1; 1]; + "SortedByTypes"=[["DataType";"Uint64"]; ["DataType";"String"]]; + "Type" = [ + "StructType"; + [ + [ + "Group"; + [ + "DataType"; + "Uint64" + ] + ]; + [ + "Name"; + [ + "DataType"; + "String" + ] + ]; + [ + "Amount"; + [ + "DataType"; + "Int64" + ] + ]; + [ + "Comment"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/input2.txt b/yql/essentials/tests/s-expressions/suites/Optimizers/input2.txt new file mode 100644 index 0000000000..d1fa0973d9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/input2.txt @@ -0,0 +1,8 @@ +{"key"="075";"subkey"=".";"value"="abc"}; +{"key"="911";"subkey"=".";"value"="kkk"}; +{"key"="023";"subkey"=".";"value"="aaa"}; +{"key"="527";"subkey"=".";"value"="bbb"}; +{"key"="037";"subkey"=".";"value"="ddd"}; +{"key"="761";"subkey"=".";"value"="ccc"}; +{"key"="200";"subkey"=".";"value"="qqq"}; +{"key"="150";"subkey"=".";"value"="zzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/input2.txt.attr b/yql/essentials/tests/s-expressions/suites/Optimizers/input2.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/input2.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/Optimizers/input3.txt b/yql/essentials/tests/s-expressions/suites/Optimizers/input3.txt new file mode 100644 index 0000000000..045bc6bd14 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/input3.txt @@ -0,0 +1,200 @@ +{"key"="180";"subkey"="7";"value"="Value #44"}; +{"key"="178";"subkey"="17";"value"="Value #7"}; +{"key"="6";"subkey"="4";"value"="Value #1"}; +{"key"="53";"subkey"="19";"value"="Value #41"}; +{"key"="112";"subkey"="15";"value"="Value #14"}; +{"key"="121";"subkey"="11";"value"="Value #58"}; +{"key"="69";"subkey"="5";"value"="Value #49"}; +{"key"="142";"subkey"="3";"value"="Value #5"}; +{"key"="73";"subkey"="8";"value"="Value #33"}; +{"key"="52";"subkey"="14";"value"="Value #45"}; +{"key"="18";"subkey"="6";"value"="Value #40"}; +{"key"="141";"subkey"="16";"value"="Value #35"}; +{"key"="63";"subkey"="18";"value"="Value #12"}; +{"key"="5";"subkey"="13";"value"="Value #28"}; +{"key"="128";"subkey"="2";"value"="Value #56"}; +{"key"="48";"subkey"="12";"value"="Value #13"}; +{"key"="93";"subkey"="9";"value"="Value #20"}; +{"key"="49";"subkey"="0";"value"="Value #30"}; +{"key"="95";"subkey"="1";"value"="Value #34"}; +{"key"="159";"subkey"="10";"value"="Value #52"}; +{"key"="55";"subkey"="7";"value"="Value #15"}; +{"key"="7";"subkey"="17";"value"="Value #24"}; +{"key"="35";"subkey"="4";"value"="Value #51"}; +{"key"="82";"subkey"="19";"value"="Value #0"}; +{"key"="170";"subkey"="15";"value"="Value #26"}; +{"key"="150";"subkey"="11";"value"="Value #27"}; +{"key"="26";"subkey"="5";"value"="Value #54"}; +{"key"="58";"subkey"="3";"value"="Value #37"}; +{"key"="16";"subkey"="8";"value"="Value #46"}; +{"key"="166";"subkey"="14";"value"="Value #4"}; +{"key"="86";"subkey"="6";"value"="Value #16"}; +{"key"="101";"subkey"="16";"value"="Value #32"}; +{"key"="160";"subkey"="18";"value"="Value #39"}; +{"key"="199";"subkey"="13";"value"="Value #25"}; +{"key"="138";"subkey"="2";"value"="Value #6"}; +{"key"="96";"subkey"="12";"value"="Value #57"}; +{"key"="33";"subkey"="9";"value"="Value #21"}; +{"key"="9";"subkey"="0";"value"="Value #42"}; +{"key"="21";"subkey"="1";"value"="Value #55"}; +{"key"="176";"subkey"="10";"value"="Value #23"}; +{"key"="0";"subkey"="7";"value"="Value #18"}; +{"key"="66";"subkey"="17";"value"="Value #3"}; +{"key"="198";"subkey"="4";"value"="Value #22"}; +{"key"="186";"subkey"="19";"value"="Value #17"}; +{"key"="83";"subkey"="15";"value"="Value #2"}; +{"key"="179";"subkey"="11";"value"="Value #19"}; +{"key"="64";"subkey"="5";"value"="Value #38"}; +{"key"="56";"subkey"="3";"value"="Value #50"}; +{"key"="155";"subkey"="8";"value"="Value #43"}; +{"key"="143";"subkey"="14";"value"="Value #9"}; +{"key"="188";"subkey"="6";"value"="Value #8"}; +{"key"="172";"subkey"="16";"value"="Value #53"}; +{"key"="103";"subkey"="18";"value"="Value #11"}; +{"key"="44";"subkey"="13";"value"="Value #36"}; +{"key"="173";"subkey"="2";"value"="Value #10"}; +{"key"="133";"subkey"="12";"value"="Value #48"}; +{"key"="168";"subkey"="9";"value"="Value #29"}; +{"key"="157";"subkey"="0";"value"="Value #31"}; +{"key"="152";"subkey"="1";"value"="Value #47"}; +{"key"="74";"subkey"="10";"value"="Value #59"}; +{"key"="154";"subkey"="7";"value"="Value #44"}; +{"key"="40";"subkey"="17";"value"="Value #7"}; +{"key"="89";"subkey"="4";"value"="Value #1"}; +{"key"="41";"subkey"="19";"value"="Value #41"}; +{"key"="24";"subkey"="15";"value"="Value #14"}; +{"key"="182";"subkey"="11";"value"="Value #58"}; +{"key"="80";"subkey"="5";"value"="Value #49"}; +{"key"="196";"subkey"="3";"value"="Value #5"}; +{"key"="43";"subkey"="8";"value"="Value #33"}; +{"key"="156";"subkey"="14";"value"="Value #45"}; +{"key"="34";"subkey"="6";"value"="Value #40"}; +{"key"="88";"subkey"="16";"value"="Value #35"}; +{"key"="22";"subkey"="18";"value"="Value #12"}; +{"key"="27";"subkey"="13";"value"="Value #28"}; +{"key"="84";"subkey"="2";"value"="Value #56"}; +{"key"="12";"subkey"="12";"value"="Value #13"}; +{"key"="98";"subkey"="9";"value"="Value #20"}; +{"key"="140";"subkey"="0";"value"="Value #30"}; +{"key"="31";"subkey"="1";"value"="Value #34"}; +{"key"="105";"subkey"="10";"value"="Value #52"}; +{"key"="149";"subkey"="7";"value"="Value #15"}; +{"key"="153";"subkey"="17";"value"="Value #24"}; +{"key"="177";"subkey"="4";"value"="Value #51"}; +{"key"="14";"subkey"="19";"value"="Value #0"}; +{"key"="190";"subkey"="15";"value"="Value #26"}; +{"key"="118";"subkey"="11";"value"="Value #27"}; +{"key"="174";"subkey"="5";"value"="Value #54"}; +{"key"="104";"subkey"="3";"value"="Value #37"}; +{"key"="47";"subkey"="8";"value"="Value #46"}; +{"key"="46";"subkey"="14";"value"="Value #4"}; +{"key"="124";"subkey"="6";"value"="Value #16"}; +{"key"="70";"subkey"="16";"value"="Value #32"}; +{"key"="110";"subkey"="18";"value"="Value #39"}; +{"key"="91";"subkey"="13";"value"="Value #25"}; +{"key"="192";"subkey"="2";"value"="Value #6"}; +{"key"="183";"subkey"="12";"value"="Value #57"}; +{"key"="100";"subkey"="9";"value"="Value #21"}; +{"key"="38";"subkey"="0";"value"="Value #42"}; +{"key"="71";"subkey"="1";"value"="Value #55"}; +{"key"="29";"subkey"="10";"value"="Value #23"}; +{"key"="51";"subkey"="7";"value"="Value #18"}; +{"key"="32";"subkey"="17";"value"="Value #3"}; +{"key"="130";"subkey"="4";"value"="Value #22"}; +{"key"="77";"subkey"="19";"value"="Value #17"}; +{"key"="4";"subkey"="15";"value"="Value #2"}; +{"key"="97";"subkey"="11";"value"="Value #19"}; +{"key"="67";"subkey"="5";"value"="Value #38"}; +{"key"="158";"subkey"="3";"value"="Value #50"}; +{"key"="25";"subkey"="8";"value"="Value #43"}; +{"key"="119";"subkey"="14";"value"="Value #9"}; +{"key"="2";"subkey"="6";"value"="Value #8"}; +{"key"="167";"subkey"="16";"value"="Value #53"}; +{"key"="193";"subkey"="18";"value"="Value #11"}; +{"key"="11";"subkey"="13";"value"="Value #36"}; +{"key"="129";"subkey"="2";"value"="Value #10"}; +{"key"="187";"subkey"="12";"value"="Value #48"}; +{"key"="20";"subkey"="9";"value"="Value #29"}; +{"key"="134";"subkey"="0";"value"="Value #31"}; +{"key"="115";"subkey"="1";"value"="Value #47"}; +{"key"="94";"subkey"="10";"value"="Value #59"}; +{"key"="30";"subkey"="7";"value"="Value #44"}; +{"key"="175";"subkey"="17";"value"="Value #7"}; +{"key"="62";"subkey"="4";"value"="Value #1"}; +{"key"="147";"subkey"="19";"value"="Value #41"}; +{"key"="87";"subkey"="15";"value"="Value #14"}; +{"key"="99";"subkey"="11";"value"="Value #58"}; +{"key"="114";"subkey"="5";"value"="Value #49"}; +{"key"="117";"subkey"="3";"value"="Value #5"}; +{"key"="10";"subkey"="8";"value"="Value #33"}; +{"key"="162";"subkey"="14";"value"="Value #45"}; +{"key"="171";"subkey"="6";"value"="Value #40"}; +{"key"="108";"subkey"="16";"value"="Value #35"}; +{"key"="60";"subkey"="18";"value"="Value #12"}; +{"key"="144";"subkey"="13";"value"="Value #28"}; +{"key"="113";"subkey"="2";"value"="Value #56"}; +{"key"="102";"subkey"="12";"value"="Value #13"}; +{"key"="194";"subkey"="9";"value"="Value #20"}; +{"key"="76";"subkey"="0";"value"="Value #30"}; +{"key"="189";"subkey"="1";"value"="Value #34"}; +{"key"="164";"subkey"="10";"value"="Value #52"}; +{"key"="23";"subkey"="7";"value"="Value #15"}; +{"key"="65";"subkey"="17";"value"="Value #24"}; +{"key"="54";"subkey"="4";"value"="Value #51"}; +{"key"="148";"subkey"="19";"value"="Value #0"}; +{"key"="123";"subkey"="15";"value"="Value #26"}; +{"key"="185";"subkey"="11";"value"="Value #27"}; +{"key"="28";"subkey"="5";"value"="Value #54"}; +{"key"="13";"subkey"="3";"value"="Value #37"}; +{"key"="136";"subkey"="8";"value"="Value #46"}; +{"key"="57";"subkey"="14";"value"="Value #4"}; +{"key"="184";"subkey"="6";"value"="Value #16"}; +{"key"="36";"subkey"="16";"value"="Value #32"}; +{"key"="132";"subkey"="18";"value"="Value #39"}; +{"key"="120";"subkey"="13";"value"="Value #25"}; +{"key"="50";"subkey"="2";"value"="Value #6"}; +{"key"="195";"subkey"="12";"value"="Value #57"}; +{"key"="135";"subkey"="9";"value"="Value #21"}; +{"key"="92";"subkey"="0";"value"="Value #42"}; +{"key"="151";"subkey"="1";"value"="Value #55"}; +{"key"="125";"subkey"="10";"value"="Value #23"}; +{"key"="146";"subkey"="7";"value"="Value #18"}; +{"key"="45";"subkey"="17";"value"="Value #3"}; +{"key"="90";"subkey"="4";"value"="Value #22"}; +{"key"="126";"subkey"="19";"value"="Value #17"}; +{"key"="145";"subkey"="15";"value"="Value #2"}; +{"key"="19";"subkey"="11";"value"="Value #19"}; +{"key"="127";"subkey"="5";"value"="Value #38"}; +{"key"="79";"subkey"="3";"value"="Value #50"}; +{"key"="131";"subkey"="8";"value"="Value #43"}; +{"key"="111";"subkey"="14";"value"="Value #9"}; +{"key"="75";"subkey"="6";"value"="Value #8"}; +{"key"="191";"subkey"="16";"value"="Value #53"}; +{"key"="3";"subkey"="18";"value"="Value #11"}; +{"key"="165";"subkey"="13";"value"="Value #36"}; +{"key"="85";"subkey"="2";"value"="Value #10"}; +{"key"="1";"subkey"="12";"value"="Value #48"}; +{"key"="161";"subkey"="9";"value"="Value #29"}; +{"key"="37";"subkey"="0";"value"="Value #31"}; +{"key"="107";"subkey"="1";"value"="Value #47"}; +{"key"="122";"subkey"="10";"value"="Value #59"}; +{"key"="139";"subkey"="7";"value"="Value #44"}; +{"key"="15";"subkey"="17";"value"="Value #7"}; +{"key"="106";"subkey"="4";"value"="Value #1"}; +{"key"="59";"subkey"="19";"value"="Value #41"}; +{"key"="61";"subkey"="15";"value"="Value #14"}; +{"key"="17";"subkey"="11";"value"="Value #58"}; +{"key"="68";"subkey"="5";"value"="Value #49"}; +{"key"="163";"subkey"="3";"value"="Value #5"}; +{"key"="197";"subkey"="8";"value"="Value #33"}; +{"key"="81";"subkey"="14";"value"="Value #45"}; +{"key"="169";"subkey"="6";"value"="Value #40"}; +{"key"="8";"subkey"="16";"value"="Value #35"}; +{"key"="109";"subkey"="18";"value"="Value #12"}; +{"key"="78";"subkey"="13";"value"="Value #28"}; +{"key"="181";"subkey"="2";"value"="Value #56"}; +{"key"="116";"subkey"="12";"value"="Value #13"}; +{"key"="137";"subkey"="9";"value"="Value #20"}; +{"key"="39";"subkey"="0";"value"="Value #30"}; +{"key"="72";"subkey"="1";"value"="Value #34"}; +{"key"="42";"subkey"="10";"value"="Value #52"}; diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/input3.txt.attr b/yql/essentials/tests/s-expressions/suites/Optimizers/input3.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/input3.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/Optimizers/input4.txt b/yql/essentials/tests/s-expressions/suites/Optimizers/input4.txt new file mode 100644 index 0000000000..0827c839a2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/input4.txt @@ -0,0 +1,13 @@ +{"key"="023";"subkey"="3";"value"="aaa"}; +{"key"="037";"subkey"="5";"value"="ddd"}; +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="150";"subkey"="1";"value"="aaa"}; +{"key"="150";"subkey"="3";"value"="iii"}; +{"key"="150";"subkey"="8";"value"="zzz"}; +{"key"="200";"subkey"="7";"value"="qqq"}; +{"key"="527";"subkey"="4";"value"="bbb"}; +{"key"="761";"subkey"="6";"value"="ccc"}; +{"key"="911";"subkey"="1";"value"="kkk"}; +{"key"="911";"subkey"="2";"value"="hjk"}; +{"key"="911";"subkey"="3";"value"="def"}; +{"key"="911";"subkey"="4";"value"="xyz"}; diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/input4.txt.attr b/yql/essentials/tests/s-expressions/suites/Optimizers/input4.txt.attr new file mode 100644 index 0000000000..6ee50d08cc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/input4.txt.attr @@ -0,0 +1,11 @@ +{"_yql_row_spec"={ + "Type"=["StructType";[ + ["key";["DataType";"String"]]; + ["subkey";["DataType";"String"]]; + ["value";["DataType";"String"]] + ]]; + "SortDirections"=[1;1;]; + "SortedBy"=["key";"subkey";]; + "SortedByTypes"=[["DataType";"String";];["DataType";"String";];]; + "SortMembers"=["key";"subkey";]; +}} diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/inputDistinctKey.txt b/yql/essentials/tests/s-expressions/suites/Optimizers/inputDistinctKey.txt new file mode 100644 index 0000000000..6b1dac36b1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/inputDistinctKey.txt @@ -0,0 +1,8 @@ +{"key"="1";"subkey"=".";"value"="abc"}; +{"key"="1";"subkey"=".";"value"="kkk"}; +{"key"="2";"subkey"=".";"value"="aaa"}; +{"key"="2";"subkey"=".";"value"="bbb"}; +{"key"="2";"subkey"=".";"value"="ddd"}; +{"key"="bad";"subkey"=".";"value"="ccc"}; +{"key"="1";"subkey"=".";"value"="qqq"}; +{"key"="1";"subkey"=".";"value"="zzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/inputDistinctKey.txt.attr b/yql/essentials/tests/s-expressions/suites/Optimizers/inputDistinctKey.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/inputDistinctKey.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/Optimizers/inputUnion1.txt b/yql/essentials/tests/s-expressions/suites/Optimizers/inputUnion1.txt new file mode 100644 index 0000000000..93251b80a0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/inputUnion1.txt @@ -0,0 +1,6 @@ +{"age"="30";"name1"="bob"}; +{"age"="16";"name1"="alice"}; +{"age"="55";"name1"="jone"}; +{"age"="45";"name1"="silver"}; +{"age"="45";"name1"="smith"}; +{"age"="90";"name1"="stive"}; diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/inputUnion1.txt.attr b/yql/essentials/tests/s-expressions/suites/Optimizers/inputUnion1.txt.attr new file mode 100644 index 0000000000..bdbbea169d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/inputUnion1.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"Type"=["StructType";[["age";["DataType";"String"]];["name1";["DataType";"String"]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/inputUnion2.txt b/yql/essentials/tests/s-expressions/suites/Optimizers/inputUnion2.txt new file mode 100644 index 0000000000..1d9b6e8b42 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/inputUnion2.txt @@ -0,0 +1,6 @@ +{"age"="30";"name2"="bob"}; +{"age"="16";"name2"="alice"}; +{"age"="55";"name2"="jone"}; +{"age"="45";"name2"="silver"}; +{"age"="45";"name2"="smith"}; +{"age"="90";"name2"="stive"}; diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/inputUnion2.txt.attr b/yql/essentials/tests/s-expressions/suites/Optimizers/inputUnion2.txt.attr new file mode 100644 index 0000000000..6d032642cf --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/inputUnion2.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"Type"=["StructType";[["age";["DataType";"String"]];["name2";["DataType";"String"]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/input_tbl_content.txt b/yql/essentials/tests/s-expressions/suites/Optimizers/input_tbl_content.txt new file mode 100644 index 0000000000..d1fa0973d9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/input_tbl_content.txt @@ -0,0 +1,8 @@ +{"key"="075";"subkey"=".";"value"="abc"}; +{"key"="911";"subkey"=".";"value"="kkk"}; +{"key"="023";"subkey"=".";"value"="aaa"}; +{"key"="527";"subkey"=".";"value"="bbb"}; +{"key"="037";"subkey"=".";"value"="ddd"}; +{"key"="761";"subkey"=".";"value"="ccc"}; +{"key"="200";"subkey"=".";"value"="qqq"}; +{"key"="150";"subkey"=".";"value"="zzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/input_tbl_content.txt.attr b/yql/essentials/tests/s-expressions/suites/Optimizers/input_tbl_content.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/input_tbl_content.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/Optimizers/typed_table.txt b/yql/essentials/tests/s-expressions/suites/Optimizers/typed_table.txt new file mode 100644 index 0000000000..cc1df00106 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/typed_table.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="";"value"="a7c"}; +{"key"="800";"subkey"="2";"value"="ddd"}; +{"key"="020";"subkey"="";"value"="q"}; +{"key"="150";"subkey"="4";"value"="q8z"}; diff --git a/yql/essentials/tests/s-expressions/suites/Optimizers/typed_table.txt.attr b/yql/essentials/tests/s-expressions/suites/Optimizers/typed_table.txt.attr new file mode 100644 index 0000000000..9061763bd6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Optimizers/typed_table.txt.attr @@ -0,0 +1,32 @@ +{ + "_yql_view_opt_struct"="SELECT AsList(1,2,3) as b FROM self;"; + "_yql_syntax_version_opt_struct"=1; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/Result/AfterTransform.yql b/yql/essentials/tests/s-expressions/suites/Result/AfterTransform.yql new file mode 100644 index 0000000000..f0514c97b1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/AfterTransform.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 tresh (String '100)) +(let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1low '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/Apply.yql b/yql/essentials/tests/s-expressions/suites/Result/Apply.yql new file mode 100644 index 0000000000..ee940f6d93 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/Apply.yql @@ -0,0 +1,26 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let f1 (lambda '(x y) (block '( + (return (+ x y)) +)))) + +(let f2 (lambda '(x) (block '( + (return (Apply f1 x (Uint64 '2))) +)))) + +(let writer (lambda '(world data) (block '( + (let world (Write! world res_sink (Key) data '())) + (let world (Commit! world res_sink)) + (return world) +)))) + +(let data1 (Apply f2 (Uint64 '3))) +(let data2 (Apply f2 (Uint64 '4))) +(let world (Apply writer world data1)) +(let world (Apply writer world data2)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/AutoRefBig.yql b/yql/essentials/tests/s-expressions/suites/Result/AutoRefBig.yql new file mode 100644 index 0000000000..d54b9c6ce3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/AutoRefBig.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 tresh (String '100)) +(let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1low '('('take '1) '('autoref)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/AutoRefSmall.yql b/yql/essentials/tests/s-expressions/suites/Result/AutoRefSmall.yql new file mode 100644 index 0000000000..6c7ca6eabd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/AutoRefSmall.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 tresh (String '100)) +(let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1low '('('autoref)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/AutoRefTwoTables.yql b/yql/essentials/tests/s-expressions/suites/Result/AutoRefTwoTables.yql new file mode 100644 index 0000000000..f4c7304639 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/AutoRefTwoTables.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source '((Key '('table (String 'Input))) (Key '('table (String 'Input)))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('take '1) '('autoref)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/Empty.yql b/yql/essentials/tests/s-expressions/suites/Result/Empty.yql new file mode 100644 index 0000000000..3a0cc2e5e5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/Empty.yql @@ -0,0 +1,3 @@ +( +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/LastInTempTable.yql b/yql/essentials/tests/s-expressions/suites/Result/LastInTempTable.yql new file mode 100644 index 0000000000..29dc7a9481 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/LastInTempTable.yql @@ -0,0 +1,14 @@ +( +#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 tresh (String '100)) +(let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let res_sink (DataSink 'result)) +(let data (Skip table1low (- (Max (Uint64 '1) (Length table1low)) (Uint64 '1)))) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/LengthOfTable.yql b/yql/essentials/tests/s-expressions/suites/Result/LengthOfTable.yql new file mode 100644 index 0000000000..c6c4df1772 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/LengthOfTable.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 res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Length table1) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/LengthOfTempTable.yql b/yql/essentials/tests/s-expressions/suites/Result/LengthOfTempTable.yql new file mode 100644 index 0000000000..34a926b1dc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/LengthOfTempTable.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 tresh (Int32 'x"64000000")) +(let table1low (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let ret (FlatMap intValueOpt (lambda '(item2) (block '( + (return (ListIf (< item2 tresh) item)) + ))))) + (return ret) +))))) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Length table1low) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/ListTakeOption.yql b/yql/essentials/tests/s-expressions/suites/Result/ListTakeOption.yql new file mode 100644 index 0000000000..215ec6bf79 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/ListTakeOption.yql @@ -0,0 +1,11 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (AsList (Uint32 '3) (Uint32 '5) (Uint32 '7) (Uint32 '10))) +(let world (Write! world res_sink (Key) data '('('take '2)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/PagedTable.yql b/yql/essentials/tests/s-expressions/suites/Result/PagedTable.yql new file mode 100644 index 0000000000..1a7772c21f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PagedTable.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 table1 (Skip table1 (Uint64 '1))) +(let table1 (Take table1 (Uint64 '2))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/ParseType.yql b/yql/essentials/tests/s-expressions/suites/Result/ParseType.yql new file mode 100644 index 0000000000..13c3e97d5b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/ParseType.yql @@ -0,0 +1,11 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let t (ParseType '"(List<Int32?>,Struct<'b':Dict<Int32,Double>,'a':Int32>)->Tuple<String,Uint64>")) +(let world (Write! world res_sink (Key) (FormatType t) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/Pickle.yql b/yql/essentials/tests/s-expressions/suites/Result/Pickle.yql new file mode 100644 index 0000000000..ff6b2d9159 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/Pickle.yql @@ -0,0 +1,57 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let vt1 (VariantType (TupleType (DataType 'Int32) (DataType 'String)))) +(let vt2 (VariantType (StructType '('x (DataType 'Int32)) '('y (DataType 'String))))) + +(let res_sink (DataSink 'result)) +(let data '( +(Uint32 '1) +(Int32 '-2) +(Uint64 '3) +(Int64 '-4) +(Double '-5) +(Float '-6) +(Bool 'true) +(Yson '@@[1u;"3"]@@) +(Json '@@{"id":1}@@) +(Date '11) +(Datetime '12) +(Timestamp '13) +(Interval '-13) +(Uint8 '14) +(Int8 '-15) +(Uint16 '16) +(Int16 '-17) +(TzDate '"18,Europe/Moscow") +(TzDate '"19,America/Los_Angeles") +(TzDatetime '"20,Etc/GMT-1") +(TzDatetime '"4291747199,Europe/Moscow") +(TzDatetime '"4291747198,America/Los_Angeles") +(TzTimestamp '"21,Etc/GMT+1") +(Cast (Datetime '"1262347200") 'String) +(TzDatetime '"1262347200,Europe/Moscow") +(Cast (Datetime '"1277985600") 'String) +(TzDatetime '"1277985600,Europe/Moscow") +(Uuid '"0123456789abcdef") +(AsStruct '('k (String 'key)) '('v (Uint64 '456))) +(AsList (Uint32 '2)) +(Just (Uint32 '3)) +(Nothing (OptionalType (DataType 'String))) +(ToDict (AsList '((String 'dkey1) (String 'dvalue1)) '((String 'dkey2) (String 'dvalue2))) + (lambda '(x) (Nth x '0)) (lambda '(x) (Nth x '1)) '('Sorted 'One) +) +(Void) +(Variant (Int32 '7) '0 vt1) +(Variant (String 'qwe) 'y vt2) +)) +(let save (Pickle data)) +(let data2 (Unpickle (TypeOf data) save)) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Write! world res_sink (Key) save '('('type)))) +(let world (Write! world res_sink (Key) data2 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullColumns.yql b/yql/essentials/tests/s-expressions/suites/Result/PullColumns.yql new file mode 100644 index 0000000000..110fdcc060 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullColumns.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('columns '('value 'subkey)) '('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullColumnsFiltered.yql b/yql/essentials/tests/s-expressions/suites/Result/PullColumnsFiltered.yql new file mode 100644 index 0000000000..01484b19ae --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullColumnsFiltered.yql @@ -0,0 +1,12 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let res_sink (DataSink 'result)) +(let mr_sink (DataSink 'yt 'plato)) +(let world (Write! world res_sink (Key) table '('('type) '('ref) '('columns '('value 'key))))) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullDict.cfg b/yql/essentials/tests/s-expressions/suites/Result/PullDict.cfg new file mode 100644 index 0000000000..8a0f058a3b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullDict.cfg @@ -0,0 +1,2 @@ +in Input dict.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullDict.yql b/yql/essentials/tests/s-expressions/suites/Result/PullDict.yql new file mode 100644 index 0000000000..c3b00f1716 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullDict.yql @@ -0,0 +1,11 @@ +( +#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 res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullDictAsStruct.cfg b/yql/essentials/tests/s-expressions/suites/Result/PullDictAsStruct.cfg new file mode 100644 index 0000000000..d1391bb33f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullDictAsStruct.cfg @@ -0,0 +1,2 @@ +in Input struct.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullDictAsStruct.yql b/yql/essentials/tests/s-expressions/suites/Result/PullDictAsStruct.yql new file mode 100644 index 0000000000..b4e64a1d6d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullDictAsStruct.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 table1 (FlatMap table1 (lambda '(x) (AsList x x)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullKeyOnly.yql b/yql/essentials/tests/s-expressions/suites/Result/PullKeyOnly.yql new file mode 100644 index 0000000000..a71800ecf9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullKeyOnly.yql @@ -0,0 +1,11 @@ +( +(let x (Read! world (DataSource 'yt 'plato) (Key '('table (String 'Input))) '('key) '())) +(let world (Left! x)) +(let data (Right! x)) +(let result_sink (DataSink 'result)) +(let world (Write! world result_sink (Key) data '('('type) '('autoref)))) +(let plato_sink (DataSink 'yt 'plato)) +(let world (Commit! world plato_sink)) +(let world (Commit! world result_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullNumbers.yql b/yql/essentials/tests/s-expressions/suites/Result/PullNumbers.yql new file mode 100644 index 0000000000..8684754149 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullNumbers.yql @@ -0,0 +1,30 @@ +# do not check tmp here (YQL-130, YQL-131) +( +(let x (Read! world (DataSource 'yt 'plato) (Key '('table (String 'Input))) (Void) '())) +(let world (Left! x)) +(let yt.plato.Input (Right! x)) +(let select1_input3 yt.plato.Input) +(let output5 (block '( + (let select1_output select1_input3) + (let select1_output (Map select1_output (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res 'x (Int64 '1))) + (return res) +) +)))) + (let select1_output (Sort select1_output (Bool 'false) (lambda '(row) (block '( + (let res (Member row 'x)) + (return res) +) +)))) + (let select1_output (Take select1_output (Uint64 '2))) + (return select1_output) +) +)) +(let result_sink (DataSink 'result)) +(let world (Write! world result_sink (Key) output5 '('('type) '('autoref)))) +(let plato_sink (DataSink 'yt 'plato)) +(let world (Commit! world plato_sink)) +(let world (Commit! world result_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullOverExactLimit.yql b/yql/essentials/tests/s-expressions/suites/Result/PullOverExactLimit.yql new file mode 100644 index 0000000000..353d36313c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullOverExactLimit.yql @@ -0,0 +1,12 @@ +( +(let result_sink (DataSink 'result)) +(let plato_sink (DataSink 'yt 'plato)) + +(let x (Read! world (DataSource 'yt 'plato) (Key '('table (String 'Input))) (Void) '())) +(let world (Left! x)) +(let data (Take (Right! x) (Uint64 '3))) +(let world (Write! world result_sink (Key) data '('('type) '('autoref) '('take '3)))) +(let world (Commit! world plato_sink)) +(let world (Commit! world result_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullOverLimit.yql b/yql/essentials/tests/s-expressions/suites/Result/PullOverLimit.yql new file mode 100644 index 0000000000..4b7f4fc30c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullOverLimit.yql @@ -0,0 +1,11 @@ +( +(let x (Read! world (DataSource 'yt 'plato) (Key '('table (String 'Input))) (Void) '())) +(let world (Left! x)) +(let data (Take (Right! x) (Uint64 '3))) +(let result_sink (DataSink 'result)) +(let world (Write! world result_sink (Key) data '('('type) '('autoref) '('take '2)))) +(let plato_sink (DataSink 'yt 'plato)) +(let world (Commit! world plato_sink)) +(let world (Commit! world result_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullWithDefValues.cfg b/yql/essentials/tests/s-expressions/suites/Result/PullWithDefValues.cfg new file mode 100644 index 0000000000..068d78205f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullWithDefValues.cfg @@ -0,0 +1,2 @@ +in Input def_values.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullWithDefValues.yql b/yql/essentials/tests/s-expressions/suites/Result/PullWithDefValues.yql new file mode 100644 index 0000000000..69f204a707 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullWithDefValues.yql @@ -0,0 +1,11 @@ +( +(let x (Read! world (DataSource 'yt 'plato) (Key '('table (String 'Input))) (Void) '('('infer_scheme)))) +(let world (Left! x)) +(let data (Take (Right! x) (Uint64 '3))) +(let result_sink (DataSink 'result)) +(let world (Write! world result_sink (Key) data '('('type) '('autoref) '('take '2)))) +(let plato_sink (DataSink 'yt 'plato)) +(let world (Commit! world plato_sink)) +(let world (Commit! world result_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullWithDirectRead.yql b/yql/essentials/tests/s-expressions/suites/Result/PullWithDirectRead.yql new file mode 100644 index 0000000000..6c4b1851e0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullWithDirectRead.yql @@ -0,0 +1,11 @@ +( +(let x (Read! world (DataSource 'yt 'plato) (Key '('table (String 'Input))) (Void) '('('direct_read)))) +(let world (Left! x)) +(let data (Take (Right! x) (Uint64 '3))) +(let result_sink (DataSink 'result)) +(let world (Write! world result_sink (Key) data '('('type) '('autoref) '('take '2)))) +(let plato_sink (DataSink 'yt 'plato)) +(let world (Commit! world plato_sink)) +(let world (Commit! world result_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullWithInferScheme.cfg b/yql/essentials/tests/s-expressions/suites/Result/PullWithInferScheme.cfg new file mode 100644 index 0000000000..94fcaf1f6f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullWithInferScheme.cfg @@ -0,0 +1,2 @@ +in Input infer_scheme.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullWithInferScheme.yql b/yql/essentials/tests/s-expressions/suites/Result/PullWithInferScheme.yql new file mode 100644 index 0000000000..69f204a707 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullWithInferScheme.yql @@ -0,0 +1,11 @@ +( +(let x (Read! world (DataSource 'yt 'plato) (Key '('table (String 'Input))) (Void) '('('infer_scheme)))) +(let world (Left! x)) +(let data (Take (Right! x) (Uint64 '3))) +(let result_sink (DataSink 'result)) +(let world (Write! world result_sink (Key) data '('('type) '('autoref) '('take '2)))) +(let plato_sink (DataSink 'yt 'plato)) +(let world (Commit! world plato_sink)) +(let world (Commit! world result_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullYson.cfg b/yql/essentials/tests/s-expressions/suites/Result/PullYson.cfg new file mode 100644 index 0000000000..e25ff9f9ff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullYson.cfg @@ -0,0 +1,2 @@ +in Input yson.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Result/PullYson.yql b/yql/essentials/tests/s-expressions/suites/Result/PullYson.yql new file mode 100644 index 0000000000..c3b00f1716 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PullYson.yql @@ -0,0 +1,11 @@ +( +#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 res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/Pure.yql b/yql/essentials/tests/s-expressions/suites/Result/Pure.yql new file mode 100644 index 0000000000..9ad249ecf2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/Pure.yql @@ -0,0 +1,52 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let vt1 (VariantType (TupleType (DataType 'Int32) (DataType 'String)))) +(let vt2 (VariantType (StructType '('x (DataType 'Int32)) '('y (DataType 'String))))) +(let res_sink (DataSink 'result)) +(let data '( +(Uint32 '1) +(Int32 '-2) +(Uint64 '3) +(Int64 '-4) +(Double '-5) +(Float '-6) +(Bool 'true) +(Yson '@@[1u;"3"]@@) +(Json '@@{"id":1}@@) +(Date '11) +(Datetime '12) +(Timestamp '13) +(Interval '-13) +(Uint8 '14) +(Int8 '-15) +(Uint16 '16) +(Int16 '-17) +(TzDate '"18,Europe/Moscow") +(TzDate '"19,America/Los_Angeles") +(TzDatetime '"20,Etc/GMT-1") +(TzDatetime '"4291747199,Europe/Moscow") +(TzDatetime '"4291747198,America/Los_Angeles") +(TzTimestamp '"21,Etc/GMT+1") +(Cast (Datetime '"1262347200") 'String) +(TzDatetime '"1262347200,Europe/Moscow") +(Cast (Datetime '"1277985600") 'String) +(TzDatetime '"1277985600,Europe/Moscow") +(Uuid '"0123456789abcdef") +(AsStruct '('k (String 'key)) '('v (Uint64 '456))) +(AsList (Uint32 '2)) +(Just (Uint32 '3)) +(Nothing (OptionalType (DataType 'String))) +(ToDict (AsList '((String 'dkey1) (String 'dvalue1)) '((String 'dkey2) (String 'dvalue2))) + (lambda '(x) (Nth x '0)) (lambda '(x) (Nth x '1)) '('Sorted 'One) +) +(Void) +(Variant (Int32 '7) '0 vt1) +(Variant (String 'qwe) 'y vt2) +)) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/PureWithType.yql b/yql/essentials/tests/s-expressions/suites/Result/PureWithType.yql new file mode 100644 index 0000000000..9fdf74cfdf --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/PureWithType.yql @@ -0,0 +1,21 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data '( +(Uint32 '1) +(AsStruct '('k (String 'key)) '('v (Uint64 '456))) +(AsList (Uint32 '2)) +(Just (Uint32 '3)) +(Nothing (OptionalType (DataType 'String))) +(ToDict (AsList '((String 'dkey1) (String 'dvalue1)) '((String 'dkey2) (String 'dvalue2))) + (lambda '(x) (Nth x '0)) (lambda '(x) (Nth x '1)) '('Sorted 'One) +) +(Void) +)) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Result/ReadAllFields.yql b/yql/essentials/tests/s-expressions/suites/Result/ReadAllFields.yql new file mode 100644 index 0000000000..77573dbc12 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/ReadAllFields.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/Resource.yql b/yql/essentials/tests/s-expressions/suites/Result/Resource.yql new file mode 100644 index 0000000000..97aa87cca3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/Resource.yql @@ -0,0 +1,17 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let gen (NewMTRand (Uint64 '42))) +(let p (NextMTRand gen)) +(let gen (Nth p '1)) +(let v1 (Nth p '0)) +(let p (NextMTRand gen)) +(let gen (Nth p '1)) +(let v2 (Nth p '0)) +(let world (Write! world res_sink (Key) '(v1 v2) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/ResultColumns.yql b/yql/essentials/tests/s-expressions/suites/Result/ResultColumns.yql new file mode 100644 index 0000000000..cf2253c9bc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/ResultColumns.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let row1 (AsStruct '('key (String 'key1)) '('subkey (String '.)) '('value (String 'value1)))) +(let row2 (AsStruct '('key (String 'key2)) '('subkey (String '.)) '('value (String 'value2)))) +(let table1 (AsList row1 row2)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('columns '('value 'subkey 'key)) '('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/ResultColumnsPrefixes.yql b/yql/essentials/tests/s-expressions/suites/Result/ResultColumnsPrefixes.yql new file mode 100644 index 0000000000..5be6c09045 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/ResultColumnsPrefixes.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let row1 (AsStruct '('key1 (String 'key1)) '('key2 (String '.)) '('aaa (String 'value1)))) +(let row2 (AsStruct '('key1 (String 'key2)) '('key2 (String '.)) '('aaa (String 'value2)))) +(let table1 (AsList row1 row2)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('columns '('('prefix 'key) 'aaa)) '('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/SeveralWritesAndCommits.yql b/yql/essentials/tests/s-expressions/suites/Result/SeveralWritesAndCommits.yql new file mode 100644 index 0000000000..4780768ff4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/SeveralWritesAndCommits.yql @@ -0,0 +1,15 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (Int32 '1) '())) +(let world (Write! world res_sink (Key) (Int32 '2) '())) +(let world (Write! world res_sink (Key) (Int32 '3) '())) +(let world (Commit! world res_sink)) +(let world (Write! world res_sink (Key) (Int32 '4) '())) +(let world (Write! world res_sink (Key) (Int32 '5) '())) +(let world (Write! world res_sink (Key) (Int32 '6) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/SimpleWrite.yql b/yql/essentials/tests/s-expressions/suites/Result/SimpleWrite.yql new file mode 100644 index 0000000000..d91538e365 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/SimpleWrite.yql @@ -0,0 +1,11 @@ +( +#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 res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/SimpleWriteByRef.yql b/yql/essentials/tests/s-expressions/suites/Result/SimpleWriteByRef.yql new file mode 100644 index 0000000000..b8fd35ae40 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/SimpleWriteByRef.yql @@ -0,0 +1,11 @@ +( +#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 res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('ref)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/SkipTableByTempTableLength.yql b/yql/essentials/tests/s-expressions/suites/Result/SkipTableByTempTableLength.yql new file mode 100644 index 0000000000..2924cf4e00 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/SkipTableByTempTableLength.yql @@ -0,0 +1,14 @@ +( +#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 tresh (String '100)) +(let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let res_sink (DataSink 'result)) +(let data (Skip table1 (- (Max (Uint64 '1) (Length table1low)) (Uint64 '1)))) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/TableScheme.cfg b/yql/essentials/tests/s-expressions/suites/Result/TableScheme.cfg new file mode 100644 index 0000000000..94fcaf1f6f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/TableScheme.cfg @@ -0,0 +1,2 @@ +in Input infer_scheme.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Result/TableScheme.yql b/yql/essentials/tests/s-expressions/suites/Result/TableScheme.yql new file mode 100644 index 0000000000..e4180b783f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/TableScheme.yql @@ -0,0 +1,16 @@ +( +(let mr_source (DataSource 'yt 'plato)) + +(let x (Read! world mr_source + (Key '('tablescheme (String 'Input))) + (Void) '('('infer_scheme)) +)) + +(let world (Left! x)) +(let scheme (Right! x)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) scheme '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/TableSchemeNotFail.yql b/yql/essentials/tests/s-expressions/suites/Result/TableSchemeNotFail.yql new file mode 100644 index 0000000000..729098839b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/TableSchemeNotFail.yql @@ -0,0 +1,18 @@ +( +(let mr_source (DataSource 'yt 'plato)) + +(let x (Read! world mr_source + (Key '('tablescheme (String 'Input))) + (Void) '( + '('do_not_fail_on_invalid_schema) + ) +)) + +(let world (Left! x)) +(let scheme (Right! x)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) scheme '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/TypeOf.yql b/yql/essentials/tests/s-expressions/suites/Result/TypeOf.yql new file mode 100644 index 0000000000..66bf82a11d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/TypeOf.yql @@ -0,0 +1,23 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let vt1 (VariantType (TupleType (DataType 'Int32) (DataType 'String)))) +(let vt2 (VariantType (StructType '('x (DataType 'Int32)) '('y (DataType 'String))))) +(let res_sink (DataSink 'result)) +(let data '( +(Uint32 '1) +(AsStruct '('k (String 'key)) '('v (Uint64 '456))) +(AsList (Uint32 '2)) +(Just (Uint32 '3)) +(Nothing (OptionalType (DataType 'String))) +(AsDict '((String 'dkey1) (String 'dvalue1)) '((String 'dkey2) (String 'dvalue2))) +(Variant (Int32 '7) '0 vt1) +(Variant (String 'qwe) 'y vt2) +)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf data)) '())) +(let world (Write! world res_sink (Key) (FormatType (TypeOf (TypeOf data))) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/TypeReflection.yql b/yql/essentials/tests/s-expressions/suites/Result/TypeReflection.yql new file mode 100644 index 0000000000..c5def78d58 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/TypeReflection.yql @@ -0,0 +1,29 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let x (Uint32 '1)) +(let y (String 'asd)) +(let o (Just x)) +(let l (AsList x)) +(let d (AsDict '(x y))) +(let t '(x y)) +(let s (AsStruct '('a x) '('b y))) +(let vt1 (VariantType (TupleType (DataType 'Int32) (DataType 'String)))) +(let vt2 (VariantType (StructType '('x (DataType 'Int32)) '('y (DataType 'String))))) +(let world (Write! world res_sink (Key) (FormatType (OptionalItemType (TypeOf o))) '())) +(let world (Write! world res_sink (Key) (FormatType (ListItemType (TypeOf l))) '())) +(let world (Write! world res_sink (Key) (FormatType (DictKeyType (TypeOf d))) '())) +(let world (Write! world res_sink (Key) (FormatType (DictPayloadType (TypeOf d))) '())) +(let world (Write! world res_sink (Key) (FormatType (TupleElementType (TypeOf t) '0)) '())) +(let world (Write! world res_sink (Key) (FormatType (TupleElementType (TypeOf t) '1)) '())) +(let world (Write! world res_sink (Key) (FormatType (StructMemberType (TypeOf s) 'a)) '())) +(let world (Write! world res_sink (Key) (FormatType (StructMemberType (TypeOf s) 'b)) '())) +(let world (Write! world res_sink (Key) (FormatType (VariantUnderlyingType vt1)) '())) +(let world (Write! world res_sink (Key) (FormatType (VariantUnderlyingType vt2)) '())) +(let world (Write! world res_sink (Key) (FormatType (StreamItemType (StreamType (DataType 'String)))) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/TypeStructs.yql b/yql/essentials/tests/s-expressions/suites/Result/TypeStructs.yql new file mode 100644 index 0000000000..5b80134b73 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/TypeStructs.yql @@ -0,0 +1,16 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let s1 (AsStruct '('a (Uint32 '1)) '('b (String 'qwe)))) +(let s2 (AsStruct '('c (Uint32 '1)) '('d (Just (String 'asd))))) +(let world (Write! world res_sink (Key) (FormatType (AddMemberType (TypeOf s1) 'q (DataType 'Double))) '())) +(let world (Write! world res_sink (Key) (FormatType (RemoveMemberType (TypeOf s1) 'a)) '())) +(let world (Write! world res_sink (Key) (FormatType (ForceRemoveMemberType (TypeOf s1) 'q)) '())) +(let world (Write! world res_sink (Key) (FormatType (FlattenMembersType '('"p." (TypeOf s1)) '('"q." (TypeOf s2)))) '())) +(let world (Write! world res_sink (Key) (FormatType (FlattenMembersType '('"p." (TypeOf s1)) '('"q." (OptionalType (TypeOf s2))))) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/WorldIf.yql b/yql/essentials/tests/s-expressions/suites/Result/WorldIf.yql new file mode 100644 index 0000000000..a634dbecb2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/WorldIf.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 tresh (String '100)) +(let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let res_sink (DataSink 'result)) + +(let world (Write! world res_sink (Key) (String '1) '())) +(let world (If! world (Bool 'false) (Write! world res_sink (Key) table1low '()) world)) +(let world (Commit! world res_sink)) + +(let world (Write! world res_sink (Key) (String '2) '())) +(let world (If! world (Bool 'true) (Write! world res_sink (Key) table1low '()) world)) +(let world (Commit! world res_sink)) + +(let world (Write! world res_sink (Key) (String '3) '())) +(let world (If! world (<= (Length table1low) (Uint64 '1)) + (Write! world res_sink (Key) table1low '()) + (Write! world res_sink (Key) table1 '()))) +(let world (Commit! world res_sink)) + +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/Yson.yql b/yql/essentials/tests/s-expressions/suites/Result/Yson.yql new file mode 100644 index 0000000000..f978241cfc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/Yson.yql @@ -0,0 +1,21 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let data (Yson '@@ +{ +"a"=1; +"$b"=#; +"c"=2u; +"d"=4.1; +"e"=%true; +"f"=[1;<x=1>"english text"]; +"g"=<u=2>{x=<v="\xff\xff binary">[];y="русский текст"}; +} +@@)) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Result/def_values.txt b/yql/essentials/tests/s-expressions/suites/Result/def_values.txt new file mode 100644 index 0000000000..5a5fca5c32 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/def_values.txt @@ -0,0 +1,2 @@ +{"key"="1";value="3"}; +{"key"="2";value="4";"subkey"="123"}; diff --git a/yql/essentials/tests/s-expressions/suites/Result/def_values.txt.attr b/yql/essentials/tests/s-expressions/suites/Result/def_values.txt.attr new file mode 100644 index 0000000000..de393c2dc7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/def_values.txt.attr @@ -0,0 +1,15 @@ +{ + "_yql_row_spec"={ + "Type"=["StructType";[ + ["key";["DataType";"String"]]; + ["subkey";["DataType";"String"]]; + ["value";["DataType";"String"]]; + ]]; + "DefaultValues"={"key"="\"\"";"subkey"="\"\"";"value"="\"\"";}; + }; + "schema"=<"strict" = %true> [ + {"type"="string"; "name"="key"}; + {"type"="string"; "name"="subkey"}; + {"type"="string"; "name"="value"} + ] +} diff --git a/yql/essentials/tests/s-expressions/suites/Result/default.cfg b/yql/essentials/tests/s-expressions/suites/Result/default.cfg new file mode 100644 index 0000000000..fe2b19a9ff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/default.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/Result/dict.txt b/yql/essentials/tests/s-expressions/suites/Result/dict.txt new file mode 100644 index 0000000000..c189e76627 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/dict.txt @@ -0,0 +1,6 @@ +{"key"="075";"subkey"="1";"value"={"b"=11;"a"=1;}}; +{"key"="800";"subkey"="2";"value"={"a"=2;}}; +{"key"="020";"subkey"="3";"value"={}}; +{"key"="150";"subkey"="4";"value"={"b"=13;"a"=4;}}; +{"key"="075";"subkey"="5";"value"={"b"=14;"a"=5;}}; +{"key"="100";"subkey"="6";"value"={"c"=15;"a"=6;}}; diff --git a/yql/essentials/tests/s-expressions/suites/Result/dict.txt.attr b/yql/essentials/tests/s-expressions/suites/Result/dict.txt.attr new file mode 100644 index 0000000000..6dd8d28db1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/dict.txt.attr @@ -0,0 +1,27 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + ["DictType"; ["DataType";"String"]; ["DataType";"Int32"];] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Result/infer_scheme.txt b/yql/essentials/tests/s-expressions/suites/Result/infer_scheme.txt new file mode 100644 index 0000000000..eff01d5cf2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/infer_scheme.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="800";"subkey"="2";"value"="ddd";"extra"=1u}; +{"key"="020";"subkey"="3";"value"="q";"extra"=1u}; +{"key"="150";"subkey"="4";"value"="qzz";"extra"=1u}; diff --git a/yql/essentials/tests/s-expressions/suites/Result/infer_scheme.txt.attr b/yql/essentials/tests/s-expressions/suites/Result/infer_scheme.txt.attr new file mode 100644 index 0000000000..bbd3d58b0d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/infer_scheme.txt.attr @@ -0,0 +1,7 @@ +{ + "infer_schema" = %true; + "schema_mode" = "strong"; + "schema" = <strict=%false>[ + {"type"="string"; "name"="key"}; + ] +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Result/input.txt b/yql/essentials/tests/s-expressions/suites/Result/input.txt new file mode 100644 index 0000000000..65949ea745 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/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/Result/input.txt.attr b/yql/essentials/tests/s-expressions/suites/Result/input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/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/Result/struct.txt b/yql/essentials/tests/s-expressions/suites/Result/struct.txt new file mode 100644 index 0000000000..c92d2d7733 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/struct.txt @@ -0,0 +1,6 @@ +{"key"="075";"subkey"="1";"value"={"b"=11u;"a"=1;}}; +{"key"="800";"subkey"="2";"value"={"a"=2;}}; +{"key"="020";"subkey"="3";"value"={"a"=7}}; +{"key"="150";"subkey"="4";"value"={"b"=13u;"a"=4;}}; +{"key"="075";"subkey"="5";"value"={"b"=14u;"a"=5;}}; +{"key"="100";"subkey"="6";"value"={"a"=6;"c"="foo"}}; diff --git a/yql/essentials/tests/s-expressions/suites/Result/struct.txt.attr b/yql/essentials/tests/s-expressions/suites/Result/struct.txt.attr new file mode 100644 index 0000000000..1b386b578c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/struct.txt.attr @@ -0,0 +1,27 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + ["StructType"; [["a";["DataType";"Int32"]]; ["b";["OptionalType";["DataType";"Uint32"];]]]] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Result/yson.txt b/yql/essentials/tests/s-expressions/suites/Result/yson.txt new file mode 100644 index 0000000000..925448ce22 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/yson.txt @@ -0,0 +1,7 @@ +{"key"="075";"subkey"="1";"value"={"a"=1;}}; +{"key"="075";"subkey"="1";"value"={"$b"=#;}}; +{"key"="075";"subkey"="1";"value"={"c"=2u;}}; +{"key"="075";"subkey"="1";"value"={"d"=4.1;}}; +{"key"="075";"subkey"="1";"value"={"e"=%true;}}; +{"key"="075";"subkey"="1";"value"={"f"=[1;<x=1>"english text"]}}; +{"key"="100";"subkey"="6";"value"={"g"=<u=2>{x=<v="\xff\xff binary">[];y="русский текст"}}}; diff --git a/yql/essentials/tests/s-expressions/suites/Result/yson.txt.attr b/yql/essentials/tests/s-expressions/suites/Result/yson.txt.attr new file mode 100644 index 0000000000..0c28bda505 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Result/yson.txt.attr @@ -0,0 +1,30 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "Yson" + ] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/Bug635.yql b/yql/essentials/tests/s-expressions/suites/Scheme/Bug635.yql new file mode 100644 index 0000000000..d2aee30dd8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/Bug635.yql @@ -0,0 +1,46 @@ +( +(let world (block '( + (let values (block '( + (let values (Struct)) + (let values (AddMember values '"key" ("Just" (Cast ("Minus" (Int64 '"1")) 'Int32)))) + (let values (AddMember values '"x" (String '"2"))) + (return (AsList values)) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"Output"))) values '('('mode 'append)))) + (return (Commit! world sink)) + ))) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Output"))) '('"key") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core table0) + (let core (block '( + (return (Aggregate core '('"key") '())) + ))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"column0" ("ToString" ("Coalesce" (Member row '"key") (Int64 '"34"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/DropEmpty.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/DropEmpty.cfg new file mode 100644 index 0000000000..ed153c6223 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/DropEmpty.cfg @@ -0,0 +1 @@ +out Output empty.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/DropEmpty.yql b/yql/essentials/tests/s-expressions/suites/Scheme/DropEmpty.yql new file mode 100644 index 0000000000..6c9fb4ca13 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/DropEmpty.yql @@ -0,0 +1,4 @@ +( + (let world (Write! world (DataSink '"yt" '"plato") (Key '('table (String '"Output"))) (Void) '('('mode 'drop)))) + (return (Commit! world (DataSink '"yt" '"plato"))) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/FailInferEmptyRow.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/FailInferEmptyRow.cfg new file mode 100644 index 0000000000..2047856002 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/FailInferEmptyRow.cfg @@ -0,0 +1,2 @@ +xfail +in Input empty_row.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/FailInferEmptyRow.yql b/yql/essentials/tests/s-expressions/suites/Scheme/FailInferEmptyRow.yql new file mode 100644 index 0000000000..2080bede74 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/FailInferEmptyRow.yql @@ -0,0 +1,6 @@ +( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) (Void) '('('infer_scheme)))) + (let result (DataSink 'result)) + (let world (Write! (Left! x) result (Key) (FlatMap (Right! x) (lambda '(item) (AsList item))) '('('type) '('autoref)))) + (return (Commit! (Commit! world result) (DataSink '"yt" '"plato"))) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/FailReadEmpty.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/FailReadEmpty.cfg new file mode 100644 index 0000000000..3091572fb8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/FailReadEmpty.cfg @@ -0,0 +1,2 @@ +xfail +in Input empty.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/FailReadEmpty.yql b/yql/essentials/tests/s-expressions/suites/Scheme/FailReadEmpty.yql new file mode 100644 index 0000000000..921334c2cb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/FailReadEmpty.yql @@ -0,0 +1,6 @@ +( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) (Void) '())) + (let result (DataSink 'result)) + (let world (Write! (Left! x) result (Key) (FlatMap (Right! x) (lambda '(item) (AsList item))) '('('type) '('autoref)))) + (return (Commit! (Commit! world result) (DataSink '"yt" '"plato"))) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/FailReadWithoutScheme.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/FailReadWithoutScheme.cfg new file mode 100644 index 0000000000..1e9928289c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/FailReadWithoutScheme.cfg @@ -0,0 +1,2 @@ +xfail +in Input no_scheme.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/FailReadWithoutScheme.yql b/yql/essentials/tests/s-expressions/suites/Scheme/FailReadWithoutScheme.yql new file mode 100644 index 0000000000..921334c2cb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/FailReadWithoutScheme.yql @@ -0,0 +1,6 @@ +( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) (Void) '())) + (let result (DataSink 'result)) + (let world (Write! (Left! x) result (Key) (FlatMap (Right! x) (lambda '(item) (AsList item))) '('('type) '('autoref)))) + (return (Commit! (Commit! world result) (DataSink '"yt" '"plato"))) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/FieldNames.yql b/yql/essentials/tests/s-expressions/suites/Scheme/FieldNames.yql new file mode 100644 index 0000000000..ab951ab11b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/FieldNames.yql @@ -0,0 +1,32 @@ +( +# read data from Input table +(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)) + +# filter keys less than 100 +(let tresh (Int32 '100)) +(let table1low (Map table1 (lambda '(item) (block '( + (let val (Struct)) + (let val (AddMember val 'foo (Member item 'key))) + (let val (AddMember val 'bar (Member item 'value))) + (let ret (Struct)) + (let ret (AddMember ret 'key (Member item 'value))) + (let ret (AddMember ret 'subkey (String '""))) + (let ret (AddMember ret 'value val)) + (return ret) +))))) + +# write table1low to result sink +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink + (Key) + table1low '())) + +# finish +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/FieldNamesAndTypes.yql b/yql/essentials/tests/s-expressions/suites/Scheme/FieldNamesAndTypes.yql new file mode 100644 index 0000000000..9db3af4c99 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/FieldNamesAndTypes.yql @@ -0,0 +1,20 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let data (block '( + (let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) + (let world (Left! x)) + (let input (Right! x)) + (let output (FlatMap input (lambda '(item) (block '( + (let res (Struct)) + (let res (AddMember res 'foo (Member item 'key))) + (let res (AddMember res 'bar (Member item 'subkey))) + (return (AsList res)) + ))))) + (return output) +))) +(let mr_sink (DataSink 'result)) +(let world (Write! world mr_sink (Key) data '())) +(let world (Commit! world mr_sink)) +(return world) +) + diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferPragma.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferPragma.cfg new file mode 100644 index 0000000000..b156037a24 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferPragma.cfg @@ -0,0 +1 @@ +in Input ForceInferPragma.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferPragma.txt b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferPragma.txt new file mode 100644 index 0000000000..4f5501a315 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferPragma.txt @@ -0,0 +1,2 @@ +{"key"="023";"subkey"="3";"value"="aaa"}; +{"key"="037";"subkey"="5";"value"=1}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferPragma.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferPragma.txt.attr new file mode 100644 index 0000000000..376c9c6bf6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferPragma.txt.attr @@ -0,0 +1,34 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value1"; + [ + "DataType"; + "String" + ] + ] + ] + ] + }; + "schema"=<"strict" = %false> [ + {"type"="string"; "name"="key"}; + {"type"="string"; "name"="subkey"}; + ] +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferPragma.yql b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferPragma.yql new file mode 100644 index 0000000000..33f40d279a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferPragma.yql @@ -0,0 +1,7 @@ +( + (let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"forceinferschema" '"2")) + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) (Void) '())) + (let result (DataSink 'result)) + (let world (Write! (Left! x) result (Key) (Right! x) '('('type) '('autoref)))) + (return (Commit! (Commit! world result) (DataSink '"yt" '"plato"))) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSort.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSort.cfg new file mode 100644 index 0000000000..02f8cd81f4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSort.cfg @@ -0,0 +1,2 @@ +in Input ForceInferSchemaSort.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSort.txt b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSort.txt new file mode 100644 index 0000000000..1e61934b94 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSort.txt @@ -0,0 +1,3 @@ +{"a"="a"; "b"="b"; "c"="c1"}; +{"a"="a"; "b"="b"; "c"="c2"}; +{"a"="a"; "b"="b"; "c"="c3"}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSort.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSort.txt.attr new file mode 100644 index 0000000000..35c55ae0f6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSort.txt.attr @@ -0,0 +1,8 @@ +{ + "schema"=<"strict" = %true; "unique_keys" = %true> + [ + {"type"="string"; "name"="a"; "sort_order"="ascending"}; + {"type"="string"; "name"="b"; "sort_order"="ascending"}; + {"type"="string"; "name"="c"; "sort_order"="ascending"} + ] +} diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSort.yql b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSort.yql new file mode 100644 index 0000000000..3ef24c07f7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSort.yql @@ -0,0 +1,17 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"forceinferschema" '"")) + +(let x (Read! world mr_source + (Key '('tablescheme (String 'Input))) + (Void) '() +)) + +(let world (Left! x)) +(let scheme (Right! x)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) scheme '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullPrefix.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullPrefix.cfg new file mode 100644 index 0000000000..a02e32d085 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullPrefix.cfg @@ -0,0 +1,2 @@ +in Input ForceInferSchemaSortNullPrefix.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullPrefix.txt b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullPrefix.txt new file mode 100644 index 0000000000..01081ba8ce --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullPrefix.txt @@ -0,0 +1,3 @@ +{"a"=#; "b"=#; "c"="c1"}; +{"a"="a"; "b"="b"; "c"="c2"}; +{"a"="a"; "b"="b"; "c"="c3"}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullPrefix.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullPrefix.txt.attr new file mode 100644 index 0000000000..35c55ae0f6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullPrefix.txt.attr @@ -0,0 +1,8 @@ +{ + "schema"=<"strict" = %true; "unique_keys" = %true> + [ + {"type"="string"; "name"="a"; "sort_order"="ascending"}; + {"type"="string"; "name"="b"; "sort_order"="ascending"}; + {"type"="string"; "name"="c"; "sort_order"="ascending"} + ] +} diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullPrefix.yql b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullPrefix.yql new file mode 100644 index 0000000000..3ef24c07f7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullPrefix.yql @@ -0,0 +1,17 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"forceinferschema" '"")) + +(let x (Read! world mr_source + (Key '('tablescheme (String 'Input))) + (Void) '() +)) + +(let world (Left! x)) +(let scheme (Right! x)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) scheme '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullSuffix.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullSuffix.cfg new file mode 100644 index 0000000000..a956100087 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullSuffix.cfg @@ -0,0 +1,2 @@ +in Input ForceInferSchemaSortNullSuffix.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullSuffix.txt b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullSuffix.txt new file mode 100644 index 0000000000..449b660552 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullSuffix.txt @@ -0,0 +1,3 @@ +{"a"="a"; "b"="b"; "c"=#}; +{"a"="a"; "b"="b"; "c"="c2"}; +{"a"="a"; "b"="b"; "c"="c3"}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullSuffix.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullSuffix.txt.attr new file mode 100644 index 0000000000..35c55ae0f6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullSuffix.txt.attr @@ -0,0 +1,8 @@ +{ + "schema"=<"strict" = %true; "unique_keys" = %true> + [ + {"type"="string"; "name"="a"; "sort_order"="ascending"}; + {"type"="string"; "name"="b"; "sort_order"="ascending"}; + {"type"="string"; "name"="c"; "sort_order"="ascending"} + ] +} diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullSuffix.yql b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullSuffix.yql new file mode 100644 index 0000000000..3ef24c07f7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/ForceInferSchemaSortNullSuffix.yql @@ -0,0 +1,17 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"forceinferschema" '"")) + +(let x (Read! world mr_source + (Key '('tablescheme (String 'Input))) + (Void) '() +)) + +(let world (Left! x)) +(let scheme (Right! x)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) scheme '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaForceInfer.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaForceInfer.cfg new file mode 100644 index 0000000000..f11401b640 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaForceInfer.cfg @@ -0,0 +1,2 @@ +in Input IgnoreWeakSchemaOnWeak.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaForceInfer.yql b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaForceInfer.yql new file mode 100644 index 0000000000..aaf61a9163 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaForceInfer.yql @@ -0,0 +1,18 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"ignoreweakschema" '"")) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"forceinferschema" '"")) + +(let x (Read! world mr_source + (Key '('tablescheme (String 'Input))) + (Void) '() +)) + +(let world (Left! x)) +(let scheme (Right! x)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) scheme '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaInfer.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaInfer.cfg new file mode 100644 index 0000000000..f11401b640 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaInfer.cfg @@ -0,0 +1,2 @@ +in Input IgnoreWeakSchemaOnWeak.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaInfer.yql b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaInfer.yql new file mode 100644 index 0000000000..85f3775676 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaInfer.yql @@ -0,0 +1,18 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"ignoreweakschema" '"")) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"inferschema" '"")) + +(let x (Read! world mr_source + (Key '('tablescheme (String 'Input))) + (Void) '() +)) + +(let world (Left! x)) +(let scheme (Right! x)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) scheme '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnStrong.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnStrong.cfg new file mode 100644 index 0000000000..1b9a911d74 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnStrong.cfg @@ -0,0 +1,2 @@ +in Input IgnoreWeakSchemaOnStrong.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnStrong.txt b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnStrong.txt new file mode 100644 index 0000000000..1e61934b94 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnStrong.txt @@ -0,0 +1,3 @@ +{"a"="a"; "b"="b"; "c"="c1"}; +{"a"="a"; "b"="b"; "c"="c2"}; +{"a"="a"; "b"="b"; "c"="c3"}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnStrong.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnStrong.txt.attr new file mode 100644 index 0000000000..c78fe74feb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnStrong.txt.attr @@ -0,0 +1,9 @@ +{ + "schema"=<"strict" = %false; "unique_keys" = %false> + [ + {"type"="any"; "name"="a"; "sort_order"="ascending"}; + {"type"="any"; "name"="b"; "sort_order"="ascending"}; + {"type"="any"; "name"="c"; "sort_order"="ascending"} + ]; + "schema_mode"="strong" +} diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnStrong.yql b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnStrong.yql new file mode 100644 index 0000000000..40addc79c3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnStrong.yql @@ -0,0 +1,17 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"ignoreweakschema" '"")) + +(let x (Read! world mr_source + (Key '('tablescheme (String 'Input))) + (Void) '() +)) + +(let world (Left! x)) +(let scheme (Right! x)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) scheme '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnWeak.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnWeak.cfg new file mode 100644 index 0000000000..0c64f31555 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnWeak.cfg @@ -0,0 +1,2 @@ +in Input IgnoreWeakSchemaOnWeak.txt +xfail diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnWeak.txt b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnWeak.txt new file mode 100644 index 0000000000..1e61934b94 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnWeak.txt @@ -0,0 +1,3 @@ +{"a"="a"; "b"="b"; "c"="c1"}; +{"a"="a"; "b"="b"; "c"="c2"}; +{"a"="a"; "b"="b"; "c"="c3"}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnWeak.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnWeak.txt.attr new file mode 100644 index 0000000000..1574638558 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnWeak.txt.attr @@ -0,0 +1,9 @@ +{ + "schema"=<"strict" = %false; "unique_keys" = %false> + [ + {"type"="any"; "name"="a"; "sort_order"="ascending"}; + {"type"="any"; "name"="b"; "sort_order"="ascending"}; + {"type"="any"; "name"="c"; "sort_order"="ascending"} + ]; + "schema_mode"="weak" +} diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnWeak.yql b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnWeak.yql new file mode 100644 index 0000000000..40addc79c3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/IgnoreWeakSchemaOnWeak.yql @@ -0,0 +1,17 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"ignoreweakschema" '"")) + +(let x (Read! world mr_source + (Key '('tablescheme (String 'Input))) + (Void) '() +)) + +(let world (Left! x)) +(let scheme (Right! x)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) scheme '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/InferPragma.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/InferPragma.cfg new file mode 100644 index 0000000000..cfe28950fc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/InferPragma.cfg @@ -0,0 +1 @@ +in Input InferPragma.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/InferPragma.txt b/yql/essentials/tests/s-expressions/suites/Scheme/InferPragma.txt new file mode 100644 index 0000000000..4f5501a315 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/InferPragma.txt @@ -0,0 +1,2 @@ +{"key"="023";"subkey"="3";"value"="aaa"}; +{"key"="037";"subkey"="5";"value"=1}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/InferPragma.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/InferPragma.txt.attr new file mode 100644 index 0000000000..3c0f7e55c1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/InferPragma.txt.attr @@ -0,0 +1,3 @@ +{ + "infer_schema" = %true +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/InferPragma.yql b/yql/essentials/tests/s-expressions/suites/Scheme/InferPragma.yql new file mode 100644 index 0000000000..cd6fe7c84c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/InferPragma.yql @@ -0,0 +1,7 @@ +( + (let world (Configure! world (DataSource '"yt" '"$all") '"Attr" '"inferschema" '"2")) + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) (Void) '())) + (let result (DataSink 'result)) + (let world (Write! (Left! x) result (Key) (Right! x) '('('type) '('autoref)))) + (return (Commit! (Commit! world result) (DataSink '"yt" '"plato"))) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/MapDict.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/MapDict.cfg new file mode 100644 index 0000000000..5f5d93efe2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/MapDict.cfg @@ -0,0 +1,3 @@ +in Input dict.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/MapDict.yql b/yql/essentials/tests/s-expressions/suites/Scheme/MapDict.yql new file mode 100644 index 0000000000..c04cb6b397 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/MapDict.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 table1low (Map table1 (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (Member item 'subkey))) + (let keys (DictKeys (Member item 'value))) + (let keys (Sort keys (Bool 'True) (lambda '(x) x))) + (let s (AddMember s 'value keys)) + (return s) +))))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1low '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/NonKsvSortByKeyDesc.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/NonKsvSortByKeyDesc.cfg new file mode 100644 index 0000000000..42f62f4dfb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/NonKsvSortByKeyDesc.cfg @@ -0,0 +1,3 @@ +in Input non_ksv_input.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/NonKsvSortByKeyDesc.yql b/yql/essentials/tests/s-expressions/suites/Scheme/NonKsvSortByKeyDesc.yql new file mode 100644 index 0000000000..cc664b337a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/NonKsvSortByKeyDesc.yql @@ -0,0 +1,19 @@ +( +(let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"age" '"name") '())) +(let data (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s '"age" (Cast (Member item '"age") 'Uint64))) + (let s (AddMember s '"name" (Member item '"name"))) + (return (AsList s)) +)))) +(let data (FlatMap (Right! x) data)) +(let key (lambda '(item) (block '( + (let age (Member item '"age")) + (let name (Member item '"name")) + (return '(age name)) +)))) +(let res (Sort data '((Bool 'false) (Bool 'false)) key)) +(let mr_sink (DataSink '"yt" '"plato")) +(let res (Write! (Left! x) mr_sink (Key '('table (String '"Output"))) res '('('mode 'append)))) +(return (Commit! res mr_sink)) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/OverrideEmpty.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/OverrideEmpty.cfg new file mode 100644 index 0000000000..bad9ad9043 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/OverrideEmpty.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output empty.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/OverrideEmpty.yql b/yql/essentials/tests/s-expressions/suites/Scheme/OverrideEmpty.yql new file mode 100644 index 0000000000..ad8e17ad01 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/OverrideEmpty.yql @@ -0,0 +1,5 @@ +( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) (Void) '())) + (let world (Write! (Left! x) (DataSink '"yt" '"plato") (Key '('table (String '"Output"))) (FlatMap (Right! x) (lambda '(item) (AsList item))) '('('mode 'renew)))) + (return (Commit! world (DataSink '"yt" '"plato"))) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByTuple.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByTuple.cfg new file mode 100644 index 0000000000..4f895b9823 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByTuple.cfg @@ -0,0 +1,2 @@ +in Input group_by_tuple_input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByTuple.yql b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByTuple.yql new file mode 100644 index 0000000000..5b0236af0c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByTuple.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 table (Right! x)) +(let keySelector (lambda '(x) '((Member x 'value) (Member x 'subkey)))) +(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 (Nth key '0))) + (let s (AddMember s 'subkey (Nth key '1))) + (let s (AddMember s 'value (ToString (Length list)))) + (let ret (AsList s)) + (return ret) +)))))) +(let result (PartitionByKey table keySelector (Void) (Void) listHandler)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) result '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByValue.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByValue.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByValue.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByValue.yql b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByValue.yql new file mode 100644 index 0000000000..b6bb863891 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByValue.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 'value))) +(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 (Void) (Void) listHandler)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) reducedTable '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByValueAndMap.yql b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByValueAndMap.yql new file mode 100644 index 0000000000..bc7222e7e1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionByValueAndMap.yql @@ -0,0 +1,41 @@ +( +(let x (Read! world (DataSource 'yt 'plato) (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let yt.plato.Input (Right! x)) +(let select@0:0_input yt.plato.Input) +(let output (block '( + (let select@0:0_output (Map select@0:0_input (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res 'foo (Member row 'value))) + (let res (AddMember res 'bar (Member row 'key))) + (return res) +) +)))) + (let select@0:0_output (PartitionByKey select@0:0_output (lambda '(row) (block '( + (let res (Member row 'foo)) + (return res) +) +)) (Void) (Void) (lambda '(stream) (FlatMap stream (lambda '(pair) (block '( + (let key (Nth pair '0)) + (let group (Collect (Nth pair '1))) + (let res (FlatMap group (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res 'subkey (ToString (Length group)))) + (let res (AddMember res 'value (Member row 'bar))) + (let res (AddMember res 'key (Member row 'foo))) + (let res (AsList res)) + (return res) +) +)))) + (return res) +))))) +)) + (return select@0:0_output) +) +)) +(let output (Sort output (Bool 'true) (lambda '(x) (Concat (Member x 'subkey) (Member x 'value))))) +(let sink (DataSink 'result)) +(let world (Write! world sink (Key) output '())) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/PartitionsByTuple.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionsByTuple.cfg new file mode 100644 index 0000000000..4f895b9823 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionsByTuple.cfg @@ -0,0 +1,2 @@ +in Input group_by_tuple_input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/PartitionsByTuple.yql b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionsByTuple.yql new file mode 100644 index 0000000000..acd5dca2d2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionsByTuple.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 table (Right! x)) +(let keySelector (lambda '(x) '((Member x 'value) (Member x 'subkey)))) +(let result (PartitionsByKeys table keySelector (Void) (Void) (lambda '(x) x))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) result '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/PartitionsByValue.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionsByValue.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionsByValue.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/PartitionsByValue.yql b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionsByValue.yql new file mode 100644 index 0000000000..227eeaa709 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/PartitionsByValue.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 keySelector (lambda '(x) (Member x 'value))) +(let reducedTable (PartitionsByKeys table1 keySelector (Void) (Void) (lambda '(x) x))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) reducedTable '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/RangeFailEmpty.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/RangeFailEmpty.cfg new file mode 100644 index 0000000000..effc27a938 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/RangeFailEmpty.cfg @@ -0,0 +1,3 @@ +xfail +in Input1 empty.txt +in Input2 input.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/RangeFailEmpty.yql b/yql/essentials/tests/s-expressions/suites/Scheme/RangeFailEmpty.yql new file mode 100644 index 0000000000..954ed3d61f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/RangeFailEmpty.yql @@ -0,0 +1,33 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(let world (block '( + (let filter (lambda '(name) (And (>= name (String '"Input1")) (<= name (String '"Input2"))))) + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (MrTableRangeStrict '"" filter))) (Void) '('('infer_scheme)))) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/SortAndTake.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/SortAndTake.cfg new file mode 100644 index 0000000000..f3b77c80df --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/SortAndTake.cfg @@ -0,0 +1,3 @@ +in Input sort_input.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/SortAndTake.yql b/yql/essentials/tests/s-expressions/suites/Scheme/SortAndTake.yql new file mode 100644 index 0000000000..6c106597e1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/SortAndTake.yql @@ -0,0 +1,17 @@ +# do not check tmp here (YQL-130, YQL-131) +( +(let x (Read! world (DataSource 'yt 'plato) (Key '('table (String 'Input))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let yt.plato.Input (Right! x)) +(let input yt.plato.Input) +(let output (Sort input (Bool 'true) (lambda '(row) (block '( + (let res (Member row 'value)) + (return res) +) +)))) +(let output (Take output (Uint64 '5))) +(let sink (DataSink 'result)) +(let world (Write! world sink (Key) output '())) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/SortByDouble.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/SortByDouble.cfg new file mode 100644 index 0000000000..f3b77c80df --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/SortByDouble.cfg @@ -0,0 +1,3 @@ +in Input sort_input.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/SortByDouble.yql b/yql/essentials/tests/s-expressions/suites/Scheme/SortByDouble.yql new file mode 100644 index 0000000000..01624bc527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/SortByDouble.yql @@ -0,0 +1,16 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let data (block '( + (let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) + (let world (Left! x)) + (let input (Right! x)) + (let output (Sort input (Bool 'true) (lambda '(item) (block '( + (return (/ (FromString (Member item 'key) 'Double) (FromString (Member item 'subkey) 'Double))) + ))))) + (return output) +))) +(let mr_sink (DataSink 'result)) +(let world (Write! world mr_sink (Key) data '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/SortByKeyDesc.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/SortByKeyDesc.cfg new file mode 100644 index 0000000000..c9fc780575 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/SortByKeyDesc.cfg @@ -0,0 +1,3 @@ +in Input desc_sort_input.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/SortByKeyDesc.yql b/yql/essentials/tests/s-expressions/suites/Scheme/SortByKeyDesc.yql new file mode 100644 index 0000000000..6b98c46713 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/SortByKeyDesc.yql @@ -0,0 +1,16 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let data (block '( + (let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) + (let world (Left! x)) + (let input (Right! x)) + (let output (Sort input (Bool 'false) (lambda '(item) (block '( + (return (Member item 'key)) + ))))) + (return output) +))) +(let mr_sink (DataSink 'result)) +(let world (Write! world mr_sink (Key) data '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/SortByValue.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/SortByValue.cfg new file mode 100644 index 0000000000..f3b77c80df --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/SortByValue.cfg @@ -0,0 +1,3 @@ +in Input sort_input.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/SortByValue.yql b/yql/essentials/tests/s-expressions/suites/Scheme/SortByValue.yql new file mode 100644 index 0000000000..3d74c7388a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/SortByValue.yql @@ -0,0 +1,17 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let data (block '( + (let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) + (let world (Left! x)) + (let input (Right! x)) + (let output (Sort input (Bool 'true) (lambda '(item) (block '( + (return (Member item 'value)) + ))))) + (return output) +))) +(let mr_sink (DataSink 'result)) +(let world (Write! world mr_sink (Key) data '())) +(let world (Commit! world mr_sink)) +(return world) +) + diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/SortDoubles.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/SortDoubles.cfg new file mode 100644 index 0000000000..d1e6db2a43 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/SortDoubles.cfg @@ -0,0 +1,3 @@ +in Input doubles_input.txt +out Output output.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/SortDoubles.yql b/yql/essentials/tests/s-expressions/suites/Scheme/SortDoubles.yql new file mode 100644 index 0000000000..6508146c9e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/SortDoubles.yql @@ -0,0 +1,16 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let data (block '( + (let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) + (let world (Left! x)) + (let input (Right! x)) + (let output (Sort input (Bool 'true) (lambda '(item) (block '( + (return (Coalesce (FromString (Member item 'key) 'Double) (Double '0))) + ))))) + (return output) +))) +(let mr_sink (DataSink 'result)) +(let world (Write! world mr_sink (Key) data '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/SortInts.yql b/yql/essentials/tests/s-expressions/suites/Scheme/SortInts.yql new file mode 100644 index 0000000000..a2266c98de --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/SortInts.yql @@ -0,0 +1,16 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let data (block '( + (let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) + (let world (Left! x)) + (let input (Right! x)) + (let output (Sort input (Bool 'true) (lambda '(item) (block '( + (return (Coalesce (FromString (Member item 'subkey) 'Uint64) (Uint64 '0))) + ))))) + (return output) +))) +(let mr_sink (DataSink 'result)) +(let world (Write! world mr_sink (Key) data '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/SortTuples.yql b/yql/essentials/tests/s-expressions/suites/Scheme/SortTuples.yql new file mode 100644 index 0000000000..0275b2d11d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/SortTuples.yql @@ -0,0 +1,16 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let data (block '( + (let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) + (let world (Left! x)) + (let input (Right! x)) + (let output (Sort input '((Bool 'true) (Bool 'true)) (lambda '(item) (block '( + (return '((Member item 'value) (Member item 'subkey))) + ))))) + (return output) +))) +(let mr_sink (DataSink 'result)) +(let world (Write! world mr_sink (Key) data '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/SortTuplesAndWrite.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/SortTuplesAndWrite.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/SortTuplesAndWrite.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/SortTuplesAndWrite.yql b/yql/essentials/tests/s-expressions/suites/Scheme/SortTuplesAndWrite.yql new file mode 100644 index 0000000000..05e9777d03 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/SortTuplesAndWrite.yql @@ -0,0 +1,16 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let data (block '( + (let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) + (let world (Left! x)) + (let input (Right! x)) + (let output (Sort input '((Bool 'true) (Bool 'true)) (lambda '(item) (block '( + (return '((Member item 'value) (Member item 'subkey))) + ))))) + (return output) +))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) data '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/UniqueKeys.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/UniqueKeys.cfg new file mode 100644 index 0000000000..590d6de49e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/UniqueKeys.cfg @@ -0,0 +1,2 @@ +in Input unique_keys.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/UniqueKeys.yql b/yql/essentials/tests/s-expressions/suites/Scheme/UniqueKeys.yql new file mode 100644 index 0000000000..c65fa8f8ac --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/UniqueKeys.yql @@ -0,0 +1,16 @@ +( +(let mr_source (DataSource 'yt 'plato)) + +(let x (Read! world mr_source + (Key '('tablescheme (String 'Input))) + (Void) '() +)) + +(let world (Left! x)) +(let scheme (Right! x)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) scheme '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/UniqueKeysStrip.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/UniqueKeysStrip.cfg new file mode 100644 index 0000000000..5318593448 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/UniqueKeysStrip.cfg @@ -0,0 +1,2 @@ +in Input unique_keys_strip.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/UniqueKeysStrip.yql b/yql/essentials/tests/s-expressions/suites/Scheme/UniqueKeysStrip.yql new file mode 100644 index 0000000000..c65fa8f8ac --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/UniqueKeysStrip.yql @@ -0,0 +1,16 @@ +( +(let mr_source (DataSource 'yt 'plato)) + +(let x (Read! world mr_source + (Key '('tablescheme (String 'Input))) + (Void) '() +)) + +(let world (Left! x)) +(let scheme (Right! x)) + +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) scheme '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/WeakRangeOnlyEmpty.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/WeakRangeOnlyEmpty.cfg new file mode 100644 index 0000000000..e39613226c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/WeakRangeOnlyEmpty.cfg @@ -0,0 +1,3 @@ +in Input1 empty.txt +in Input2 empty.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/WeakRangeOnlyEmpty.yql b/yql/essentials/tests/s-expressions/suites/Scheme/WeakRangeOnlyEmpty.yql new file mode 100644 index 0000000000..b27b58aa03 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/WeakRangeOnlyEmpty.yql @@ -0,0 +1,33 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(let world (block '( + (let filter (lambda '(name) (And (>= name (String '"Input1")) (<= name (String '"Input2"))))) + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (MrTableRange '"" filter))) (Void) '('('infer_scheme)))) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/WeakRangeSkipEmpty.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/WeakRangeSkipEmpty.cfg new file mode 100644 index 0000000000..abafdbeb96 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/WeakRangeSkipEmpty.cfg @@ -0,0 +1,3 @@ +in Input1 empty.txt +in Input2 input.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/WeakRangeSkipEmpty.yql b/yql/essentials/tests/s-expressions/suites/Scheme/WeakRangeSkipEmpty.yql new file mode 100644 index 0000000000..b27b58aa03 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/WeakRangeSkipEmpty.yql @@ -0,0 +1,33 @@ +( +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(let world (block '( + (let filter (lambda '(name) (And (>= name (String '"Input1")) (<= name (String '"Input2"))))) + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (MrTableRange '"" filter))) (Void) '('('infer_scheme)))) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsList row)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref)))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/WriteNumbers.yql b/yql/essentials/tests/s-expressions/suites/Scheme/WriteNumbers.yql new file mode 100644 index 0000000000..d9bfcea077 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/WriteNumbers.yql @@ -0,0 +1,15 @@ +( +(let output5 (block '( + (let row (Struct)) + (let row (AddMember row 'x (Int64 '1))) + (let row (AddMember row 'y (Int64 '2))) + (let row (AddMember row 'z (Int64 '3))) + (let insert1_output (AsList row)) + (return insert1_output) +) +)) +(let sink (DataSink 'yt 'plato)) +(let world (Write! world sink (Key '('table (String 'Output))) output5 '('('mode 'append)))) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/WriteStructThenCopyOneField.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/WriteStructThenCopyOneField.cfg new file mode 100644 index 0000000000..d611f0155e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/WriteStructThenCopyOneField.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +out Output2 output2.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/WriteStructThenCopyOneField.yql b/yql/essentials/tests/s-expressions/suites/Scheme/WriteStructThenCopyOneField.yql new file mode 100644 index 0000000000..7af6edc4ca --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/WriteStructThenCopyOneField.yql @@ -0,0 +1,27 @@ +( +(let output1 (block '( + (let row (Struct)) + (let row (AddMember row 'x (String 'abc))) + (let row (AddMember row 'y (Int32 '2))) + (let row (AddMember row 'z (Int64 '3))) + (let insert1_output (AsList row)) + (return insert1_output) +) +)) +(let sink (DataSink 'yt 'plato)) +(let world (Write! world sink (Key '('table (String 'Output))) output1 '('('mode 'append)))) +(let world (Commit! world sink)) +(let source (DataSource 'yt 'plato)) +(let x (Read! world source (Key '('table (String 'Output))) '('y) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let world (Write! world sink (Key '('table (String 'Output2))) table1 '('('mode 'append)))) +(let world (Commit! world sink)) +(let x (Read! world source (Key '('table (String 'Output2))) (Void) '())) +(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 res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/default.cfg b/yql/essentials/tests/s-expressions/suites/Scheme/default.cfg new file mode 100644 index 0000000000..fe2b19a9ff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/default.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/Scheme/desc_sort_input.txt b/yql/essentials/tests/s-expressions/suites/Scheme/desc_sort_input.txt new file mode 100644 index 0000000000..48706ed4c9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/desc_sort_input.txt @@ -0,0 +1,6 @@ +{"key"="abc";"subkey"="1";"value"="075"}; +{"key"="ddd";"subkey"="2";"value"="800"}; +{"key"="q";"subkey"="3";"value"="020"}; +{"key"="qzz";"subkey"="4";"value"="150"}; +{"key"="qw";"subkey"="5";"value"="075"}; +{"key"="dddx";"subkey"="6";"value"="100"}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/desc_sort_input.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/desc_sort_input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/desc_sort_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/Scheme/dict.txt b/yql/essentials/tests/s-expressions/suites/Scheme/dict.txt new file mode 100644 index 0000000000..c189e76627 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/dict.txt @@ -0,0 +1,6 @@ +{"key"="075";"subkey"="1";"value"={"b"=11;"a"=1;}}; +{"key"="800";"subkey"="2";"value"={"a"=2;}}; +{"key"="020";"subkey"="3";"value"={}}; +{"key"="150";"subkey"="4";"value"={"b"=13;"a"=4;}}; +{"key"="075";"subkey"="5";"value"={"b"=14;"a"=5;}}; +{"key"="100";"subkey"="6";"value"={"c"=15;"a"=6;}}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/dict.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/dict.txt.attr new file mode 100644 index 0000000000..6dd8d28db1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/dict.txt.attr @@ -0,0 +1,27 @@ +{ + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + ["DictType"; ["DataType";"String"]; ["DataType";"Int32"];] + ] + ] + ] + } +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/doubles_input.txt b/yql/essentials/tests/s-expressions/suites/Scheme/doubles_input.txt new file mode 100644 index 0000000000..54b881cf72 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/doubles_input.txt @@ -0,0 +1,7 @@ +{"key"="1";"subkey"="6";"value"="a"}; +{"key"="1.1";"subkey"="7";"value"="b"}; +{"key"="0.1";"subkey"="5";"value"="c"}; +{"key"="-1";"subkey"="2";"value"="d"}; +{"key"="-1.1";"subkey"="1";"value"="e"}; +{"key"="-0.1";"subkey"="3";"value"="f"}; +{"key"="0";"subkey"="4";"value"="z"}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/doubles_input.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/doubles_input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/doubles_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/Scheme/empty.txt b/yql/essentials/tests/s-expressions/suites/Scheme/empty.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/empty.txt diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/empty.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/empty.txt.attr new file mode 100644 index 0000000000..ada1f836f8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/empty.txt.attr @@ -0,0 +1,3 @@ +{ + "infer_schema"=%true +} diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/empty_row.txt b/yql/essentials/tests/s-expressions/suites/Scheme/empty_row.txt new file mode 100644 index 0000000000..d268b7d3ae --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/empty_row.txt @@ -0,0 +1 @@ +{}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/empty_row.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/empty_row.txt.attr new file mode 100644 index 0000000000..3c0f7e55c1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/empty_row.txt.attr @@ -0,0 +1,3 @@ +{ + "infer_schema" = %true +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/group_by_tuple_input.txt b/yql/essentials/tests/s-expressions/suites/Scheme/group_by_tuple_input.txt new file mode 100644 index 0000000000..613ebe7f0d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/group_by_tuple_input.txt @@ -0,0 +1,6 @@ +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="800";"subkey"="2";"value"="ddd"}; +{"key"="020";"subkey"="3";"value"="q"}; +{"key"="150";"subkey"="4";"value"="qzz"}; +{"key"="075";"subkey"="3";"value"="q"}; +{"key"="100";"subkey"="2";"value"="ddd"}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/group_by_tuple_input.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/group_by_tuple_input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/group_by_tuple_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/Scheme/input.txt b/yql/essentials/tests/s-expressions/suites/Scheme/input.txt new file mode 100644 index 0000000000..7d4ce31a5d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/input.txt @@ -0,0 +1,6 @@ +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="800";"subkey"="2";"value"="ddd"}; +{"key"="020";"subkey"="3";"value"="q"}; +{"key"="150";"subkey"="4";"value"="qzz"}; +{"key"="075";"subkey"="5";"value"="q"}; +{"key"="100";"subkey"="6";"value"="ddd"}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/input.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/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/Scheme/no_scheme.txt b/yql/essentials/tests/s-expressions/suites/Scheme/no_scheme.txt new file mode 100644 index 0000000000..65949ea745 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/no_scheme.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/Scheme/no_scheme.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/no_scheme.txt.attr new file mode 100644 index 0000000000..3c0f7e55c1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/no_scheme.txt.attr @@ -0,0 +1,3 @@ +{ + "infer_schema" = %true +}
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/non_ksv_input.txt b/yql/essentials/tests/s-expressions/suites/Scheme/non_ksv_input.txt new file mode 100644 index 0000000000..acb15b8973 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/non_ksv_input.txt @@ -0,0 +1,6 @@ +{"age"="30";"name"="bob"}; +{"age"="16";"name"="alice"}; +{"age"="55";"name"="jone"}; +{"age"="45";"name"="silver"}; +{"age"="45";"name"="smith"}; +{"age"="90";"name"="stive"}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/non_ksv_input.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/non_ksv_input.txt.attr new file mode 100644 index 0000000000..db02940d83 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/non_ksv_input.txt.attr @@ -0,0 +1,3 @@ +{ + "_yql_row_spec"={"Type"=["StructType";[["age";["DataType";"String"]];["name";["DataType";"String"]]]]} +} diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/sort_input.txt b/yql/essentials/tests/s-expressions/suites/Scheme/sort_input.txt new file mode 100644 index 0000000000..fe02ecfe9e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/sort_input.txt @@ -0,0 +1,6 @@ +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="800";"subkey"="2";"value"="ddd"}; +{"key"="020";"subkey"="3";"value"="q"}; +{"key"="150";"subkey"="4";"value"="qzz"}; +{"key"="075";"subkey"="5";"value"="qw"}; +{"key"="100";"subkey"="6";"value"="dddx"}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/sort_input.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/sort_input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/sort_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/Scheme/unique_keys.txt b/yql/essentials/tests/s-expressions/suites/Scheme/unique_keys.txt new file mode 100644 index 0000000000..6e7e05cd2e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/unique_keys.txt @@ -0,0 +1,3 @@ +{"a"="a"; "b"="b"; c="c1"}; +{"a"="a"; "b"="b"; c="c2"}; +{"a"="a"; "b"="b"; c="c3"}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/unique_keys.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/unique_keys.txt.attr new file mode 100644 index 0000000000..8d0816e3f5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/unique_keys.txt.attr @@ -0,0 +1,14 @@ +{ + "_read_schema"=<"strict"=%false> + [ + {"type"="string"; "name"="a"}; + {"type"="string"; "name"="b"}; + {"type"="string"; "name"="c"} + ]; + "schema"=<"strict" = %true; "unique_keys" = %true> + [ + {"type"="string"; "name"="a"; "sort_order"="ascending"}; + {"type"="string"; "name"="b"; "sort_order"="ascending"}; + {"type"="string"; "name"="c"; "sort_order"="ascending"} + ] +} diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/unique_keys_strip.txt b/yql/essentials/tests/s-expressions/suites/Scheme/unique_keys_strip.txt new file mode 100644 index 0000000000..6e7e05cd2e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/unique_keys_strip.txt @@ -0,0 +1,3 @@ +{"a"="a"; "b"="b"; c="c1"}; +{"a"="a"; "b"="b"; c="c2"}; +{"a"="a"; "b"="b"; c="c3"}; diff --git a/yql/essentials/tests/s-expressions/suites/Scheme/unique_keys_strip.txt.attr b/yql/essentials/tests/s-expressions/suites/Scheme/unique_keys_strip.txt.attr new file mode 100644 index 0000000000..b709a3f991 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Scheme/unique_keys_strip.txt.attr @@ -0,0 +1,13 @@ +{ + "_read_schema"=<"strict"=%false> + [ + {"type"="string"; "name"="a"}; + {"type"="string"; "name"="b"} + ]; + "schema"=<"strict" = %true; "unique_keys" = %true> + [ + {"type"="string"; "name"="a"; "sort_order"="ascending"}; + {"type"="string"; "name"="b"; "sort_order"="ascending"}; + {"type"="string"; "name"="c"; "sort_order"="ascending"} + ] +} diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/CombineByKey.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/CombineByKey.cfg new file mode 100644 index 0000000000..7e61f75847 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/CombineByKey.cfg @@ -0,0 +1,2 @@ +in Input SomeKeys.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/CombineByKey.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/CombineByKey.yql new file mode 100644 index 0000000000..2e63d28e6a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/CombineByKey.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 preMap (lambda '(item) (Just item))) +(let keyExtractor (lambda '(item) (Member item 'key))) +(let init (lambda '(key item) (FromString (Member item 'subkey) 'Uint32))) +(let update (lambda '(key item state) (+ state (FromString (Member item 'subkey) 'Uint32)))) +(let finish (lambda '(key state) (block '( + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Coalesce (Map state (lambda '(x) (ToString x))) (String '"")))) + (return (Just s)) +)))) +(let table2 (CombineByKey table1 preMap keyExtractor init update finish)) +(let mr_sink (DataSink 'yt 'plato)) +(let result (Sort table2 (Bool 'true) (lambda '(x) (Member x 'key)))) +(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/SingleYamrOperation/CombineByKeyStream.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/CombineByKeyStream.cfg new file mode 100644 index 0000000000..7e61f75847 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/CombineByKeyStream.cfg @@ -0,0 +1,2 @@ +in Input SomeKeys.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/CombineByKeyStream.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/CombineByKeyStream.yql new file mode 100644 index 0000000000..4957a8671d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/CombineByKeyStream.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 preMap (lambda '(item) (Iterator (AsList item)))) +(let keyExtractor (lambda '(item) (Member item 'key))) +(let init (lambda '(key item) (FromString (Member item 'subkey) 'Uint32))) +(let update (lambda '(key item state) (+ state (FromString (Member item 'subkey) 'Uint32)))) +(let finish (lambda '(key state) (block '( + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Coalesce (Map state (lambda '(x) (ToString x))) (String '"")))) + (return (Iterator (AsList s))) +)))) +(let table2 (CombineByKey table1 preMap keyExtractor init update finish)) +(let mr_sink (DataSink 'yt 'plato)) +(let result (Sort table2 (Bool 'true) (lambda '(x) (Member x 'key)))) +(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/SingleYamrOperation/Drop.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/Drop.yql new file mode 100644 index 0000000000..72c7873e91 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/Drop.yql @@ -0,0 +1,19 @@ +( +(let mr_sink (DataSink 'yt 'plato)) +(let data (AsList (AsStruct '('key (String 'abc))))) + +(let world (Write! world mr_sink + (Key '('table (String 'Output))) + data '('('mode 'renew)) +)) + +(let world (Commit! world mr_sink)) + +(let world (Write! world mr_sink + (Key '('table (String 'Output))) + (Void) '('('mode 'drop)) +)) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/EmptyCopy.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/EmptyCopy.cfg new file mode 100644 index 0000000000..e98936751d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/EmptyCopy.cfg @@ -0,0 +1,2 @@ +in InputEmpty input_empty.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/EmptyCopy.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/EmptyCopy.yql new file mode 100644 index 0000000000..fbe31a1f8f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/EmptyCopy.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'InputEmpty))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/EnumerateInsideReduce.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/EnumerateInsideReduce.cfg new file mode 100644 index 0000000000..7e61f75847 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/EnumerateInsideReduce.cfg @@ -0,0 +1,2 @@ +in Input SomeKeys.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/EnumerateInsideReduce.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/EnumerateInsideReduce.yql new file mode 100644 index 0000000000..c28ef4d035 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/EnumerateInsideReduce.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 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 list (Skip (Take (Enumerate list) (Uint64 '2)) (Uint64 '1))) + (let r (FlatMap list (lambda '(x) (block '( + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Concat (ToString (Nth x '0)) (ToString (Member (Nth x '1) 'value))))) + (return (AsList s)) + ))))) + (return r) +)))))) +(let reducedTable (PartitionByKey table1 keySelector (Void) (Void)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/SingleYamrOperation/Fill.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/Fill.yql new file mode 100644 index 0000000000..e48c1f7a2f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/Fill.yql @@ -0,0 +1,11 @@ +( +#comment +(let data (AsList +(AsStruct '('key (String 'key1)) '('subkey (String '"")) '('value (String 'value1))) +(AsStruct '('key (String 'key2)) '('subkey (String '"")) '('value (String 'value2))) +)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) data '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/FillWithCount.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/FillWithCount.yql new file mode 100644 index 0000000000..20f0cd1ac2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/FillWithCount.yql @@ -0,0 +1,15 @@ +( +#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 data (AsList +(AsStruct '('key (String 'key1)) '('subkey (String '"")) '('value (String 'value1))) +(AsStruct '('key (String 'key2)) '('subkey (String '"")) '('value (ToString (Length table1)))) +)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) data '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/FilterThenCombineByKey.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/FilterThenCombineByKey.cfg new file mode 100644 index 0000000000..7e61f75847 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/FilterThenCombineByKey.cfg @@ -0,0 +1,2 @@ +in Input SomeKeys.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/FilterThenCombineByKey.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/FilterThenCombineByKey.yql new file mode 100644 index 0000000000..a5be6f207c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/FilterThenCombineByKey.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 table1 (Filter table1 (lambda '(x) (< (Member x 'key) (String '500))))) +(let preMap (lambda '(item) (Just item))) +(let keyExtractor (lambda '(item) (Member item 'key))) +(let init (lambda '(key item) (FromString (Member item 'subkey) 'Uint32))) +(let update (lambda '(key item state) (+ state (FromString (Member item 'subkey) 'Uint32)))) +(let finish (lambda '(key state) (block '( + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Coalesce (Map state (lambda '(x) (ToString x))) (String '"")))) + (return (Just s)) +)))) +(let table2 (CombineByKey table1 preMap keyExtractor init update finish)) +(let result (Sort table2 (Bool 'true) (lambda '(x) (Member x 'key)))) +(let mr_sink (DataSink 'yt '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/SingleYamrOperation/IteratorInMap.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/IteratorInMap.yql new file mode 100644 index 0000000000..fcc89eb21c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/IteratorInMap.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 handler (lambda '(row) (block '( + (let value (Member row 'value)) + (return (ReplaceMember row 'value (Collect (Iterator (AsList value value))))) + )))) +(let data (Map table1 handler)) +(let data (Sort data (Bool 'true) (lambda '(row) (Member row 'key)))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) data '('('mode 'append)))) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/LMapOverTable.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/LMapOverTable.yql new file mode 100644 index 0000000000..f86f4c0c21 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/LMapOverTable.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 tresh (Int32 '100)) +(let table1low (LMap table1 (lambda '(stream) (block '( + (return (FlatMap stream (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let ret (FlatMap intValueOpt (lambda '(item2) (block '( + (return (ListIf (< item2 tresh) item)) + ))))) + (return ret)))))) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/LengthOfTableInsideMap.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/LengthOfTableInsideMap.yql new file mode 100644 index 0000000000..ccbd5bbbb4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/LengthOfTableInsideMap.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 x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let table3 (Map table1 (lambda '(item) (block '( + (let s (AsStruct + '('key (Member item 'key)) + '('subkey (ToString (Length table2))) + '('value (Member item 'value)) + )) + + (return s) +))))) + +(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/SingleYamrOperation/LengthOfTempTableInsideMap.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/LengthOfTempTableInsideMap.yql new file mode 100644 index 0000000000..d2e6fd6aec --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/LengthOfTempTableInsideMap.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 tresh (Int32 'x"64000000")) +(let table1low (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let ret (FlatMap intValueOpt (lambda '(item2) (block '( + (return (ListIf (< item2 tresh) item)) + ))))) + (return ret) +))))) + +(let table2 (Map table1 (lambda '(item) (block '( + (let s (AsStruct + '('key (Member item 'key)) + '('subkey (ToString (Length table1low))) + '('value (Member item 'value)) + )) + + (return s) +))))) + +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table2 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOther.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOther.cfg new file mode 100644 index 0000000000..8e3bf0495d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOther.cfg @@ -0,0 +1,2 @@ +in Input input_other.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOther.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOther.yql new file mode 100644 index 0000000000..e8caad830b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOther.yql @@ -0,0 +1,19 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('_other) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let tresh (String 'abc)) +(let table1low (FlatMap table1 (lambda '(item) (block '( + (let value (Lookup (Member item '_other) (String 'value)) ) + (let ret (FlatMap value (lambda '(item2) (block '( + (return (ListIf (== item2 tresh) item)) + ))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOtherMixed.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOtherMixed.cfg new file mode 100644 index 0000000000..846f89d5a3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOtherMixed.cfg @@ -0,0 +1,3 @@ +in Input1 input_other.txt +in Input2 input_other_strict.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOtherMixed.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOtherMixed.yql new file mode 100644 index 0000000000..772527f2f6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOtherMixed.yql @@ -0,0 +1,19 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source '((Key '('table (String 'Input1))) (Key '('table (String 'Input2)))) '('_other) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let tresh (String 'abc)) +(let table1low (FlatMap table1 (lambda '(item) (block '( + (let value (Lookup (Member item '_other) (String 'value)) ) + (let ret (FlatMap value (lambda '(item2) (block '( + (return (ListIf (== item2 tresh) item)) + ))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOtherStrict.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOtherStrict.cfg new file mode 100644 index 0000000000..23b0cd29bd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOtherStrict.cfg @@ -0,0 +1,2 @@ +in Input input_other_strict.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOtherStrict.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOtherStrict.yql new file mode 100644 index 0000000000..e8caad830b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapOtherStrict.yql @@ -0,0 +1,19 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('_other) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let tresh (String 'abc)) +(let table1low (FlatMap table1 (lambda '(item) (block '( + (let value (Lookup (Member item '_other) (String 'value)) ) + (let ret (FlatMap value (lambda '(item2) (block '( + (return (ListIf (== item2 tresh) item)) + ))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapStream.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapStream.yql new file mode 100644 index 0000000000..e9fe1806e8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MapStream.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 tresh (Int32 '100)) +(let table1low (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let ret (Collect (FlatMap intValueOpt (lambda '(item2) (block '( + (return (Iterator (ListIf (< item2 tresh) item))) + )))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MissingColumn.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MissingColumn.yql new file mode 100644 index 0000000000..73e0d903b4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/MissingColumn.yql @@ -0,0 +1,19 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey2 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let tresh (Int32 'x"64000000")) +(let table1low (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let ret (FlatMap intValueOpt (lambda '(item2) (block '( + (return (ListIf (< item2 tresh) item)) + ))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/OrderedLMapOverTable.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/OrderedLMapOverTable.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/OrderedLMapOverTable.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/OrderedLMapOverTable.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/OrderedLMapOverTable.yql new file mode 100644 index 0000000000..cb740182a1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/OrderedLMapOverTable.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 tresh (Int32 '100)) +(let table1low (OrderedLMap table1 (lambda '(stream) (block '( + (return (OrderedFlatMap stream (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let ret (FlatMap intValueOpt (lambda '(item2) (block '( + (return (ListIf (< item2 tresh) item)) + ))))) + (return ret)))))) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKey.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKey.cfg new file mode 100644 index 0000000000..d87afdedc4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKey.cfg @@ -0,0 +1,2 @@ +in Input program26.input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKey.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKey.yql new file mode 100644 index 0000000000..2645b699e4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKey.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 keySelector (lambda '(x) (Member x 'key))) +(let listHandler (lambda '(groups) (block '( + (return (Map groups (lambda '(group) (block '( + (let key (Nth group '0)) + (let stream (Nth group '1)) + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (ToString (Length (ForwardList stream))))) + (return s) + ))))) +)))) +(let reducedTable (PartitionByKey table1 keySelector (Void) (Void) 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/SingleYamrOperation/PartitionByKeySorted.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKeySorted.cfg new file mode 100644 index 0000000000..d87afdedc4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKeySorted.cfg @@ -0,0 +1,2 @@ +in Input program26.input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKeySorted.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKeySorted.yql new file mode 100644 index 0000000000..88c71a6f9d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKeySorted.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 keySelector (lambda '(x) (Member x 'key))) +(let sortKeySelector (lambda '(x) (Member x 'value))) +(let listHandler (lambda '(groups) (block '( + (return (Map groups (lambda '(group) (block '( + (let key (Nth group '0)) + (let stream (Nth group '1)) + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Collect (Condense stream (String '"") (lambda '(item state) (Bool 'False)) (lambda '(item state) (Concat (Concat state (String '" ")) (Member item 'value))))))) + (return s) + ))))) +)))) +(let reducedTable (PartitionByKey table1 keySelector (Bool 'false) sortKeySelector 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/SingleYamrOperation/PartitionByKeyStream.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKeyStream.cfg new file mode 100644 index 0000000000..7e61f75847 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKeyStream.cfg @@ -0,0 +1,2 @@ +in Input SomeKeys.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKeyStream.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKeyStream.yql new file mode 100644 index 0000000000..938bb3e859 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/PartitionByKeyStream.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 keyExtractor (lambda '(item) (Member item 'key))) +(let handler (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)))) + (return (Iterator (AsList s))) +)))))) +(let table2 (PartitionByKey table1 keyExtractor (Void) (Void) handler)) +(let mr_sink (DataSink 'yt 'plato)) +(let result (Sort table2 (Bool 'true) (lambda '(x) (Member x 'key)))) +(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/SingleYamrOperation/Skip.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/Skip.yql new file mode 100644 index 0000000000..f7d625e18f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/Skip.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 offset (Uint64 '1)) +(let table2 (Skip table1 offset)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table2 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/SkipTakeThenMap.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/SkipTakeThenMap.yql new file mode 100644 index 0000000000..5af618e78f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/SkipTakeThenMap.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 table1 (Skip table1 (Uint64 '1))) +(let table1 (Take table1 (Uint64 '2))) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '""))) + (let s (AddMember s 'value value)) + (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/SingleYamrOperation/SomeKeys.txt b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/SomeKeys.txt new file mode 100644 index 0000000000..6d0b5b4d40 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/SomeKeys.txt @@ -0,0 +1,7 @@ +{"key"="075";"subkey"="1";"value"="abc"}; +{"key"="075";"subkey"="2";"value"="abc2"}; +{"key"="075";"subkey"="3";"value"="abc3"}; +{"key"="800";"subkey"="4";"value"="ddd"}; +{"key"="020";"subkey"="5";"value"="q"}; +{"key"="150";"subkey"="6";"value"="qzz"}; +{"key"="150";"subkey"="7";"value"="zz"}; diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/SomeKeys.txt.attr b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/SomeKeys.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/SomeKeys.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/SingleYamrOperation/TableInsertCastList.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/TableInsertCastList.yql new file mode 100644 index 0000000000..ce2f6fa8eb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/TableInsertCastList.yql @@ -0,0 +1,53 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let values (block '( + (let select (block '( + (let core table0) + (let core (Filter core (lambda '(row) (Coalesce ("<" (Member row '"key") (String '"100")) (Bool 'false))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"value" (MatchType (Member row '"key") 'Optional (lambda '(item) (Coalesce (Map item (lambda '(val) (IfType val (DataType 'String) (lambda '(item) (FromString item '"Int64")) (lambda '(item) (Just (Convert item '"Int64")))))) (Nothing (OptionalType (DataType '"Int64"))))) (lambda '(item) (IfType item (DataType 'String) (lambda '(item) (FromString item '"Int64")) (lambda '(item) (Convert item '"Int64"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"Output"))) values '('('mode 'append)))) + (return (Commit! world sink)) + ))) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let values (block '( + (let select (block '( + (let core table0) + (let core (Filter core (lambda '(row) (Coalesce (">=" (Member row '"key") (String '"100")) (Bool 'false))))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"value" (Int64 '"1"))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let sink (DataSink '"yt" '"plato")) + (let world (Write! world sink (Key '('table (String '"Output"))) values '('('mode 'append)))) + (return (Commit! world sink)) + ))) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/Take.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/Take.yql new file mode 100644 index 0000000000..6a8c55c92d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/Take.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 limit (Uint64 '2)) +(let table2 (Take table1 limit)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table2 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/ZipInsideReduce.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/ZipInsideReduce.cfg new file mode 100644 index 0000000000..7e61f75847 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/ZipInsideReduce.cfg @@ -0,0 +1,2 @@ +in Input SomeKeys.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/ZipInsideReduce.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/ZipInsideReduce.yql new file mode 100644 index 0000000000..80371ba528 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/ZipInsideReduce.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 keySelector (lambda '(x) (Member x 'key))) +(let listHandler (lambda '(stream) (FlatMap stream (lambda '(pair) (block '( + (let key (Nth pair '0)) + (let list (Collect (Nth pair '1))) + (let list (Zip list (Skip list (Uint64 '1)))) + (let r (FlatMap list (lambda '(x) (block '( + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Concat (Member (Nth x '0) 'value) (ToString (Member (Nth x '1) 'value))))) + (return (AsList s)) + ))))) + (return r) +)))))) +(let reducedTable (PartitionByKey table1 keySelector (Void) (Void) 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/SingleYamrOperation/default.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/default.cfg new file mode 100644 index 0000000000..d481615947 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/default.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +in Input2 input.txt +out Output2 output2.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input.txt b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input.txt new file mode 100644 index 0000000000..65949ea745 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/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/SingleYamrOperation/input.txt.attr b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/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/SingleYamrOperation/input2.txt b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input2.txt new file mode 100644 index 0000000000..3803cb8d65 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input2.txt @@ -0,0 +1,3 @@ +{"key"="a";"subkey"="1";"value"="b"}; +{"key"="c";"subkey"="2";"value"="d"}; +{"key"="e";"subkey"="3";"value"="f"}; diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input2.txt.attr b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input2.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input2.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/SingleYamrOperation/input_empty.txt b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_empty.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_empty.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_empty.txt.attr b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_empty.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_empty.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/SingleYamrOperation/input_other.txt b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_other.txt new file mode 100644 index 0000000000..65949ea745 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_other.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/SingleYamrOperation/input_other.txt.attr b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_other.txt.attr new file mode 100644 index 0000000000..8cc87a0668 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_other.txt.attr @@ -0,0 +1,10 @@ +{ + "schema" = < + "strict" = %false; + "unique_keys" = %false + > + [{ + "name" = "key"; + "type" = "string" + }]; +} diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_other_strict.txt b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_other_strict.txt new file mode 100644 index 0000000000..b043b210b0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_other_strict.txt @@ -0,0 +1,4 @@ +{"key"="075";"_other"=[["subkey";"1"];["value";"abc"]]}; +{"key"="800";"_other"=[["subkey";"2"];["value";"ddd"]]}; +{"key"="020";"_other"=[["subkey";"3"];["value";"q"]]}; +{"key"="150";"_other"=[["subkey";"4"];["value";"qzz"]]}; diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_other_strict.txt.attr b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_other_strict.txt.attr new file mode 100644 index 0000000000..e7d68f4eea --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/input_other_strict.txt.attr @@ -0,0 +1,28 @@ +{ + "_yql_row_spec" = {"Type" = [ + "StructType"; + [ + [ + "_other"; + [ + "DictType"; + [ + "DataType"; + "String" + ]; + [ + "DataType"; + "String" + ] + ] + ]; + [ + "key"; + [ + "DataType"; + "Yson" + ] + ] + ] + ]}; +} diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program1.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program1.yql new file mode 100644 index 0000000000..47e3d28b9e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program1.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 tresh (Int32 'x"64000000")) +(let table1low (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let ret (FlatMap intValueOpt (lambda '(item2) (block '( + (return (ListIf (< item2 tresh) item)) + ))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program10.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program10.yql new file mode 100644 index 0000000000..8abd57a84b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program10.yql @@ -0,0 +1,14 @@ +( +#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 tresh (String '100)) +(let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let table1low2 (Filter table1low (lambda '(item2) (> (Member item2 'value) (String 'd))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low2 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program11.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program11.yql new file mode 100644 index 0000000000..746ca7e40b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program11.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 tresh (ToString (+ (Int32 '100) (Int32 '200)))) +(let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program12.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program12.yql new file mode 100644 index 0000000000..56a3ae6931 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program12.yql @@ -0,0 +1,16 @@ +( +#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 table1low (Filter table1 (lambda '(item) (block '( + (let tresh (String '100)) + (let predicate (< (Member item 'key) tresh)) + (return predicate) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program13.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program13.yql new file mode 100644 index 0000000000..1b3276e796 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program13.yql @@ -0,0 +1,16 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let data (block '( + (let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'subkey 'value) '())) + (let world (Left! x)) + (let table1 (Right! x)) + (let tresh (String '100)) + (let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) + (return table1low) +))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) data '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program14.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program14.yql new file mode 100644 index 0000000000..218e366ef9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program14.yql @@ -0,0 +1,14 @@ +( +(let sink (DataSink 'yt 'plato)) +(let source (DataSource 'yt 'plato)) +(let table (Right! (Read! world source (Key '('table (String 'Input))) '('key 'subkey 'value) '()))) +(let filter (lambda '(item) (block '( + (let res (And (> (Member item 'value) (String 'd)) (< (Member item 'key) (String '100)))) + (return res) +) +))) +(let table (Filter table filter)) +(let world (Write! world sink (Key '('table (String 'Output))) table '('('mode 'append)))) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program15.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program15.yql new file mode 100644 index 0000000000..de5a1d5a47 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program15.yql @@ -0,0 +1,14 @@ +( +#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 tresh (String '100)) +(let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let table1low2 (Filter table1low (lambda '(item) (> (Member item 'key) (String '050))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low2 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program16.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program16.yql new file mode 100644 index 0000000000..0347e8bef3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program16.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 tresh (String '100)) +(let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let table1new (Map table1low (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (Concat (String '*) (Member item 'key)))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (String '.))) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1new '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program17.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program17.yql new file mode 100644 index 0000000000..de6ff0054b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program17.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 tresh (String '100)) +(let table1low (FlatMap table1 (lambda '(item) (ListIf (< (Member item 'key) tresh) item)))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program18.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program18.yql new file mode 100644 index 0000000000..60ab38e5e0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program18.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 tresh (String '100)) +(let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let table1new (Map table1low (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (Concat (String '*) (Member item 'key)))) + (return s) +))))) +(let table1new2 (Map table1new (lambda '(item) (block '( + (let s (AddMember item 'subkey (String '.))) + (let s (AddMember s 'value (String '.))) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1new2 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program19.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program19.yql new file mode 100644 index 0000000000..0bd4afc826 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program19.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 tresh (String '100)) +(let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let table1new (Map table1low (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (Concat (String '*) (Member item 'key)))) + (return s) +))))) +(let table1new2 (FlatMap table1new (lambda '(item) (block '( + (let s (AddMember item 'value (String '.))) + (let s (AddMember s 'subkey (String '.))) + (let s (AsList s)) + (let s (Extend s s)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1new2 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program2.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program2.cfg new file mode 100644 index 0000000000..3ad8212f69 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program2.cfg @@ -0,0 +1,4 @@ +in Input input.txt +in Input2 input2.txt +out Output output1.txt +out Output2 output2.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program2.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program2.yql new file mode 100644 index 0000000000..697af6afa2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program2.yql @@ -0,0 +1,15 @@ +( +#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 mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1 '('('mode 'append)))) +(let x (Read! world mr_source (Key '('table (String 'Input2))) '('key 'subkey 'value) '())) +(let world (Left! x)) +(let table2 (Right! x)) +(let world (Write! world mr_sink (Key '('table (String 'Output2))) table2 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program20.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program20.yql new file mode 100644 index 0000000000..237d4babc1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program20.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 tresh (String '100)) +(let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let table1new (Map table1low (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (Concat (String '*) (Member item 'key)))) + (return s) +))))) +(let table1new2 (FlatMap table1new (lambda '(item) (block '( + (let s (AddMember item 'value (String '.))) + (let s (AddMember s 'subkey (String '.))) + (let s1 (AsList s)) + (let s (Append s1 s)) + (return s) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1new2 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program21.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program21.yql new file mode 100644 index 0000000000..8492d10a4d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program21.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 tresh (String '100)) +(let table1low (Filter table1 (lambda '(item) (< (Member item 'key) tresh)))) +(let table1new (Map table1low (lambda '(item) (block '( + (let s (Struct)) + (let s (AddMember s 'key (Concat (String '*) (Member item 'key)))) + (return s) +))))) +(let table1new2 (FlatMap table1new (lambda '(item) (block '( + (let s (AddMember item 'value (String '.))) + (let s (AddMember s 'subkey (String '.))) + (let s1 (AsList s)) + (let s (Append s1 s)) + (return s) +))))) +(let table1new3 (Filter table1new2 (lambda '(item) (> (Member item 'key) (String '*030))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1new3 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program22.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program22.yql new file mode 100644 index 0000000000..76674f13da --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program22.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 table1sorted (Sort table1 (Bool 'true) (lambda '(item) (Member item 'key)))) +#(let table1sorted (Sort table1 (Tuple (Bool 'true) (Bool 'false)) (lambda '(item) (Tuple (Member item 'key) (Member item 'value))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1sorted '())) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program23.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program23.yql new file mode 100644 index 0000000000..378711e378 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program23.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 tresh (Int32 '100)) +(let table1low (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let optPlus50 (Map intValueOpt (lambda '(item2) (+ (Int32 '50) item2)))) + (let ret (FlatMap optPlus50 (lambda '(item2) (block '( + (let s (ListIf (< item2 tresh) item)) + (return s) + ))))) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program24.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program24.yql new file mode 100644 index 0000000000..1c3c39d3ea --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program24.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 table1even (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (FromString (Member item 'key) 'Int32)) + (let equalsZero (lambda '(x) (== x (Int32 '0)))) + (let isEven (lambda '(x) (Coalesce (Map (% x (Int32 '2)) equalsZero) (Bool 'false)))) + (let filteredValue (Filter intValueOpt isEven)) + (let ret (ListIf (Exists filteredValue) item)) + (return ret) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1even '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program26.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program26.cfg new file mode 100644 index 0000000000..d87afdedc4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program26.cfg @@ -0,0 +1,2 @@ +in Input program26.input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program26.input.txt b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program26.input.txt new file mode 100644 index 0000000000..55183cdd00 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program26.input.txt @@ -0,0 +1,4 @@ +{"key"="0";"subkey"="1";"value"="abc"}; +{"key"="8";"subkey"="2";"value"="ddd"}; +{"key"="0";"subkey"="3";"value"="q"}; +{"key"="1";"subkey"="4";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program26.input.txt.attr b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program26.input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program26.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/SingleYamrOperation/program26.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program26.yql new file mode 100644 index 0000000000..11dcbbbe57 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program26.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 (Just s)) + (return ret) +)))))) +(let reducedTable (PartitionByKey table1 keySelector (Void) (Void) 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/SingleYamrOperation/program27.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program27.cfg new file mode 100644 index 0000000000..f23f5c9676 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program27.cfg @@ -0,0 +1,2 @@ +in Input program27.input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program27.input.txt b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program27.input.txt new file mode 100644 index 0000000000..55183cdd00 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program27.input.txt @@ -0,0 +1,4 @@ +{"key"="0";"subkey"="1";"value"="abc"}; +{"key"="8";"subkey"="2";"value"="ddd"}; +{"key"="0";"subkey"="3";"value"="q"}; +{"key"="1";"subkey"="4";"value"="qzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program27.input.txt.attr b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program27.input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program27.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/SingleYamrOperation/program27.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program27.yql new file mode 100644 index 0000000000..2663ed1bb0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program27.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 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 revLen (Length (Reverse list))) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (ToString revLen))) + (let ret (AsList s)) + (return ret) +)))))) +(let reducedTable (PartitionByKey table1 keySelector (Void) (Void) 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/SingleYamrOperation/program28.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program28.cfg new file mode 100644 index 0000000000..6f69ec10ac --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program28.cfg @@ -0,0 +1,2 @@ +in Input program28.input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program28.input.txt b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program28.input.txt new file mode 100644 index 0000000000..c59dba9c7b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program28.input.txt @@ -0,0 +1,9 @@ +{"key"="0";"subkey"="1";"value"="abc"}; +{"key"="1";"subkey"="2";"value"="qzz"}; +{"key"="2";"subkey"="3";"value"="uuu"}; +{"key"="0";"subkey"="4";"value"="aa"}; +{"key"="0";"subkey"="5";"value"="asd"}; +{"key"="0";"subkey"="6";"value"="asd"}; +{"key"="0";"subkey"="7";"value"="ss"}; +{"key"="0";"subkey"="8";"value"="ss"}; +{"key"="2";"subkey"="9";"value"="qqq"}; diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program28.input.txt.attr b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program28.input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program28.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/SingleYamrOperation/program28.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program28.yql new file mode 100644 index 0000000000..8ad311cd3c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program28.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 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 list1 (Take list (Uint64 '5))) + (let list2 (Skip list (Uint64 '1))) + (let x (Concat (Concat (ToString (Length list1)) (String '"_")) (ToString (Length list2)))) + (let s (AddMember s 'value (ToString x))) + (let ret (AsList s)) + (return ret) +)))))) +(let reducedTable (PartitionByKey table1 keySelector (Void) (Void) 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/SingleYamrOperation/program29.cfg b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program29.cfg new file mode 100644 index 0000000000..3123d957f8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program29.cfg @@ -0,0 +1,2 @@ +in Input program29.input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program29.input.txt b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program29.input.txt new file mode 100644 index 0000000000..684f20f67a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program29.input.txt @@ -0,0 +1,5 @@ +{"key"="0";"subkey"="1";"value"="15"}; +{"key"="8";"subkey"="2";"value"="23"}; +{"key"="0";"subkey"="3";"value"="3"}; +{"key"="1";"subkey"="4";"value"="10"}; +{"key"="2";"subkey"="5";"value"="zzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program29.input.txt.attr b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program29.input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program29.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/SingleYamrOperation/program29.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program29.yql new file mode 100644 index 0000000000..40a2407e1f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program29.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 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 ilist (FlatMap list (lambda '(item) (FromString (Member item 'value) 'Int32)))) + (let sum (Fold ilist (Int32 '0) (lambda '(item state) (+ item state)))) + (let s (AddMember s 'value (ToString sum))) + (let ret (AsList s)) + (return ret) +)))))) +(let reducedTable (PartitionByKey table1 keySelector (Void) (Void) 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/SingleYamrOperation/program8.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program8.yql new file mode 100644 index 0000000000..894e1a15a1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program8.yql @@ -0,0 +1,11 @@ +( +#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 mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program9.yql b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program9.yql new file mode 100644 index 0000000000..894e1a15a1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/SingleYamrOperation/program9.yql @@ -0,0 +1,11 @@ +( +#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 mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/FilterTable.yql b/yql/essentials/tests/s-expressions/suites/TableContent/FilterTable.yql new file mode 100644 index 0000000000..47e6d9a517 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/FilterTable.yql @@ -0,0 +1,15 @@ +( + #comment + (let mr_source (DataSource 'yt 'plato)) + (let table1 (Right! (Read! world mr_source (Key '('table (String 'Input))) (Void) '('('inline))))) + (let tresh (String '300)) + (let table1low (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (Member item 'key)) + (return (ListIf (< intValueOpt tresh) item)) + ))))) + (let mr_sink (DataSink 'yt 'plato)) + (let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) + (let world (Commit! world mr_sink)) + (return world) +) + diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/FilterWithComplexSkip.cfg b/yql/essentials/tests/s-expressions/suites/TableContent/FilterWithComplexSkip.cfg new file mode 100644 index 0000000000..386ab9ac7f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/FilterWithComplexSkip.cfg @@ -0,0 +1,3 @@ +in Input input.txt +out Output output.txt +udf string_udf diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/FilterWithComplexSkip.yql b/yql/essentials/tests/s-expressions/suites/TableContent/FilterWithComplexSkip.yql new file mode 100644 index 0000000000..3d7eadd8df --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/FilterWithComplexSkip.yql @@ -0,0 +1,17 @@ +( + #comment + (let mr_source (DataSource 'yt 'plato)) + (let strip (Udf 'String.Strip)) + (let skip (Unwrap (Cast (Apply strip (String '" 4")) 'Uint64))) + (let table1 (Right! (Read! world mr_source (Key '('table (String 'Input))) (Void) '('('inline) '('skip skip) '('take (Uint64 '3)))))) + (let tresh (String '300)) + (let table1low (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (Member item 'key)) + (return (ListIf (< intValueOpt tresh) item)) + ))))) + (let mr_sink (DataSink 'yt 'plato)) + (let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) + (let world (Commit! world mr_sink)) + (return world) +) + diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/FilterWithFields.yql b/yql/essentials/tests/s-expressions/suites/TableContent/FilterWithFields.yql new file mode 100644 index 0000000000..e5293e0a57 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/FilterWithFields.yql @@ -0,0 +1,15 @@ +( + #comment + (let mr_source (DataSource 'yt 'plato)) + (let table1 (Right! (Read! world mr_source (Key '('table (String 'Input))) '('key 'value) '('('inline))))) + (let tresh (String '300)) + (let table1low (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (Member item 'key)) + (return (ListIf (< intValueOpt tresh) item)) + ))))) + (let mr_sink (DataSink 'yt 'plato)) + (let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) + (let world (Commit! world mr_sink)) + (return world) +) + diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/FilterWithTake.yql b/yql/essentials/tests/s-expressions/suites/TableContent/FilterWithTake.yql new file mode 100644 index 0000000000..e0d516738d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/FilterWithTake.yql @@ -0,0 +1,15 @@ +( + #comment + (let mr_source (DataSource 'yt 'plato)) + (let table1 (Right! (Read! world mr_source (Key '('table (String 'Input))) (Void) '('('inline) '('take (Uint64 '3)))))) + (let tresh (String '300)) + (let table1low (FlatMap table1 (lambda '(item) (block '( + (let intValueOpt (Member item 'key)) + (return (ListIf (< intValueOpt tresh) item)) + ))))) + (let mr_sink (DataSink 'yt 'plato)) + (let world (Write! world mr_sink (Key '('table (String 'Output))) table1low '('('mode 'append)))) + (let world (Commit! world mr_sink)) + (return world) +) + diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/InsideCombine.yql b/yql/essentials/tests/s-expressions/suites/TableContent/InsideCombine.yql new file mode 100644 index 0000000000..529cd9be35 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/InsideCombine.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 mrtc (Right! (Read! world mr_source (Key '('table (String 'Input))) (Void) '('('inline))))) + (let filter (FlatMap mrtc (lambda '(item) (block '( + (let value (Member item 'value)) + (return (ListIf (< value (String 'qqq)) item)) + ))))) + (let filter (ToDict mrtc (lambda '(x) (Member x 'value)) (lambda '(x) (Member x 'subkey)) '('Hashed 'One 'Compact))) + + (let preMap (lambda '(item) (Just item))) + (let keyExtractor (lambda '(item) (Member item 'key))) + (let init (lambda '(key item) (Contains filter (Member item 'value)))) + (let update (lambda '(key item state) (And state (Contains filter (Member item 'value))))) + (let finish (lambda '(key state) (block '( + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (ToString state))) + (return (Just s)) + )))) + (let out (CombineByKey table1 preMap keyExtractor init update finish)) + + (let mr_sink (DataSink 'yt 'plato)) + (let world (Write! world mr_sink (Key '('table (String 'Output))) out '('('mode 'append)))) + (let world (Commit! world mr_sink)) + (return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/InsideMap.yql b/yql/essentials/tests/s-expressions/suites/TableContent/InsideMap.yql new file mode 100644 index 0000000000..1c9999ee3a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/InsideMap.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 mrtc (Right! (Read! world mr_source (Key '('table (String 'Input))) (Void) '('('inline))))) + (let mrtc (FlatMap mrtc (lambda '(item) (block '( + (let key (Member item 'key)) + (return (ListIf (> key (String '100)) item)) + ))))) + (let filter (ToDict mrtc (lambda '(x) (Member x 'key)) (lambda '(x) (Member x 'value)) '('Hashed 'One 'Compact))) + + (let tresh (String '500)) + (let out (FlatMap table1 (lambda '(item) (block '( + (let key (Member item 'key)) + (return (ListIf (And (< key tresh) (Contains filter key)) item)) + ))))) + (let mr_sink (DataSink 'yt 'plato)) + (let world (Write! world mr_sink (Key '('table (String 'Output))) out '('('mode 'append)))) + (let world (Commit! world mr_sink)) + (return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/InsideReduce.yql b/yql/essentials/tests/s-expressions/suites/TableContent/InsideReduce.yql new file mode 100644 index 0000000000..71d61c2a0c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/InsideReduce.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 mrtc (Right! (Read! world mr_source (Key '('table (String 'Input))) (Void) '('('inline))))) + (let mrtc (FlatMap mrtc (lambda '(item) (block '( + (let value (Member item 'value)) + (return (ListIf (< value (String 'qqq)) item)) + ))))) + (let filter (ToDict mrtc (lambda '(x) (Member x 'value)) (lambda '(x) (Member x 'subkey)) '('Hashed 'One 'Compact))) + + (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 r (FlatMap list (lambda '(item) (block '( + (return (ListIf (Contains filter (Member item 'value)) item)) + ))))) + (return (FlatListIf (< key (String '500)) r)) + )))))) + (let out (PartitionByKey table1 keySelector (Void) (Void) listHandler)) + (let out (Sort out (Bool 'true) (lambda '(x) (Member x 'key)))) + + (let mr_sink (DataSink 'yt 'plato)) + (let world (Write! world mr_sink (Key '('table (String 'Output))) out '('('mode 'append)))) + (let world (Commit! world mr_sink)) + (return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/MixedOther.cfg b/yql/essentials/tests/s-expressions/suites/TableContent/MixedOther.cfg new file mode 100644 index 0000000000..d14bf78557 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/MixedOther.cfg @@ -0,0 +1,4 @@ +in Input input.txt +in Input1 input_other.txt +in Input2 input_other_strict.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/MixedOther.yql b/yql/essentials/tests/s-expressions/suites/TableContent/MixedOther.yql new file mode 100644 index 0000000000..adde05c66d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/MixedOther.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 r (Right! (Read! world mr_source '((Key '('table (String 'Input1))) (Key '('table (String 'Input2)))) '('_other) '('('inline))))) + + (let out (FlatMap table1 (lambda '(item) (block '( + (let key (Member item 'key)) + (return (Map r (lambda '(x) (block '( + (let value (Lookup (Member x '_other) (String 'value))) + (return (AsStruct '('key key) '('value value))) + ))))) + ))))) + (let mr_sink (DataSink 'yt 'plato)) + (let world (Write! world mr_sink (Key '('table (String 'Output))) out '('('mode 'append)))) + (let world (Commit! world mr_sink)) + (return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/NonStrict.cfg b/yql/essentials/tests/s-expressions/suites/TableContent/NonStrict.cfg new file mode 100644 index 0000000000..2372a67784 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/NonStrict.cfg @@ -0,0 +1,3 @@ +in Input input.txt +in Input1 input_other.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/NonStrict.yql b/yql/essentials/tests/s-expressions/suites/TableContent/NonStrict.yql new file mode 100644 index 0000000000..5ef7216f81 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/NonStrict.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 r (Right! (Read! world mr_source (Key '('table (String 'Input1))) '('_other) '('('inline))))) + + (let out (FlatMap table1 (lambda '(item) (block '( + (let key (Member item 'key)) + (return (Map r (lambda '(x) (block '( + (let value (Lookup (Member x '_other) (String 'value))) + (return (AsStruct '('key key) '('value value))) + ))))) + ))))) + (let mr_sink (DataSink 'yt 'plato)) + (let world (Write! world mr_sink (Key '('table (String 'Output))) out '('('mode 'append)))) + (let world (Commit! world mr_sink)) + (return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/StrictOther.cfg b/yql/essentials/tests/s-expressions/suites/TableContent/StrictOther.cfg new file mode 100644 index 0000000000..938bc7ecfc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/StrictOther.cfg @@ -0,0 +1,3 @@ +in Input input.txt +in Input1 input_other_strict.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/StrictOther.yql b/yql/essentials/tests/s-expressions/suites/TableContent/StrictOther.yql new file mode 100644 index 0000000000..5ef7216f81 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/StrictOther.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 r (Right! (Read! world mr_source (Key '('table (String 'Input1))) '('_other) '('('inline))))) + + (let out (FlatMap table1 (lambda '(item) (block '( + (let key (Member item 'key)) + (return (Map r (lambda '(x) (block '( + (let value (Lookup (Member x '_other) (String 'value))) + (return (AsStruct '('key key) '('value value))) + ))))) + ))))) + (let mr_sink (DataSink 'yt 'plato)) + (let world (Write! world mr_sink (Key '('table (String 'Output))) out '('('mode 'append)))) + (let world (Commit! world mr_sink)) + (return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/default.cfg b/yql/essentials/tests/s-expressions/suites/TableContent/default.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/default.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/input.txt b/yql/essentials/tests/s-expressions/suites/TableContent/input.txt new file mode 100644 index 0000000000..d1fa0973d9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/input.txt @@ -0,0 +1,8 @@ +{"key"="075";"subkey"=".";"value"="abc"}; +{"key"="911";"subkey"=".";"value"="kkk"}; +{"key"="023";"subkey"=".";"value"="aaa"}; +{"key"="527";"subkey"=".";"value"="bbb"}; +{"key"="037";"subkey"=".";"value"="ddd"}; +{"key"="761";"subkey"=".";"value"="ccc"}; +{"key"="200";"subkey"=".";"value"="qqq"}; +{"key"="150";"subkey"=".";"value"="zzz"}; diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/input.txt.attr b/yql/essentials/tests/s-expressions/suites/TableContent/input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/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/TableContent/input_other.txt b/yql/essentials/tests/s-expressions/suites/TableContent/input_other.txt new file mode 100644 index 0000000000..65949ea745 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/input_other.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/TableContent/input_other.txt.attr b/yql/essentials/tests/s-expressions/suites/TableContent/input_other.txt.attr new file mode 100644 index 0000000000..371a0d6ec2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/input_other.txt.attr @@ -0,0 +1,10 @@ +{ + "schema" = < + "strict" = %false; + "unique_keys" = %false + > + [{ + "name" = "key"; + "type" = "string" + }]; +} diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/input_other_strict.txt b/yql/essentials/tests/s-expressions/suites/TableContent/input_other_strict.txt new file mode 100644 index 0000000000..b043b210b0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/input_other_strict.txt @@ -0,0 +1,4 @@ +{"key"="075";"_other"=[["subkey";"1"];["value";"abc"]]}; +{"key"="800";"_other"=[["subkey";"2"];["value";"ddd"]]}; +{"key"="020";"_other"=[["subkey";"3"];["value";"q"]]}; +{"key"="150";"_other"=[["subkey";"4"];["value";"qzz"]]}; diff --git a/yql/essentials/tests/s-expressions/suites/TableContent/input_other_strict.txt.attr b/yql/essentials/tests/s-expressions/suites/TableContent/input_other_strict.txt.attr new file mode 100644 index 0000000000..e7d68f4eea --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TableContent/input_other_strict.txt.attr @@ -0,0 +1,28 @@ +{ + "_yql_row_spec" = {"Type" = [ + "StructType"; + [ + [ + "_other"; + [ + "DictType"; + [ + "DataType"; + "String" + ]; + [ + "DataType"; + "String" + ] + ] + ]; + [ + "key"; + [ + "DataType"; + "Yson" + ] + ] + ] + ]}; +} diff --git a/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/ahead.yql b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/ahead.yql new file mode 100644 index 0000000000..b555f9f06c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/ahead.yql @@ -0,0 +1,14 @@ +( +(let $1 (DataSink 'result)) +(let $2 (Right! (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) (Void) '()))) +(let inputFlow (ToFlow (PersistableRepr (OrderedSqlProject $2 '((SqlProjectStarItem (TypeOf $2) '"" (lambda '($4) $4) '())))))) +(let timeOrderRecover (TimeOrderRecover + inputFlow + (lambda '($3) (Member $3 '"ts")) + (Interval '-10) + (Interval '5) + (Uint32 '12) +)) +(let $3 (Write! world $1 (Key)(ForwardList timeOrderRecover)'('('type) '('autoref)))) +(return (CommitAll! (Commit! $3 $1))) +) diff --git a/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/default.cfg b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/default.cfg new file mode 100644 index 0000000000..58878f8945 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/default.cfg @@ -0,0 +1 @@ +in Input input.txt diff --git a/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/delayed.yql b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/delayed.yql new file mode 100644 index 0000000000..e72c6ab87e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/delayed.yql @@ -0,0 +1,14 @@ +( +(let $1 (DataSink 'result)) +(let $2 (Right! (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) (Void) '()))) +(let inputFlow (ToFlow (PersistableRepr (OrderedSqlProject $2 '((SqlProjectStarItem (TypeOf $2) '"" (lambda '($4) $4) '())))))) +(let timeOrderRecover (TimeOrderRecover + inputFlow + (lambda '($3) (Member $3 '"ts")) + (Interval '-8) + (Interval '10) + (Uint32 '12) +)) +(let $3 (Write! world $1 (Key)(ForwardList timeOrderRecover)'('('type) '('autoref)))) +(return (CommitAll! (Commit! $3 $1))) +) diff --git a/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/happy_path.yql b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/happy_path.yql new file mode 100644 index 0000000000..6e247b28bd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/happy_path.yql @@ -0,0 +1,14 @@ +( +(let $1 (DataSink 'result)) +(let $2 (Right! (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) (Void) '()))) +(let inputFlow (ToFlow (PersistableRepr (OrderedSqlProject $2 '((SqlProjectStarItem (TypeOf $2) '"" (lambda '($4) $4) '())))))) +(let timeOrderRecover (TimeOrderRecover + inputFlow + (lambda '($3) (Member $3 '"ts")) + (Interval '-10) + (Interval '10) + (Uint32 '20) +)) +(let $3 (Write! world $1 (Key)(ForwardList timeOrderRecover)'('('type) '('autoref)))) +(return (CommitAll! (Commit! $3 $1))) +) diff --git a/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/happy_path_tighter.yql b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/happy_path_tighter.yql new file mode 100644 index 0000000000..3844a8e284 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/happy_path_tighter.yql @@ -0,0 +1,14 @@ +( +(let $1 (DataSink 'result)) +(let $2 (Right! (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) (Void) '()))) +(let inputFlow (ToFlow (PersistableRepr (OrderedSqlProject $2 '((SqlProjectStarItem (TypeOf $2) '"" (lambda '($4) $4) '())))))) +(let timeOrderRecover (TimeOrderRecover + inputFlow + (lambda '($3) (Member $3 '"ts")) + (Interval '-9) + (Interval '10) + (Uint32 '12) +)) +(let $3 (Write! world $1 (Key)(ForwardList timeOrderRecover)'('('type) '('autoref)))) +(return (CommitAll! (Commit! $3 $1))) +) diff --git a/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/input.txt b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/input.txt new file mode 100644 index 0000000000..995734fc7d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/input.txt @@ -0,0 +1,20 @@ +{"ts"=1000u; "col1"="a"}; +{"ts"=1009u; "col1"="aaa"}; +{"ts"=1001u; "col1"="a"}; +{"ts"=1003u; "col1"="aaa"}; +{"ts"=1002u; "col1"="aa"}; +{"ts"=1005u; "col1"="aa"}; +{"ts"=1004u; "col1"="a"}; +{"ts"=1006u; "col1"="aaa"}; +{"ts"=1015u; "col1"="aa"}; +{"ts"=1007u; "col1"="a"}; +{"ts"=1008u; "col1"="aa"}; +{"ts"=1010u; "col1"="aa"}; +{"ts"=1011u; "col1"="aaa"}; +{"ts"=1012u; "col1"="aa"}; +{"ts"=1013u; "col1"="aaa"}; +{"ts"=1014u; "col1"="a"}; +{"ts"=1016u; "col1"="aaa"}; +{"ts"=1017u; "col1"="aaa"}; +{"ts"=1018u; "col1"="a"}; +{"ts"=1019u; "col1"="aaa"}; diff --git a/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/input.txt.attr b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/input.txt.attr new file mode 100644 index 0000000000..63d77d6812 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/input.txt.attr @@ -0,0 +1,6 @@ +{"_yql_row_spec"={ + "Type"=["StructType";[ + ["ts";["DataType";"Timestamp"]]; + ["col1";["DataType";"String"]]; + ]]; +}} diff --git a/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/input_ordering.txt b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/input_ordering.txt new file mode 100644 index 0000000000..1363c953b6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/input_ordering.txt @@ -0,0 +1,15 @@ +{"ts"=1000u; "col1"="a1"}; +{"ts"=1000u; "col1"="a2"}; +{"ts"=1000u; "col1"="a3"}; +{"ts"=1000u; "col1"="a4"}; +{"ts"=1000u; "col1"="a5"}; +{"ts"=1001u; "col1"="b1"}; +{"ts"=1001u; "col1"="b2"}; +{"ts"=1001u; "col1"="b3"}; +{"ts"=1001u; "col1"="b4"}; +{"ts"=1001u; "col1"="b5"}; +{"ts"=1002u; "col1"="c1"}; +{"ts"=1002u; "col1"="c2"}; +{"ts"=1002u; "col1"="c3"}; +{"ts"=1002u; "col1"="c4"}; +{"ts"=1002u; "col1"="c5"};
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/input_ordering.txt.attr b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/input_ordering.txt.attr new file mode 100644 index 0000000000..63d77d6812 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/input_ordering.txt.attr @@ -0,0 +1,6 @@ +{"_yql_row_spec"={ + "Type"=["StructType";[ + ["ts";["DataType";"Timestamp"]]; + ["col1";["DataType";"String"]]; + ]]; +}} diff --git a/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/ordering.cfg b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/ordering.cfg new file mode 100644 index 0000000000..144fceddb1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/ordering.cfg @@ -0,0 +1 @@ +in Input input_ordering.txt diff --git a/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/ordering.yql b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/ordering.yql new file mode 100644 index 0000000000..840af03240 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/ordering.yql @@ -0,0 +1,14 @@ +( +(let $1 (DataSink 'result)) +(let $2 (Right! (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) (Void) '()))) +(let inputFlow (ToFlow (PersistableRepr (OrderedSqlProject $2 '((SqlProjectStarItem (TypeOf $2) '"" (lambda '($4) $4) '())))))) +(let timeOrderRecover (TimeOrderRecover + inputFlow + (lambda '($3) (Member $3 '"ts")) + (Interval '-10) + (Interval '10) + (Uint32 '100) +)) +(let $3 (Write! world $1 (Key)(ForwardList timeOrderRecover)'('('type) '('autoref)))) +(return (CommitAll! (Commit! $3 $1))) +) diff --git a/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/row_limit.yql b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/row_limit.yql new file mode 100644 index 0000000000..1eec5d6236 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/TimeOrderRecover/row_limit.yql @@ -0,0 +1,14 @@ +( +(let $1 (DataSink 'result)) +(let $2 (Right! (Read! world (DataSource '"yt" '"plato") (MrTableConcat (Key '('table (String '"Input")))) (Void) '()))) +(let inputFlow (ToFlow (PersistableRepr (OrderedSqlProject $2 '((SqlProjectStarItem (TypeOf $2) '"" (lambda '($4) $4) '())))))) +(let timeOrderRecover (TimeOrderRecover + inputFlow + (lambda '($3) (Member $3 '"ts")) + (Interval '-10) + (Interval '10) + (Uint32 '3) +)) +(let $3 (Write! world $1 (Key)(ForwardList timeOrderRecover)'('('type) '('autoref)))) +(return (CommitAll! (Commit! $3 $1))) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/AllFieldsAfterRemap.cfg b/yql/essentials/tests/s-expressions/suites/Udf/AllFieldsAfterRemap.cfg new file mode 100644 index 0000000000..9bed8d5096 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/AllFieldsAfterRemap.cfg @@ -0,0 +1,3 @@ +in Input input4.txt +res result.txt +udf dummylog diff --git a/yql/essentials/tests/s-expressions/suites/Udf/AllFieldsAfterRemap.yql b/yql/essentials/tests/s-expressions/suites/Udf/AllFieldsAfterRemap.yql new file mode 100644 index 0000000000..77573dbc12 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/AllFieldsAfterRemap.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/AutoMap.yql b/yql/essentials/tests/s-expressions/suites/Udf/AutoMap.yql new file mode 100644 index 0000000000..cd809a5881 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/AutoMap.yql @@ -0,0 +1,56 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"column0" ("Apply" ("Udf" '"SimpleUdf.Increment") (Cast (Member row '"key") 'Uint32) (Int64 '"1")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"column0" ("Apply" ("Udf" '"SimpleUdf.IncrementOpt") (Cast (Member row '"key") 'Uint32) (Int64 '"2")))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/AutoMapMany.cfg b/yql/essentials/tests/s-expressions/suites/Udf/AutoMapMany.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/AutoMapMany.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/AutoMapMany.sql b/yql/essentials/tests/s-expressions/suites/Udf/AutoMapMany.sql new file mode 100644 index 0000000000..74baf57176 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/AutoMapMany.sql @@ -0,0 +1,18 @@ +USE plato; + +$script = @@ +def f(x,y,z): + return x + y + z +@@; + +$udf1=Python::f("(Int32{Flags:AutoMap},Int32{Flags:AutoMap},Int32{Flags:AutoMap})->Int32",$script); +select $udf1(1,2,3); +select $udf1(YQL::Just(1),2,3); +select $udf1(YQL::Just(1),YQL::Just(2),3); +select $udf1(YQL::Just(1),YQL::Just(2),YQL::Just(3)); + +$udf2=Python::f("(Int32{Flags:AutoMap},Int32{Flags:AutoMap},Int32{Flags:AutoMap})->Int32?",$script); +select $udf2(4,5,6); +select $udf2(YQL::Just(4),5,6); +select $udf2(YQL::Just(4),YQL::Just(5),6); +select $udf2(YQL::Just(4),YQL::Just(5),YQL::Just(6)); diff --git a/yql/essentials/tests/s-expressions/suites/Udf/AutoMapMany.yql b/yql/essentials/tests/s-expressions/suites/Udf/AutoMapMany.yql new file mode 100644 index 0000000000..e179419a5c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/AutoMapMany.yql @@ -0,0 +1,206 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let scriptudf0 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf1 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf2 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf3 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf4 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf5 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf6 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf7 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(import core_module '"/lib/yql/core.yql") +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Apply" (ScriptUdf 'Python '"f" (CallableType '() '((DataType 'Int32)) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1)) scriptudf0) (Int32 '"1") (Int32 '"2") (Int32 '"3"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Apply" (ScriptUdf 'Python '"f" (CallableType '() '((DataType 'Int32)) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1)) scriptudf1) ("Just" (Int32 '"1")) (Int32 '"2") (Int32 '"3"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Apply" (ScriptUdf 'Python '"f" (CallableType '() '((DataType 'Int32)) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1)) scriptudf2) ("Just" (Int32 '"1")) ("Just" (Int32 '"2")) (Int32 '"3"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Apply" (ScriptUdf 'Python '"f" (CallableType '() '((DataType 'Int32)) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1)) scriptudf3) ("Just" (Int32 '"1")) ("Just" (Int32 '"2")) ("Just" (Int32 '"3")))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Apply" (ScriptUdf 'Python '"f" (CallableType '() '((OptionalType (DataType 'Int32))) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1)) scriptudf4) (Int32 '"4") (Int32 '"5") (Int32 '"6"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Apply" (ScriptUdf 'Python '"f" (CallableType '() '((OptionalType (DataType 'Int32))) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1)) scriptudf5) ("Just" (Int32 '"4")) (Int32 '"5") (Int32 '"6"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Apply" (ScriptUdf 'Python '"f" (CallableType '() '((OptionalType (DataType 'Int32))) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1)) scriptudf6) ("Just" (Int32 '"4")) ("Just" (Int32 '"5")) (Int32 '"6"))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("Apply" (ScriptUdf 'Python '"f" (CallableType '() '((OptionalType (DataType 'Int32))) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1) '((DataType 'Int32) '"" '1)) scriptudf7) ("Just" (Int32 '"4")) ("Just" (Int32 '"5")) ("Just" (Int32 '"6")))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/AutoMapManyNamed.cfg b/yql/essentials/tests/s-expressions/suites/Udf/AutoMapManyNamed.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/AutoMapManyNamed.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/AutoMapManyNamed.sql b/yql/essentials/tests/s-expressions/suites/Udf/AutoMapManyNamed.sql new file mode 100644 index 0000000000..fff1174f57 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/AutoMapManyNamed.sql @@ -0,0 +1,22 @@ +USE plato; + +$script = @@ +def f(x,y,z): + return x + y + z +@@; + +$udf1=Python::f("(x:Int32{Flags:AutoMap},y:Int32{Flags:AutoMap},z:Int32{Flags:AutoMap})->Int32",$script); +select $udf1(1 as x,2 as y,3 as z); +select $udf1(YQL::Just(1) as x,2 as y,3 as z); +select $udf1(YQL::Just(1) as x,YQL::Just(2) as y,3 as z); +select $udf1(YQL::Just(1) as x,YQL::Just(2) as y,YQL::Just(3) as z); +select $udf1(YQL::Just(1),YQL::Just(2) as y,YQL::Just(3) as z); +select $udf1(YQL::Just(1),YQL::Just(2),YQL::Just(3) as z); + +$udf2=Python::f("(x:Int32{Flags:AutoMap},y:Int32{Flags:AutoMap},z:Int32{Flags:AutoMap})->Int32?",$script); +select $udf2(4 as x,5 as y,6 as z); +select $udf2(YQL::Just(4) as x,5 as y,6 as z); +select $udf2(YQL::Just(4) as x,YQL::Just(5) as y,6 as z); +select $udf2(YQL::Just(4) as x,YQL::Just(5) as y,YQL::Just(6) as z); +select $udf2(YQL::Just(4),YQL::Just(5) as y,YQL::Just(6) as z); +select $udf2(YQL::Just(4),YQL::Just(5),YQL::Just(6) as z); diff --git a/yql/essentials/tests/s-expressions/suites/Udf/AutoMapManyNamed.yql b/yql/essentials/tests/s-expressions/suites/Udf/AutoMapManyNamed.yql new file mode 100644 index 0000000000..2225ad9b7e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/AutoMapManyNamed.yql @@ -0,0 +1,302 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let scriptudf0 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf1 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf10 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf11 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf2 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf3 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf4 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf5 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf6 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf7 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf8 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(let scriptudf9 (String '@@ +def f(x,y,z): + return x + y + z +@@)) +(import aggregate_module '"/lib/yql/aggregate.yql") +(import window_module '"/lib/yql/window.yql") +(import core_module '"/lib/yql/core.yql") +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("NamedApply" (ScriptUdf 'Python '"f" (CallableType '() '((DataType 'Int32)) '((DataType 'Int32) 'x '1) '((DataType 'Int32) 'y '1) '((DataType 'Int32) 'z '1)) scriptudf0) '() (AsStruct '('x (Int32 '"1")) '('y (Int32 '"2")) '('z (Int32 '"3"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("NamedApply" (ScriptUdf 'Python '"f" (CallableType '() '((DataType 'Int32)) '((DataType 'Int32) 'x '1) '((DataType 'Int32) 'y '1) '((DataType 'Int32) 'z '1)) scriptudf1) '() (AsStruct '('x ("Just" (Int32 '"1"))) '('y (Int32 '"2")) '('z (Int32 '"3"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("NamedApply" (ScriptUdf 'Python '"f" (CallableType '() '((DataType 'Int32)) '((DataType 'Int32) 'x '1) '((DataType 'Int32) 'y '1) '((DataType 'Int32) 'z '1)) scriptudf2) '() (AsStruct '('x ("Just" (Int32 '"1"))) '('y ("Just" (Int32 '"2"))) '('z (Int32 '"3"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("NamedApply" (ScriptUdf 'Python '"f" (CallableType '() '((DataType 'Int32)) '((DataType 'Int32) 'x '1) '((DataType 'Int32) 'y '1) '((DataType 'Int32) 'z '1)) scriptudf3) '() (AsStruct '('x ("Just" (Int32 '"1"))) '('y ("Just" (Int32 '"2"))) '('z ("Just" (Int32 '"3")))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("NamedApply" (ScriptUdf 'Python '"f" (CallableType '() '((DataType 'Int32)) '((DataType 'Int32) 'x '1) '((DataType 'Int32) 'y '1) '((DataType 'Int32) 'z '1)) scriptudf4) '(("Just" (Int32 '"1"))) (AsStruct '('y ("Just" (Int32 '"2"))) '('z ("Just" (Int32 '"3")))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("NamedApply" (ScriptUdf 'Python '"f" (CallableType '() '((DataType 'Int32)) '((DataType 'Int32) 'x '1) '((DataType 'Int32) 'y '1) '((DataType 'Int32) 'z '1)) scriptudf5) '(("Just" (Int32 '"1")) ("Just" (Int32 '"2"))) (AsStruct '('z ("Just" (Int32 '"3")))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("NamedApply" (ScriptUdf 'Python '"f" (CallableType '() '((OptionalType (DataType 'Int32))) '((DataType 'Int32) 'x '1) '((DataType 'Int32) 'y '1) '((DataType 'Int32) 'z '1)) scriptudf6) '() (AsStruct '('x (Int32 '"4")) '('y (Int32 '"5")) '('z (Int32 '"6"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("NamedApply" (ScriptUdf 'Python '"f" (CallableType '() '((OptionalType (DataType 'Int32))) '((DataType 'Int32) 'x '1) '((DataType 'Int32) 'y '1) '((DataType 'Int32) 'z '1)) scriptudf7) '() (AsStruct '('x ("Just" (Int32 '"4"))) '('y (Int32 '"5")) '('z (Int32 '"6"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("NamedApply" (ScriptUdf 'Python '"f" (CallableType '() '((OptionalType (DataType 'Int32))) '((DataType 'Int32) 'x '1) '((DataType 'Int32) 'y '1) '((DataType 'Int32) 'z '1)) scriptudf8) '() (AsStruct '('x ("Just" (Int32 '"4"))) '('y ("Just" (Int32 '"5"))) '('z (Int32 '"6"))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("NamedApply" (ScriptUdf 'Python '"f" (CallableType '() '((OptionalType (DataType 'Int32))) '((DataType 'Int32) 'x '1) '((DataType 'Int32) 'y '1) '((DataType 'Int32) 'z '1)) scriptudf9) '() (AsStruct '('x ("Just" (Int32 '"4"))) '('y ("Just" (Int32 '"5"))) '('z ("Just" (Int32 '"6")))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("NamedApply" (ScriptUdf 'Python '"f" (CallableType '() '((OptionalType (DataType 'Int32))) '((DataType 'Int32) 'x '1) '((DataType 'Int32) 'y '1) '((DataType 'Int32) 'z '1)) scriptudf10) '(("Just" (Int32 '"4"))) (AsStruct '('y ("Just" (Int32 '"5"))) '('z ("Just" (Int32 '"6")))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let output (block '( + (let select (block '( + (let core (AsList (Uint32 '0))) + (let core (FlatMap core (lambda '(row) (block '( + (let res (AsStruct '('"column0" ("NamedApply" (ScriptUdf 'Python '"f" (CallableType '() '((OptionalType (DataType 'Int32))) '((DataType 'Int32) 'x '1) '((DataType 'Int32) 'y '1) '((DataType 'Int32) 'z '1)) scriptudf11) '(("Just" (Int32 '"4")) ("Just" (Int32 '"5"))) (AsStruct '('z ("Just" (Int32 '"6")))))))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/CachedUdfType.yql b/yql/essentials/tests/s-expressions/suites/Udf/CachedUdfType.yql new file mode 100644 index 0000000000..178b280ad6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/CachedUdfType.yql @@ -0,0 +1,14 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let cachedType (CallableType '() '((DataType 'String)) '((OptionalType (DataType 'String))))) +(let udf (Udf 'SimpleUdf.Echo (Void) (Void) '"" cachedType)) +(let x (String 'aaa)) +(let data (Apply udf x)) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/CallOtherCallable.cfg b/yql/essentials/tests/s-expressions/suites/Udf/CallOtherCallable.cfg new file mode 100644 index 0000000000..49968d37d7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/CallOtherCallable.cfg @@ -0,0 +1,2 @@ +udf callables_udf +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Udf/CallOtherCallable.yql b/yql/essentials/tests/s-expressions/suites/Udf/CallOtherCallable.yql new file mode 100644 index 0000000000..5d5a0989e0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/CallOtherCallable.yql @@ -0,0 +1,14 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let fromString (Udf 'Callables.FromString)) +(let mul (Udf 'Callables.Mul)) +(let list (AsList (String '1) (String '2) (String '3) (String '4) (String '5))) +(let data (Apply mul list fromString)) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/CallableAsLambda.cfg b/yql/essentials/tests/s-expressions/suites/Udf/CallableAsLambda.cfg new file mode 100644 index 0000000000..57571ef968 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/CallableAsLambda.cfg @@ -0,0 +1,3 @@ +in Input input.txt +out Output output.txt +udf simple_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/CallableAsLambda.yql b/yql/essentials/tests/s-expressions/suites/Udf/CallableAsLambda.yql new file mode 100644 index 0000000000..aebf755663 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/CallableAsLambda.yql @@ -0,0 +1,12 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let udf (Udf 'SimpleUdf.Echo)) +(let data (Map (AsList (String 'a) (String 'b)) udf)) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/CallableType.yql b/yql/essentials/tests/s-expressions/suites/Udf/CallableType.yql new file mode 100644 index 0000000000..817a744385 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/CallableType.yql @@ -0,0 +1,18 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let t1 (DataType 'Uint32)) +(let o1 (OptionalType t1)) +(let str (DataType 'String)) +(let s1 (StructType '('key str) '('subkey str) '('value str))) +(let c1 (CallableType '() '(t1) '(o1) '(s1))) +(let world (Write! world res_sink (Key) (FormatType c1) '())) +(let world (Write! world res_sink (Key) (FormatType (CallableResultType c1)) '())) +(let world (Write! world res_sink (Key) (FormatType (CallableArgumentType c1 '0)) '())) +(let world (Write! world res_sink (Key) (FormatType (CallableArgumentType c1 '1)) '())) +(let world (Commit! world res_sink)) +(return world) +)
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/Udf/CustomPython.cfg b/yql/essentials/tests/s-expressions/suites/Udf/CustomPython.cfg new file mode 100644 index 0000000000..f493bfe9eb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/CustomPython.cfg @@ -0,0 +1,5 @@ +in Input input.txt +out Output output.txt +res result.txt +file custom_python.so yql/udfs/examples/custom_python/libcustom_python_udf.so +os linux diff --git a/yql/essentials/tests/s-expressions/suites/Udf/CustomPython.yql b/yql/essentials/tests/s-expressions/suites/Udf/CustomPython.yql new file mode 100644 index 0000000000..a683757f68 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/CustomPython.yql @@ -0,0 +1,24 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# prepare python udf +(let world (Configure! world (DataSource 'config) 'ImportUdfs 'custom_python.so)) + +(let json (DataType 'Json)) +(let udfType (CallableType '() '(json) '(json))) +(let udfScript (String '"from custom_python.foo import bar")) +(let udf (ScriptUdf 'CustomPython 'bar udfType udfScript)) + +# call udf +(let x (Json '@@{"abc":1}@@)) +(let result (Apply udf x)) + +# output result with type +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result '( '('type) ))) + +# finish +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/ImportUdfs.cfg b/yql/essentials/tests/s-expressions/suites/Udf/ImportUdfs.cfg new file mode 100644 index 0000000000..240cfb2bf5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/ImportUdfs.cfg @@ -0,0 +1,3 @@ +file myfile yql/essentials/udfs/test/test_import/libtest_import_udf.so +res result.txt +os linux diff --git a/yql/essentials/tests/s-expressions/suites/Udf/ImportUdfs.yql b/yql/essentials/tests/s-expressions/suites/Udf/ImportUdfs.yql new file mode 100644 index 0000000000..e9da004a74 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/ImportUdfs.yql @@ -0,0 +1,23 @@ +# not supported on windows +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# (1) import udfs from 'myfile' +(let config (DataSource 'config)) +(let world (Configure! world config 'ImportUdfs 'myfile)) +# (2) execute 'TestImportUdf.Concat' +(let name (String 'Jamel)) +(let hello (Udf 'TestImportUdf.Concat)) +(let foo_data (Apply hello (String '"Hello, ") name)) + +# (3) execute 'TestImportUdf.Repeat' +(let bar_data (Apply (Udf 'TestImportUdf.Repeat) (String 'x) (Uint64 '3))) + +# (4) output results +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) foo_data '('('type)))) +(let world (Write! world res_sink (Key) bar_data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/LambdaAsCallable.cfg b/yql/essentials/tests/s-expressions/suites/Udf/LambdaAsCallable.cfg new file mode 100644 index 0000000000..3d92a5a733 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/LambdaAsCallable.cfg @@ -0,0 +1,2 @@ +udf type_inspection_udf +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Udf/LambdaAsCallable.yql b/yql/essentials/tests/s-expressions/suites/Udf/LambdaAsCallable.yql new file mode 100644 index 0000000000..082da79b04 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/LambdaAsCallable.yql @@ -0,0 +1,25 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list (AsList (String 'A) (String 'B) (String 'C) (String 'D) (String 'E))) +(let state (String '"")) +(let fold (Udf 'TypeInspection.Fold (Void) + (TupleType + (TupleType + (TypeOf list) + (TypeOf state) + (CallableType '() '((DataType 'String)) '((DataType 'String)) '((DataType 'String))) + ) + (StructType) + (TupleType) + ) +)) +(let func (lambda '(item state) (Concat state item))) +(let data (Apply fold list state func)) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/NamedApply.yql b/yql/essentials/tests/s-expressions/suites/Udf/NamedApply.yql new file mode 100644 index 0000000000..adfa44066a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/NamedApply.yql @@ -0,0 +1,66 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let f1 (lambda '(x y) (block '( + (return (+ x (Coalesce y (Uint32 '100)))) +)))) + +(let f1dep (lambda '(x dep) (block '( + (return (+ x x)) +)))) + +(let tuple (lambda '() '((Uint32 '1) (Uint32 '2)))) +(let tuple_ctype (CallableType '() '((TupleType (DataType 'Uint32) (DataType 'Uint32))))) +(let tuple_call (Callable tuple_ctype tuple)) + +(let ctype (CallableType '() '((DataType 'Uint32)) '((DataType 'Uint32) 'Arg1) '((DataType 'Uint32) 'Arg2))) +(let call (Callable ctype f1)) + +(let optTuple1 (lambda '() '((Uint32 '1) (Just (Uint32 '2))))) +(let optTuple2 (lambda '() '((Uint32 '1) (Nothing (OptionalType (DataType 'Uint32)))))) +(let optCtype (CallableType '('1) + '((DataType 'Uint32)) + '((DataType 'Uint32) 'Arg1) + '((OptionalType (DataType 'Uint32)) 'Arg2))) +(let optCall (Callable optCtype f1)) + +(let s1 (AsStruct '('Arg2 (Uint32 '2)) '('Arg1 (Uint32 '1)))) +(let strType (CallableType '() '((TypeOf s1)))) +(let strCall (Callable strType (lambda '() s1))) + +# lambdas +(let world (Write! world res_sink (Key) (NamedApply f1 '((Uint32 '1) (Uint32 '2)) (AsStruct)) '())) +(let world (Write! world res_sink (Key) (NamedApply f1dep '((Uint32 '1)) (AsStruct) (DependsOn (Uint32 '2))) '())) + +# callables +(let world (Write! world res_sink (Key) (NamedApply call '((Uint32 '1) (Uint32 '2)) (AsStruct)) '())) +(let world (Write! world res_sink (Key) (NamedApply call (Apply tuple_call) (AsStruct)) '())) + +# opt. positional +(let world (Write! world res_sink (Key) (NamedApply optCall '((Uint32 '1) (Uint32 '2)) (AsStruct)) '())) +(let world (Write! world res_sink (Key) (NamedApply optCall (Apply optTuple1) (AsStruct)) '())) +(let world (Write! world res_sink (Key) (NamedApply optCall (Apply optTuple2) (AsStruct)) '())) +(let world (Write! world res_sink (Key) (NamedApply optCall '((Uint32 '1)) (AsStruct)) '())) + +# named +(let world (Write! world res_sink (Key) (NamedApply call '((Uint32 '1)) (AsStruct +'('Arg2 (Uint32 '2)) +)) '())) + +(let world (Write! world res_sink (Key) (NamedApply call '() (AsStruct +'('Arg2 (Uint32 '2)) '('Arg1 (Uint32 '1)) +)) '())) + +(let world (Write! world res_sink (Key) (NamedApply call '() (Apply strCall)) '())) + +#opt. named +(let world (Write! world res_sink (Key) (NamedApply optCall '() (AsStruct +'('Arg1 (Uint32 '1)) +)) '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/NamedArgUdf.yql b/yql/essentials/tests/s-expressions/suites/Udf/NamedArgUdf.yql new file mode 100644 index 0000000000..b32401ac2c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/NamedArgUdf.yql @@ -0,0 +1,44 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let udf (Udf 'SimpleUdf.NamedArgs )) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) (FormatType (TypeOf udf)) '('('type)))) +(let world (Write! world res_sink (Key) (NamedApply udf + '((Uint32 '1)) + (AsStruct)) +'())) +(let world (Write! world res_sink (Key) (NamedApply udf + '((Uint32 '1) (Uint32 '2)) + (AsStruct)) +'())) +(let world (Write! world res_sink (Key) (NamedApply udf + '((Uint32 '1)) + (AsStruct '('C (Uint32 '3)))) +'())) +(let world (Write! world res_sink (Key) (NamedApply udf + '((Uint32 '1)) + (AsStruct '('C (Uint32 '3)) '('D (Uint32 '4)))) +'())) +(let world (Write! world res_sink (Key) (NamedApply udf + '((Uint32 '1)) + (AsStruct '('D (Uint32 '4)))) +'())) +(let world (Write! world res_sink (Key) (NamedApply udf + '((Uint32 '1) (Uint32 '2)) + (AsStruct '('D (Uint32 '4)))) +'())) +(let world (Write! world res_sink (Key) (NamedApply udf + '((Uint32 '1) (Uint32 '2) (Uint32 '3)) + (AsStruct)) +'())) +(let world (Write! world res_sink (Key) (NamedApply udf + '((Uint32 '1) (Uint32 '2) (Uint32 '3) (Uint32 '4)) + (AsStruct)) +'())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/NamedAutoMapName.yql b/yql/essentials/tests/s-expressions/suites/Udf/NamedAutoMapName.yql new file mode 100644 index 0000000000..719a56a72d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/NamedAutoMapName.yql @@ -0,0 +1,60 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"column0" ("NamedApply" ("Udf" '"SimpleUdf.Increment") '() (AsStruct + '('Arg1 (Cast (Member row '"key") 'Uint32)) '('Arg2 (Uint32 '"1")) + )))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"column0" ("NamedApply" ("Udf" '"SimpleUdf.IncrementOpt") '() (AsStruct + '('Arg1 (Cast (Member row '"key") 'Uint32)) '('Arg2 (Uint32 '"2")) + )))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/NamedAutoMapPos.yql b/yql/essentials/tests/s-expressions/suites/Udf/NamedAutoMapPos.yql new file mode 100644 index 0000000000..37c8674711 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/NamedAutoMapPos.yql @@ -0,0 +1,56 @@ +( +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"column0" ("NamedApply" ("Udf" '"SimpleUdf.Increment") '((Cast (Member row '"key") 'Uint32) (Uint32 '"1")) (AsStruct)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let x (Read! world (DataSource '"yt" '"plato") (Key '('table (String '"Input"))) '('"key") '())) + (let world (Left! x)) + (let table0 (Right! x)) + (let output (block '( + (let select (block '( + (let core table0) + (let core (FlatMap core (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res '"column0" ("NamedApply" ("Udf" '"SimpleUdf.IncrementOpt") '((Cast (Member row '"key") 'Uint32) (Uint32 '"2")) (AsStruct)))) + (let res (AsList res)) + (return res) + ))))) + (return core) + ))) + (return select) + ))) + (let world (block '( + (let result_sink (DataSink 'result)) + (let world (Write! world result_sink (Key) output '('('type) '('autoref) '('columns '('"column0"))))) + (return (Commit! world result_sink)) + ))) + (return world) +))) +(let world (block '( + (let plato_sink (DataSink '"yt" '"plato")) + (let world (Commit! world plato_sink)) + (return world) +))) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/OptionalReduceWithResource.cfg b/yql/essentials/tests/s-expressions/suites/Udf/OptionalReduceWithResource.cfg new file mode 100644 index 0000000000..956cb08312 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/OptionalReduceWithResource.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +udf stat_udf +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Udf/OptionalReduceWithResource.yql b/yql/essentials/tests/s-expressions/suites/Udf/OptionalReduceWithResource.yql new file mode 100644 index 0000000000..affd7f4d55 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/OptionalReduceWithResource.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 udfTDigest_Create (Udf 'Stat.TDigest_Create)) +(let udfTDigest_AddValue (Udf 'Stat.TDigest_AddValue)) +(let udfTDigest_GetPercentile (Udf 'Stat.TDigest_GetPercentile)) +(let udfTDigest_Serialize (Udf 'Stat.TDigest_Serialize)) +(let udfTDigest_Deserialize (Udf 'Stat.TDigest_Deserialize)) +(let udfTDigest_Merge (Udf 'Stat.TDigest_Merge)) +(let table1map (Map table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (let x (Apply udfTDigest_Create (Double '1.0))) + (let y (Apply udfTDigest_Create (Double '2.0))) + (let jx (Just x)) + (let jy (Just y)) + (let n (Nothing (OptionalType (TypeOf x)))) + (let handler (lambda '(x y) (Apply udfTDigest_Merge x y))) + (let newValue value) + (let newValue (Concat newValue (String '" => "))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Map + (OptionalReduce jx jy handler) (lambda '(r) + (ToString (Apply udfTDigest_GetPercentile r (Double '0.75)) + ))) (String '?))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Map + (OptionalReduce jx n handler) (lambda '(r) + (ToString (Apply udfTDigest_GetPercentile r (Double '0.75)) + ))) (String '?))))) + (let newValue (Concat newValue (Concat (String '" ") (Coalesce (Map + (OptionalReduce n n handler) (lambda '(r) + (ToString (Apply udfTDigest_GetPercentile r (Double '0.75)) + ))) (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/Udf/OptionalRunConfig.cfg b/yql/essentials/tests/s-expressions/suites/Udf/OptionalRunConfig.cfg new file mode 100644 index 0000000000..57571ef968 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/OptionalRunConfig.cfg @@ -0,0 +1,3 @@ +in Input input.txt +out Output output.txt +udf simple_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/OptionalRunConfig.yql b/yql/essentials/tests/s-expressions/suites/Udf/OptionalRunConfig.yql new file mode 100644 index 0000000000..8703e76e49 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/OptionalRunConfig.yql @@ -0,0 +1,16 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let x (String 'bbb)) +(let udf (Udf 'SimpleUdf.EchoWithRunPrefix (String 'aaa) (Void) '"")) +(let data (Apply udf x)) +(let world (Write! world res_sink (Key) data '())) +(let udf (Udf 'SimpleUdf.EchoWithRunPrefix)) +(let data (Apply udf x)) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PartialCall.cfg b/yql/essentials/tests/s-expressions/suites/Udf/PartialCall.cfg new file mode 100644 index 0000000000..57571ef968 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PartialCall.cfg @@ -0,0 +1,3 @@ +in Input input.txt +out Output output.txt +udf simple_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PartialCall.yql b/yql/essentials/tests/s-expressions/suites/Udf/PartialCall.yql new file mode 100644 index 0000000000..ce81c3df0d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PartialCall.yql @@ -0,0 +1,16 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let udf (Udf 'SimpleUdf.EchoWithPrefix)) +(let x (String 'aaa)) +(let y (String 'bbb)) +(let data (Apply udf x)) +(let world (Write! world res_sink (Key) data '())) +(let data (Apply udf x y)) +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PartialFieldsAfterRemap.cfg b/yql/essentials/tests/s-expressions/suites/Udf/PartialFieldsAfterRemap.cfg new file mode 100644 index 0000000000..9bed8d5096 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PartialFieldsAfterRemap.cfg @@ -0,0 +1,3 @@ +in Input input4.txt +res result.txt +udf dummylog diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PartialFieldsAfterRemap.yql b/yql/essentials/tests/s-expressions/suites/Udf/PartialFieldsAfterRemap.yql new file mode 100644 index 0000000000..4e5766f779 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PartialFieldsAfterRemap.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/Percentiles.cfg b/yql/essentials/tests/s-expressions/suites/Udf/Percentiles.cfg new file mode 100644 index 0000000000..4de5e2339f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/Percentiles.cfg @@ -0,0 +1,4 @@ +in Input Percentiles.txt +out Output output.txt +udf stat_udf +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Udf/Percentiles.txt b/yql/essentials/tests/s-expressions/suites/Udf/Percentiles.txt new file mode 100644 index 0000000000..b500ea3b02 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/Percentiles.txt @@ -0,0 +1,16 @@ +{"key"="a";"subkey"=".";"value"="2"}; +{"key"="b";"subkey"=".";"value"="1"}; +{"key"="b";"subkey"=".";"value"="10"}; +{"key"="b";"subkey"=".";"value"="2"}; +{"key"="a";"subkey"=".";"value"="3"}; +{"key"="a";"subkey"=".";"value"="2"}; +{"key"="b";"subkey"=".";"value"="1"}; +{"key"="b";"subkey"=".";"value"="1"}; +{"key"="a";"subkey"=".";"value"="2"}; +{"key"="a";"subkey"=".";"value"="2"}; +{"key"="a";"subkey"=".";"value"="2"}; +{"key"="a";"subkey"=".";"value"="2"}; +{"key"="b";"subkey"=".";"value"="1"}; +{"key"="b";"subkey"=".";"value"="1"}; +{"key"="b";"subkey"=".";"value"="1"}; +{"key"="b";"subkey"=".";"value"="1"}; diff --git a/yql/essentials/tests/s-expressions/suites/Udf/Percentiles.txt.attr b/yql/essentials/tests/s-expressions/suites/Udf/Percentiles.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/Percentiles.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/Udf/Percentiles.yql b/yql/essentials/tests/s-expressions/suites/Udf/Percentiles.yql new file mode 100644 index 0000000000..0a15c6095a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/Percentiles.yql @@ -0,0 +1,45 @@ +( +#comment +(let udfTDigest_Create (Udf 'Stat.TDigest_Create)) +(let udfTDigest_AddValue (Udf 'Stat.TDigest_AddValue)) +(let udfTDigest_GetPercentile (Udf 'Stat.TDigest_GetPercentile)) +(let udfTDigest_Serialize (Udf 'Stat.TDigest_Serialize)) +(let udfTDigest_Deserialize (Udf 'Stat.TDigest_Deserialize)) +(let udfTDigest_Merge (Udf 'Stat.TDigest_Merge)) +(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 preMap (lambda '(item) (Just item))) +(let keyExtractor (lambda '(item) (Member item 'key))) +(let init (lambda '(key item) (Apply udfTDigest_Create (Unwrap (FromString (Member item 'value) 'Double))))) +(let update (lambda '(key item state) (Apply udfTDigest_AddValue state (Unwrap (FromString (Member item 'value) 'Double))))) +(let finish (lambda '(key state) (block '( + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value (Apply udfTDigest_Serialize state))) + (return (Just s)) +)))) +(let table2 (CombineByKey table1 preMap keyExtractor init update finish)) +(let listHandler (lambda '(stream) (FlatMap stream (lambda '(pair) (block '( + (let key (Nth pair '0)) + (let list (ForwardList (Nth pair '1))) + (let init (lambda '(item) (Apply udfTDigest_Deserialize (Member item 'value)))) + (let update (lambda '(item state) (Apply udfTDigest_Merge (Apply udfTDigest_Deserialize (Member item 'value)) state))) + (let state (Unwrap (Fold1 list init update))) + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let g1 (ToString (Apply udfTDigest_GetPercentile state (Double '0.75)))) + (let g2 (ToString (Apply udfTDigest_GetPercentile state (Double '0.999)))) + (let s (AddMember s 'value (Concat (Concat g1 (String '" ")) g2))) + (let ret (Just s)) + (return ret) +)))))) +(let table3 (PartitionByKey table2 keyExtractor (Void) (Void) listHandler)) +(let mr_sink (DataSink 'yt '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/Udf/PireMatchInMap.cfg b/yql/essentials/tests/s-expressions/suites/Udf/PireMatchInMap.cfg new file mode 100644 index 0000000000..8bd0a53757 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PireMatchInMap.cfg @@ -0,0 +1,3 @@ +in Input input.txt +out Output output.txt +udf pire_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PireMatchInMap.yql b/yql/essentials/tests/s-expressions/suites/Udf/PireMatchInMap.yql new file mode 100644 index 0000000000..54c06596ad --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PireMatchInMap.yql @@ -0,0 +1,16 @@ +( +#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 udf (Udf 'Pire.Match (String '\d+))) +(let table1map (Filter table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (return (Apply udf value)) +))))) +(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/Udf/PireMatchRes.cfg b/yql/essentials/tests/s-expressions/suites/Udf/PireMatchRes.cfg new file mode 100644 index 0000000000..d01e7622a0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PireMatchRes.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf pire_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PireMatchRes.yql b/yql/essentials/tests/s-expressions/suites/Udf/PireMatchRes.yql new file mode 100644 index 0000000000..90391c2264 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PireMatchRes.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let udf (Udf 'Pire.Match (String '.?\d.?))) +(let world (Write! world res_sink (Key) (Apply udf (String 'abc)) '())) +(let world (Write! world res_sink (Key) (Apply udf (String 'x6y)) '())) +(let world (Write! world res_sink (Key) (FormatType (TypeOf udf)) '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/ProtoField.cfg b/yql/essentials/tests/s-expressions/suites/Udf/ProtoField.cfg new file mode 100644 index 0000000000..8fa549ddb5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/ProtoField.cfg @@ -0,0 +1,3 @@ +in Input input_proto.txt +udf protobuf_udf +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Udf/ProtoField.yql b/yql/essentials/tests/s-expressions/suites/Udf/ProtoField.yql new file mode 100644 index 0000000000..c3b00f1716 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/ProtoField.yql @@ -0,0 +1,11 @@ +( +#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 res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/ProtoFieldOpt.cfg b/yql/essentials/tests/s-expressions/suites/Udf/ProtoFieldOpt.cfg new file mode 100644 index 0000000000..8dd001f619 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/ProtoFieldOpt.cfg @@ -0,0 +1,3 @@ +in Input input_proto_opt.txt +udf protobuf_udf +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Udf/ProtoFieldOpt.yql b/yql/essentials/tests/s-expressions/suites/Udf/ProtoFieldOpt.yql new file mode 100644 index 0000000000..c3b00f1716 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/ProtoFieldOpt.yql @@ -0,0 +1,11 @@ +( +#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 res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/ProtoFieldScheme.cfg b/yql/essentials/tests/s-expressions/suites/Udf/ProtoFieldScheme.cfg new file mode 100644 index 0000000000..8fa549ddb5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/ProtoFieldScheme.cfg @@ -0,0 +1,3 @@ +in Input input_proto.txt +udf protobuf_udf +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Udf/ProtoFieldScheme.yql b/yql/essentials/tests/s-expressions/suites/Udf/ProtoFieldScheme.yql new file mode 100644 index 0000000000..89ab89671f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/ProtoFieldScheme.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('tablescheme (String 'Input))) (Void) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonAvg.cfg b/yql/essentials/tests/s-expressions/suites/Udf/PythonAvg.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonAvg.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonAvg.yql b/yql/essentials/tests/s-expressions/suites/Udf/PythonAvg.yql new file mode 100644 index 0000000000..62dc07db05 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonAvg.yql @@ -0,0 +1,57 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# prepare python udf +(let ui32 (DataType 'Uint32)) +(let dbl (DataType 'Double)) +(let rt (ResourceType 'Python2)) + +(let udfScript (String '@@ +class AvgCalc: + def __init__(self): + self.__count = 0 + self.__sum = 0 + + def add(self, value): + self.__sum = self.__sum + value + self.__count = self.__count + 1 + + def result(self): + return self.__sum / float(self.__count) + +def avg_create(): + return AvgCalc() + +def avg_add(avg, value): + avg.add(value) + return avg + +def avg_result(avg): + return avg.result() + +@@)) + +(let avgCreate (ScriptUdf 'Python 'avg_create (CallableType '() '(rt)) udfScript)) +(let avgAdd (ScriptUdf 'Python 'avg_add (CallableType '() '(rt) '(rt) '(ui32)) udfScript)) +(let avgResult (ScriptUdf 'Python 'avg_result (CallableType '() '(dbl) '(rt)) udfScript)) + +# data +(let x (Uint32 '10)) +(let y (Uint32 '30)) +(let z (Uint32 '5)) + +# call udfs +(let avg (Apply avgCreate)) +(let avg (Apply avgAdd avg x)) +(let avg (Apply avgAdd avg y)) +(let avg (Apply avgAdd avg z)) +(let result (Apply avgResult avg)) + +# output result with type +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result '( '('type) ))) + +# finish +(return (Commit! world res_sink)) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonCallableAsArg.cfg b/yql/essentials/tests/s-expressions/suites/Udf/PythonCallableAsArg.cfg new file mode 100644 index 0000000000..0bffbd4f08 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonCallableAsArg.cfg @@ -0,0 +1,5 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf +udf simple_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonCallableAsArg.yql b/yql/essentials/tests/s-expressions/suites/Udf/PythonCallableAsArg.yql new file mode 100644 index 0000000000..36a70677e4 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonCallableAsArg.yql @@ -0,0 +1,31 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# common types +(let ui64 (DataType 'Uint64)) +(let str (DataType 'String)) + +# callable func +(let funcType (CallableType '() '(str) '(str) '(ui64))) +(let func (Udf 'SimpleUdf.Repeat)) + +# python udf +(let udfType (CallableType '() '(str) '(funcType) '(ui64))) +(let udfScript (String '@@ +def new_string(func, x): + return func('x', x) + ':' + func('y', x) +@@)) +(let udf (ScriptUdf 'Python 'new_string udfType udfScript)) + +# call udf +(let x (Uint64 '3)) +(let result (Apply udf func x)) + +# output result with type +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result '( '('type) ))) + +# finish +(return (Commit! world res_sink)) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonCallableAsResult.cfg b/yql/essentials/tests/s-expressions/suites/Udf/PythonCallableAsResult.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonCallableAsResult.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonCallableAsResult.yql b/yql/essentials/tests/s-expressions/suites/Udf/PythonCallableAsResult.yql new file mode 100644 index 0000000000..7a7a6a995a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonCallableAsResult.yql @@ -0,0 +1,39 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# prepare python udf +(let ui64 (DataType 'Uint64)) +(let str (DataType 'String)) +(let funcType (CallableType '() '(ui64) '(ui64))) + +(let udfType (CallableType '() '(funcType) '(ui64))) +(let udfScript (String '@@ +def create_counter(start): + def counter(step): + v = counter.x + counter.x += step + return v + + counter.x = start + return counter +@@)) + +(let udf (ScriptUdf 'Python 'create_counter udfType udfScript)) + +# call udf +(let counter (Apply udf (Uint64 '1))) +(let result (AsList + (Apply counter (Uint64 '1)) + (Apply counter (Uint64 '2)) + (Apply counter (Uint64 '3)) + (Apply counter (Uint64 '4)) +)) + +# output result with type +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result '( '('type) ))) + +# finish +(return (Commit! world res_sink)) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonGenerator.cfg b/yql/essentials/tests/s-expressions/suites/Udf/PythonGenerator.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonGenerator.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonGenerator.yql b/yql/essentials/tests/s-expressions/suites/Udf/PythonGenerator.yql new file mode 100644 index 0000000000..d225a14c1b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonGenerator.yql @@ -0,0 +1,26 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# prepare python udf +(let i64 (DataType 'Int64)) +(let udfType (CallableType '() '((ListType i64)))) +(let udfScript (String '@@ +def g0(): + def gen(): + for x in xrange(1, 4): + yield long(x + 42) + return gen +@@)) +(let udf (ScriptUdf 'Python 'g0 udfType udfScript)) + +# call udf +(let result (Apply udf)) + +# output result with type +(let sink (DataSink 'result)) +(let world (Write! world sink (Key) result '( '('type) ))) + +# finish +(return (Commit! world sink)) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonGeneratorExprWithClosure.cfg b/yql/essentials/tests/s-expressions/suites/Udf/PythonGeneratorExprWithClosure.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonGeneratorExprWithClosure.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonGeneratorExprWithClosure.yql b/yql/essentials/tests/s-expressions/suites/Udf/PythonGeneratorExprWithClosure.yql new file mode 100644 index 0000000000..86a1c9a0bb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonGeneratorExprWithClosure.yql @@ -0,0 +1,25 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# prepare python udf +(let i64 (DataType 'Int64)) +(let udfType (CallableType '() '((ListType i64)) '((ListType i64)))) +(let udfScript (String '@@ +def g(input): + def gen(): + return (long(x + 42) for x in input) + return gen +@@)) +(let udf (ScriptUdf 'Python 'g udfType udfScript)) + +# call udf +(let result (Apply udf (AsList (Int64 '1) (Int64 '2) (Int64 '3)))) + +# output result with type +(let sink (DataSink 'result)) +(let world (Write! world sink (Key) result '( '('type) ))) + +# finish +(return (Commit! world sink)) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonGeneratorWithClosure.cfg b/yql/essentials/tests/s-expressions/suites/Udf/PythonGeneratorWithClosure.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonGeneratorWithClosure.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonGeneratorWithClosure.yql b/yql/essentials/tests/s-expressions/suites/Udf/PythonGeneratorWithClosure.yql new file mode 100644 index 0000000000..87799cbf69 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonGeneratorWithClosure.yql @@ -0,0 +1,26 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# prepare python udf +(let i64 (DataType 'Int64)) +(let udfType (CallableType '() '((ListType i64)) '((ListType i64)))) +(let udfScript (String '@@ +def h(input): + def gen(): + for x in input: + yield long(x + 42) + return gen +@@)) +(let udf (ScriptUdf 'Python 'h udfType udfScript)) + +# call udf +(let result (Apply udf (AsList (Int64 '1) (Int64 '2) (Int64 '3)))) + +# output result with type +(let sink (DataSink 'result)) +(let world (Write! world sink (Key) result '( '('type) ))) + +# finish +(return (Commit! world sink)) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonPartialCall.cfg b/yql/essentials/tests/s-expressions/suites/Udf/PythonPartialCall.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonPartialCall.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonPartialCall.yql b/yql/essentials/tests/s-expressions/suites/Udf/PythonPartialCall.yql new file mode 100644 index 0000000000..f45e2d9157 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonPartialCall.yql @@ -0,0 +1,22 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# prepare python udf +(let ui32 (DataType 'Uint32)) +(let udfType (CallableType '('1) '(ui32) '(ui32) '((OptionalType ui32)))) +(let udfScript (String '"def Add(x, y): return x + (y if y is not None else 1)")) +(let udf (ScriptUdf 'Python 'Add udfType udfScript)) + +# call udf +(let x (Uint32 '20)) +(let result (Apply udf x)) + +# output result with type +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result '( '('type) ))) + +# finish +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonStruct.cfg b/yql/essentials/tests/s-expressions/suites/Udf/PythonStruct.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonStruct.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonStruct.yql b/yql/essentials/tests/s-expressions/suites/Udf/PythonStruct.yql new file mode 100644 index 0000000000..38a484a4c3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonStruct.yql @@ -0,0 +1,33 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# prepare python udf +(let ui32 (DataType 'Uint32)) +(let str (DataType 'String)) +(let personType (StructType '('name str) '('age ui32))) +(let udfType (CallableType '() '(personType) '(str) '(ui32))) +(let udfScript (String '@@ + +class Person: + def __init__(self, name, age): + self.name = name + self.age = age + +def NewPerson(name, age): + return Person(name, age) + +@@)) +(let udf (ScriptUdf 'Python 'NewPerson udfType udfScript)) + +# call udf +(let result (Apply udf (String 'Jamel) (Uint32 '99))) + +# output result with type +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result '())) + +# finish +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonSum.cfg b/yql/essentials/tests/s-expressions/suites/Udf/PythonSum.cfg new file mode 100644 index 0000000000..0bbf3ad9f0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonSum.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/PythonSum.yql b/yql/essentials/tests/s-expressions/suites/Udf/PythonSum.yql new file mode 100644 index 0000000000..b240dc0f58 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/PythonSum.yql @@ -0,0 +1,23 @@ +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +# prepare python udf +(let ui32 (DataType 'Uint32)) +(let udfType (CallableType '() '(ui32) '(ui32) '(ui32))) +(let udfScript (String '"def Sum(x, y): return x + y")) +(let udf (ScriptUdf 'Python 'Sum udfType udfScript)) + +# call udf +(let x (Uint32 '10)) +(let y (Uint32 '32)) +(let result (Apply udf x y)) + +# output result with type +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) result '( '('type) ))) + +# finish +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapCopy.cfg b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapCopy.cfg new file mode 100644 index 0000000000..ce0f9208d8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapCopy.cfg @@ -0,0 +1,3 @@ +in Input input2.txt +out Output output.txt +udf dummylog diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapCopy.yql b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapCopy.yql new file mode 100644 index 0000000000..894e1a15a1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapCopy.yql @@ -0,0 +1,11 @@ +( +#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 mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapFilter.cfg b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapFilter.cfg new file mode 100644 index 0000000000..cb892c3e09 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapFilter.cfg @@ -0,0 +1,4 @@ +in Input input2.txt +out Output output.txt +udf dummylog +udf pire_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapFilter.yql b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapFilter.yql new file mode 100644 index 0000000000..c3752b674e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapFilter.yql @@ -0,0 +1,16 @@ +( +#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 udf (Udf 'Pire.Match (String '@@.*\d.*@@))) +(let table1map (Filter table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (return (Apply udf value)) +))))) +(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/Udf/RecordRemapFilter2.cfg b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapFilter2.cfg new file mode 100644 index 0000000000..b6d398353a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapFilter2.cfg @@ -0,0 +1,5 @@ +in Input input2.txt +in Input2 input3.txt +out Output output.txt +udf dummylog +udf pire_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapFilter2.yql b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapFilter2.yql new file mode 100644 index 0000000000..58c57253c1 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapFilter2.yql @@ -0,0 +1,22 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source +'( +(Key '('table (String 'Input))) +(Key '('table (String 'Input2))) +) + +'('key 'subkey 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let udf (Udf 'Pire.Match (String '@@.*\d.*@@))) +(let table1map (Filter table1 (lambda '(item) (block '( + (let value (Member item 'value)) + (return (Apply udf value)) +))))) +(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/Udf/RecordRemapRangeDiffUdf.cfg b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeDiffUdf.cfg new file mode 100644 index 0000000000..cf41c46471 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeDiffUdf.cfg @@ -0,0 +1,6 @@ +in Input1 input_many1.txt +in Input2 input_many2.txt +in Input3 input_many3.txt +in Input4 input_many4.txt +out Output output.txt +udf dummylog diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeDiffUdf.yql b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeDiffUdf.yql new file mode 100644 index 0000000000..fad593cd98 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeDiffUdf.yql @@ -0,0 +1,14 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source +(Key '('table (MrTableRange '"" (lambda '($i) (And (>= $i (String '"Input1")) (<= $i (String '"Input~")))) '""))) +'('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableLimit (Take table (Uint64 '9))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) tableLimit '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeDiffUdfPartial.cfg b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeDiffUdfPartial.cfg new file mode 100644 index 0000000000..227f4e34f7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeDiffUdfPartial.cfg @@ -0,0 +1,7 @@ +in Input1 input_many1.txt +in Input2 input_many1.txt +in Input3 input_many2.txt +in Input4 input_many2.txt +out Output output.txt +udf dummylog +udf pire_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeDiffUdfPartial.yql b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeDiffUdfPartial.yql new file mode 100644 index 0000000000..d86392d08a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeDiffUdfPartial.yql @@ -0,0 +1,19 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source +(Key '('table (MrTableRange '"" (lambda '($i) (And (>= $i (String '"Input1")) (<= $i (String '"Input~")))) '""))) +'('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let udf (Udf 'Pire.Match (String '@@.*\d.*@@))) +(let table (Filter table (lambda '(item) (block '( + (let value (Member item 'value)) + (return (Apply udf value)) +))))) +(let tableLimit (Take table (Uint64 '9))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) tableLimit '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeSameUdf.cfg b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeSameUdf.cfg new file mode 100644 index 0000000000..076884ed54 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeSameUdf.cfg @@ -0,0 +1,6 @@ +in Input1 input_many1.txt +in Input2 input_many1.txt +in Input3 input_many1.txt +in Input4 input_many1.txt +out Output output.txt +udf dummylog diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeSameUdf.yql b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeSameUdf.yql new file mode 100644 index 0000000000..fad593cd98 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapRangeSameUdf.yql @@ -0,0 +1,14 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source +(Key '('table (MrTableRange '"" (lambda '($i) (And (>= $i (String '"Input1")) (<= $i (String '"Input~")))) '""))) +'('key 'subkey 'value) '())) +(let world (Left! x)) +(let table (Right! x)) +(let tableLimit (Take table (Uint64 '9))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) tableLimit '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapReduce.cfg b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapReduce.cfg new file mode 100644 index 0000000000..ce0f9208d8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapReduce.cfg @@ -0,0 +1,3 @@ +in Input input2.txt +out Output output.txt +udf dummylog diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapReduce.yql b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapReduce.yql new file mode 100644 index 0000000000..df1bf89415 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapReduce.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 listHandler (lambda '(stream) (FlatMap stream (lambda '(pair) (block '( + (let key (Nth pair '0)) + (let list (Collect (Nth pair '1))) + (let r (FlatMap list (lambda '(x) (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 r) +)))))) +(let keySelector (lambda '(x) (Member x 'key))) +(let reducedTable (PartitionByKey table1 keySelector (Void) (Void) listHandler)) +(let mr_sink (DataSink 'yt '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/Udf/RecordRemapSort.cfg b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapSort.cfg new file mode 100644 index 0000000000..ce0f9208d8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapSort.cfg @@ -0,0 +1,3 @@ +in Input input2.txt +out Output output.txt +udf dummylog diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapSort.yql b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapSort.yql new file mode 100644 index 0000000000..01df591aa8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapSort.yql @@ -0,0 +1,14 @@ +( +#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 output (Sort table1 (Bool 'true) (lambda '(item) (block '( + (return (Member item 'key)) +))))) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) output '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWeakRange.cfg b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWeakRange.cfg new file mode 100644 index 0000000000..43da70bb81 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWeakRange.cfg @@ -0,0 +1,4 @@ +in Input input2.txt +out Output output.txt +udf dummylog +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWeakRange.yql b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWeakRange.yql new file mode 100644 index 0000000000..09a346ac6d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWeakRange.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (MrTableRange '"" (lambda '($i) (And (>= $i (String '"Input")) (<= $i (String '"Input~")))) '""))) '('key) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWithConfigCopy.cfg b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWithConfigCopy.cfg new file mode 100644 index 0000000000..5f1288aa57 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWithConfigCopy.cfg @@ -0,0 +1,3 @@ +in Input input4.txt +out Output output.txt +udf dummylog diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWithConfigCopy.yql b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWithConfigCopy.yql new file mode 100644 index 0000000000..ffc63f7bb5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWithConfigCopy.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let mr_sink (DataSink 'yt (quote plato))) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1 '('('mode 'append)))) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWithConfigResult.cfg b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWithConfigResult.cfg new file mode 100644 index 0000000000..9bed8d5096 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWithConfigResult.cfg @@ -0,0 +1,3 @@ +in Input input4.txt +res result.txt +udf dummylog diff --git a/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWithConfigResult.yql b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWithConfigResult.yql new file mode 100644 index 0000000000..b39a63ed36 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/RecordRemapWithConfigResult.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) '('key 'value) '())) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/ResultWithRemapConfig.cfg b/yql/essentials/tests/s-expressions/suites/Udf/ResultWithRemapConfig.cfg new file mode 100644 index 0000000000..c60ed039b2 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/ResultWithRemapConfig.cfg @@ -0,0 +1,2 @@ +in Input input5.txt +udf structs_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/ResultWithRemapConfig.yql b/yql/essentials/tests/s-expressions/suites/Udf/ResultWithRemapConfig.yql new file mode 100644 index 0000000000..2f14a89709 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/ResultWithRemapConfig.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input))) (Void) '())) +(let world (Left! x)) +(let table (Right! x)) +(let sink (DataSink 'result)) +(let world (Write! world sink (Key) table '('('type)))) +(let world (Commit! world sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/Sleep.cfg b/yql/essentials/tests/s-expressions/suites/Udf/Sleep.cfg new file mode 100644 index 0000000000..7cb3e39eea --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/Sleep.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf simple_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/Sleep.yql b/yql/essentials/tests/s-expressions/suites/Udf/Sleep.yql new file mode 100644 index 0000000000..86d036c80f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/Sleep.yql @@ -0,0 +1,35 @@ +( +(let sleep (Udf 'SimpleUdf.Sleep)) +(let 01sec (Uint64 '100000)) +(let 05sec (Uint64 '500000)) +(let 03sec (Uint64 '300000)) + +#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 data1 (Apply sleep (+ 05sec 01sec))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '1))) + (let s (AddMember s 'value (ToString data1))) + (return s) +))))) +(let table2map (Map table1 (lambda '(item) (block '( + (let data1 (Apply sleep (+ 03sec 03sec))) + (let s (Struct)) + (let s (AddMember s 'key (Member item 'key))) + (let s (AddMember s 'subkey (String '2))) + (let s (AddMember s 'value (ToString data1))) + (return s) +))))) +(let mr_sink (DataSink 'yt 'plato)) +(let res_sink (DataSink 'result)) +(let world (Write! world mr_sink (Key '('table (String 'Output))) table1map '())) +(let world (Write! world res_sink (Key) table2map '())) +(let world (Commit! world mr_sink)) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/StringJoinFromList.cfg b/yql/essentials/tests/s-expressions/suites/Udf/StringJoinFromList.cfg new file mode 100644 index 0000000000..386ab9ac7f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/StringJoinFromList.cfg @@ -0,0 +1,3 @@ +in Input input.txt +out Output output.txt +udf string_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/StringJoinFromList.yql b/yql/essentials/tests/s-expressions/suites/Udf/StringJoinFromList.yql new file mode 100644 index 0000000000..6085f8d620 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/StringJoinFromList.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 udf (Udf 'String.JoinFromList)) +(let table1map (Map table1 (lambda '(item) (block '( + (let key (Member item 'key)) + (let value (Apply udf (AsList (Member item 'key) (Member item 'subkey) (Member item 'value)) (String '"_"))) + (let s (Struct)) + (let s (AddMember s 'key key)) + (let s (AddMember s 'subkey (String '.))) + (let s (AddMember s 'value value)) + (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/Udf/TableSchemeWithRemap.cfg b/yql/essentials/tests/s-expressions/suites/Udf/TableSchemeWithRemap.cfg new file mode 100644 index 0000000000..9bed8d5096 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/TableSchemeWithRemap.cfg @@ -0,0 +1,3 @@ +in Input input4.txt +res result.txt +udf dummylog diff --git a/yql/essentials/tests/s-expressions/suites/Udf/TableSchemeWithRemap.yql b/yql/essentials/tests/s-expressions/suites/Udf/TableSchemeWithRemap.yql new file mode 100644 index 0000000000..dd7da1dfb0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/TableSchemeWithRemap.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('tablescheme (String 'Input))) (Void) '())) +(let world (Left! x)) +(let scheme (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) scheme '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/TopFreq.cfg b/yql/essentials/tests/s-expressions/suites/Udf/TopFreq.cfg new file mode 100644 index 0000000000..38a048bf8d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/TopFreq.cfg @@ -0,0 +1,4 @@ +in Input TopFreq.txt +out Output output.txt +udf topfreq_udf +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Udf/TopFreq.txt b/yql/essentials/tests/s-expressions/suites/Udf/TopFreq.txt new file mode 100644 index 0000000000..b500ea3b02 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/TopFreq.txt @@ -0,0 +1,16 @@ +{"key"="a";"subkey"=".";"value"="2"}; +{"key"="b";"subkey"=".";"value"="1"}; +{"key"="b";"subkey"=".";"value"="10"}; +{"key"="b";"subkey"=".";"value"="2"}; +{"key"="a";"subkey"=".";"value"="3"}; +{"key"="a";"subkey"=".";"value"="2"}; +{"key"="b";"subkey"=".";"value"="1"}; +{"key"="b";"subkey"=".";"value"="1"}; +{"key"="a";"subkey"=".";"value"="2"}; +{"key"="a";"subkey"=".";"value"="2"}; +{"key"="a";"subkey"=".";"value"="2"}; +{"key"="a";"subkey"=".";"value"="2"}; +{"key"="b";"subkey"=".";"value"="1"}; +{"key"="b";"subkey"=".";"value"="1"}; +{"key"="b";"subkey"=".";"value"="1"}; +{"key"="b";"subkey"=".";"value"="1"}; diff --git a/yql/essentials/tests/s-expressions/suites/Udf/TopFreq.txt.attr b/yql/essentials/tests/s-expressions/suites/Udf/TopFreq.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/TopFreq.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/Udf/TopFreq.yql b/yql/essentials/tests/s-expressions/suites/Udf/TopFreq.yql new file mode 100644 index 0000000000..ff322d1a1e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/TopFreq.yql @@ -0,0 +1,47 @@ +#program +( +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(import agg_module '"/lib/yql/aggregate.yql") +(let list (AsList +(AsStruct '('key (Int32 '1)) '('value (Just (Int32 '1)))) +(AsStruct '('key (Int32 '1)) '('value (Just (Int32 '4)))) +(AsStruct '('key (Int32 '1)) '('value (Just (Int32 '8)))) +(AsStruct '('key (Int32 '1)) '('value (Just (Int32 '8)))) +(AsStruct '('key (Int32 '1)) '('value (Just (Int32 '3)))) +(AsStruct '('key (Int32 '1)) '('value (Just (Int32 '3)))) +(AsStruct '('key (Int32 '1)) '('value (Just (Int32 '3)))) +(AsStruct '('key (Int32 '1)) '('value (Just (Int32 '8)))) +(AsStruct '('key (Int32 '1)) '('value (Just (Int32 '1)))) +(AsStruct '('key (Int32 '2)) '('value (Just (Int32 '2)))) +(AsStruct '('key (Int32 '2)) '('value (Just (Int32 '2)))) +(AsStruct '('key (Int32 '2)) '('value (Just (Int32 '2)))) +(AsStruct '('key (Int32 '2)) '('value (Just (Int32 '8)))) +(AsStruct '('key (Int32 '2)) '('value (Just (Int32 '3)))) +(AsStruct '('key (Int32 '2)) '('value (Just (Int32 '3)))) +(AsStruct '('key (Int32 '2)) '('value (Just (Int32 '3)))) +(AsStruct '('key (Int32 '2)) '('value (Just (Int32 '8)))) +(AsStruct '('key (Int32 '2)) '('value (Just (Int32 '1)))) +(AsStruct '('key (Int32 '3)) '('value (Just (Int32 '1)))) +(AsStruct '('key (Int32 '3)) '('value (Just (Int32 '2)))) +(AsStruct '('key (Int32 '3)) '('value (Just (Int32 '3)))) +(AsStruct '('key (Int32 '3)) '('value (Just (Int32 '4)))) +(AsStruct '('key (Int32 '3)) '('value (Just (Int32 '5)))) +(AsStruct '('key (Int32 '3)) '('value (Just (Int32 '6)))) +(AsStruct '('key (Int32 '3)) '('value (Just (Int32 '7)))) +(AsStruct '('key (Int32 '3)) '('value (Just (Int32 '8)))) +(AsStruct '('key (Int32 '3)) '('value (Just (Int32 '9)))) +)) +(let res_sink (DataSink 'result)) +(let topfreq_traits (Apply (bind agg_module 'topfreq_traits_factory) (TypeOf list) (lambda '(row) (Member row 'value)) (Uint32 '2) (Uint32 '2))) +(let resKey (Aggregate list '('key) '('('topfreq_value topfreq_traits)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) + +(let topfreq_traits2 (Apply (bind agg_module 'topfreq_traits_factory) (TypeOf list) (lambda '(row) (Unwrap (ToString (Member row 'value)))) (Uint32 '2) (Uint32 '2))) +(let resKey (Aggregate list '('key) '('('topfreq_value topfreq_traits2)))) +(let world (Write! world res_sink (Key) resKey '('('type)))) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/TypeInspection.cfg b/yql/essentials/tests/s-expressions/suites/Udf/TypeInspection.cfg new file mode 100644 index 0000000000..3d92a5a733 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/TypeInspection.cfg @@ -0,0 +1,2 @@ +udf type_inspection_udf +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/Udf/TypeInspection.yql b/yql/essentials/tests/s-expressions/suites/Udf/TypeInspection.yql new file mode 100644 index 0000000000..eecfa7e41d --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/TypeInspection.yql @@ -0,0 +1,32 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) + +(let res_sink (DataSink 'result)) +(let list1 (AsList (String 'A) (String 'B) (String 'C) (String 'D) (String 'E))) +(let list2 (AsList (Uint32 '1) (Uint32 '2) (Uint32 '3))) +(let zip (Udf 'TypeInspection.Zip (Void) + (TupleType + (TypeOf '(list1 list2)) + (StructType) + (TupleType) + ) +)) +(let data (Apply zip list1 list2)) +(let world (Write! world res_sink (Key) data '('('type)))) + +(let stream1 (Iterator list1)) +(let stream2 (Iterator list2)) +(let interleave (Udf 'TypeInspection.Interleave (Void) + (TupleType + (TypeOf '(stream1 stream2)) + (StructType) + (TupleType) + ) +)) +(let data (Apply interleave stream1 stream2)) +(let world (Write! world res_sink (Key) (Collect data) '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/Udf/block_4_columns.csv b/yql/essentials/tests/s-expressions/suites/Udf/block_4_columns.csv new file mode 100644 index 0000000000..15956fb4fe --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/block_4_columns.csv @@ -0,0 +1,7 @@ +a,b,c,d +1,2,3,4 +one,two,three,four +A,B,C,D + +E,F,G,dgf +G,H,I,J diff --git a/yql/essentials/tests/s-expressions/suites/Udf/default.cfg b/yql/essentials/tests/s-expressions/suites/Udf/default.cfg new file mode 100644 index 0000000000..7cb3e39eea --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/default.cfg @@ -0,0 +1,4 @@ +in Input input.txt +out Output output.txt +res result.txt +udf simple_udf diff --git a/yql/essentials/tests/s-expressions/suites/Udf/file_3_columns.csv b/yql/essentials/tests/s-expressions/suites/Udf/file_3_columns.csv new file mode 100644 index 0000000000..e4324930c7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/file_3_columns.csv @@ -0,0 +1,8 @@ +key,subkey,value +String,String,String +k1,sk1,v1 +k2,sk2,v2 + + +this line will be ignored + diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input.txt b/yql/essentials/tests/s-expressions/suites/Udf/input.txt new file mode 100644 index 0000000000..df76c64125 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="1";"value"="a7c"}; +{"key"="800";"subkey"="2";"value"="ddd"}; +{"key"="020";"subkey"="3";"value"="q"}; +{"key"="150";"subkey"="4";"value"="q8z"}; diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input.txt.attr b/yql/essentials/tests/s-expressions/suites/Udf/input.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/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/Udf/input2.txt b/yql/essentials/tests/s-expressions/suites/Udf/input2.txt new file mode 100644 index 0000000000..df76c64125 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input2.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="1";"value"="a7c"}; +{"key"="800";"subkey"="2";"value"="ddd"}; +{"key"="020";"subkey"="3";"value"="q"}; +{"key"="150";"subkey"="4";"value"="q8z"}; diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input2.txt.attr b/yql/essentials/tests/s-expressions/suites/Udf/input2.txt.attr new file mode 100644 index 0000000000..c6f7f36696 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input2.txt.attr @@ -0,0 +1,31 @@ +{ + "_yql_read_udf"="DummyLog.ReadRecord"; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input3.txt b/yql/essentials/tests/s-expressions/suites/Udf/input3.txt new file mode 100644 index 0000000000..090fe1cefd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input3.txt @@ -0,0 +1,4 @@ +{"key"="834";"subkey"="5";"value"="aa"}; +{"key"="987";"subkey"="6";"value"="798"}; +{"key"="124";"subkey"="7";"value"="001"}; +{"key"="623";"subkey"="8";"value"="002"}; diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input3.txt.attr b/yql/essentials/tests/s-expressions/suites/Udf/input3.txt.attr new file mode 100644 index 0000000000..c6f7f36696 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input3.txt.attr @@ -0,0 +1,31 @@ +{ + "_yql_read_udf"="DummyLog.ReadRecord"; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input4.txt b/yql/essentials/tests/s-expressions/suites/Udf/input4.txt new file mode 100644 index 0000000000..090fe1cefd --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input4.txt @@ -0,0 +1,4 @@ +{"key"="834";"subkey"="5";"value"="aa"}; +{"key"="987";"subkey"="6";"value"="798"}; +{"key"="124";"subkey"="7";"value"="001"}; +{"key"="623";"subkey"="8";"value"="002"}; diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input4.txt.attr b/yql/essentials/tests/s-expressions/suites/Udf/input4.txt.attr new file mode 100644 index 0000000000..5c5444bff8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input4.txt.attr @@ -0,0 +1,33 @@ +{ + "_yql_read_udf"="DummyLog.ReadRecord2"; + "_yql_read_udf_type_config"="AAA"; + "_yql_read_udf_run_config"="BBB"; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input5.txt b/yql/essentials/tests/s-expressions/suites/Udf/input5.txt new file mode 100644 index 0000000000..de514b7e8b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input5.txt @@ -0,0 +1,2 @@ +{"key"="Vasya";"subkey"="Pupkin";"value"="33"}; +{"key"="Naum";"subkey"="Prikhoder";"value"="66"}; diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input5.txt.attr b/yql/essentials/tests/s-expressions/suites/Udf/input5.txt.attr new file mode 100644 index 0000000000..6c072165b5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input5.txt.attr @@ -0,0 +1,32 @@ +{ + "_yql_read_udf"="Person.New"; + "_yql_read_udf_type_config"="RemapKSV"; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input_many1.txt b/yql/essentials/tests/s-expressions/suites/Udf/input_many1.txt new file mode 100644 index 0000000000..2fa12a4a52 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input_many1.txt @@ -0,0 +1,5 @@ +{"key"="075";"subkey"="1_1";"value"="a7c"}; +{"key"="800";"subkey"="2_1";"value"="ddd"}; +{"key"="020";"subkey"="3_1";"value"="q"}; +{"key"="150";"subkey"="4_1";"value"="q8z"}; +{"key"="200";"subkey"="5_1";"value"="a7a"}; diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input_many1.txt.attr b/yql/essentials/tests/s-expressions/suites/Udf/input_many1.txt.attr new file mode 100644 index 0000000000..5f9afadd11 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input_many1.txt.attr @@ -0,0 +1,32 @@ +{ + "_yql_read_udf"="DummyLog.ReadRecord"; + "_yql_read_udf_type_config"="1"; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input_many2.txt b/yql/essentials/tests/s-expressions/suites/Udf/input_many2.txt new file mode 100644 index 0000000000..2b1bab42f8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input_many2.txt @@ -0,0 +1,5 @@ +{"key"="075";"subkey"="1_2";"value"="a7c"}; +{"key"="800";"subkey"="2_2";"value"="ddd"}; +{"key"="020";"subkey"="3_2";"value"="q"}; +{"key"="150";"subkey"="4_2";"value"="q8z"}; +{"key"="200";"subkey"="5_2";"value"="a7a"}; diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input_many2.txt.attr b/yql/essentials/tests/s-expressions/suites/Udf/input_many2.txt.attr new file mode 100644 index 0000000000..4e7e0e6b62 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input_many2.txt.attr @@ -0,0 +1,32 @@ +{ + "_yql_read_udf"="DummyLog.ReadRecord"; + "_yql_read_udf_type_config"="2"; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input_many3.txt b/yql/essentials/tests/s-expressions/suites/Udf/input_many3.txt new file mode 100644 index 0000000000..2ce03b8925 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input_many3.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="1_3";"value"="a7c"}; +{"key"="800";"subkey"="2_3";"value"="ddd"}; +{"key"="020";"subkey"="3_3";"value"="q"}; +{"key"="150";"subkey"="4_3";"value"="q8z"}; diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input_many3.txt.attr b/yql/essentials/tests/s-expressions/suites/Udf/input_many3.txt.attr new file mode 100644 index 0000000000..f09165629a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input_many3.txt.attr @@ -0,0 +1,32 @@ +{ + "_yql_read_udf"="DummyLog.ReadRecord"; + "_yql_read_udf_type_config"="3"; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input_many4.txt b/yql/essentials/tests/s-expressions/suites/Udf/input_many4.txt new file mode 100644 index 0000000000..c9f1e005d9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input_many4.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="1_4";"value"="a7c"}; +{"key"="800";"subkey"="2_4";"value"="ddd"}; +{"key"="020";"subkey"="3_4";"value"="q"}; +{"key"="150";"subkey"="4_4";"value"="q8z"}; diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input_many4.txt.attr b/yql/essentials/tests/s-expressions/suites/Udf/input_many4.txt.attr new file mode 100644 index 0000000000..f491d07f59 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input_many4.txt.attr @@ -0,0 +1,32 @@ +{ + "_yql_read_udf"="DummyLog.ReadRecord"; + "_yql_read_udf_type_config"="4"; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input_proto.txt b/yql/essentials/tests/s-expressions/suites/Udf/input_proto.txt new file mode 100644 index 0000000000..d2eaef7f29 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input_proto.txt @@ -0,0 +1 @@ +{"key"="1";"subkey"="\n\x10\x08\7\x12\x0C\n\ntext value";"value"="\n\x10\x08\7\x12\x0C\n\ntext value"}; diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input_proto.txt.attr b/yql/essentials/tests/s-expressions/suites/Udf/input_proto.txt.attr new file mode 100644 index 0000000000..f11824f2b8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input_proto.txt.attr @@ -0,0 +1,32 @@ +{ + "_yql_proto_field_value"="{\"name\":\"TA\",\"meta\":\"H4sIAAAAAAAAA42Puw6CQBBFszw0DEp0Y4E2GmyolriJHyAPS6rVflFMTBCUR8Hn+KcuD0ui3WRy59wzcIJ1co9yntfOM8/KLKpuTv1KnKp0rqTdWBQk5uM5SEFhKhvZNqhKmE8CPAHF5yU30QbZmqUDCvAIpONuhmA/jL30WCywXsMI+SPuGJAOn0XdGVZDFhfl6qf1VuBdPAX1zJOq46vYAOSbkhh1Kosf4I2GC/mfhb3YcOD78EoYHfACkNva6FQjLZow11rCmJ3SqoivjaPXB4Sj9wEBmoL3ogEAAA==\",\"lists\":{\"optional\":true}}"; + "_yql_proto_field_subkey"="{\"name\":\"TA\",\"meta\":\"H4sIAAAAAAAAA42Puw6CQBBFszw0DEp0Y4E2GmyolriJHyAPS6rVflFMTBCUR8Hn+KcuD0ui3WRy59wzcIJ1co9yntfOM8/KLKpuTv1KnKp0rqTdWBQk5uM5SEFhKhvZNqhKmE8CPAHF5yU30QbZmqUDCvAIpONuhmA/jL30WCywXsMI+SPuGJAOn0XdGVZDFhfl6qf1VuBdPAX1zJOq46vYAOSbkhh1Kosf4I2GC/mfhb3YcOD78EoYHfACkNva6FQjLZow11rCmJ3SqoivjaPXB4Sj9wEBmoL3ogEAAA==\",\"lists\":{\"optional\":true}}"; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input_proto_opt.txt b/yql/essentials/tests/s-expressions/suites/Udf/input_proto_opt.txt new file mode 100644 index 0000000000..d2eaef7f29 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input_proto_opt.txt @@ -0,0 +1 @@ +{"key"="1";"subkey"="\n\x10\x08\7\x12\x0C\n\ntext value";"value"="\n\x10\x08\7\x12\x0C\n\ntext value"}; diff --git a/yql/essentials/tests/s-expressions/suites/Udf/input_proto_opt.txt.attr b/yql/essentials/tests/s-expressions/suites/Udf/input_proto_opt.txt.attr new file mode 100644 index 0000000000..ad3ff15521 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/input_proto_opt.txt.attr @@ -0,0 +1,5 @@ +{ + "_yql_row_spec"={"Type"=["StructType";[["key";["OptionalType";["DataType";"String"]]];["subkey";["OptionalType";["DataType";"String"]]];["value";["OptionalType";["DataType";"String"]]]]]}; + "_yql_proto_field_value"="{\"name\":\"TA\",\"meta\":\"H4sIAAAAAAAAA42Puw6CQBBFszw0DEp0Y4E2GmyolriJHyAPS6rVflFMTBCUR8Hn+KcuD0ui3WRy59wzcIJ1co9yntfOM8/KLKpuTv1KnKp0rqTdWBQk5uM5SEFhKhvZNqhKmE8CPAHF5yU30QbZmqUDCvAIpONuhmA/jL30WCywXsMI+SPuGJAOn0XdGVZDFhfl6qf1VuBdPAX1zJOq46vYAOSbkhh1Kosf4I2GC/mfhb3YcOD78EoYHfACkNva6FQjLZow11rCmJ3SqoivjaPXB4Sj9wEBmoL3ogEAAA==\",\"lists\":{\"optional\":true}}"; + "_yql_proto_field_subkey"="{\"name\":\"TA\",\"meta\":\"H4sIAAAAAAAAA42Puw6CQBBFszw0DEp0Y4E2GmyolriJHyAPS6rVflFMTBCUR8Hn+KcuD0ui3WRy59wzcIJ1co9yntfOM8/KLKpuTv1KnKp0rqTdWBQk5uM5SEFhKhvZNqhKmE8CPAHF5yU30QbZmqUDCvAIpONuhmA/jL30WCywXsMI+SPuGJAOn0XdGVZDFhfl6qf1VuBdPAX1zJOq46vYAOSbkhh1Kosf4I2GC/mfhb3YcOD78EoYHfACkNva6FQjLZow11rCmJ3SqoivjaPXB4Sj9wEBmoL3ogEAAA==\",\"lists\":{\"optional\":true}}"; +} diff --git a/yql/essentials/tests/s-expressions/suites/Udf/struct_4_fields.csv b/yql/essentials/tests/s-expressions/suites/Udf/struct_4_fields.csv new file mode 100644 index 0000000000..fab478d14a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/Udf/struct_4_fields.csv @@ -0,0 +1,5 @@ +F1I,F2OI,F3N,F4ON +Int32,Uint32?,Float,Double? +1,,1.5,3.1415926 +5,1,2.5, +-12,100,44,105
\ No newline at end of file diff --git a/yql/essentials/tests/s-expressions/suites/View/DoubleGlobViewRead.cfg b/yql/essentials/tests/s-expressions/suites/View/DoubleGlobViewRead.cfg new file mode 100644 index 0000000000..2ac9312f92 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/DoubleGlobViewRead.cfg @@ -0,0 +1,4 @@ +in Input1 input.txt +in Input2 input6.txt +in InputView input_view.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/View/DoubleGlobViewRead.yql b/yql/essentials/tests/s-expressions/suites/View/DoubleGlobViewRead.yql new file mode 100644 index 0000000000..5a2597e5cc --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/DoubleGlobViewRead.yql @@ -0,0 +1,32 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) +(let res_sink (DataSink 'result)) +(let source_any (DataSource 'yt '"$all")) + +(let world (Configure! world source_any '"Attr" '"inferschema" '"1")) +(let world (Configure! world source_any '"Attr" '"maxrowweight" '"128m")) + +(let x1 (Read! world mr_source (Key + '('table (String 'InputView)) +) (Void) '())) + +(let world (Left! x1)) +(let data (Right! x1)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) + +(let x2 (Read! world mr_source (Key + '('table (String 'InputView)) +) (Void) '())) + +(let world (Left! x2)) +(let data (Right! x2)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) + +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/DsvCount.cfg b/yql/essentials/tests/s-expressions/suites/View/DsvCount.cfg new file mode 100644 index 0000000000..db6c9d1b8c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/DsvCount.cfg @@ -0,0 +1,4 @@ +in Input input3.txt +out Output output.txt +res result.txt +udf dsv_udf diff --git a/yql/essentials/tests/s-expressions/suites/View/DsvCount.yql b/yql/essentials/tests/s-expressions/suites/View/DsvCount.yql new file mode 100644 index 0000000000..3fa0a24d9b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/DsvCount.yql @@ -0,0 +1,50 @@ +( +(let x (Read! world (DataSource 'yt 'plato) (Key '('table (String 'Input))) '('dict) '())) +(let world (Left! x)) +(let Input (Right! x)) +(let select1_input11 Input) +(let output12 (block '( + (let select1_output select1_input11) + (let select1_output (Filter select1_output (lambda '(row) (block '( + (let res (Coalesce (!= (Not (Exists (Lookup (Member row 'dict) (String '"c")))) (Bool 'true)) (Bool 'false))) + (return res) +) +)))) + (let select1_output (PartitionByKey select1_output (lambda '(row) (block '( + (let res (String '"")) + (return res) +) +)) (Void) (Void) (lambda '(stream) (FlatMap stream (lambda '(pair) (block '( + (let key (Nth pair '0)) + (let group (ForwardList (Nth pair '1))) + (let aggr (Fold1 group (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res 'Count7 (Convert (Exists (Unwrap (Lookup (Member row 'dict) (String '"a")))) 'Uint64))) + (return res) +) +)) (lambda '(row state) (block '( + (let res (Struct)) + (let res (AddMember res 'Count7 (OptionalReduce (Member state 'Count7) (Convert (Exists (Unwrap (Lookup (Member row 'dict) (String '"a")))) 'Uint64) (lambda '(a b) (+ a b))))) + (return res) +) +)))) + (let res (FlatMap aggr (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res 'a_count (Member row 'Count7))) + (let res (AsList res)) + (return res) +) +)))) + (return res) +))))) +)) + (return select1_output) +) +)) +(let result_sink (DataSink 'result)) +(let world (Write! world result_sink (Key) output12 '('('type) '('autoref) '('columns '('a_count))))) +(let plato_sink (DataSink 'yt 'plato)) +(let world (Commit! world plato_sink)) +(let world (Commit! world result_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/DsvCountPartitionBy.cfg b/yql/essentials/tests/s-expressions/suites/View/DsvCountPartitionBy.cfg new file mode 100644 index 0000000000..db6c9d1b8c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/DsvCountPartitionBy.cfg @@ -0,0 +1,4 @@ +in Input input3.txt +out Output output.txt +res result.txt +udf dsv_udf diff --git a/yql/essentials/tests/s-expressions/suites/View/DsvCountPartitionBy.yql b/yql/essentials/tests/s-expressions/suites/View/DsvCountPartitionBy.yql new file mode 100644 index 0000000000..f186cb7101 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/DsvCountPartitionBy.yql @@ -0,0 +1,53 @@ +( +(let x (Read! world (DataSource 'yt 'plato) (Key '('table (String 'Input))) '('dict 'key) '())) +(let world (Left! x)) +(let Input (Right! x)) +(let select1_input12 Input) +(let output13 (block '( + (let select1_output select1_input12) + (let select1_output (Filter select1_output (lambda '(row) (block '( + (let res (Coalesce (!= (Not (Exists (Lookup (Member row 'dict) (String '"b")))) (Bool 'true)) (Bool 'false))) + (return res) +) +)))) + (let select1_output (PartitionByKey select1_output (lambda '(row) (block '( + (let res (Member row 'key)) + (return res) +) +)) (Void) (Void) (lambda '(stream) (FlatMap stream (lambda '(pair) (block '( + (let key (Nth pair '0)) + (let group (ForwardList (Nth pair '1))) + (let aggr (Fold1 group (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res 'key (Member row 'key))) + (let res (AddMember res 'Count7 (Convert (Exists (Lookup (Member row 'dict) (String '"a"))) 'Uint64))) + (return res) +) +)) (lambda '(row state) (block '( + (let res (Struct)) + (let res (AddMember res 'key (Member row 'key))) + (let res (AddMember res 'Count7 (OptionalReduce (Member state 'Count7) (Convert (Exists (Lookup (Member row 'dict) (String '"a"))) 'Uint64) (lambda '(a b) (+ a b))))) + (return res) +) +)))) + (let res (FlatMap aggr (lambda '(row) (block '( + (let res (Struct)) + (let res (AddMember res 'key (Member row 'key))) + (let res (AddMember res 'a (Member row 'Count7))) + (let res (AsList res)) + (return res) +) +)))) + (return res) +))) +)))) + (return select1_output) +) +)) +(let result_sink (DataSink 'result)) +(let world (Write! world result_sink (Key) output13 '('('type) '('autoref) '('columns '('key 'a))))) +(let plato_sink (DataSink 'yt 'plato)) +(let world (Commit! world plato_sink)) +(let world (Commit! world result_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfData.cfg b/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfData.cfg new file mode 100644 index 0000000000..44b1761859 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfData.cfg @@ -0,0 +1,4 @@ +in Input input2.txt +out Output output.txt +res result.txt +udf dummylog diff --git a/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfData.yql b/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfData.yql new file mode 100644 index 0000000000..3574c04daf --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfData.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input)) '('view (String 'key1))) '('column0) '() ) ) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfRawData.cfg b/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfRawData.cfg new file mode 100644 index 0000000000..44b1761859 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfRawData.cfg @@ -0,0 +1,4 @@ +in Input input2.txt +out Output output.txt +res result.txt +udf dummylog diff --git a/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfRawData.yql b/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfRawData.yql new file mode 100644 index 0000000000..7e579328e6 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfRawData.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input)) '('view (String 'key2))) '('column0) '() ) ) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfScheme.cfg b/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfScheme.cfg new file mode 100644 index 0000000000..44b1761859 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfScheme.cfg @@ -0,0 +1,4 @@ +in Input input2.txt +out Output output.txt +res result.txt +udf dummylog diff --git a/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfScheme.yql b/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfScheme.yql new file mode 100644 index 0000000000..5d429021c3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/Key1AfterUdfScheme.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('tablescheme (String 'Input)) '('view (String 'key1))) (Void) '()) ) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/Key1Data.yql b/yql/essentials/tests/s-expressions/suites/View/Key1Data.yql new file mode 100644 index 0000000000..85a3398e41 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/Key1Data.yql @@ -0,0 +1,16 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let source_any (DataSource 'yt '"$all")) + +(let world (Configure! world source_any '"Attr" '"inferschema" '"1")) +(let world (Configure! world source_any '"Attr" '"maxrowweight" '"128m")) + +(let x (Read! world mr_source (Key '('table (String 'Input)) '('view (String 'key1))) '('column0) '() ) ) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/Key1Scheme.yql b/yql/essentials/tests/s-expressions/suites/View/Key1Scheme.yql new file mode 100644 index 0000000000..5d429021c3 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/Key1Scheme.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('tablescheme (String 'Input)) '('view (String 'key1))) (Void) '()) ) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/MasterScheme.yql b/yql/essentials/tests/s-expressions/suites/View/MasterScheme.yql new file mode 100644 index 0000000000..0a9e55e5a5 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/MasterScheme.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('tablescheme (String 'Input))) (Void) '()) ) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/NoReadData.yql b/yql/essentials/tests/s-expressions/suites/View/NoReadData.yql new file mode 100644 index 0000000000..7e27b9b42a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/NoReadData.yql @@ -0,0 +1,16 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let source_any (DataSource 'yt '"$all")) + +(let world (Configure! world source_any '"Attr" '"inferschema" '"1")) +(let world (Configure! world source_any '"Attr" '"maxrowweight" '"128m")) + +(let x (Read! world mr_source (Key '('table (String 'Input)) '('view (String 'noread))) '('value) '() ) ) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/NoReadScheme.yql b/yql/essentials/tests/s-expressions/suites/View/NoReadScheme.yql new file mode 100644 index 0000000000..b231e96834 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/NoReadScheme.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('tablescheme (String 'Input)) '('view (String 'noread))) (Void) '()) ) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/RawView.cfg b/yql/essentials/tests/s-expressions/suites/View/RawView.cfg new file mode 100644 index 0000000000..61289d7a17 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/RawView.cfg @@ -0,0 +1,4 @@ +in Input1 input2.txt +in Input2 input5.txt +res result.txt +udf dummylog diff --git a/yql/essentials/tests/s-expressions/suites/View/RawView.yql b/yql/essentials/tests/s-expressions/suites/View/RawView.yql new file mode 100644 index 0000000000..d23c50d85c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/RawView.yql @@ -0,0 +1,40 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let res_sink (DataSink 'result)) +(let source_any (DataSource 'yt '"$all")) + +(let world (Configure! world source_any '"Attr" '"inferschema" '"1")) +(let world (Configure! world source_any '"Attr" '"maxrowweight" '"128m")) + +(let x (Read! world mr_source (Key + '('table (String 'Input1)) + '('view (String 'raw)) +) (Void) '())) + +(let world (Left! x)) +(let data (Right! x)) + +(let world (Write! world res_sink (Key) data '())) + +(let x (Read! world mr_source (Key + '('table (String 'Input1)) +) (Void) '())) + +(let world (Left! x)) +(let data (Right! x)) + +(let world (Write! world res_sink (Key) data '())) + +(let x (Read! world mr_source (Key + '('table (String 'Input2)) + '('view (String 'raw)) +) (Void) '())) + +(let world (Left! x)) +(let data (Right! x)) + +(let world (Write! world res_sink (Key) data '())) + +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/ReadGlobView.cfg b/yql/essentials/tests/s-expressions/suites/View/ReadGlobView.cfg new file mode 100644 index 0000000000..2ac9312f92 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/ReadGlobView.cfg @@ -0,0 +1,4 @@ +in Input1 input.txt +in Input2 input6.txt +in InputView input_view.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/View/ReadGlobView.yql b/yql/essentials/tests/s-expressions/suites/View/ReadGlobView.yql new file mode 100644 index 0000000000..8588e4df39 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/ReadGlobView.yql @@ -0,0 +1,21 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) +(let res_sink (DataSink 'result)) +(let source_any (DataSource 'yt '"$all")) + +(let world (Configure! world source_any '"Attr" '"inferschema" '"1")) +(let world (Configure! world source_any '"Attr" '"maxrowweight" '"128m")) + +(let x (Read! world mr_source (Key + '('table (String 'InputView)) +) (Void) '())) + +(let world (Left! x)) +(let data (Right! x)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/SchemeGlobView.cfg b/yql/essentials/tests/s-expressions/suites/View/SchemeGlobView.cfg new file mode 100644 index 0000000000..2ac9312f92 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/SchemeGlobView.cfg @@ -0,0 +1,4 @@ +in Input1 input.txt +in Input2 input6.txt +in InputView input_view.txt +res result.txt diff --git a/yql/essentials/tests/s-expressions/suites/View/SchemeGlobView.yql b/yql/essentials/tests/s-expressions/suites/View/SchemeGlobView.yql new file mode 100644 index 0000000000..c90fdf788a --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/SchemeGlobView.yql @@ -0,0 +1,17 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let mr_sink (DataSink 'yt 'plato)) +(let res_sink (DataSink 'result)) + +(let x (Read! world mr_source (Key + '('tablescheme (String 'InputView)) +) (Void) '())) + +(let world (Left! x)) +(let data (Right! x)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/TrivialDataCopy.cfg b/yql/essentials/tests/s-expressions/suites/View/TrivialDataCopy.cfg new file mode 100644 index 0000000000..ad52c79527 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/TrivialDataCopy.cfg @@ -0,0 +1,2 @@ +in Input input.txt +out Output output.txt diff --git a/yql/essentials/tests/s-expressions/suites/View/TrivialDataCopy.yql b/yql/essentials/tests/s-expressions/suites/View/TrivialDataCopy.yql new file mode 100644 index 0000000000..f5eb0c356b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/TrivialDataCopy.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('table (String 'Input)) '('view (String 'trivial))) '('value) '() ) ) +(let world (Left! x)) +(let table1 (Right! x)) +(let mr_sink (DataSink 'yt 'plato)) +(let world (Write! world mr_sink (Key '('table (String 'Output)) ) table1 '() )) +(let world (Commit! world mr_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/TrivialScheme.yql b/yql/essentials/tests/s-expressions/suites/View/TrivialScheme.yql new file mode 100644 index 0000000000..8062a7feb8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/TrivialScheme.yql @@ -0,0 +1,11 @@ +( +#comment +(let mr_source (DataSource 'yt 'plato)) +(let x (Read! world mr_source (Key '('tablescheme (String 'Input)) '('view (String 'trivial))) (Void) '()) ) +(let world (Left! x)) +(let table1 (Right! x)) +(let res_sink (DataSink 'result)) +(let world (Write! world res_sink (Key) table1 '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/ViewWithUdf.cfg b/yql/essentials/tests/s-expressions/suites/View/ViewWithUdf.cfg new file mode 100644 index 0000000000..d3e8c7c671 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/ViewWithUdf.cfg @@ -0,0 +1,3 @@ +in Input input4.txt +res result.txt +udf simple_udf diff --git a/yql/essentials/tests/s-expressions/suites/View/ViewWithUdf.yql b/yql/essentials/tests/s-expressions/suites/View/ViewWithUdf.yql new file mode 100644 index 0000000000..4d2b6066ad --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/ViewWithUdf.yql @@ -0,0 +1,16 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let res_sink (DataSink 'result)) + +(let x (Read! world mr_source (Key + '('table (String 'Input)) + '('view (String 'key1)) +) (Void) '())) + +(let world (Left! x)) +(let data (Right! x)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/ViewWithUdfProcess.cfg b/yql/essentials/tests/s-expressions/suites/View/ViewWithUdfProcess.cfg new file mode 100644 index 0000000000..b2849b4f98 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/ViewWithUdfProcess.cfg @@ -0,0 +1,3 @@ +in Input input6.txt +res result.txt +udf python2_udf diff --git a/yql/essentials/tests/s-expressions/suites/View/ViewWithUdfProcess.yql b/yql/essentials/tests/s-expressions/suites/View/ViewWithUdfProcess.yql new file mode 100644 index 0000000000..e5dc7a8838 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/ViewWithUdfProcess.yql @@ -0,0 +1,16 @@ +( +(let mr_source (DataSource 'yt 'plato)) +(let res_sink (DataSink 'result)) + +(let x (Read! world mr_source (Key + '('table (String 'Input)) + '('view (String 'my)) +) (Void) '())) + +(let world (Left! x)) +(let data (Right! x)) + +(let world (Write! world res_sink (Key) data '())) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/View/default.cfg b/yql/essentials/tests/s-expressions/suites/View/default.cfg new file mode 100644 index 0000000000..fe2b19a9ff --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/default.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/View/input.txt b/yql/essentials/tests/s-expressions/suites/View/input.txt new file mode 100644 index 0000000000..df76c64125 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/input.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="1";"value"="a7c"}; +{"key"="800";"subkey"="2";"value"="ddd"}; +{"key"="020";"subkey"="3";"value"="q"}; +{"key"="150";"subkey"="4";"value"="q8z"}; diff --git a/yql/essentials/tests/s-expressions/suites/View/input.txt.attr b/yql/essentials/tests/s-expressions/suites/View/input.txt.attr new file mode 100644 index 0000000000..06c67fd2cb --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/input.txt.attr @@ -0,0 +1,33 @@ +{ + "_yql_view_trivial"="SELECT key, subkey, value FROM self"; + "_yql_view_key1"="SELECT key || \"key\" FROM self"; + "_yql_view_noread"="SELECT 1 as key, 2 as value"; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/View/input2.txt b/yql/essentials/tests/s-expressions/suites/View/input2.txt new file mode 100644 index 0000000000..df76c64125 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/input2.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="1";"value"="a7c"}; +{"key"="800";"subkey"="2";"value"="ddd"}; +{"key"="020";"subkey"="3";"value"="q"}; +{"key"="150";"subkey"="4";"value"="q8z"}; diff --git a/yql/essentials/tests/s-expressions/suites/View/input2.txt.attr b/yql/essentials/tests/s-expressions/suites/View/input2.txt.attr new file mode 100644 index 0000000000..4e7dfb3804 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/input2.txt.attr @@ -0,0 +1,37 @@ +{ + "_yql_view_trivial"="SELECT key, subkey, value FROM self"; + "_yql_view_key1"="SELECT key || \"key\" FROM self"; + "_yql_view_key2"="SELECT key || \"key\" FROM self_raw"; + "_yql_view_noread"="SELECT 1 as key, 2 as value"; + "_yql_read_udf"="DummyLog.ReadRecord2"; + "_yql_read_udf_type_config"="AAA"; + "_yql_read_udf_run_config"="BBB"; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/View/input3.txt b/yql/essentials/tests/s-expressions/suites/View/input3.txt new file mode 100644 index 0000000000..ad6793f93c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/input3.txt @@ -0,0 +1,4 @@ +{"key"="075";"subkey"="1";"value"="a=B@@b=a@@c=a"}; +{"key"="800";"subkey"="2";"value"="b=1@@c=2@@d=3"}; +{"key"="020";"subkey"="3";"value"="a=i@@c=j"}; +{"key"="150";"subkey"="4";"value"="a=A"}; diff --git a/yql/essentials/tests/s-expressions/suites/View/input3.txt.attr b/yql/essentials/tests/s-expressions/suites/View/input3.txt.attr new file mode 100644 index 0000000000..14544c6d7b --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/input3.txt.attr @@ -0,0 +1,32 @@ +{ + "_yql_read_udf"="Dsv.ReadRecord"; + "_yql_read_udf_run_config"="@@"; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/View/input4.txt b/yql/essentials/tests/s-expressions/suites/View/input4.txt new file mode 100644 index 0000000000..d15f960f63 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/input4.txt @@ -0,0 +1,10 @@ +{"key"="0";"subkey"="-";"value"="zero"}; +{"key"="1";"subkey"="-";"value"="one"}; +{"key"="2";"subkey"="-";"value"="two"}; +{"key"="3";"subkey"="-";"value"="three"}; +{"key"="4";"subkey"="-";"value"="four"}; +{"key"="5";"subkey"="-";"value"="five"}; +{"key"="6";"subkey"="-";"value"="six"}; +{"key"="7";"subkey"="-";"value"="seven"}; +{"key"="8";"subkey"="-";"value"="eight"}; +{"key"="9";"subkey"="-";"value"="nine"}; diff --git a/yql/essentials/tests/s-expressions/suites/View/input4.txt.attr b/yql/essentials/tests/s-expressions/suites/View/input4.txt.attr new file mode 100644 index 0000000000..e6e4b7d750 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/input4.txt.attr @@ -0,0 +1,32 @@ +{ + "_yql_view_key1"="SELECT SimpleUdf::Concat(SimpleUdf::Concat(key, \" - \"), value) FROM self"; + "_yql_view_key2"="SELECT key || \"key\" FROM self_raw"; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/View/input5.txt b/yql/essentials/tests/s-expressions/suites/View/input5.txt new file mode 100644 index 0000000000..24f23d3d81 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/input5.txt @@ -0,0 +1 @@ +{"key"="foo";"subkey"=".";"value"="bar"}; diff --git a/yql/essentials/tests/s-expressions/suites/View/input5.txt.attr b/yql/essentials/tests/s-expressions/suites/View/input5.txt.attr new file mode 100644 index 0000000000..b6100e5fd0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/input5.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/View/input6.txt b/yql/essentials/tests/s-expressions/suites/View/input6.txt new file mode 100644 index 0000000000..d15f960f63 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/input6.txt @@ -0,0 +1,10 @@ +{"key"="0";"subkey"="-";"value"="zero"}; +{"key"="1";"subkey"="-";"value"="one"}; +{"key"="2";"subkey"="-";"value"="two"}; +{"key"="3";"subkey"="-";"value"="three"}; +{"key"="4";"subkey"="-";"value"="four"}; +{"key"="5";"subkey"="-";"value"="five"}; +{"key"="6";"subkey"="-";"value"="six"}; +{"key"="7";"subkey"="-";"value"="seven"}; +{"key"="8";"subkey"="-";"value"="eight"}; +{"key"="9";"subkey"="-";"value"="nine"}; diff --git a/yql/essentials/tests/s-expressions/suites/View/input6.txt.attr b/yql/essentials/tests/s-expressions/suites/View/input6.txt.attr new file mode 100644 index 0000000000..501fdca6db --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/input6.txt.attr @@ -0,0 +1,31 @@ +{ + "_yql_view_my"="$udfScript=\"def f(row):\n\treturn {'myvalue':b'm' + row.value}\n\";$udf=Python::f(Callable<(Struct<key:String,subkey:String,value:String>)->Struct<myvalue:String>>, $udfScript);PROCESS self USING $udf(TableRow());"; + "_yql_row_spec" = { + "Type" = [ + "StructType"; + [ + [ + "key"; + [ + "DataType"; + "String" + ] + ]; + [ + "subkey"; + [ + "DataType"; + "String" + ] + ]; + [ + "value"; + [ + "DataType"; + "String" + ] + ] + ] + ] + } +} diff --git a/yql/essentials/tests/s-expressions/suites/View/input_view.txt b/yql/essentials/tests/s-expressions/suites/View/input_view.txt new file mode 100644 index 0000000000..d664c9eec9 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/input_view.txt @@ -0,0 +1,10 @@ +$f = ($x)->{return $x+1}; + +select key,min(num) as num from ( +select key,$f(0) as `num` from Input1 +union all +select key,$f(1) as `num` from Input2 +) +group by key +order by key + diff --git a/yql/essentials/tests/s-expressions/suites/View/input_view.txt.attr b/yql/essentials/tests/s-expressions/suites/View/input_view.txt.attr new file mode 100644 index 0000000000..41ea51e276 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/View/input_view.txt.attr @@ -0,0 +1,4 @@ +{ + "_yql_type"="view"; + "type"="document"; +} diff --git a/yql/essentials/tests/s-expressions/suites/YtNative/PureImportUdf.cfg b/yql/essentials/tests/s-expressions/suites/YtNative/PureImportUdf.cfg new file mode 100644 index 0000000000..907c9ea175 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/YtNative/PureImportUdf.cfg @@ -0,0 +1,3 @@ +res result.txt +file myfile yql/essentials/udfs/test/test_import/libtest_import_udf.so +os linux diff --git a/yql/essentials/tests/s-expressions/suites/YtNative/PureImportUdf.yql b/yql/essentials/tests/s-expressions/suites/YtNative/PureImportUdf.yql new file mode 100644 index 0000000000..92abfcd35c --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/YtNative/PureImportUdf.yql @@ -0,0 +1,12 @@ +# not supported on windows +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'ImportUdfs 'myfile)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) +(let data (Apply (Udf 'TestImportUdf.Concat) (String 'abc) (String '""))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/YtNative/PureList.yql b/yql/essentials/tests/s-expressions/suites/YtNative/PureList.yql new file mode 100644 index 0000000000..224d23514f --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/YtNative/PureList.yql @@ -0,0 +1,10 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) +(let data (AsList (Uint32 '1))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/YtNative/PureLongList.yql b/yql/essentials/tests/s-expressions/suites/YtNative/PureLongList.yql new file mode 100644 index 0000000000..94a8922948 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/YtNative/PureLongList.yql @@ -0,0 +1,15 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) +(let data (AsList (Uint32 '1))) +(let data (Extend data data data data data)) +(let data (Extend data data data data data)) +(let data (Extend data data data data data)) +(let data (Extend data data data data data)) +(let data (Extend data data)) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/YtNative/PureNonList.yql b/yql/essentials/tests/s-expressions/suites/YtNative/PureNonList.yql new file mode 100644 index 0000000000..eb00aa902e --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/YtNative/PureNonList.yql @@ -0,0 +1,10 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) +(let data (Uint32 '1)) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/YtNative/PureStructList.yql b/yql/essentials/tests/s-expressions/suites/YtNative/PureStructList.yql new file mode 100644 index 0000000000..0c6513f8c7 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/YtNative/PureStructList.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) +(let data (AsList + (AsStruct '('b (Uint32 '1)) '('a (String 'a)) '('c (String 'DDD))) + (AsStruct '('b (Uint32 '2)) '('a (String 'b)) '('c (String 'EEE))) +)) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/YtNative/PureStructListWithFields.yql b/yql/essentials/tests/s-expressions/suites/YtNative/PureStructListWithFields.yql new file mode 100644 index 0000000000..623ed4b8b0 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/YtNative/PureStructListWithFields.yql @@ -0,0 +1,13 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) +(let data (AsList + (AsStruct '('b (Uint32 '1)) '('a (String 'a)) '('c (String 'DDD))) + (AsStruct '('b (Uint32 '2)) '('a (String 'b)) '('c (String 'EEE))) +)) +(let world (Write! world res_sink (Key) data '('('type) '('columns '('c 'a 'b))))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/YtNative/PureUdf.cfg b/yql/essentials/tests/s-expressions/suites/YtNative/PureUdf.cfg new file mode 100644 index 0000000000..8da645df35 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/YtNative/PureUdf.cfg @@ -0,0 +1,3 @@ +res result.txt +udf simple_udf + diff --git a/yql/essentials/tests/s-expressions/suites/YtNative/PureUdf.yql b/yql/essentials/tests/s-expressions/suites/YtNative/PureUdf.yql new file mode 100644 index 0000000000..0f09553c83 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/YtNative/PureUdf.yql @@ -0,0 +1,10 @@ +( +#comment +(let config (DataSource 'config)) +(let world (Configure! world config 'PureDataSource 'yt)) +(let res_sink (DataSink 'result)) +(let data (Apply (Udf 'SimpleUdf.Echo) (String 'abc))) +(let world (Write! world res_sink (Key) data '('('type)))) +(let world (Commit! world res_sink)) +(return world) +) diff --git a/yql/essentials/tests/s-expressions/suites/YtNative/default.cfg b/yql/essentials/tests/s-expressions/suites/YtNative/default.cfg new file mode 100644 index 0000000000..00dec6c3f8 --- /dev/null +++ b/yql/essentials/tests/s-expressions/suites/YtNative/default.cfg @@ -0,0 +1 @@ +res result.txt |