Skip to content

Commit ca0c92f

Browse files
committed
Undo decimal indentifier
Signed-off-by: Adam Gutglick <adamgsal@gmail.com>
1 parent ec92d2f commit ca0c92f

48 files changed

Lines changed: 269 additions & 298 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

datafusion/sqllogictest/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ query <type_string> <sort_mode>
397397
- 'P' - timestam**P**,
398398
- 'R' - floating-point results,
399399
- 'T' - **T**ext,
400-
- 'L' - decima**L**,
401400
- "?" - any other types
402401
- `expected_result`: In the results section, some values are converted according to some rules:
403402
- floating point values are rounded to the scale of "12",

datafusion/sqllogictest/src/engines/datafusion_engine/normalize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pub fn convert_schema_to_types(columns: &Fields) -> Vec<DFColumnType> {
284284
DataType::Decimal32(_, _)
285285
| DataType::Decimal64(_, _)
286286
| DataType::Decimal128(_, _)
287-
| DataType::Decimal256(_, _) => DFColumnType::Decimal,
287+
| DataType::Decimal256(_, _) => DFColumnType::Float,
288288
DataType::Utf8 | DataType::LargeUtf8 | DataType::Utf8View => {
289289
DFColumnType::Text
290290
}

datafusion/sqllogictest/src/engines/output.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub enum DFColumnType {
2323
DateTime,
2424
Integer,
2525
Float,
26-
Decimal,
2726
Text,
2827
Timestamp,
2928
Another,
@@ -38,7 +37,6 @@ impl ColumnType for DFColumnType {
3837
'P' => Some(Self::Timestamp),
3938
'R' => Some(Self::Float),
4039
'T' => Some(Self::Text),
41-
'L' => Some(Self::Decimal),
4240
_ => Some(Self::Another),
4341
}
4442
}
@@ -51,7 +49,6 @@ impl ColumnType for DFColumnType {
5149
Self::Timestamp => 'P',
5250
Self::Float => 'R',
5351
Self::Text => 'T',
54-
Self::Decimal => 'L',
5552
Self::Another => '?',
5653
}
5754
}

datafusion/sqllogictest/src/engines/postgres_engine/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,7 @@ fn convert_types(types: Vec<Type>) -> Vec<DFColumnType> {
417417
Type::BOOL => DFColumnType::Boolean,
418418
Type::INT2 | Type::INT4 | Type::INT8 => DFColumnType::Integer,
419419
Type::BPCHAR | Type::VARCHAR | Type::TEXT => DFColumnType::Text,
420-
Type::FLOAT4 | Type::FLOAT8 => DFColumnType::Float,
421-
Type::NUMERIC => DFColumnType::Decimal,
420+
Type::FLOAT4 | Type::FLOAT8 | Type::NUMERIC => DFColumnType::Float,
422421
Type::DATE | Type::TIME => DFColumnType::DateTime,
423422
Type::TIMESTAMP => DFColumnType::Timestamp,
424423
_ => DFColumnType::Another,

datafusion/sqllogictest/test_files/aggregate.slt

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ NULL Null
14271427
statement ok
14281428
create table t(c decimal(10, 4)) as values (0.0001), (0.0002), (0.0003), (0.0004), (0.0005), (0.0006);
14291429

1430-
query LT
1430+
query RT
14311431
select median(c), arrow_typeof(median(c)) from t;
14321432
----
14331433
0.0003 Decimal128(10, 4)
@@ -1444,7 +1444,7 @@ drop table t;
14441444
statement ok
14451445
create table t(c decimal(10, 4)) as values (0.0001), (null), (0.0003), (0.0004), (0.0005);
14461446

1447-
query LT
1447+
query RT
14481448
select median(c), arrow_typeof(median(c)) from t;
14491449
----
14501450
0.0003 Decimal128(10, 4)
@@ -1456,7 +1456,7 @@ drop table t;
14561456
statement ok
14571457
create table t(c decimal(10, 4)) as values (null), (null), (null);
14581458

1459-
query LT
1459+
query RT
14601460
select median(c), arrow_typeof(median(c)) from t;
14611461
----
14621462
NULL Decimal128(10, 4)
@@ -1540,7 +1540,7 @@ drop table t;
15401540
statement ok
15411541
create table t(c decimal(10, 4)) as values (0.0001), (0.0001), (0.0001), (0.0001), (0.0002), (0.0002), (0.0003), (0.0003);
15421542

1543-
query L
1543+
query R
15441544
select median(distinct c) from t;
15451545
----
15461546
0.0002
@@ -1552,7 +1552,7 @@ drop table t;
15521552
statement ok
15531553
create table t(c decimal(10, 4)) as values (0.0001), (0.0001), (0.0001), (null), (null), (0.0002), (0.0003), (0.0003);
15541554

1555-
query L
1555+
query R
15561556
select median(distinct c) from t;
15571557
----
15581558
0.0002
@@ -3291,7 +3291,7 @@ select avg(c1) from test
32913291
statement ok
32923292
create table t (c1 decimal(10, 0)) as values (1), (2), (3), (4), (5), (6);
32933293

3294-
query LT
3294+
query RT
32953295
select avg(c1), arrow_typeof(avg(c1)) from t;
32963296
----
32973297
3.5 Decimal128(14, 4)
@@ -3303,7 +3303,7 @@ drop table t;
33033303
statement ok
33043304
create table t (c1 decimal(10, 0)) as values (1), (NULL), (3), (4), (5);
33053305

3306-
query LT
3306+
query RT
33073307
select avg(c1), arrow_typeof(avg(c1)) from t;
33083308
----
33093309
3.25 Decimal128(14, 4)
@@ -3315,7 +3315,7 @@ drop table t;
33153315
statement ok
33163316
create table t (c1 decimal(10, 0)) as values (NULL), (NULL), (NULL), (NULL), (NULL), (NULL);
33173317

3318-
query LT
3318+
query RT
33193319
select avg(c1), arrow_typeof(avg(c1)) from t;
33203320
----
33213321
NULL Decimal128(14, 4)
@@ -4019,7 +4019,7 @@ drop table t;
40194019
statement ok
40204020
create table t (c decimal(35, 0)) as values (1), (2), (1), (3), (null), (null), (3), (-2);
40214021

4022-
query LT
4022+
query RT
40234023
select sum(distinct c), arrow_typeof(sum(distinct c)) from t;
40244024
----
40254025
4 Decimal128(38, 0)
@@ -4983,7 +4983,7 @@ CREATE TABLE decimals (value DECIMAL(10, 2));
49834983
statement ok
49844984
INSERT INTO decimals VALUES (123.0001), (124.00);
49854985

4986-
query LL
4986+
query RR
49874987
SELECT MIN(value), MAX(value) FROM decimals;
49884988
----
49894989
123 124
@@ -4997,7 +4997,7 @@ CREATE TABLE decimals_batch (value DECIMAL(10, 0));
49974997
statement ok
49984998
INSERT INTO decimals_batch VALUES (1), (2), (3), (4), (5);
49994999

5000-
query LL
5000+
query RR
50015001
SELECT MIN(value), MAX(value) FROM decimals_batch;
50025002
----
50035003
1 5
@@ -5008,7 +5008,7 @@ DROP TABLE decimals_batch;
50085008
statement ok
50095009
CREATE TABLE decimals_empty (value DECIMAL(10, 0));
50105010

5011-
query LL
5011+
query RR
50125012
SELECT MIN(value), MAX(value) FROM decimals_empty;
50135013
----
50145014
NULL NULL
@@ -5023,7 +5023,7 @@ CREATE TABLE decimals_all_nulls (value DECIMAL(10, 0));
50235023
statement ok
50245024
INSERT INTO decimals_all_nulls VALUES (NULL), (NULL), (NULL), (NULL), (NULL), (NULL);
50255025

5026-
query LL
5026+
query RR
50275027
SELECT MIN(value), MAX(value) FROM decimals_all_nulls;
50285028
----
50295029
NULL NULL
@@ -5038,7 +5038,7 @@ CREATE TABLE decimals_with_nulls (value DECIMAL(10, 0));
50385038
statement ok
50395039
INSERT INTO decimals_with_nulls VALUES (1), (NULL), (3), (4), (5);
50405040

5041-
query LL
5041+
query RR
50425042
SELECT MIN(value), MAX(value) FROM decimals_with_nulls;
50435043
----
50445044
1 5
@@ -5052,7 +5052,7 @@ CREATE TABLE decimals_error (value DECIMAL(10, 2));
50525052
statement ok
50535053
INSERT INTO decimals_error VALUES (123.00), (arrow_cast(124.001, 'Decimal128(10, 3)'));
50545054

5055-
query LL
5055+
query RR
50565056
SELECT MIN(value), MAX(value) FROM decimals_error;
50575057
----
50585058
123 124
@@ -5066,7 +5066,7 @@ CREATE TABLE decimals_agg (value DECIMAL(10, 0));
50665066
statement ok
50675067
INSERT INTO decimals_agg VALUES (1), (2), (3), (4), (5);
50685068

5069-
query LL
5069+
query RR
50705070
SELECT MIN(value), MAX(value) FROM decimals_agg;
50715071
----
50725072
1 5
@@ -6202,7 +6202,7 @@ select approx_median(a) from (select 1 as a where 1=0);
62026202
NULL
62036203

62046204
# aggregate_decimal_sum
6205-
query LT
6205+
query RT
62066206
select sum(c1), arrow_typeof(sum(c1)) from d_table;
62076207
----
62086208
100 Decimal128(20, 3)
@@ -6211,7 +6211,7 @@ select sum(c1), arrow_typeof(sum(c1)) from d_table;
62116211
statement ok
62126212
create table t (c decimal(35, 3)) as values (10), (null), (20);
62136213

6214-
query LT
6214+
query RT
62156215
select sum(c), arrow_typeof(sum(c)) from t;
62166216
----
62176217
30 Decimal128(38, 3)
@@ -6235,7 +6235,7 @@ drop table t;
62356235
statement ok
62366236
create table t (c1 decimal(10, 0), c2 int) as values (null, null), (null, null), (null, null);
62376237

6238-
query LTIT
6238+
query RTIT
62396239
select
62406240
sum(c1), arrow_typeof(sum(c1)),
62416241
sum(c2), arrow_typeof(sum(c2))
@@ -6282,20 +6282,20 @@ select sum(c), arrow_typeof(sum(c)) from t;
62826282
statement ok
62836283
drop table t;
62846284

6285-
query TLT
6285+
query TRT
62866286
select c2, sum(c1), arrow_typeof(sum(c1)) from d_table GROUP BY c2 ORDER BY c2;
62876287
----
62886288
A 1100.045 Decimal128(20, 3)
62896289
B -1000.045 Decimal128(20, 3)
62906290

62916291

62926292
# aggregate_decimal_avg
6293-
query LT
6293+
query RT
62946294
select avg(c1), arrow_typeof(avg(c1)) from d_table
62956295
----
62966296
5 Decimal128(14, 7)
62976297

6298-
query TLT
6298+
query TRT
62996299
select c2, avg(c1), arrow_typeof(avg(c1)) from d_table GROUP BY c2 ORDER BY c2
63006300
----
63016301
A 110.0045 Decimal128(14, 7)
@@ -6468,15 +6468,15 @@ statement ok
64686468
INSERT INTO test_decimal_table VALUES (1, 10.10, 100.1, NULL), (1, 20.20, 200.2, NULL), (2, 10.10, 700.1, NULL), (2, 20.20, 700.1, NULL), (3, 10.1, 100.1, NULL), (3, 10.1, NULL, NULL)
64696469

64706470
# aggregate_decimal_with_group_by
6471-
query IILLLLIILL rowsort
6471+
query IIRRRRIIRR rowsort
64726472
select c1, count(c2), avg(c2), sum(c2), min(c2), max(c2), count(c3), count(c4), sum(c4), avg(c4) from test_decimal_table group by c1
64736473
----
64746474
1 2 15.15 30.3 10.1 20.2 2 0 NULL NULL
64756475
2 2 15.15 30.3 10.1 20.2 2 0 NULL NULL
64766476
3 2 10.1 20.2 10.1 10.1 1 0 NULL NULL
64776477

64786478
# aggregate_decimal_with_group_by_decimal
6479-
query LILLLLIL rowsort
6479+
query RIRRRRIR rowsort
64806480
select c3, count(c2), avg(c2), sum(c2), min(c2), max(c2), count(c4), sum(c4) from test_decimal_table group by c3
64816481
----
64826482
100.1 2 10.1 20.2 10.1 10.1 0 NULL
@@ -8519,14 +8519,14 @@ group0 NaN
85198519
group1 NaN
85208520

85218521
# group median decimal128 non-nullable
8522-
query TL rowsort
8522+
query TR rowsort
85238523
SELECT col_group, median(col_decimal128) FROM group_median_table_non_nullable GROUP BY col_group
85248524
----
85258525
group0 0.0002
85268526
group1 0.0003
85278527

85288528
# group median decimal256 non-nullable
8529-
query TL rowsort
8529+
query TR rowsort
85308530
SELECT col_group, median(col_decimal256) FROM group_median_table_non_nullable GROUP BY col_group
85318531
----
85328532
group0 0.0002
@@ -8610,14 +8610,14 @@ group0 NaN
86108610
group1 NaN
86118611

86128612
# group median decimal128 nullable
8613-
query TL rowsort
8613+
query TR rowsort
86148614
SELECT col_group, median(col_decimal128) FROM group_median_table_nullable GROUP BY col_group
86158615
----
86168616
group0 0.0002
86178617
group1 0.0003
86188618

86198619
# group median decimal256 nullable
8620-
query TL rowsort
8620+
query TR rowsort
86218621
SELECT col_group, median(col_decimal256) FROM group_median_table_nullable GROUP BY col_group
86228622
----
86238623
group0 0.0002
@@ -8646,7 +8646,7 @@ statement ok
86468646
create table t_decimal (c decimal(10, 4)) as values (100.00), (125.00), (175.00), (200.00), (200.00), (300.00), (null), (null);
86478647

86488648
# Test avg_distinct for Decimal128
8649-
query LT
8649+
query RT
86508650
select avg(distinct c), arrow_typeof(avg(distinct c)) from t_decimal;
86518651
----
86528652
180 Decimal128(14, 8)
@@ -8666,7 +8666,7 @@ create table t_decimal256 (c decimal(50, 2)) as values
86668666
(null),
86678667
(null);
86688668

8669-
query LT
8669+
query RT
86708670
select avg(distinct c), arrow_typeof(avg(distinct c)) from t_decimal256;
86718671
----
86728672
180 Decimal256(54, 6)
@@ -8810,7 +8810,7 @@ create table distinct_avg (a int, b double, c decimal(10, 4), d decimal(50, 2))
88108810
;
88118811

88128812
# Need two columns to ensure single_distinct_to_group_by rule doesn't kick in, so we know our actual avg(distinct) code is being tested
8813-
query RTRTLTLTRRLL
8813+
query RTRTRTRTRRRR
88148814
select
88158815
avg(distinct a),
88168816
arrow_typeof(avg(distinct a)),
@@ -8828,7 +8828,7 @@ from distinct_avg;
88288828
----
88298829
3 Float64 37.4255 Float64 698.56005 Decimal128(14, 8) 15041.868333 Decimal256(54, 6) 4 56.52525 957.11074444 1272562.81625
88308830

8831-
query RRLL rowsort
8831+
query RRRR rowsort
88328832
select
88338833
avg(distinct a),
88348834
avg(distinct b),
@@ -8843,7 +8843,7 @@ group by b;
88438843
5 100.5 -49.5781 0.333333
88448844
5 44.112 -132.12 NULL
88458845

8846-
query RRLL
8846+
query RRRR
88478847
select
88488848
avg(distinct a),
88498849
avg(distinct b),

datafusion/sqllogictest/test_files/aggregate_skip_partial.slt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ VALUES (1, 1.1), (2, 2.2), (3, 3.3), (2, 4.4), (1, 5.5);
698698
statement ok
699699
CREATE TABLE t(id int) as values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
700700

701-
query IL
701+
query IR
702702
SELECT i, sum(d)
703703
FROM decimal_table CROSS JOIN t
704704
GROUP BY i

datafusion/sqllogictest/test_files/aggregates_simplify.slt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ physical_plan
332332
05)--------DataSourceExec: partitions=1, partition_sizes=[2]
333333

334334
# Checks equivalent rewritten form (SUM + COUNT terms) matches transformed SUM semantics.
335-
query LL
335+
query RR
336336
SELECT SUM(val) + 1 * COUNT(val), SUM(val) + 2 * COUNT(val) FROM tbl;
337337
----
338338
8589934592 8589934594

datafusion/sqllogictest/test_files/array/array_min_max.slt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ from (
293293
----
294294
1970-01-01T00:00:00.000000010Z 1970-01-01T00:00:00.000000030Z Timestamp(ns, "UTC") Timestamp(ns, "UTC")
295295

296-
query LLTT
296+
query RRTT
297297
select
298298
array_min(dec_list),
299299
array_max(dec_list),

datafusion/sqllogictest/test_files/arrow_typeof.slt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ SELECT
198198
Decimal128(5, 2) Decimal256(5, 2)
199199

200200

201-
query LL
201+
query RR
202202
SELECT
203203
col_d128,
204204
col_d256

0 commit comments

Comments
 (0)