Skip to content

Commit 2f532ea

Browse files
committed
Fix test error.
1 parent fe73cb4 commit 2f532ea

File tree

2 files changed

+55
-59
lines changed

2 files changed

+55
-59
lines changed

sql/core/src/test/resources/sql-tests/inputs/typeCoercion/native/decimalArithmeticOperations.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ select 1e35 / 0.1;
4949

5050
-- arithmetic operations causing a precision loss are truncated
5151
select 123456789123456789.1234567890 * 1.123456789123456789;
52-
select 0.001 / 9876543210987654321098765432109876543.2
52+
select 0.001 / 9876543210987654321098765432109876543.2;
5353

5454
-- return NULL instead of rounding, according to old Spark versions' behavior
5555
set spark.sql.decimalOperations.allowPrecisionLoss=false;
@@ -75,6 +75,6 @@ select 1e35 / 0.1;
7575

7676
-- arithmetic operations causing a precision loss return NULL
7777
select 123456789123456789.1234567890 * 1.123456789123456789;
78-
select 0.001 / 9876543210987654321098765432109876543.2
78+
select 0.001 / 9876543210987654321098765432109876543.2;
7979

8080
drop table decimals_test;

sql/core/src/test/resources/sql-tests/results/typeCoercion/native/decimalArithmeticOperations.sql.out

Lines changed: 53 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Automatically generated by SQLQueryTestSuite
2-
-- Number of queries: 32
2+
-- Number of queries: 34
33

44

55
-- !query 0
@@ -155,137 +155,133 @@ struct<(CAST(123456789123456789.1234567890 AS DECIMAL(36,18)) * CAST(1.123456789
155155

156156
-- !query 18
157157
select 0.001 / 9876543210987654321098765432109876543.2
158-
159-
set spark.sql.decimalOperations.allowPrecisionLoss=false
160158
-- !query 18 schema
161-
struct<>
159+
struct<(CAST(0.001 AS DECIMAL(38,3)) / CAST(9876543210987654321098765432109876543.2 AS DECIMAL(38,3))):decimal(38,37)>
162160
-- !query 18 output
163-
org.apache.spark.sql.catalyst.parser.ParseException
164-
165-
mismatched input 'spark' expecting <EOF>(line 3, pos 4)
166-
167-
== SQL ==
168-
select 0.001 / 9876543210987654321098765432109876543.2
169-
170-
set spark.sql.decimalOperations.allowPrecisionLoss=false
171-
----^^^
161+
NULL
172162

173163

174164
-- !query 19
175-
select id, a+b, a-b, a*b, a/b from decimals_test order by id
165+
set spark.sql.decimalOperations.allowPrecisionLoss=false
176166
-- !query 19 schema
177-
struct<id:int,(a + b):decimal(38,17),(a - b):decimal(38,17),(a * b):decimal(38,6),(a / b):decimal(38,6)>
167+
struct<key:string,value:string>
178168
-- !query 19 output
179-
1 1099 -899 99900 0.1001
180-
2 24690.246 0 152402061.885129 1
181-
3 1234.2234567891011 -1233.9765432108989 152.358023 0.0001
182-
4 123456789123456790.12345678912345679 123456789123456787.87654321087654321 138698367904130467.515623 109890109097814272.043109
169+
spark.sql.decimalOperations.allowPrecisionLoss false
183170

184171

185172
-- !query 20
186-
select id, a*10, b/10 from decimals_test order by id
173+
select id, a+b, a-b, a*b, a/b from decimals_test order by id
187174
-- !query 20 schema
188-
struct<id:int,(CAST(a AS DECIMAL(38,18)) * CAST(CAST(10 AS DECIMAL(2,0)) AS DECIMAL(38,18))):decimal(38,15),(CAST(b AS DECIMAL(38,18)) / CAST(CAST(10 AS DECIMAL(2,0)) AS DECIMAL(38,18))):decimal(38,18)>
175+
struct<id:int,(a + b):decimal(38,18),(a - b):decimal(38,18),(a * b):decimal(38,36),(a / b):decimal(38,18)>
189176
-- !query 20 output
190-
1 1000 99.9
191-
2 123451.23 1234.5123
192-
3 1.234567891011 123.41
193-
4 1234567891234567890 0.112345678912345679
177+
1 1099 -899 NULL 0.1001001001001001
178+
2 24690.246 0 NULL 1
179+
3 1234.2234567891011 -1233.9765432108989 NULL 0.000100037913541123
180+
4 123456789123456790.123456789123456789 123456789123456787.876543210876543211 NULL 109890109097814272.043109406191131436
194181

195182

196183
-- !query 21
197-
select 10.3 * 3.0
184+
select id, a*10, b/10 from decimals_test order by id
198185
-- !query 21 schema
199-
struct<(CAST(10.3 AS DECIMAL(3,1)) * CAST(3.0 AS DECIMAL(3,1))):decimal(6,2)>
186+
struct<id:int,(CAST(a AS DECIMAL(38,18)) * CAST(CAST(10 AS DECIMAL(2,0)) AS DECIMAL(38,18))):decimal(38,18),(CAST(b AS DECIMAL(38,18)) / CAST(CAST(10 AS DECIMAL(2,0)) AS DECIMAL(38,18))):decimal(38,19)>
200187
-- !query 21 output
201-
30.9
188+
1 1000 99.9
189+
2 123451.23 1234.5123
190+
3 1.234567891011 123.41
191+
4 1234567891234567890 0.1123456789123456789
202192

203193

204194
-- !query 22
205-
select 10.3000 * 3.0
195+
select 10.3 * 3.0
206196
-- !query 22 schema
207-
struct<(CAST(10.3000 AS DECIMAL(6,4)) * CAST(3.0 AS DECIMAL(6,4))):decimal(9,5)>
197+
struct<(CAST(10.3 AS DECIMAL(3,1)) * CAST(3.0 AS DECIMAL(3,1))):decimal(6,2)>
208198
-- !query 22 output
209199
30.9
210200

211201

212202
-- !query 23
213-
select 10.30000 * 30.0
203+
select 10.3000 * 3.0
214204
-- !query 23 schema
215-
struct<(CAST(10.30000 AS DECIMAL(7,5)) * CAST(30.0 AS DECIMAL(7,5))):decimal(11,6)>
205+
struct<(CAST(10.3000 AS DECIMAL(6,4)) * CAST(3.0 AS DECIMAL(6,4))):decimal(9,5)>
216206
-- !query 23 output
217-
309
207+
30.9
218208

219209

220210
-- !query 24
221-
select 10.300000000000000000 * 3.000000000000000000
211+
select 10.30000 * 30.0
222212
-- !query 24 schema
223-
struct<(CAST(10.300000000000000000 AS DECIMAL(20,18)) * CAST(3.000000000000000000 AS DECIMAL(20,18))):decimal(38,34)>
213+
struct<(CAST(10.30000 AS DECIMAL(7,5)) * CAST(30.0 AS DECIMAL(7,5))):decimal(11,6)>
224214
-- !query 24 output
225-
30.9
215+
309
226216

227217

228218
-- !query 25
229-
select 10.300000000000000000 * 3.0000000000000000000
219+
select 10.300000000000000000 * 3.000000000000000000
230220
-- !query 25 schema
231-
struct<(CAST(10.300000000000000000 AS DECIMAL(21,19)) * CAST(3.0000000000000000000 AS DECIMAL(21,19))):decimal(38,34)>
221+
struct<(CAST(10.300000000000000000 AS DECIMAL(20,18)) * CAST(3.000000000000000000 AS DECIMAL(20,18))):decimal(38,36)>
232222
-- !query 25 output
233223
30.9
234224

235225

236226
-- !query 26
237-
select (5e36 + 0.1) + 5e36
227+
select 10.300000000000000000 * 3.0000000000000000000
238228
-- !query 26 schema
239-
struct<(CAST((CAST(5E+36 AS DECIMAL(38,1)) + CAST(0.1 AS DECIMAL(38,1))) AS DECIMAL(38,1)) + CAST(5E+36 AS DECIMAL(38,1))):decimal(38,1)>
229+
struct<(CAST(10.300000000000000000 AS DECIMAL(21,19)) * CAST(3.0000000000000000000 AS DECIMAL(21,19))):decimal(38,37)>
240230
-- !query 26 output
241231
NULL
242232

243233

244234
-- !query 27
245-
select (-4e36 - 0.1) - 7e36
235+
select (5e36 + 0.1) + 5e36
246236
-- !query 27 schema
247-
struct<(CAST((CAST(-4E+36 AS DECIMAL(38,1)) - CAST(0.1 AS DECIMAL(38,1))) AS DECIMAL(38,1)) - CAST(7E+36 AS DECIMAL(38,1))):decimal(38,1)>
237+
struct<(CAST((CAST(5E+36 AS DECIMAL(38,1)) + CAST(0.1 AS DECIMAL(38,1))) AS DECIMAL(38,1)) + CAST(5E+36 AS DECIMAL(38,1))):decimal(38,1)>
248238
-- !query 27 output
249239
NULL
250240

251241

252242
-- !query 28
253-
select 12345678901234567890.0 * 12345678901234567890.0
243+
select (-4e36 - 0.1) - 7e36
254244
-- !query 28 schema
255-
struct<(12345678901234567890.0 * 12345678901234567890.0):decimal(38,2)>
245+
struct<(CAST((CAST(-4E+36 AS DECIMAL(38,1)) - CAST(0.1 AS DECIMAL(38,1))) AS DECIMAL(38,1)) - CAST(7E+36 AS DECIMAL(38,1))):decimal(38,1)>
256246
-- !query 28 output
257247
NULL
258248

259249

260250
-- !query 29
261-
select 1e35 / 0.1
251+
select 12345678901234567890.0 * 12345678901234567890.0
262252
-- !query 29 schema
263-
struct<(CAST(1E+35 AS DECIMAL(37,1)) / CAST(0.1 AS DECIMAL(37,1))):decimal(38,6)>
253+
struct<(12345678901234567890.0 * 12345678901234567890.0):decimal(38,2)>
264254
-- !query 29 output
265255
NULL
266256

267257

268258
-- !query 30
269-
select 123456789123456789.1234567890 * 1.123456789123456789
259+
select 1e35 / 0.1
270260
-- !query 30 schema
271-
struct<(CAST(123456789123456789.1234567890 AS DECIMAL(36,18)) * CAST(1.123456789123456789 AS DECIMAL(36,18))):decimal(38,18)>
261+
struct<(CAST(1E+35 AS DECIMAL(37,1)) / CAST(0.1 AS DECIMAL(37,1))):decimal(38,3)>
272262
-- !query 30 output
273-
138698367904130467.654320988515622621
263+
NULL
274264

275265

276266
-- !query 31
277-
select 0.001 / 9876543210987654321098765432109876543.2
278-
279-
drop table decimals_test
267+
select 123456789123456789.1234567890 * 1.123456789123456789
280268
-- !query 31 schema
281-
struct<>
269+
struct<(CAST(123456789123456789.1234567890 AS DECIMAL(36,18)) * CAST(1.123456789123456789 AS DECIMAL(36,18))):decimal(38,28)>
282270
-- !query 31 output
283-
org.apache.spark.sql.catalyst.parser.ParseException
271+
NULL
284272

285-
mismatched input 'table' expecting <EOF>(line 3, pos 5)
286273

287-
== SQL ==
274+
-- !query 32
288275
select 0.001 / 9876543210987654321098765432109876543.2
276+
-- !query 32 schema
277+
struct<(CAST(0.001 AS DECIMAL(38,3)) / CAST(9876543210987654321098765432109876543.2 AS DECIMAL(38,3))):decimal(38,37)>
278+
-- !query 32 output
279+
NULL
280+
289281

282+
-- !query 33
290283
drop table decimals_test
291-
-----^^^
284+
-- !query 33 schema
285+
struct<>
286+
-- !query 33 output
287+

0 commit comments

Comments
 (0)