summaryrefslogtreecommitdiffstats
path: root/tests/fixtures/optimizer/expand_laterals.sql
blob: 09bbd0f3c4a8af7f86124658a30aa6f2e4763a78 (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# title: expand alias reference
SELECT
  x.a + 1 AS i,
  i + 1 AS j,
  j + 1 AS k
FROM x;
SELECT
  x.a + 1 AS i,
  x.a + 1 + 1 AS j,
  x.a + 1 + 1 + 1 AS k
FROM x;

# title: noop - reference comes before alias
SELECT
  b + 1 AS j,
  x.a + 1 AS i
FROM x;
SELECT
  b + 1 AS j,
  x.a + 1 AS i
FROM x;


# title: subquery
SELECT
  *
FROM (
  SELECT
    x.a + 1 AS i,
    i + 1 AS j
  FROM x
);
SELECT
  *
FROM (
  SELECT
    x.a + 1 AS i,
    x.a + 1 + 1 AS j
  FROM x
);