Skip to content

Commit d2bbcb0

Browse files
test: add comprehensive aggregate tests for streaming aggregation
1 parent f84a390 commit d2bbcb0

File tree

1 file changed

+278
-38
lines changed

1 file changed

+278
-38
lines changed

datafusion/sqllogictest/test_files/aggregate.slt

Lines changed: 278 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3054,44 +3054,6 @@ drop table corr_single_row;
30543054
statement ok
30553055
drop table corr_all_nulls;
30563056

3057-
# correlation with streaming aggregation (EmitTo::First)
3058-
# Verify that CORR's GroupsAccumulator properly drains state vectors when EmitTo::First is called.
3059-
# Set target_partitions to 1 to ensure the optimizer uses streaming aggregation (ordering_mode=Sorted) based on the input order.
3060-
statement ok
3061-
set datafusion.execution.target_partitions = 1;
3062-
3063-
# Bucket 1: CORR = 1, -1, 1, -1 (y varies)
3064-
# Bucket 2: CORR = NULL (y constant, zero variance)
3065-
query IIR
3066-
SELECT bucket, grp, CORR(x, y) FROM (
3067-
SELECT * FROM (VALUES
3068-
(1, 1, 1.0, 1.0), (1, 1, 2.0, 2.0),
3069-
(1, 2, 1.0, 2.0), (1, 2, 2.0, 1.0),
3070-
(1, 3, 1.0, 1.0), (1, 3, 2.0, 2.0),
3071-
(1, 4, 1.0, 2.0), (1, 4, 2.0, 1.0),
3072-
(2, 1, 1.0, 5.0), (2, 1, 2.0, 5.0),
3073-
(2, 2, 1.0, 5.0), (2, 2, 2.0, 5.0),
3074-
(2, 3, 1.0, 5.0), (2, 3, 2.0, 5.0),
3075-
(2, 4, 1.0, 5.0), (2, 4, 2.0, 5.0)
3076-
) AS t(bucket, grp, x, y)
3077-
ORDER BY bucket
3078-
LIMIT 1000000
3079-
) AS ordered_data
3080-
GROUP BY bucket, grp
3081-
ORDER BY bucket, grp;
3082-
----
3083-
1 1 1
3084-
1 2 -1
3085-
1 3 1
3086-
1 4 -1
3087-
2 1 NULL
3088-
2 2 NULL
3089-
2 3 NULL
3090-
2 4 NULL
3091-
3092-
statement ok
3093-
set datafusion.execution.target_partitions = 4;
3094-
30953057
# covariance_f64_4
30963058
statement ok
30973059
drop table if exists t;
@@ -8284,3 +8246,281 @@ query R
82848246
select percentile_cont(null, 0.5);
82858247
----
82868248
NULL
8249+
8250+
8251+
# Enable streaming aggregation by limiting partitions and ensuring sorted input
8252+
statement ok
8253+
set datafusion.execution.target_partitions = 1;
8254+
8255+
# Setup data
8256+
statement ok
8257+
CREATE TABLE stream_test (
8258+
g INT,
8259+
x DOUBLE,
8260+
y DOUBLE,
8261+
i INT,
8262+
b BOOLEAN,
8263+
s VARCHAR
8264+
) AS VALUES
8265+
(1, 1.0, 1.0, 1, true, 'a'), (1, 2.0, 2.0, 2, true, 'b'),
8266+
(2, 1.0, 5.0, 3, false, 'c'), (2, 2.0, 5.0, 4, true, 'd'),
8267+
(3, 1.0, 1.0, 7, false, 'e'), (3, 2.0, 2.0, 8, false, 'f');
8268+
8269+
# Test comprehensive aggregates with streaming
8270+
# This verifies that CORR and other aggregates work together in a streaming plan (ordering_mode=Sorted)
8271+
8272+
# Basic Aggregates
8273+
query TT
8274+
EXPLAIN SELECT
8275+
g,
8276+
COUNT(*),
8277+
SUM(x),
8278+
AVG(x),
8279+
MEAN(x),
8280+
MIN(x),
8281+
MAX(y),
8282+
BIT_AND(i),
8283+
BIT_OR(i),
8284+
BIT_XOR(i),
8285+
BOOL_AND(b),
8286+
BOOL_OR(b),
8287+
MEDIAN(x),
8288+
GROUPING(g),
8289+
VAR(x),
8290+
VAR_SAMP(x),
8291+
VAR_POP(x),
8292+
VAR_SAMPLE(x),
8293+
VAR_POPULATION(x),
8294+
STDDEV(x),
8295+
STDDEV_SAMP(x),
8296+
STDDEV_POP(x)
8297+
FROM (SELECT * FROM stream_test ORDER BY g LIMIT 10000)
8298+
GROUP BY g
8299+
ORDER BY g;
8300+
----
8301+
logical_plan
8302+
01)Sort: stream_test.g ASC NULLS LAST
8303+
02)--Projection: stream_test.g, count(Int64(1)) AS count(*), sum(stream_test.x), avg(stream_test.x), avg(stream_test.x) AS mean(stream_test.x), min(stream_test.x), max(stream_test.y), bit_and(stream_test.i), bit_or(stream_test.i), bit_xor(stream_test.i), bool_and(stream_test.b), bool_or(stream_test.b), median(stream_test.x), Int32(0) AS grouping(stream_test.g), var(stream_test.x), var(stream_test.x) AS var_samp(stream_test.x), var_pop(stream_test.x), var(stream_test.x) AS var_sample(stream_test.x), var_pop(stream_test.x) AS var_population(stream_test.x), stddev(stream_test.x), stddev(stream_test.x) AS stddev_samp(stream_test.x), stddev_pop(stream_test.x)
8304+
03)----Aggregate: groupBy=[[stream_test.g]], aggr=[[count(Int64(1)), sum(stream_test.x), avg(stream_test.x), min(stream_test.x), max(stream_test.y), bit_and(stream_test.i), bit_or(stream_test.i), bit_xor(stream_test.i), bool_and(stream_test.b), bool_or(stream_test.b), median(stream_test.x), var(stream_test.x), var_pop(stream_test.x), stddev(stream_test.x), stddev_pop(stream_test.x)]]
8305+
04)------Sort: stream_test.g ASC NULLS LAST, fetch=10000
8306+
05)--------TableScan: stream_test projection=[g, x, y, i, b]
8307+
physical_plan
8308+
01)ProjectionExec: expr=[g@0 as g, count(Int64(1))@1 as count(*), sum(stream_test.x)@2 as sum(stream_test.x), avg(stream_test.x)@3 as avg(stream_test.x), avg(stream_test.x)@3 as mean(stream_test.x), min(stream_test.x)@4 as min(stream_test.x), max(stream_test.y)@5 as max(stream_test.y), bit_and(stream_test.i)@6 as bit_and(stream_test.i), bit_or(stream_test.i)@7 as bit_or(stream_test.i), bit_xor(stream_test.i)@8 as bit_xor(stream_test.i), bool_and(stream_test.b)@9 as bool_and(stream_test.b), bool_or(stream_test.b)@10 as bool_or(stream_test.b), median(stream_test.x)@11 as median(stream_test.x), 0 as grouping(stream_test.g), var(stream_test.x)@12 as var(stream_test.x), var(stream_test.x)@12 as var_samp(stream_test.x), var_pop(stream_test.x)@13 as var_pop(stream_test.x), var(stream_test.x)@12 as var_sample(stream_test.x), var_pop(stream_test.x)@13 as var_population(stream_test.x), stddev(stream_test.x)@14 as stddev(stream_test.x), stddev(stream_test.x)@14 as stddev_samp(stream_test.x), stddev_pop(stream_test.x)@15 as stddev_pop(stream_test.x)]
8309+
02)--AggregateExec: mode=Single, gby=[g@0 as g], aggr=[count(Int64(1)), sum(stream_test.x), avg(stream_test.x), min(stream_test.x), max(stream_test.y), bit_and(stream_test.i), bit_or(stream_test.i), bit_xor(stream_test.i), bool_and(stream_test.b), bool_or(stream_test.b), median(stream_test.x), var(stream_test.x), var_pop(stream_test.x), stddev(stream_test.x), stddev_pop(stream_test.x)], ordering_mode=Sorted
8310+
03)----SortExec: TopK(fetch=10000), expr=[g@0 ASC NULLS LAST], preserve_partitioning=[false]
8311+
04)------DataSourceExec: partitions=1, partition_sizes=[1]
8312+
8313+
query IIRRRRRIIIBBRIRRRRRRRR
8314+
SELECT
8315+
g,
8316+
COUNT(*),
8317+
SUM(x),
8318+
AVG(x),
8319+
MEAN(x),
8320+
MIN(x),
8321+
MAX(y),
8322+
BIT_AND(i),
8323+
BIT_OR(i),
8324+
BIT_XOR(i),
8325+
BOOL_AND(b),
8326+
BOOL_OR(b),
8327+
MEDIAN(x),
8328+
GROUPING(g),
8329+
VAR(x),
8330+
VAR_SAMP(x),
8331+
VAR_POP(x),
8332+
VAR_SAMPLE(x),
8333+
VAR_POPULATION(x),
8334+
STDDEV(x),
8335+
STDDEV_SAMP(x),
8336+
STDDEV_POP(x)
8337+
FROM (SELECT * FROM stream_test ORDER BY g LIMIT 10000)
8338+
GROUP BY g
8339+
ORDER BY g;
8340+
----
8341+
1 2 3 1.5 1.5 1 2 0 3 3 true true 1.5 0 0.5 0.5 0.25 0.5 0.25 0.707106781187 0.707106781187 0.5
8342+
2 2 3 1.5 1.5 1 5 0 7 7 false true 1.5 0 0.5 0.5 0.25 0.5 0.25 0.707106781187 0.707106781187 0.5
8343+
3 2 3 1.5 1.5 1 2 0 15 15 false false 1.5 0 0.5 0.5 0.25 0.5 0.25 0.707106781187 0.707106781187 0.5
8344+
8345+
# Ordered Aggregates (by x)
8346+
query TT
8347+
EXPLAIN SELECT
8348+
g,
8349+
ARRAY_AGG(x ORDER BY x),
8350+
ARRAY_AGG(DISTINCT x ORDER BY x),
8351+
FIRST_VALUE(x ORDER BY x),
8352+
LAST_VALUE(x ORDER BY x),
8353+
NTH_VALUE(x, 1 ORDER BY x)
8354+
FROM (SELECT * FROM stream_test ORDER BY g LIMIT 10000)
8355+
GROUP BY g
8356+
ORDER BY g;
8357+
----
8358+
logical_plan
8359+
01)Sort: stream_test.g ASC NULLS LAST
8360+
02)--Aggregate: groupBy=[[stream_test.g]], aggr=[[array_agg(stream_test.x) ORDER BY [stream_test.x ASC NULLS LAST], array_agg(DISTINCT stream_test.x) ORDER BY [stream_test.x ASC NULLS LAST], first_value(stream_test.x) ORDER BY [stream_test.x ASC NULLS LAST], last_value(stream_test.x) ORDER BY [stream_test.x ASC NULLS LAST], nth_value(stream_test.x, Int64(1)) ORDER BY [stream_test.x ASC NULLS LAST]]]
8361+
03)----Sort: stream_test.g ASC NULLS LAST, fetch=10000
8362+
04)------TableScan: stream_test projection=[g, x]
8363+
physical_plan
8364+
01)AggregateExec: mode=Single, gby=[g@0 as g], aggr=[array_agg(stream_test.x) ORDER BY [stream_test.x ASC NULLS LAST], array_agg(DISTINCT stream_test.x) ORDER BY [stream_test.x ASC NULLS LAST], first_value(stream_test.x) ORDER BY [stream_test.x ASC NULLS LAST], last_value(stream_test.x) ORDER BY [stream_test.x ASC NULLS LAST], nth_value(stream_test.x,Int64(1)) ORDER BY [stream_test.x ASC NULLS LAST]], ordering_mode=Sorted
8365+
02)--SortExec: TopK(fetch=10000), expr=[g@0 ASC NULLS LAST, x@1 ASC NULLS LAST], preserve_partitioning=[false]
8366+
03)----DataSourceExec: partitions=1, partition_sizes=[1]
8367+
8368+
query I??RRR
8369+
SELECT
8370+
g,
8371+
ARRAY_AGG(x ORDER BY x),
8372+
ARRAY_AGG(DISTINCT x ORDER BY x),
8373+
FIRST_VALUE(x ORDER BY x),
8374+
LAST_VALUE(x ORDER BY x),
8375+
NTH_VALUE(x, 1 ORDER BY x)
8376+
FROM (SELECT * FROM stream_test ORDER BY g LIMIT 10000)
8377+
GROUP BY g
8378+
ORDER BY g;
8379+
----
8380+
1 [1.0, 2.0] [1.0, 2.0] 1 2 1
8381+
2 [1.0, 2.0] [1.0, 2.0] 1 2 1
8382+
3 [1.0, 2.0] [1.0, 2.0] 1 2 1
8383+
8384+
# Ordered Aggregates (by s)
8385+
query TT
8386+
EXPLAIN SELECT
8387+
g,
8388+
ARRAY_AGG(s ORDER BY s),
8389+
STRING_AGG(s, '|' ORDER BY s),
8390+
STRING_AGG(DISTINCT s, '|' ORDER BY s)
8391+
FROM (SELECT * FROM stream_test ORDER BY g LIMIT 10000)
8392+
GROUP BY g
8393+
ORDER BY g;
8394+
----
8395+
logical_plan
8396+
01)Sort: stream_test.g ASC NULLS LAST
8397+
02)--Aggregate: groupBy=[[stream_test.g]], aggr=[[array_agg(stream_test.s) ORDER BY [stream_test.s ASC NULLS LAST], string_agg(stream_test.s, Utf8("|")) ORDER BY [stream_test.s ASC NULLS LAST], string_agg(DISTINCT stream_test.s, Utf8("|")) ORDER BY [stream_test.s ASC NULLS LAST]]]
8398+
03)----Sort: stream_test.g ASC NULLS LAST, fetch=10000
8399+
04)------TableScan: stream_test projection=[g, s]
8400+
physical_plan
8401+
01)AggregateExec: mode=Single, gby=[g@0 as g], aggr=[array_agg(stream_test.s) ORDER BY [stream_test.s ASC NULLS LAST], string_agg(stream_test.s,Utf8("|")) ORDER BY [stream_test.s ASC NULLS LAST], string_agg(DISTINCT stream_test.s,Utf8("|")) ORDER BY [stream_test.s ASC NULLS LAST]], ordering_mode=Sorted
8402+
02)--SortExec: TopK(fetch=10000), expr=[g@0 ASC NULLS LAST, s@1 ASC NULLS LAST], preserve_partitioning=[false]
8403+
03)----DataSourceExec: partitions=1, partition_sizes=[1]
8404+
8405+
query I?TT
8406+
SELECT
8407+
g,
8408+
ARRAY_AGG(s ORDER BY s),
8409+
STRING_AGG(s, '|' ORDER BY s),
8410+
STRING_AGG(DISTINCT s, '|' ORDER BY s)
8411+
FROM (SELECT * FROM stream_test ORDER BY g LIMIT 10000)
8412+
GROUP BY g
8413+
ORDER BY g;
8414+
----
8415+
1 [a, b] a|b a|b
8416+
2 [c, d] c|d c|d
8417+
3 [e, f] e|f e|f
8418+
8419+
# Statistical & Regression Aggregates
8420+
query TT
8421+
EXPLAIN SELECT
8422+
g,
8423+
CORR(x, y),
8424+
COVAR(x, y),
8425+
COVAR_SAMP(x, y),
8426+
COVAR_POP(x, y),
8427+
REGR_SXX(x, y),
8428+
REGR_SXY(x, y),
8429+
REGR_SYY(x, y),
8430+
REGR_AVGX(x, y),
8431+
REGR_AVGY(x, y),
8432+
REGR_COUNT(x, y),
8433+
REGR_SLOPE(x, y),
8434+
REGR_INTERCEPT(x, y),
8435+
REGR_R2(x, y)
8436+
FROM (SELECT * FROM stream_test ORDER BY g LIMIT 10000)
8437+
GROUP BY g
8438+
ORDER BY g;
8439+
----
8440+
logical_plan
8441+
01)Sort: stream_test.g ASC NULLS LAST
8442+
02)--Projection: stream_test.g, corr(stream_test.x,stream_test.y), covar_samp(stream_test.x,stream_test.y) AS covar(stream_test.x,stream_test.y), covar_samp(stream_test.x,stream_test.y), covar_pop(stream_test.x,stream_test.y), regr_sxx(stream_test.x,stream_test.y), regr_sxy(stream_test.x,stream_test.y), regr_syy(stream_test.x,stream_test.y), regr_avgx(stream_test.x,stream_test.y), regr_avgy(stream_test.x,stream_test.y), regr_count(stream_test.x,stream_test.y), regr_slope(stream_test.x,stream_test.y), regr_intercept(stream_test.x,stream_test.y), regr_r2(stream_test.x,stream_test.y)
8443+
03)----Aggregate: groupBy=[[stream_test.g]], aggr=[[corr(stream_test.x, stream_test.y), covar_samp(stream_test.x, stream_test.y), covar_pop(stream_test.x, stream_test.y), regr_sxx(stream_test.x, stream_test.y), regr_sxy(stream_test.x, stream_test.y), regr_syy(stream_test.x, stream_test.y), regr_avgx(stream_test.x, stream_test.y), regr_avgy(stream_test.x, stream_test.y), regr_count(stream_test.x, stream_test.y), regr_slope(stream_test.x, stream_test.y), regr_intercept(stream_test.x, stream_test.y), regr_r2(stream_test.x, stream_test.y)]]
8444+
04)------Sort: stream_test.g ASC NULLS LAST, fetch=10000
8445+
05)--------TableScan: stream_test projection=[g, x, y]
8446+
physical_plan
8447+
01)ProjectionExec: expr=[g@0 as g, corr(stream_test.x,stream_test.y)@1 as corr(stream_test.x,stream_test.y), covar_samp(stream_test.x,stream_test.y)@2 as covar(stream_test.x,stream_test.y), covar_samp(stream_test.x,stream_test.y)@2 as covar_samp(stream_test.x,stream_test.y), covar_pop(stream_test.x,stream_test.y)@3 as covar_pop(stream_test.x,stream_test.y), regr_sxx(stream_test.x,stream_test.y)@4 as regr_sxx(stream_test.x,stream_test.y), regr_sxy(stream_test.x,stream_test.y)@5 as regr_sxy(stream_test.x,stream_test.y), regr_syy(stream_test.x,stream_test.y)@6 as regr_syy(stream_test.x,stream_test.y), regr_avgx(stream_test.x,stream_test.y)@7 as regr_avgx(stream_test.x,stream_test.y), regr_avgy(stream_test.x,stream_test.y)@8 as regr_avgy(stream_test.x,stream_test.y), regr_count(stream_test.x,stream_test.y)@9 as regr_count(stream_test.x,stream_test.y), regr_slope(stream_test.x,stream_test.y)@10 as regr_slope(stream_test.x,stream_test.y), regr_intercept(stream_test.x,stream_test.y)@11 as regr_intercept(stream_test.x,stream_test.y), regr_r2(stream_test.x,stream_test.y)@12 as regr_r2(stream_test.x,stream_test.y)]
8448+
02)--AggregateExec: mode=Single, gby=[g@0 as g], aggr=[corr(stream_test.x,stream_test.y), covar_samp(stream_test.x,stream_test.y), covar_pop(stream_test.x,stream_test.y), regr_sxx(stream_test.x,stream_test.y), regr_sxy(stream_test.x,stream_test.y), regr_syy(stream_test.x,stream_test.y), regr_avgx(stream_test.x,stream_test.y), regr_avgy(stream_test.x,stream_test.y), regr_count(stream_test.x,stream_test.y), regr_slope(stream_test.x,stream_test.y), regr_intercept(stream_test.x,stream_test.y), regr_r2(stream_test.x,stream_test.y)], ordering_mode=Sorted
8449+
03)----SortExec: TopK(fetch=10000), expr=[g@0 ASC NULLS LAST], preserve_partitioning=[false]
8450+
04)------DataSourceExec: partitions=1, partition_sizes=[1]
8451+
8452+
query IRRRRRRRRRIRRR
8453+
SELECT
8454+
g,
8455+
CORR(x, y),
8456+
COVAR(x, y),
8457+
COVAR_SAMP(x, y),
8458+
COVAR_POP(x, y),
8459+
REGR_SXX(x, y),
8460+
REGR_SXY(x, y),
8461+
REGR_SYY(x, y),
8462+
REGR_AVGX(x, y),
8463+
REGR_AVGY(x, y),
8464+
REGR_COUNT(x, y),
8465+
REGR_SLOPE(x, y),
8466+
REGR_INTERCEPT(x, y),
8467+
REGR_R2(x, y)
8468+
FROM (SELECT * FROM stream_test ORDER BY g LIMIT 10000)
8469+
GROUP BY g
8470+
ORDER BY g;
8471+
----
8472+
1 1 0.5 0.5 0.25 0.5 0.5 0.5 1.5 1.5 2 1 0 1
8473+
2 NULL 0 0 0 0 0 0.5 5 1.5 2 NULL NULL NULL
8474+
3 1 0.5 0.5 0.25 0.5 0.5 0.5 1.5 1.5 2 1 0 1
8475+
8476+
# Approximate and Ordered-Set Aggregates
8477+
query TT
8478+
EXPLAIN SELECT
8479+
g,
8480+
APPROX_DISTINCT(i),
8481+
APPROX_MEDIAN(x),
8482+
PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY x),
8483+
QUANTILE_CONT(0.5) WITHIN GROUP (ORDER BY x),
8484+
APPROX_PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY x),
8485+
APPROX_PERCENTILE_CONT_WITH_WEIGHT(1.0, 0.5) WITHIN GROUP (ORDER BY x),
8486+
PERCENTILE_CONT(x, 0.5),
8487+
APPROX_PERCENTILE_CONT(x, 0.5),
8488+
APPROX_PERCENTILE_CONT_WITH_WEIGHT(x, 1.0, 0.5)
8489+
FROM (SELECT * FROM stream_test ORDER BY g LIMIT 10000)
8490+
GROUP BY g
8491+
ORDER BY g;
8492+
----
8493+
logical_plan
8494+
01)Sort: stream_test.g ASC NULLS LAST
8495+
02)--Projection: stream_test.g, approx_distinct(stream_test.i), approx_median(stream_test.x), percentile_cont(Float64(0.5)) WITHIN GROUP [stream_test.x ASC NULLS LAST], percentile_cont(Float64(0.5)) WITHIN GROUP [stream_test.x ASC NULLS LAST] AS quantile_cont(stream_test.x,Float64(0.5)), approx_percentile_cont(Float64(0.5)) WITHIN GROUP [stream_test.x ASC NULLS LAST], approx_percentile_cont_with_weight(Float64(1),Float64(0.5)) WITHIN GROUP [stream_test.x ASC NULLS LAST], percentile_cont(stream_test.x,Float64(0.5)), approx_percentile_cont(stream_test.x,Float64(0.5)), approx_percentile_cont_with_weight(stream_test.x,Float64(1),Float64(0.5))
8496+
03)----Aggregate: groupBy=[[stream_test.g]], aggr=[[approx_distinct(stream_test.i), approx_median(stream_test.x), percentile_cont(stream_test.x, Float64(0.5)) ORDER BY [stream_test.x ASC NULLS LAST], approx_percentile_cont(stream_test.x, Float64(0.5)) ORDER BY [stream_test.x ASC NULLS LAST], approx_percentile_cont_with_weight(stream_test.x, Float64(1), Float64(0.5)) ORDER BY [stream_test.x ASC NULLS LAST], percentile_cont(stream_test.x, Float64(0.5)), approx_percentile_cont(stream_test.x, Float64(0.5)), approx_percentile_cont_with_weight(stream_test.x, Float64(1), Float64(0.5))]]
8497+
04)------Sort: stream_test.g ASC NULLS LAST, fetch=10000
8498+
05)--------TableScan: stream_test projection=[g, x, i]
8499+
physical_plan
8500+
01)ProjectionExec: expr=[g@0 as g, approx_distinct(stream_test.i)@1 as approx_distinct(stream_test.i), approx_median(stream_test.x)@2 as approx_median(stream_test.x), percentile_cont(Float64(0.5)) WITHIN GROUP [stream_test.x ASC NULLS LAST]@3 as percentile_cont(Float64(0.5)) WITHIN GROUP [stream_test.x ASC NULLS LAST], percentile_cont(Float64(0.5)) WITHIN GROUP [stream_test.x ASC NULLS LAST]@3 as quantile_cont(stream_test.x,Float64(0.5)), approx_percentile_cont(Float64(0.5)) WITHIN GROUP [stream_test.x ASC NULLS LAST]@4 as approx_percentile_cont(Float64(0.5)) WITHIN GROUP [stream_test.x ASC NULLS LAST], approx_percentile_cont_with_weight(Float64(1),Float64(0.5)) WITHIN GROUP [stream_test.x ASC NULLS LAST]@5 as approx_percentile_cont_with_weight(Float64(1),Float64(0.5)) WITHIN GROUP [stream_test.x ASC NULLS LAST], percentile_cont(stream_test.x,Float64(0.5))@6 as percentile_cont(stream_test.x,Float64(0.5)), approx_percentile_cont(stream_test.x,Float64(0.5))@7 as approx_percentile_cont(stream_test.x,Float64(0.5)), approx_percentile_cont_with_weight(stream_test.x,Float64(1),Float64(0.5))@8 as approx_percentile_cont_with_weight(stream_test.x,Float64(1),Float64(0.5))]
8501+
02)--AggregateExec: mode=Single, gby=[g@0 as g], aggr=[approx_distinct(stream_test.i), approx_median(stream_test.x), percentile_cont(Float64(0.5)) WITHIN GROUP [stream_test.x ASC NULLS LAST], approx_percentile_cont(Float64(0.5)) WITHIN GROUP [stream_test.x ASC NULLS LAST], approx_percentile_cont_with_weight(Float64(1),Float64(0.5)) WITHIN GROUP [stream_test.x ASC NULLS LAST], percentile_cont(stream_test.x,Float64(0.5)), approx_percentile_cont(stream_test.x,Float64(0.5)), approx_percentile_cont_with_weight(stream_test.x,Float64(1),Float64(0.5))], ordering_mode=Sorted
8502+
03)----SortExec: TopK(fetch=10000), expr=[g@0 ASC NULLS LAST], preserve_partitioning=[false]
8503+
04)------DataSourceExec: partitions=1, partition_sizes=[1]
8504+
8505+
query IIRRRRRRRR
8506+
SELECT
8507+
g,
8508+
APPROX_DISTINCT(i),
8509+
APPROX_MEDIAN(x),
8510+
PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY x),
8511+
QUANTILE_CONT(0.5) WITHIN GROUP (ORDER BY x),
8512+
APPROX_PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY x),
8513+
APPROX_PERCENTILE_CONT_WITH_WEIGHT(1.0, 0.5) WITHIN GROUP (ORDER BY x),
8514+
PERCENTILE_CONT(x, 0.5),
8515+
APPROX_PERCENTILE_CONT(x, 0.5),
8516+
APPROX_PERCENTILE_CONT_WITH_WEIGHT(x, 1.0, 0.5)
8517+
FROM (SELECT * FROM stream_test ORDER BY g LIMIT 10000)
8518+
GROUP BY g
8519+
ORDER BY g;
8520+
----
8521+
1 2 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5
8522+
2 2 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5
8523+
3 2 1.5 1.5 1.5 1.5 1.5 1.5 1.5 1.5
8524+
8525+
statement ok
8526+
DROP TABLE stream_test;

0 commit comments

Comments
 (0)