into_values()

This function returns the data accumulated in a frequency aggregate or top N aggregate. The aggregate operates over AnyElement types, so this method requires a type parameter to determine the type of the output.

warning

Experimental features could have bugs. They might not be backwards compatible, and could be removed in future releases. Use these features at your own risk, and do not use any experimental features in production.

Required arguments

Name Type Description
agg FrequencyAggregate The aggregate to display the values for

Returns

Column Type Description
value AnyElement One of the most common values in the data from which the aggregate was created
min_freq DOUBLE PRECISION The minimum frequency of the value in the originating data
max_freq DOUBLE PRECISION The maximum frequency of the value in the originating data

Sample usage

This test uses a table of randomly generated data. The values used are the integer square roots of a random number in the range (0,400).

2. CREATE TABLE value_test(value INTEGER);

4. INSERT INTO value_test SELECT floor(sqrt(random() * 400)) FROM generate_series(1,100000);

This returns values representing more than 5% of the input:

2. SELECT value, min_freq, max_freq

4. FROM toolkit_experimental.into_values(

6. (SELECT toolkit_experimental.freq_agg(0.05, value) FROM value_test));

The output for this query looks like this, with some variation due to randomness:

2. value | min_freq | max_freq

5. -------+----------+----------

7. 19 |  0.09815 |  0.09815

9. 18 |  0.09169 |  0.09169

11. 17 |  0.08804 |  0.08804

13. 16 |  0.08248 |  0.08248

15. 15 |  0.07703 |  0.07703

17. 14 |  0.07157 |  0.07157

19. 13 |  0.06746 |  0.06746

21. 12 |  0.06378 |  0.06378

23. 11 |  0.05565 |  0.05595

25. 10 |  0.05286 |  0.05289