Merge pull request #249 from CartoDB/nullbins

Test behavior of binning fuctions with nulls
This commit is contained in:
Javier Goizueta 2016-11-30 16:09:23 +01:00 committed by GitHub
commit 25d27263cb
8 changed files with 65 additions and 14 deletions

View File

@ -2,4 +2,10 @@ WITH data AS (
SELECT array_agg(x::numeric) s FROM generate_series(1,300) x SELECT array_agg(x::numeric) s FROM generate_series(1,300) x
WHERE x % 5 != 0 AND x % 7 != 0 WHERE x % 5 != 0 AND x % 7 != 0
) )
SELECT round(unnest(CDB_EqualIntervalBins(s, 7)),7) FROM data SELECT round(unnest(CDB_EqualIntervalBins(s, 7)),7) FROM data;
WITH data_nulls AS (
SELECT array_agg(CASE WHEN x % 2 != 0 THEN x ELSE NULL END::numeric) s FROM generate_series(1,100) x
WHERE x % 5 != 0 AND x % 7 != 0
)
SELECT round(unnest(CDB_EqualIntervalBins(s, 7)),7) FROM data_nulls;

View File

@ -5,3 +5,10 @@
213.8571429 213.8571429
256.4285714 256.4285714
299.0000000 299.0000000
15.0000000
29.0000000
43.0000000
57.0000000
71.0000000
85.0000000
99.0000000

View File

@ -1,5 +1,11 @@
WITH data AS ( WITH data AS (
SELECT array_agg(x) x FROM generate_series(1,100) x SELECT array_agg(x::numeric) s FROM generate_series(1,100) x
WHERE x % 5 != 0 AND x % 7 != 0 WHERE x % 5 != 0 AND x % 7 != 0
) )
SELECT round(unnest(CDB_HeadsTailsBins(x, 7)),2) FROM data SELECT round(unnest(CDB_HeadsTailsBins(s, 7)),2) FROM data;
WITH data_nulls AS (
SELECT array_agg(CASE WHEN x % 2 != 0 THEN x ELSE NULL END::numeric) s FROM generate_series(1,100) x
WHERE x % 5 != 0 AND x % 7 != 0
)
SELECT round(unnest(CDB_HeadsTailsBins(s, 7)),2) FROM data_nulls;

View File

@ -5,3 +5,9 @@
96.50 96.50
98.00 98.00
99.00 99.00
49.76
74.65
88.50
94.50
98.00
99.00

View File

@ -1,5 +1,11 @@
WITH data AS ( WITH data AS (
SELECT array_agg(x) x FROM generate_series(1,100) x SELECT array_agg(x::numeric) s FROM generate_series(1,300) x
WHERE x % 5 != 0 AND x % 7 != 0 WHERE x % 5 != 0 AND x % 7 != 0
) )
SELECT unnest(CDB_JenksBins(x, 7)) FROM data SELECT unnest(CDB_JenksBins(s, 7)) FROM data;
WITH data_nulls AS (
SELECT array_agg(CASE WHEN x % 2 != 0 THEN x ELSE NULL END::numeric) s FROM generate_series(1,300) x
WHERE x % 5 != 0 AND x % 7 != 0
)
SELECT unnest(CDB_JenksBins(s, 7)) FROM data_nulls;

View File

@ -1,7 +1,14 @@
13
29
43 43
57 86
71 129
83 172
99 213
257
299
37
51
97
157
213
241

View File

@ -1,5 +1,11 @@
WITH data AS ( WITH data AS (
SELECT array_agg(x) x FROM generate_series(1,100) x SELECT array_agg(x::numeric) s FROM generate_series(1,100) x
WHERE x % 5 != 0 AND x % 7 != 0 WHERE x % 5 != 0 AND x % 7 != 0
) )
SELECT unnest(CDB_QuantileBins(x, 7)) FROM data SELECT unnest(CDB_QuantileBins(s, 7)) FROM data;
WITH data_nulls AS (
SELECT array_agg(CASE WHEN x % 2 != 0 THEN x ELSE NULL END::numeric) s FROM generate_series(1,100) x
WHERE x % 5 != 0 AND x % 7 != 0
)
SELECT unnest(CDB_QuantileBins(s, 7)) FROM data_nulls;

View File

@ -4,4 +4,11 @@
57 57
71 71
86 86
99
29
57
87
99 99