aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/flatten_by/flatten_dict.sql
blob: a9618c7aac7d417e3e5894c56b08ed0ce7c73fbe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
/* syntax version 1 */
/* postgres can not */
pragma sampleselect;

$data_dict = (select mod, YQL::ToIndexDict(ListSort(aggregate_list(key))) as dk, ListSort(aggregate_list(subkey)) as ls, ListSort(aggregate_list(value)) as lv from plato.Input group by cast(key as uint32) % 10 as mod);

select
  mod, iv, ls,
  dd.di.0 as key,
  dd.di.1 as value
from $data_dict as dd
flatten by (dk as di, lv as iv, ls)
order by mod, iv, ls, key, value;