summaryrefslogtreecommitdiffstats
path: root/yt/yql/tests/sql/suites/window/win_func_with_struct_access.yql
blob: 47c0a0001e830a3abd3e3c87a0f3393cb43c6ec8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* postgres can not */
USE plato;

$input=(SELECT
  Cast(key as int32) / 100 as key_hundred,
  AsStruct(
    Cast(key as int32) as key,
    Cast(subkey as int32) as subkey
  ) as `struct`,
  value
FROM Input as inSrc);

--INSERT INTO Output
SELECT
  key_hundred as a_part,
  `struct`.key - lead(`struct`.key, 1) over w as keyDiff,
  value
FROM $input as outSrc
WINDOW w as (partition by key_hundred ORDER BY `struct`.key, value)
ORDER by a_part, value
;