File: cast_with_whitespaces.sql

package info (click to toggle)
sqlfluff 3.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,000 kB
  • sloc: python: 106,131; sql: 34,188; makefile: 52; sh: 8
file content (42 lines) | stat: -rw-r--r-- 1,136 bytes parent folder | download | duplicates (3)
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
41
42
-- postgres_cast_with_whitespaces.sql
/* Several valid queries where there is whitespace surrounding the Postgres
cast operator (::) */

-- query from https://github.com/sqlfluff/sqlfluff/issues/2720
SELECT amount_of_honey :: FLOAT
FROM bear_inventory;


-- should be able to support an arbitrary amount of whitespace
SELECT amount_of_honey        ::        FLOAT
FROM bear_inventory;

SELECT amount_of_honey::    FLOAT
FROM bear_inventory;

SELECT amount_of_honey        ::FLOAT
FROM bear_inventory;

-- should support a wide variety of typecasts
SELECT amount_of_honey :: time
FROM bear_inventory;

SELECT amount_of_honey :: text
FROM bear_inventory;

SELECT amount_of_honey     :: VARCHAR( 512 )
FROM bear_inventory;

SELECT amount_of_honey ::        TIMESTAMPTZ
FROM bear_inventory;

SELECT amount_of_honey    ::        TIMESTAMP WITHOUT TIME ZONE
FROM bear_inventory;

-- should support casts with arbitrary amount of whitespace in join statements
SELECT
    bi.amount_of_honey
FROM bear_inventory bi
LEFT JOIN favorite_cola fc
    ON fc.bear_id ::   VARCHAR(512) = bi.bear_id    ::VARCHAR(512)
WHERE fc.favorite_cola = 'RC Cola';