Selector Functions

Currently, IoTDB supports the following selector functions:

Function NameAllowed Input Series Data TypesRequired AttributesOutput Series Data TypeDescription
TOP_KINT32 / INT64 / FLOAT / DOUBLE / TEXTk: the maximum number of selected data points, must be greater than 0 and less than or equal to 1000Same type as the input seriesReturns k data points with the largest values in a time series.
BOTTOM_KINT32 / INT64 / FLOAT / DOUBLE / TEXTk: the maximum number of selected data points, must be greater than 0 and less than or equal to 1000Same type as the input seriesReturns k data points with the smallest values in a time series.

Example:

  1. select s1, top_k(s1, 'k'='2'), bottom_k(s1, 'k'='2') from root.sg1.d2 where time > 2020-12-10T20:36:15.530+08:00;

Result:

  1. +-----------------------------+--------------------+------------------------------+---------------------------------+
  2. | Time| root.sg1.d2.s1|top_k(root.sg1.d2.s1, "k"="2")|bottom_k(root.sg1.d2.s1, "k"="2")|
  3. +-----------------------------+--------------------+------------------------------+---------------------------------+
  4. |2020-12-10T20:36:15.531+08:00| 1531604122307244742| 1531604122307244742| null|
  5. |2020-12-10T20:36:15.532+08:00|-7426070874923281101| null| null|
  6. |2020-12-10T20:36:15.533+08:00|-7162825364312197604| -7162825364312197604| null|
  7. |2020-12-10T20:36:15.534+08:00|-8581625725655917595| null| -8581625725655917595|
  8. |2020-12-10T20:36:15.535+08:00|-7667364751255535391| null| -7667364751255535391|
  9. +-----------------------------+--------------------+------------------------------+---------------------------------+
  10. Total line number = 5
  11. It costs 0.006s