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

NameTypeDescription
aggFrequencyAggregateThe aggregate to display the values for

Returns

ColumnTypeDescription
valueAnyElementOne of the most common values in the data from which the aggregate was created
min_freqDOUBLE PRECISIONThe minimum frequency of the value in the originating data
max_freqDOUBLE PRECISIONThe 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).

  1. CREATE TABLE value_test(value INTEGER);
  2. INSERT INTO value_test SELECT floor(sqrt(random() * 400)) FROM generate_series(1,100000);

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

  1. SELECT value, min_freq, max_freq
  2. FROM toolkit_experimental.into_values(
  3. (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:

  1. value | min_freq | max_freq
  2. -------+----------+----------
  3. 19 | 0.09815 | 0.09815
  4. 18 | 0.09169 | 0.09169
  5. 17 | 0.08804 | 0.08804
  6. 16 | 0.08248 | 0.08248
  7. 15 | 0.07703 | 0.07703
  8. 14 | 0.07157 | 0.07157
  9. 13 | 0.06746 | 0.06746
  10. 12 | 0.06378 | 0.06378
  11. 11 | 0.05565 | 0.05595
  12. 10 | 0.05286 | 0.05289