Skip to content

Commit 4723902

Browse files
committed
Add two cases with null.
1 parent 092605b commit 4723902

File tree

2 files changed

+41
-28
lines changed

2 files changed

+41
-28
lines changed

sql/core/src/test/resources/sql-tests/inputs/inline-table.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ select * from values ("one", 1) as data;
99
select * from values ("one", 1) as data(a, b);
1010

1111
-- two rows
12-
select * from values ("one", 1), ("two", 2) as data(a, b);
12+
select * from values ("one", 1), ("two", 2), ("three", null) as data(a, b);
13+
14+
-- null type
15+
select * from values ("one", null), ("two", null) as data(a, b);
1316

1417
-- int and long coercion
1518
select * from values ("one", 1), ("two", 2L) as data(a, b);
Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Automatically generated by SQLQueryTestSuite
2-
-- Number of queries: 13
2+
-- Number of queries: 14
33

44

55
-- !query 0
@@ -27,90 +27,100 @@ one 1
2727

2828

2929
-- !query 3
30-
select * from values ("one", 1), ("two", 2) as data(a, b)
30+
select * from values ("one", 1), ("two", 2), ("three", null) as data(a, b)
3131
-- !query 3 schema
3232
struct<a:string,b:int>
3333
-- !query 3 output
3434
one 1
35+
three NULL
3536
two 2
3637

3738

3839
-- !query 4
39-
select * from values ("one", 1), ("two", 2L) as data(a, b)
40+
select * from values ("one", null), ("two", null) as data(a, b)
4041
-- !query 4 schema
41-
struct<a:string,b:bigint>
42+
struct<a:string,b:null>
4243
-- !query 4 output
43-
one 1
44-
two 2
44+
one NULL
45+
two NULL
4546

4647

4748
-- !query 5
48-
select * from values ("one", 1 + 0), ("two", 1 + 3L) as data(a, b)
49+
select * from values ("one", 1), ("two", 2L) as data(a, b)
4950
-- !query 5 schema
5051
struct<a:string,b:bigint>
5152
-- !query 5 output
5253
one 1
53-
two 4
54+
two 2
5455

5556

5657
-- !query 6
57-
select * from values ("one", array(0, 1)), ("two", array(2, 3)) as data(a, b)
58+
select * from values ("one", 1 + 0), ("two", 1 + 3L) as data(a, b)
5859
-- !query 6 schema
59-
struct<a:string,b:array<int>>
60+
struct<a:string,b:bigint>
6061
-- !query 6 output
61-
one [0,1]
62-
two [2,3]
62+
one 1
63+
two 4
6364

6465

6566
-- !query 7
66-
select * from values ("one", 2.0), ("two", 3.0D) as data(a, b)
67+
select * from values ("one", array(0, 1)), ("two", array(2, 3)) as data(a, b)
6768
-- !query 7 schema
68-
struct<a:string,b:double>
69+
struct<a:string,b:array<int>>
6970
-- !query 7 output
70-
one 2.0
71-
two 3.0
71+
one [0,1]
72+
two [2,3]
7273

7374

7475
-- !query 8
75-
select * from values ("one", 2.0), ("two") as data(a, b)
76+
select * from values ("one", 2.0), ("two", 3.0D) as data(a, b)
7677
-- !query 8 schema
77-
struct<>
78+
struct<a:string,b:double>
7879
-- !query 8 output
79-
org.apache.spark.sql.AnalysisException
80-
expected 2 columns but found 1 columns in row 1; line 1 pos 14
80+
one 2.0
81+
two 3.0
8182

8283

8384
-- !query 9
84-
select * from values ("one", array(0, 1)), ("two", struct(1, 2)) as data(a, b)
85+
select * from values ("one", 2.0), ("two") as data(a, b)
8586
-- !query 9 schema
8687
struct<>
8788
-- !query 9 output
8889
org.apache.spark.sql.AnalysisException
89-
incompatible types found in column 1 for inline table; line 1 pos 14
90+
expected 2 columns but found 1 columns in row 1; line 1 pos 14
9091

9192

9293
-- !query 10
93-
select * from values ("one"), ("two") as data(a, b)
94+
select * from values ("one", array(0, 1)), ("two", struct(1, 2)) as data(a, b)
9495
-- !query 10 schema
9596
struct<>
9697
-- !query 10 output
9798
org.apache.spark.sql.AnalysisException
98-
expected 2 columns but found 1 in first row; line 1 pos 14
99+
incompatible types found in column 1 for inline table; line 1 pos 14
99100

100101

101102
-- !query 11
102-
select * from values ("one", random_not_exist_func(1)), ("two", 2) as data(a, b)
103+
select * from values ("one"), ("two") as data(a, b)
103104
-- !query 11 schema
104105
struct<>
105106
-- !query 11 output
106107
org.apache.spark.sql.AnalysisException
107-
Undefined function: 'random_not_exist_func'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.; line 1 pos 29
108+
expected 2 columns but found 1 in first row; line 1 pos 14
108109

109110

110111
-- !query 12
111-
select * from values ("one", count(1)), ("two", 2) as data(a, b)
112+
select * from values ("one", random_not_exist_func(1)), ("two", 2) as data(a, b)
112113
-- !query 12 schema
113114
struct<>
114115
-- !query 12 output
115116
org.apache.spark.sql.AnalysisException
117+
Undefined function: 'random_not_exist_func'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.; line 1 pos 29
118+
119+
120+
-- !query 13
121+
select * from values ("one", count(1)), ("two", 2) as data(a, b)
122+
-- !query 13 schema
123+
struct<>
124+
-- !query 13 output
125+
org.apache.spark.sql.AnalysisException
116126
cannot evaluate expression count(1) in inline table definition; line 1 pos 29

0 commit comments

Comments
 (0)