Skip to main content

...About 1 min

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:

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:

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

Copyright © 2024 The Apache Software Foundation.
Apache and the Apache feather logo are trademarks of The Apache Software Foundation

Have a question? Connect with us on QQ, WeChat, or Slack. Join the community now.