Skip to content

Commit bc683f0

Browse files
petermaxleerxin
authored andcommitted
[SPARK-17018][SQL] literals.sql for testing literal parsing
## What changes were proposed in this pull request? This patch adds literals.sql for testing literal parsing end-to-end in SQL. ## How was this patch tested? The patch itself is only about adding test cases. Author: petermaxlee <petermaxlee@gmail.com> Closes #14598 from petermaxlee/SPARK-17018-2. (cherry picked from commit cf93678) Signed-off-by: Reynold Xin <rxin@databricks.com>
1 parent 6bf20cd commit bc683f0

5 files changed

Lines changed: 476 additions & 62 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
-- Literal parsing
2+
3+
-- null
4+
select null, Null, nUll;
5+
6+
-- boolean
7+
select true, tRue, false, fALse;
8+
9+
-- byte (tinyint)
10+
select 1Y;
11+
select 127Y, -128Y;
12+
13+
-- out of range byte
14+
select 128Y;
15+
16+
-- short (smallint)
17+
select 1S;
18+
select 32767S, -32768S;
19+
20+
-- out of range short
21+
select 32768S;
22+
23+
-- long (bigint)
24+
select 1L, 2147483648L;
25+
select 9223372036854775807L, -9223372036854775808L;
26+
27+
-- out of range long
28+
select 9223372036854775808L;
29+
30+
-- integral parsing
31+
32+
-- parse int
33+
select 1, -1;
34+
35+
-- parse int max and min value as int
36+
select 2147483647, -2147483648;
37+
38+
-- parse long max and min value as long
39+
select 9223372036854775807, -9223372036854775808;
40+
41+
-- parse as decimals (Long.MaxValue + 1, and Long.MinValue - 1)
42+
select 9223372036854775808, -9223372036854775809;
43+
44+
-- out of range decimal numbers
45+
select 1234567890123456789012345678901234567890;
46+
select 1234567890123456789012345678901234567890.0;
47+
48+
-- double
49+
select 1D, 1.2D, 1e10, 1.5e5, .10D, 0.10D, .1e5, .9e+2, 0.9e+2, 900e-1, 9.e+1;
50+
select -1D, -1.2D, -1e10, -1.5e5, -.10D, -0.10D, -.1e5;
51+
-- negative double
52+
select .e3;
53+
-- inf and -inf
54+
select 1E309, -1E309;
55+
56+
-- decimal parsing
57+
select 0.3, -0.8, .5, -.18, 0.1111, .1111;
58+
59+
-- super large scientific notation numbers should still be valid doubles
60+
select 123456789012345678901234567890123456789e10, 123456789012345678901234567890123456789.1e10;
61+
62+
-- string
63+
select "Hello Peter!", 'hello lee!';
64+
-- multi string
65+
select 'hello' 'world', 'hello' " " 'lee';
66+
-- single quote within double quotes
67+
select "hello 'peter'";
68+
select 'pattern%', 'no-pattern\%', 'pattern\\%', 'pattern\\\%';
69+
select '\'', '"', '\n', '\r', '\t', 'Z';
70+
-- "Hello!" in octals
71+
select '\110\145\154\154\157\041';
72+
-- "World :)" in unicode
73+
select '\u0057\u006F\u0072\u006C\u0064\u0020\u003A\u0029';
74+
75+
-- date
76+
select dAte '2016-03-12';
77+
-- invalid date
78+
select date 'mar 11 2016';
79+
80+
-- timestamp
81+
select tImEstAmp '2016-03-11 20:54:00.000';
82+
-- invalid timestamp
83+
select timestamp '2016-33-11 20:54:00.000';
84+
85+
-- interval
86+
select interval 13.123456789 seconds, interval -13.123456789 second;
87+
select interval 1 year 2 month 3 week 4 day 5 hour 6 minute 7 seconds 8 millisecond, 9 microsecond;
88+
-- ns is not supported
89+
select interval 10 nanoseconds;
90+
91+
-- unsupported data type
92+
select GEO '(10,-6)';

sql/core/src/test/resources/sql-tests/inputs/number-format.sql

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)