aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/sql/suites/optimizers/yql-6038_direct_row.sql
blob: 05c67797828edb555191ff751e2f3665e568c3cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* syntax version 1 */
/* postgres can not */
USE plato;

$queries_0 = (select distinct key from Input);

$queries = (select TableRecordIndex() as j, key from $queries_0);

$count = (select count(*) from $queries);

$users_0 = (
  select ListFromRange(0, 3) as lst, TableRecordIndex() as idx, subkey from Input as t
);

$users = (
    select
        cast(Random(idx + x) as Uint64) % $count as j,
        subkey
    from $users_0
    flatten by lst as x
);

select *
from $queries as queries join $users as users using(j)
order by key, subkey;