Skip to content

Commit c86cb2e

Browse files
committed
add group_median_table to test group median.
1 parent 311f82f commit c86cb2e

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

datafusion/functions-aggregate/src/median.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,14 +448,14 @@ impl<T: ArrowNumericType + Send> GroupsAccumulator for MedianGroupsAccumulator<T
448448
// `nulls` for converted `ListArray`
449449
let nulls = filtered_null_mask(opt_filter, input_array);
450450

451-
let converted_list_array = Arc::new(ListArray::new(
451+
let converted_list_array = ListArray::new(
452452
Arc::new(Field::new_list_field(self.data_type.clone(), false)),
453453
offsets,
454454
Arc::new(values),
455455
nulls,
456-
));
456+
);
457457

458-
Ok(vec![converted_list_array])
458+
Ok(vec![Arc::new(converted_list_array)])
459459
}
460460

461461
fn supports_convert_to_state(&self) -> bool {

datafusion/sqllogictest/test_files/aggregate.slt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,31 @@ statement ok
6767
CREATE TABLE test (c1 BIGINT,c2 BIGINT) as values
6868
(0,null), (1,1), (null,1), (3,2), (3,2)
6969

70+
statement ok
71+
CREATE TABLE group_median_table (
72+
col_group STRING,
73+
col_i8 TINYINT,
74+
col_i16 SMALLINT,
75+
col_i32 INT,
76+
col_i64 BIGINT,
77+
col_u8 TINYINT UNSIGNED,
78+
col_u16 SMALLINT UNSIGNED,
79+
col_u32 INT UNSIGNED,
80+
col_u64 BIGINT UNSIGNED,
81+
col_f32 FLOAT,
82+
col_f64 DOUBLE,
83+
col_f64_nan DOUBLE
84+
) as VALUES
85+
( "group0", -128, -32768, -2147483648, arrow_cast(-9223372036854775808,'Int64'), 0, 0, 0, arrow_cast(0,'UInt64'), 1.1, 1.1, 1.1 ),
86+
( "group0", -128, -32768, -2147483648, arrow_cast(-9223372036854775808,'Int64'), 0, 0, 0, arrow_cast(0,'UInt64'), 4.4, 4.4, arrow_cast('NAN','Float64') ),
87+
( "group0", 100, 100, 100, arrow_cast(100,'Int64'), 100, 100, 100, arrow_cast(100,'UInt64'), 3.3, 3.3, arrow_cast('NAN','Float64') ),
88+
( "group0", 127, 32767, 2147483647, arrow_cast(9223372036854775807,'Int64'), 255, 65535, 4294967295, 18446744073709551615, 2.2, 2.2, arrow_cast('NAN','Float64') ),
89+
( "group1", -128, -32768, -2147483648, arrow_cast(-9223372036854775808,'Int64'), 0, 0, 0, arrow_cast(0,'UInt64'), 1.1, 1.1, 1.1 ),
90+
( "group1", -128, -32768, -2147483648, arrow_cast(-9223372036854775808,'Int64'), 0, 0, 0, arrow_cast(0,'UInt64'), 4.4, 4.4, arrow_cast('NAN','Float64') ),
91+
( "group1", 100, 100, 100, arrow_cast(100,'Int64'), 101, 100, 100, arrow_cast(100,'UInt64'), 3.3, 3.3, arrow_cast('NAN','Float64') ),
92+
( "group1", 125, 32766, 2147483646, arrow_cast(9223372036854775806,'Int64'), 100, 101, 4294967294, arrow_cast(100,'UInt64'), 3.2, 5.5, arrow_cast('NAN','Float64') ),
93+
( "group1", 127, 32767, 2147483647, arrow_cast(9223372036854775807,'Int64'), 255, 65535, 4294967295, 18446744073709551615, 2.2, 2.2, arrow_cast('NAN','Float64') )
94+
7095
#######
7196
# Error tests
7297
#######

0 commit comments

Comments
 (0)