Skip to content

Commit 52f19ee

Browse files
committed
Fix Float and Decimal coercion
Before the change, Float* and Decimal* would coerce to a decimal type. However, decimal cannot store all the float values: different range, NaN, and infinity. Coercing to floating point is more desirable and also what other systems typically do.
1 parent 774d3cb commit 52f19ee

File tree

9 files changed

+48
-34
lines changed

9 files changed

+48
-34
lines changed

datafusion/core/tests/parquet/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,13 @@ impl TestOutput {
184184
/// and the appropriate scenario
185185
impl ContextWithParquet {
186186
async fn new(scenario: Scenario, unit: Unit) -> Self {
187-
Self::with_config(scenario, unit, SessionConfig::new()).await
187+
let mut session_config = SessionConfig::new();
188+
// TODO (https://github.com/apache/datafusion/issues/12817) once this is the default behavior, remove from here
189+
session_config
190+
.options_mut()
191+
.sql_parser
192+
.parse_float_as_decimal = true;
193+
Self::with_config(scenario, unit, session_config).await
188194
}
189195

190196
async fn with_config(

datafusion/expr-common/src/type_coercion/binary.rs

+5-17
Original file line numberDiff line numberDiff line change
@@ -928,9 +928,6 @@ fn coerce_numeric_type_to_decimal(numeric_type: &DataType) -> Option<DataType> {
928928
Int16 | UInt16 => Some(Decimal128(5, 0)),
929929
Int32 | UInt32 => Some(Decimal128(10, 0)),
930930
Int64 | UInt64 => Some(Decimal128(20, 0)),
931-
// TODO if we convert the floating-point data to the decimal type, it maybe overflow.
932-
Float32 => Some(Decimal128(14, 7)),
933-
Float64 => Some(Decimal128(30, 15)),
934931
_ => None,
935932
}
936933
}
@@ -946,9 +943,6 @@ fn coerce_numeric_type_to_decimal256(numeric_type: &DataType) -> Option<DataType
946943
Int16 | UInt16 => Some(Decimal256(5, 0)),
947944
Int32 | UInt32 => Some(Decimal256(10, 0)),
948945
Int64 | UInt64 => Some(Decimal256(20, 0)),
949-
// TODO if we convert the floating-point data to the decimal type, it maybe overflow.
950-
Float32 => Some(Decimal256(14, 7)),
951-
Float64 => Some(Decimal256(30, 15)),
952946
_ => None,
953947
}
954948
}
@@ -1494,8 +1488,8 @@ mod tests {
14941488
DataType::Decimal128(20, 3),
14951489
DataType::Decimal128(20, 3),
14961490
DataType::Decimal128(23, 3),
1497-
DataType::Decimal128(24, 7),
1498-
DataType::Decimal128(32, 15),
1491+
DataType::Float32,
1492+
DataType::Float64,
14991493
DataType::Decimal128(38, 10),
15001494
DataType::Decimal128(25, 8),
15011495
DataType::Decimal128(20, 3),
@@ -1541,14 +1535,8 @@ mod tests {
15411535
coerce_numeric_type_to_decimal(&DataType::Int64).unwrap(),
15421536
DataType::Decimal128(20, 0)
15431537
);
1544-
assert_eq!(
1545-
coerce_numeric_type_to_decimal(&DataType::Float32).unwrap(),
1546-
DataType::Decimal128(14, 7)
1547-
);
1548-
assert_eq!(
1549-
coerce_numeric_type_to_decimal(&DataType::Float64).unwrap(),
1550-
DataType::Decimal128(30, 15)
1551-
);
1538+
assert_eq!(coerce_numeric_type_to_decimal(&DataType::Float32), None);
1539+
assert_eq!(coerce_numeric_type_to_decimal(&DataType::Float64), None);
15521540
}
15531541

15541542
#[test]
@@ -2013,7 +2001,7 @@ mod tests {
20132001
DataType::Float64,
20142002
DataType::Decimal128(10, 3),
20152003
Operator::Gt,
2016-
DataType::Decimal128(30, 15)
2004+
DataType::Float64
20172005
);
20182006
test_coercion_binary_rule!(
20192007
DataType::Int64,

datafusion/sqllogictest/test_files/math.slt

+6
Original file line numberDiff line numberDiff line change
@@ -694,3 +694,9 @@ select FACTORIAL(350943270);
694694

695695
statement ok
696696
drop table signed_integers
697+
698+
# Should not fail. The operands should coerce to float
699+
query B
700+
SELECT '1'::decimal(10,0) = '1e40'::double;
701+
----
702+
false

datafusion/sqllogictest/test_files/tpch/plans/q1.slt.part

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ physical_plan
5757
08)--------------ProjectionExec: expr=[l_extendedprice@1 * (Some(1),20,0 - l_discount@2) as __common_expr_1, l_quantity@0 as l_quantity, l_extendedprice@1 as l_extendedprice, l_discount@2 as l_discount, l_tax@3 as l_tax, l_returnflag@4 as l_returnflag, l_linestatus@5 as l_linestatus]
5858
09)----------------CoalesceBatchesExec: target_batch_size=8192
5959
10)------------------FilterExec: l_shipdate@6 <= 1998-09-02, projection=[l_quantity@0, l_extendedprice@1, l_discount@2, l_tax@3, l_returnflag@4, l_linestatus@5]
60-
11)--------------------CsvExec: file_groups={4 groups: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:0..18561749], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:18561749..37123498], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:37123498..55685247], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:55685247..74246996]]}, projection=[l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate], has_header=false
60+
11)--------------------CsvExec: file_groups={4 groups: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:0..18561749], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:18561749..37123498], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:37123498..55685247], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:55685247..74246996]]}, projection=[l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate], has_header=false

datafusion/sqllogictest/test_files/tpch/plans/q11.slt.part

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ limit 10;
4949
logical_plan
5050
01)Sort: value DESC NULLS FIRST, fetch=10
5151
02)--Projection: partsupp.ps_partkey, sum(partsupp.ps_supplycost * partsupp.ps_availqty) AS value
52-
03)----Inner Join: Filter: CAST(sum(partsupp.ps_supplycost * partsupp.ps_availqty) AS Decimal128(38, 15)) > __scalar_sq_1.sum(partsupp.ps_supplycost * partsupp.ps_availqty) * Float64(0.0001)
52+
03)----Inner Join: Filter: CAST(sum(partsupp.ps_supplycost * partsupp.ps_availqty) AS Float64) > __scalar_sq_1.sum(partsupp.ps_supplycost * partsupp.ps_availqty) * Float64(0.0001)
5353
04)------Aggregate: groupBy=[[partsupp.ps_partkey]], aggr=[[sum(partsupp.ps_supplycost * CAST(partsupp.ps_availqty AS Decimal128(10, 0)))]]
5454
05)--------Projection: partsupp.ps_partkey, partsupp.ps_availqty, partsupp.ps_supplycost
5555
06)----------Inner Join: supplier.s_nationkey = nation.n_nationkey
@@ -61,7 +61,7 @@ logical_plan
6161
12)--------------Filter: nation.n_name = Utf8("GERMANY")
6262
13)----------------TableScan: nation projection=[n_nationkey, n_name], partial_filters=[nation.n_name = Utf8("GERMANY")]
6363
14)------SubqueryAlias: __scalar_sq_1
64-
15)--------Projection: CAST(CAST(sum(partsupp.ps_supplycost * partsupp.ps_availqty) AS Float64) * Float64(0.0001) AS Decimal128(38, 15))
64+
15)--------Projection: CAST(sum(partsupp.ps_supplycost * partsupp.ps_availqty) AS Float64) * Float64(0.0001)
6565
16)----------Aggregate: groupBy=[[]], aggr=[[sum(partsupp.ps_supplycost * CAST(partsupp.ps_availqty AS Decimal128(10, 0)))]]
6666
17)------------Projection: partsupp.ps_availqty, partsupp.ps_supplycost
6767
18)--------------Inner Join: supplier.s_nationkey = nation.n_nationkey
@@ -75,7 +75,7 @@ logical_plan
7575
physical_plan
7676
01)SortExec: TopK(fetch=10), expr=[value@1 DESC], preserve_partitioning=[false]
7777
02)--ProjectionExec: expr=[ps_partkey@0 as ps_partkey, sum(partsupp.ps_supplycost * partsupp.ps_availqty)@1 as value]
78-
03)----NestedLoopJoinExec: join_type=Inner, filter=CAST(sum(partsupp.ps_supplycost * partsupp.ps_availqty)@0 AS Decimal128(38, 15)) > sum(partsupp.ps_supplycost * partsupp.ps_availqty) * Float64(0.0001)@1, projection=[ps_partkey@0, sum(partsupp.ps_supplycost * partsupp.ps_availqty)@1]
78+
03)----NestedLoopJoinExec: join_type=Inner, filter=CAST(sum(partsupp.ps_supplycost * partsupp.ps_availqty)@0 AS Float64) > sum(partsupp.ps_supplycost * partsupp.ps_availqty) * Float64(0.0001)@1, projection=[ps_partkey@0, sum(partsupp.ps_supplycost * partsupp.ps_availqty)@1]
7979
04)------CoalescePartitionsExec
8080
05)--------AggregateExec: mode=FinalPartitioned, gby=[ps_partkey@0 as ps_partkey], aggr=[sum(partsupp.ps_supplycost * partsupp.ps_availqty)]
8181
06)----------CoalesceBatchesExec: target_batch_size=8192
@@ -100,7 +100,7 @@ physical_plan
100100
25)--------------------------FilterExec: n_name@1 = GERMANY, projection=[n_nationkey@0]
101101
26)----------------------------RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1
102102
27)------------------------------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/nation.tbl]]}, projection=[n_nationkey, n_name], has_header=false
103-
28)------ProjectionExec: expr=[CAST(CAST(sum(partsupp.ps_supplycost * partsupp.ps_availqty)@0 AS Float64) * 0.0001 AS Decimal128(38, 15)) as sum(partsupp.ps_supplycost * partsupp.ps_availqty) * Float64(0.0001)]
103+
28)------ProjectionExec: expr=[CAST(sum(partsupp.ps_supplycost * partsupp.ps_availqty)@0 AS Float64) * 0.0001 as sum(partsupp.ps_supplycost * partsupp.ps_availqty) * Float64(0.0001)]
104104
29)--------AggregateExec: mode=Final, gby=[], aggr=[sum(partsupp.ps_supplycost * partsupp.ps_availqty)]
105105
30)----------CoalescePartitionsExec
106106
31)------------AggregateExec: mode=Partial, gby=[], aggr=[sum(partsupp.ps_supplycost * partsupp.ps_availqty)]

datafusion/sqllogictest/test_files/tpch/plans/q17.slt.part

+4-5
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ logical_plan
3939
01)Projection: CAST(sum(lineitem.l_extendedprice) AS Float64) / Float64(7) AS avg_yearly
4040
02)--Aggregate: groupBy=[[]], aggr=[[sum(lineitem.l_extendedprice)]]
4141
03)----Projection: lineitem.l_extendedprice
42-
04)------Inner Join: part.p_partkey = __scalar_sq_1.l_partkey Filter: CAST(lineitem.l_quantity AS Decimal128(30, 15)) < __scalar_sq_1.Float64(0.2) * avg(lineitem.l_quantity)
42+
04)------Inner Join: part.p_partkey = __scalar_sq_1.l_partkey Filter: CAST(lineitem.l_quantity AS Float64) < __scalar_sq_1.Float64(0.2) * avg(lineitem.l_quantity)
4343
05)--------Projection: lineitem.l_quantity, lineitem.l_extendedprice, part.p_partkey
4444
06)----------Inner Join: lineitem.l_partkey = part.p_partkey
4545
07)------------TableScan: lineitem projection=[l_partkey, l_quantity, l_extendedprice]
4646
08)------------Projection: part.p_partkey
4747
09)--------------Filter: part.p_brand = Utf8("Brand#23") AND part.p_container = Utf8("MED BOX")
4848
10)----------------TableScan: part projection=[p_partkey, p_brand, p_container], partial_filters=[part.p_brand = Utf8("Brand#23"), part.p_container = Utf8("MED BOX")]
4949
11)--------SubqueryAlias: __scalar_sq_1
50-
12)----------Projection: CAST(Float64(0.2) * CAST(avg(lineitem.l_quantity) AS Float64) AS Decimal128(30, 15)), lineitem.l_partkey
50+
12)----------Projection: Float64(0.2) * CAST(avg(lineitem.l_quantity) AS Float64), lineitem.l_partkey
5151
13)------------Aggregate: groupBy=[[lineitem.l_partkey]], aggr=[[avg(lineitem.l_quantity)]]
5252
14)--------------TableScan: lineitem projection=[l_partkey, l_quantity]
5353
physical_plan
@@ -56,7 +56,7 @@ physical_plan
5656
03)----CoalescePartitionsExec
5757
04)------AggregateExec: mode=Partial, gby=[], aggr=[sum(lineitem.l_extendedprice)]
5858
05)--------CoalesceBatchesExec: target_batch_size=8192
59-
06)----------HashJoinExec: mode=Partitioned, join_type=Inner, on=[(p_partkey@2, l_partkey@1)], filter=CAST(l_quantity@0 AS Decimal128(30, 15)) < Float64(0.2) * avg(lineitem.l_quantity)@1, projection=[l_extendedprice@1]
59+
06)----------HashJoinExec: mode=Partitioned, join_type=Inner, on=[(p_partkey@2, l_partkey@1)], filter=CAST(l_quantity@0 AS Float64) < Float64(0.2) * avg(lineitem.l_quantity)@1, projection=[l_extendedprice@1]
6060
07)------------CoalesceBatchesExec: target_batch_size=8192
6161
08)--------------HashJoinExec: mode=Partitioned, join_type=Inner, on=[(l_partkey@0, p_partkey@0)], projection=[l_quantity@1, l_extendedprice@2, p_partkey@3]
6262
09)----------------CoalesceBatchesExec: target_batch_size=8192
@@ -68,10 +68,9 @@ physical_plan
6868
15)----------------------FilterExec: p_brand@1 = Brand#23 AND p_container@2 = MED BOX, projection=[p_partkey@0]
6969
16)------------------------RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1
7070
17)--------------------------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/part.tbl]]}, projection=[p_partkey, p_brand, p_container], has_header=false
71-
18)------------ProjectionExec: expr=[CAST(0.2 * CAST(avg(lineitem.l_quantity)@1 AS Float64) AS Decimal128(30, 15)) as Float64(0.2) * avg(lineitem.l_quantity), l_partkey@0 as l_partkey]
71+
18)------------ProjectionExec: expr=[0.2 * CAST(avg(lineitem.l_quantity)@1 AS Float64) as Float64(0.2) * avg(lineitem.l_quantity), l_partkey@0 as l_partkey]
7272
19)--------------AggregateExec: mode=FinalPartitioned, gby=[l_partkey@0 as l_partkey], aggr=[avg(lineitem.l_quantity)]
7373
20)----------------CoalesceBatchesExec: target_batch_size=8192
7474
21)------------------RepartitionExec: partitioning=Hash([l_partkey@0], 4), input_partitions=4
7575
22)--------------------AggregateExec: mode=Partial, gby=[l_partkey@0 as l_partkey], aggr=[avg(lineitem.l_quantity)]
7676
23)----------------------CsvExec: file_groups={4 groups: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:0..18561749], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:18561749..37123498], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:37123498..55685247], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:55685247..74246996]]}, projection=[l_partkey, l_quantity], has_header=false
77-

datafusion/sqllogictest/test_files/tpch/plans/q22.slt.part

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ logical_plan
7171
13)------------SubqueryAlias: __scalar_sq_2
7272
14)--------------Aggregate: groupBy=[[]], aggr=[[avg(customer.c_acctbal)]]
7373
15)----------------Projection: customer.c_acctbal
74-
16)------------------Filter: customer.c_acctbal > Decimal128(Some(0),15,2) AND substr(customer.c_phone, Int64(1), Int64(2)) IN ([Utf8("13"), Utf8("31"), Utf8("23"), Utf8("29"), Utf8("30"), Utf8("18"), Utf8("17")])
75-
17)--------------------TableScan: customer projection=[c_phone, c_acctbal], partial_filters=[customer.c_acctbal > Decimal128(Some(0),15,2), substr(customer.c_phone, Int64(1), Int64(2)) IN ([Utf8("13"), Utf8("31"), Utf8("23"), Utf8("29"), Utf8("30"), Utf8("18"), Utf8("17")])]
74+
16)------------------Filter: CAST(customer.c_acctbal AS Float64) > Float64(0) AND substr(customer.c_phone, Int64(1), Int64(2)) IN ([Utf8("13"), Utf8("31"), Utf8("23"), Utf8("29"), Utf8("30"), Utf8("18"), Utf8("17")])
75+
17)--------------------TableScan: customer projection=[c_phone, c_acctbal], partial_filters=[CAST(customer.c_acctbal AS Float64) > Float64(0), substr(customer.c_phone, Int64(1), Int64(2)) IN ([Utf8("13"), Utf8("31"), Utf8("23"), Utf8("29"), Utf8("30"), Utf8("18"), Utf8("17")])]
7676
physical_plan
7777
01)SortPreservingMergeExec: [cntrycode@0 ASC NULLS LAST]
7878
02)--SortExec: expr=[cntrycode@0 ASC NULLS LAST], preserve_partitioning=[true]
@@ -100,6 +100,6 @@ physical_plan
100100
24)----------------------CoalescePartitionsExec
101101
25)------------------------AggregateExec: mode=Partial, gby=[], aggr=[avg(customer.c_acctbal)]
102102
26)--------------------------CoalesceBatchesExec: target_batch_size=8192
103-
27)----------------------------FilterExec: c_acctbal@1 > Some(0),15,2 AND Use substr(c_phone@0, 1, 2) IN (SET) ([Literal { value: Utf8("13") }, Literal { value: Utf8("31") }, Literal { value: Utf8("23") }, Literal { value: Utf8("29") }, Literal { value: Utf8("30") }, Literal { value: Utf8("18") }, Literal { value: Utf8("17") }]), projection=[c_acctbal@1]
103+
27)----------------------------FilterExec: CAST(c_acctbal@1 AS Float64) > 0 AND Use substr(c_phone@0, 1, 2) IN (SET) ([Literal { value: Utf8("13") }, Literal { value: Utf8("31") }, Literal { value: Utf8("23") }, Literal { value: Utf8("29") }, Literal { value: Utf8("30") }, Literal { value: Utf8("18") }, Literal { value: Utf8("17") }]), projection=[c_acctbal@1]
104104
28)------------------------------RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1
105105
29)--------------------------------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/customer.tbl]]}, projection=[c_phone, c_acctbal], has_header=false

datafusion/sqllogictest/test_files/tpch/plans/q6.slt.part

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ logical_plan
3131
01)Projection: sum(lineitem.l_extendedprice * lineitem.l_discount) AS revenue
3232
02)--Aggregate: groupBy=[[]], aggr=[[sum(lineitem.l_extendedprice * lineitem.l_discount)]]
3333
03)----Projection: lineitem.l_extendedprice, lineitem.l_discount
34-
04)------Filter: lineitem.l_shipdate >= Date32("1994-01-01") AND lineitem.l_shipdate < Date32("1995-01-01") AND lineitem.l_discount >= Decimal128(Some(5),15,2) AND lineitem.l_discount <= Decimal128(Some(7),15,2) AND lineitem.l_quantity < Decimal128(Some(2400),15,2)
35-
05)--------TableScan: lineitem projection=[l_quantity, l_extendedprice, l_discount, l_shipdate], partial_filters=[lineitem.l_shipdate >= Date32("1994-01-01"), lineitem.l_shipdate < Date32("1995-01-01"), lineitem.l_discount >= Decimal128(Some(5),15,2), lineitem.l_discount <= Decimal128(Some(7),15,2), lineitem.l_quantity < Decimal128(Some(2400),15,2)]
34+
04)------Filter: lineitem.l_shipdate >= Date32("1994-01-01") AND lineitem.l_shipdate < Date32("1995-01-01") AND CAST(lineitem.l_discount AS Float64) >= Float64(0.049999999999999996) AND CAST(lineitem.l_discount AS Float64) <= Float64(0.06999999999999999) AND lineitem.l_quantity < Decimal128(Some(2400),15,2)
35+
05)--------TableScan: lineitem projection=[l_quantity, l_extendedprice, l_discount, l_shipdate], partial_filters=[lineitem.l_shipdate >= Date32("1994-01-01"), lineitem.l_shipdate < Date32("1995-01-01"), CAST(lineitem.l_discount AS Float64) >= Float64(0.049999999999999996), CAST(lineitem.l_discount AS Float64) <= Float64(0.06999999999999999), lineitem.l_quantity < Decimal128(Some(2400),15,2)]
3636
physical_plan
3737
01)ProjectionExec: expr=[sum(lineitem.l_extendedprice * lineitem.l_discount)@0 as revenue]
3838
02)--AggregateExec: mode=Final, gby=[], aggr=[sum(lineitem.l_extendedprice * lineitem.l_discount)]
3939
03)----CoalescePartitionsExec
4040
04)------AggregateExec: mode=Partial, gby=[], aggr=[sum(lineitem.l_extendedprice * lineitem.l_discount)]
4141
05)--------CoalesceBatchesExec: target_batch_size=8192
42-
06)----------FilterExec: l_shipdate@3 >= 1994-01-01 AND l_shipdate@3 < 1995-01-01 AND l_discount@2 >= Some(5),15,2 AND l_discount@2 <= Some(7),15,2 AND l_quantity@0 < Some(2400),15,2, projection=[l_extendedprice@1, l_discount@2]
42+
06)----------FilterExec: l_shipdate@3 >= 1994-01-01 AND l_shipdate@3 < 1995-01-01 AND CAST(l_discount@2 AS Float64) >= 0.049999999999999996 AND CAST(l_discount@2 AS Float64) <= 0.06999999999999999 AND l_quantity@0 < Some(2400),15,2, projection=[l_extendedprice@1, l_discount@2]
4343
07)------------CsvExec: file_groups={4 groups: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:0..18561749], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:18561749..37123498], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:37123498..55685247], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/tpch/data/lineitem.tbl:55685247..74246996]]}, projection=[l_quantity, l_extendedprice, l_discount, l_shipdate], has_header=false

datafusion/sqllogictest/test_files/union.slt

+15
Original file line numberDiff line numberDiff line change
@@ -836,3 +836,18 @@ physical_plan
836836
# Clean up after the test
837837
statement ok
838838
drop table aggregate_test_100;
839+
840+
query T
841+
SELECT DISTINCT arrow_typeof(a) FROM (SELECT '1'::float UNION ALL SELECT '1'::decimal(10)) t(a)
842+
----
843+
Float32
844+
845+
query T
846+
SELECT DISTINCT arrow_typeof(a) FROM (SELECT '1'::decimal(10) UNION ALL SELECT '1'::float ) t(a)
847+
----
848+
Float32
849+
850+
query T
851+
SELECT DISTINCT arrow_typeof(a) FROM (SELECT '1'::decimal(10) UNION ALL SELECT '1'::double) t(a)
852+
----
853+
Float64

0 commit comments

Comments
 (0)