Skip to content
This repository was archived by the owner on Jan 9, 2020. It is now read-only.

Commit 4677623

Browse files
wangyumgatorsmile
authored andcommitted
[SPARK-22762][TEST] Basic tests for IfCoercion and CaseWhenCoercion
## What changes were proposed in this pull request? Basic tests for IfCoercion and CaseWhenCoercion ## How was this patch tested? N/A Author: Yuming Wang <[email protected]> Closes apache#19949 from wangyum/SPARK-22762.
1 parent 9fafa82 commit 4677623

File tree

4 files changed

+2812
-0
lines changed

4 files changed

+2812
-0
lines changed
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
--
2+
-- Licensed to the Apache Software Foundation (ASF) under one or more
3+
-- contributor license agreements. See the NOTICE file distributed with
4+
-- this work for additional information regarding copyright ownership.
5+
-- The ASF licenses this file to You under the Apache License, Version 2.0
6+
-- (the "License"); you may not use this file except in compliance with
7+
-- the License. You may obtain a copy of the License at
8+
--
9+
-- http://www.apache.org/licenses/LICENSE-2.0
10+
--
11+
-- Unless required by applicable law or agreed to in writing, software
12+
-- distributed under the License is distributed on an "AS IS" BASIS,
13+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
-- See the License for the specific language governing permissions and
15+
-- limitations under the License.
16+
--
17+
18+
CREATE TEMPORARY VIEW t AS SELECT 1;
19+
20+
SELECT CASE WHEN true THEN cast(1 as tinyint) ELSE cast(2 as tinyint) END FROM t;
21+
SELECT CASE WHEN true THEN cast(1 as tinyint) ELSE cast(2 as smallint) END FROM t;
22+
SELECT CASE WHEN true THEN cast(1 as tinyint) ELSE cast(2 as int) END FROM t;
23+
SELECT CASE WHEN true THEN cast(1 as tinyint) ELSE cast(2 as bigint) END FROM t;
24+
SELECT CASE WHEN true THEN cast(1 as tinyint) ELSE cast(2 as float) END FROM t;
25+
SELECT CASE WHEN true THEN cast(1 as tinyint) ELSE cast(2 as double) END FROM t;
26+
SELECT CASE WHEN true THEN cast(1 as tinyint) ELSE cast(2 as decimal(10, 0)) END FROM t;
27+
SELECT CASE WHEN true THEN cast(1 as tinyint) ELSE cast(2 as string) END FROM t;
28+
SELECT CASE WHEN true THEN cast(1 as tinyint) ELSE cast('2' as binary) END FROM t;
29+
SELECT CASE WHEN true THEN cast(1 as tinyint) ELSE cast(2 as boolean) END FROM t;
30+
SELECT CASE WHEN true THEN cast(1 as tinyint) ELSE cast('2017-12-11 09:30:00.0' as timestamp) END FROM t;
31+
SELECT CASE WHEN true THEN cast(1 as tinyint) ELSE cast('2017-12-11 09:30:00' as date) END FROM t;
32+
33+
SELECT CASE WHEN true THEN cast(1 as smallint) ELSE cast(2 as tinyint) END FROM t;
34+
SELECT CASE WHEN true THEN cast(1 as smallint) ELSE cast(2 as smallint) END FROM t;
35+
SELECT CASE WHEN true THEN cast(1 as smallint) ELSE cast(2 as int) END FROM t;
36+
SELECT CASE WHEN true THEN cast(1 as smallint) ELSE cast(2 as bigint) END FROM t;
37+
SELECT CASE WHEN true THEN cast(1 as smallint) ELSE cast(2 as float) END FROM t;
38+
SELECT CASE WHEN true THEN cast(1 as smallint) ELSE cast(2 as double) END FROM t;
39+
SELECT CASE WHEN true THEN cast(1 as smallint) ELSE cast(2 as decimal(10, 0)) END FROM t;
40+
SELECT CASE WHEN true THEN cast(1 as smallint) ELSE cast(2 as string) END FROM t;
41+
SELECT CASE WHEN true THEN cast(1 as smallint) ELSE cast('2' as binary) END FROM t;
42+
SELECT CASE WHEN true THEN cast(1 as smallint) ELSE cast(2 as boolean) END FROM t;
43+
SELECT CASE WHEN true THEN cast(1 as smallint) ELSE cast('2017-12-11 09:30:00.0' as timestamp) END FROM t;
44+
SELECT CASE WHEN true THEN cast(1 as smallint) ELSE cast('2017-12-11 09:30:00' as date) END FROM t;
45+
46+
SELECT CASE WHEN true THEN cast(1 as int) ELSE cast(2 as tinyint) END FROM t;
47+
SELECT CASE WHEN true THEN cast(1 as int) ELSE cast(2 as smallint) END FROM t;
48+
SELECT CASE WHEN true THEN cast(1 as int) ELSE cast(2 as int) END FROM t;
49+
SELECT CASE WHEN true THEN cast(1 as int) ELSE cast(2 as bigint) END FROM t;
50+
SELECT CASE WHEN true THEN cast(1 as int) ELSE cast(2 as float) END FROM t;
51+
SELECT CASE WHEN true THEN cast(1 as int) ELSE cast(2 as double) END FROM t;
52+
SELECT CASE WHEN true THEN cast(1 as int) ELSE cast(2 as decimal(10, 0)) END FROM t;
53+
SELECT CASE WHEN true THEN cast(1 as int) ELSE cast(2 as string) END FROM t;
54+
SELECT CASE WHEN true THEN cast(1 as int) ELSE cast('2' as binary) END FROM t;
55+
SELECT CASE WHEN true THEN cast(1 as int) ELSE cast(2 as boolean) END FROM t;
56+
SELECT CASE WHEN true THEN cast(1 as int) ELSE cast('2017-12-11 09:30:00.0' as timestamp) END FROM t;
57+
SELECT CASE WHEN true THEN cast(1 as int) ELSE cast('2017-12-11 09:30:00' as date) END FROM t;
58+
59+
SELECT CASE WHEN true THEN cast(1 as bigint) ELSE cast(2 as tinyint) END FROM t;
60+
SELECT CASE WHEN true THEN cast(1 as bigint) ELSE cast(2 as smallint) END FROM t;
61+
SELECT CASE WHEN true THEN cast(1 as bigint) ELSE cast(2 as int) END FROM t;
62+
SELECT CASE WHEN true THEN cast(1 as bigint) ELSE cast(2 as bigint) END FROM t;
63+
SELECT CASE WHEN true THEN cast(1 as bigint) ELSE cast(2 as float) END FROM t;
64+
SELECT CASE WHEN true THEN cast(1 as bigint) ELSE cast(2 as double) END FROM t;
65+
SELECT CASE WHEN true THEN cast(1 as bigint) ELSE cast(2 as decimal(10, 0)) END FROM t;
66+
SELECT CASE WHEN true THEN cast(1 as bigint) ELSE cast(2 as string) END FROM t;
67+
SELECT CASE WHEN true THEN cast(1 as bigint) ELSE cast('2' as binary) END FROM t;
68+
SELECT CASE WHEN true THEN cast(1 as bigint) ELSE cast(2 as boolean) END FROM t;
69+
SELECT CASE WHEN true THEN cast(1 as bigint) ELSE cast('2017-12-11 09:30:00.0' as timestamp) END FROM t;
70+
SELECT CASE WHEN true THEN cast(1 as bigint) ELSE cast('2017-12-11 09:30:00' as date) END FROM t;
71+
72+
SELECT CASE WHEN true THEN cast(1 as float) ELSE cast(2 as tinyint) END FROM t;
73+
SELECT CASE WHEN true THEN cast(1 as float) ELSE cast(2 as smallint) END FROM t;
74+
SELECT CASE WHEN true THEN cast(1 as float) ELSE cast(2 as int) END FROM t;
75+
SELECT CASE WHEN true THEN cast(1 as float) ELSE cast(2 as bigint) END FROM t;
76+
SELECT CASE WHEN true THEN cast(1 as float) ELSE cast(2 as float) END FROM t;
77+
SELECT CASE WHEN true THEN cast(1 as float) ELSE cast(2 as double) END FROM t;
78+
SELECT CASE WHEN true THEN cast(1 as float) ELSE cast(2 as decimal(10, 0)) END FROM t;
79+
SELECT CASE WHEN true THEN cast(1 as float) ELSE cast(2 as string) END FROM t;
80+
SELECT CASE WHEN true THEN cast(1 as float) ELSE cast('2' as binary) END FROM t;
81+
SELECT CASE WHEN true THEN cast(1 as float) ELSE cast(2 as boolean) END FROM t;
82+
SELECT CASE WHEN true THEN cast(1 as float) ELSE cast('2017-12-11 09:30:00.0' as timestamp) END FROM t;
83+
SELECT CASE WHEN true THEN cast(1 as float) ELSE cast('2017-12-11 09:30:00' as date) END FROM t;
84+
85+
SELECT CASE WHEN true THEN cast(1 as double) ELSE cast(2 as tinyint) END FROM t;
86+
SELECT CASE WHEN true THEN cast(1 as double) ELSE cast(2 as smallint) END FROM t;
87+
SELECT CASE WHEN true THEN cast(1 as double) ELSE cast(2 as int) END FROM t;
88+
SELECT CASE WHEN true THEN cast(1 as double) ELSE cast(2 as bigint) END FROM t;
89+
SELECT CASE WHEN true THEN cast(1 as double) ELSE cast(2 as float) END FROM t;
90+
SELECT CASE WHEN true THEN cast(1 as double) ELSE cast(2 as double) END FROM t;
91+
SELECT CASE WHEN true THEN cast(1 as double) ELSE cast(2 as decimal(10, 0)) END FROM t;
92+
SELECT CASE WHEN true THEN cast(1 as double) ELSE cast(2 as string) END FROM t;
93+
SELECT CASE WHEN true THEN cast(1 as double) ELSE cast('2' as binary) END FROM t;
94+
SELECT CASE WHEN true THEN cast(1 as double) ELSE cast(2 as boolean) END FROM t;
95+
SELECT CASE WHEN true THEN cast(1 as double) ELSE cast('2017-12-11 09:30:00.0' as timestamp) END FROM t;
96+
SELECT CASE WHEN true THEN cast(1 as double) ELSE cast('2017-12-11 09:30:00' as date) END FROM t;
97+
98+
SELECT CASE WHEN true THEN cast(1 as decimal(10, 0)) ELSE cast(2 as tinyint) END FROM t;
99+
SELECT CASE WHEN true THEN cast(1 as decimal(10, 0)) ELSE cast(2 as smallint) END FROM t;
100+
SELECT CASE WHEN true THEN cast(1 as decimal(10, 0)) ELSE cast(2 as int) END FROM t;
101+
SELECT CASE WHEN true THEN cast(1 as decimal(10, 0)) ELSE cast(2 as bigint) END FROM t;
102+
SELECT CASE WHEN true THEN cast(1 as decimal(10, 0)) ELSE cast(2 as float) END FROM t;
103+
SELECT CASE WHEN true THEN cast(1 as decimal(10, 0)) ELSE cast(2 as double) END FROM t;
104+
SELECT CASE WHEN true THEN cast(1 as decimal(10, 0)) ELSE cast(2 as decimal(10, 0)) END FROM t;
105+
SELECT CASE WHEN true THEN cast(1 as decimal(10, 0)) ELSE cast(2 as string) END FROM t;
106+
SELECT CASE WHEN true THEN cast(1 as decimal(10, 0)) ELSE cast('2' as binary) END FROM t;
107+
SELECT CASE WHEN true THEN cast(1 as decimal(10, 0)) ELSE cast(2 as boolean) END FROM t;
108+
SELECT CASE WHEN true THEN cast(1 as decimal(10, 0)) ELSE cast('2017-12-11 09:30:00.0' as timestamp) END FROM t;
109+
SELECT CASE WHEN true THEN cast(1 as decimal(10, 0)) ELSE cast('2017-12-11 09:30:00' as date) END FROM t;
110+
111+
SELECT CASE WHEN true THEN cast(1 as string) ELSE cast(2 as tinyint) END FROM t;
112+
SELECT CASE WHEN true THEN cast(1 as string) ELSE cast(2 as smallint) END FROM t;
113+
SELECT CASE WHEN true THEN cast(1 as string) ELSE cast(2 as int) END FROM t;
114+
SELECT CASE WHEN true THEN cast(1 as string) ELSE cast(2 as bigint) END FROM t;
115+
SELECT CASE WHEN true THEN cast(1 as string) ELSE cast(2 as float) END FROM t;
116+
SELECT CASE WHEN true THEN cast(1 as string) ELSE cast(2 as double) END FROM t;
117+
SELECT CASE WHEN true THEN cast(1 as string) ELSE cast(2 as decimal(10, 0)) END FROM t;
118+
SELECT CASE WHEN true THEN cast(1 as string) ELSE cast(2 as string) END FROM t;
119+
SELECT CASE WHEN true THEN cast(1 as string) ELSE cast('2' as binary) END FROM t;
120+
SELECT CASE WHEN true THEN cast(1 as string) ELSE cast(2 as boolean) END FROM t;
121+
SELECT CASE WHEN true THEN cast(1 as string) ELSE cast('2017-12-11 09:30:00.0' as timestamp) END FROM t;
122+
SELECT CASE WHEN true THEN cast(1 as string) ELSE cast('2017-12-11 09:30:00' as date) END FROM t;
123+
124+
SELECT CASE WHEN true THEN cast('1' as binary) ELSE cast(2 as tinyint) END FROM t;
125+
SELECT CASE WHEN true THEN cast('1' as binary) ELSE cast(2 as smallint) END FROM t;
126+
SELECT CASE WHEN true THEN cast('1' as binary) ELSE cast(2 as int) END FROM t;
127+
SELECT CASE WHEN true THEN cast('1' as binary) ELSE cast(2 as bigint) END FROM t;
128+
SELECT CASE WHEN true THEN cast('1' as binary) ELSE cast(2 as float) END FROM t;
129+
SELECT CASE WHEN true THEN cast('1' as binary) ELSE cast(2 as double) END FROM t;
130+
SELECT CASE WHEN true THEN cast('1' as binary) ELSE cast(2 as decimal(10, 0)) END FROM t;
131+
SELECT CASE WHEN true THEN cast('1' as binary) ELSE cast(2 as string) END FROM t;
132+
SELECT CASE WHEN true THEN cast('1' as binary) ELSE cast('2' as binary) END FROM t;
133+
SELECT CASE WHEN true THEN cast('1' as binary) ELSE cast(2 as boolean) END FROM t;
134+
SELECT CASE WHEN true THEN cast('1' as binary) ELSE cast('2017-12-11 09:30:00.0' as timestamp) END FROM t;
135+
SELECT CASE WHEN true THEN cast('1' as binary) ELSE cast('2017-12-11 09:30:00' as date) END FROM t;
136+
137+
SELECT CASE WHEN true THEN cast(1 as boolean) ELSE cast(2 as tinyint) END FROM t;
138+
SELECT CASE WHEN true THEN cast(1 as boolean) ELSE cast(2 as smallint) END FROM t;
139+
SELECT CASE WHEN true THEN cast(1 as boolean) ELSE cast(2 as int) END FROM t;
140+
SELECT CASE WHEN true THEN cast(1 as boolean) ELSE cast(2 as bigint) END FROM t;
141+
SELECT CASE WHEN true THEN cast(1 as boolean) ELSE cast(2 as float) END FROM t;
142+
SELECT CASE WHEN true THEN cast(1 as boolean) ELSE cast(2 as double) END FROM t;
143+
SELECT CASE WHEN true THEN cast(1 as boolean) ELSE cast(2 as decimal(10, 0)) END FROM t;
144+
SELECT CASE WHEN true THEN cast(1 as boolean) ELSE cast(2 as string) END FROM t;
145+
SELECT CASE WHEN true THEN cast(1 as boolean) ELSE cast('2' as binary) END FROM t;
146+
SELECT CASE WHEN true THEN cast(1 as boolean) ELSE cast(2 as boolean) END FROM t;
147+
SELECT CASE WHEN true THEN cast(1 as boolean) ELSE cast('2017-12-11 09:30:00.0' as timestamp) END FROM t;
148+
SELECT CASE WHEN true THEN cast(1 as boolean) ELSE cast('2017-12-11 09:30:00' as date) END FROM t;
149+
150+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00.0' as timestamp) ELSE cast(2 as tinyint) END FROM t;
151+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00.0' as timestamp) ELSE cast(2 as smallint) END FROM t;
152+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00.0' as timestamp) ELSE cast(2 as int) END FROM t;
153+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00.0' as timestamp) ELSE cast(2 as bigint) END FROM t;
154+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00.0' as timestamp) ELSE cast(2 as float) END FROM t;
155+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00.0' as timestamp) ELSE cast(2 as double) END FROM t;
156+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00.0' as timestamp) ELSE cast(2 as decimal(10, 0)) END FROM t;
157+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00.0' as timestamp) ELSE cast(2 as string) END FROM t;
158+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00.0' as timestamp) ELSE cast('2' as binary) END FROM t;
159+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00.0' as timestamp) ELSE cast(2 as boolean) END FROM t;
160+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00.0' as timestamp) ELSE cast('2017-12-11 09:30:00.0' as timestamp) END FROM t;
161+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00.0' as timestamp) ELSE cast('2017-12-11 09:30:00' as date) END FROM t;
162+
163+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00' as date) ELSE cast(2 as tinyint) END FROM t;
164+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00' as date) ELSE cast(2 as smallint) END FROM t;
165+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00' as date) ELSE cast(2 as int) END FROM t;
166+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00' as date) ELSE cast(2 as bigint) END FROM t;
167+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00' as date) ELSE cast(2 as float) END FROM t;
168+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00' as date) ELSE cast(2 as double) END FROM t;
169+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00' as date) ELSE cast(2 as decimal(10, 0)) END FROM t;
170+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00' as date) ELSE cast(2 as string) END FROM t;
171+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00' as date) ELSE cast('2' as binary) END FROM t;
172+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00' as date) ELSE cast(2 as boolean) END FROM t;
173+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00' as date) ELSE cast('2017-12-11 09:30:00.0' as timestamp) END FROM t;
174+
SELECT CASE WHEN true THEN cast('2017-12-12 09:30:00' as date) ELSE cast('2017-12-11 09:30:00' as date) END FROM t;

0 commit comments

Comments
 (0)