forked from duckdb/duckdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request duckdb#9653 from carlopi/serialize_quantiles
Serialize decimal quantiles
- Loading branch information
Showing
6 changed files
with
204 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/include/duckdb/core_functions/aggregate/quantile_enum.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//===----------------------------------------------------------------------===// | ||
// DuckDB | ||
// | ||
// duckdb/core_functions/aggregate/quantile_enum.hpp | ||
// | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
|
||
namespace duckdb { | ||
|
||
enum class QuantileSerializationType : uint8_t { | ||
NON_DECIMAL = 0, | ||
DECIMAL_DISCRETE, | ||
DECIMAL_DISCRETE_LIST, | ||
DECIMAL_CONTINUOUS, | ||
DECIMAL_CONTINUOUS_LIST | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# name: test/sql/aggregate/quantile_fun.test | ||
# description: Test pg_sequence function | ||
# group: [aggregate] | ||
|
||
require tpch | ||
|
||
# scalar quantiles | ||
statement ok | ||
create table quantiles as select range r, random() FROM range(100) union all values (NULL, 0.1), (NULL, 0.5), (NULL, 0.9) order by 2; | ||
|
||
statement ok | ||
CALL dbgen(sf=0.001); | ||
|
||
statement ok | ||
PRAGMA enable_verification; | ||
|
||
statement ok | ||
PRAGMA verify_external; | ||
|
||
statement ok | ||
SELECT quantile_disc(0.1::decimal(4,1), [0.1, 0.5, 0.9]); | ||
|
||
statement ok | ||
SELECT PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY "l_extendedprice") FROM lineitem; | ||
|
||
statement ok | ||
SET default_null_order='nulls_first'; | ||
|
||
foreach type decimal(4,1) decimal(8,1) decimal(12,1) decimal(18,1) decimal(24,1) | ||
|
||
query I | ||
SELECT quantile_disc(r::${type}, 0.1) FROM quantiles | ||
---- | ||
9.0 | ||
|
||
query I | ||
SELECT quantile_disc(r::${type}, [0.1, 0.5, 0.9]) FROM quantiles | ||
---- | ||
[9.0, 49.0, 89.0] | ||
|
||
query I | ||
SELECT quantile_cont(r::${type}, 0.15) FROM quantiles | ||
---- | ||
14.8 | ||
|
||
query I | ||
SELECT quantile_cont(r::${type}, [0.15, 0.5, 0.9]) FROM quantiles | ||
---- | ||
[14.8, 49.5, 89.1] | ||
|
||
endloop |