apache / iotdb

Apache IoTDB
https://iotdb.apache.org/
Apache License 2.0
5.61k stars 1.02k forks source link

[Bug] The built-in function MAX_BY cannot be used 无法使用内置函数MAX_BY #12943

Closed LmangM closed 3 months ago

LmangM commented 3 months ago

Search before asking

Version

Version: 1.3.1 BuildInfo: 214695d

Describe the bug and provide the minimal reproduce step

SQL Refer: https://iotdb.apache.org/zh/UserGuide/latest/Reference/Function-and-Expression.html#max-by

As you can see, when using the built-in function MAX_BY, iotdb says that the function is not registered. It was also not found when I used the SHOW FUNCTIONS command to query registered functions. See the bash code below for details.

SQL参考: https://iotdb.apache.org/zh/UserGuide/latest/Reference/Function-and-Expression.html#max-by

如你所见,在使用内置函数MAX_BY时,iotdb提示该函数未注册。当我使用SHOW FUNCTIONS命令查询已注册函数时也未发现此函数。详细内容请看下方bash代码。

---------------------
Starting IoTDB Cli
---------------------
 _____       _________  ______   ______
|_   _|     |  _   _  ||_   _ `.|_   _ \
  | |   .--.|_/ | | \_|  | | `. \ | |_) |
  | | / .'`\ \  | |      | |  | | |  __'.
 _| |_| \__. | _| |_    _| |_.' /_| |__) |
|_____|'.__.' |_____|  |______.'|_______/  version 1.3.1 (Build: 214695d)

Successfully login at 192.168.123.123:6667

IoTDB> select stat from root.ln.wf01.wt01 order by time desc limit 10
+-----------------------------+----------------------+
|                         Time|root.ln.wf01.wt01.stat|
+-----------------------------+----------------------+
|2025-01-01T00:00:00.000+08:00|             2630159.0|
|2024-12-31T23:30:00.000+08:00|             2630094.5|
|2024-12-31T23:00:00.000+08:00|             2630037.2|
|2024-12-31T22:30:00.000+08:00|             2629961.5|
|2024-12-31T22:00:00.000+08:00|             2629891.5|
|2024-12-31T21:30:00.000+08:00|             2629837.0|
|2024-12-31T21:00:00.000+08:00|             2629755.0|
|2024-12-31T20:30:00.000+08:00|             2629684.2|
|2024-12-31T20:00:00.000+08:00|             2629610.0|
|2024-12-31T19:30:00.000+08:00|             2629559.2|
+-----------------------------+----------------------+
Total line number = 10
It costs 0.140s

IoTDB> select max_value(stat) from root.ln.wf01.wt01
+---------------------------------+
|max_value(root.ln.wf01.wt01.stat)|
+---------------------------------+
|                        2630159.0|
+---------------------------------+
Total line number = 1
It costs 0.079s

IoTDB> select max_by(time,stat) from root.ln.wf01.wt01
Msg: org.apache.iotdb.jdbc.IoTDBSQLException: 701: Error occurred during inferring UDF data type:
java.lang.RuntimeException: Failed to reflect UDF instance, because UDF MAX_BY has not been registered.

IoTDB> show functions
+--------------------------------+---------------+---------------------------------------------------------------------+
|                    FunctionName|   FunctionType|                                                       ClassName(UDF)|
+--------------------------------+---------------+---------------------------------------------------------------------+
|                             ABS|  built-in UDTF|                         org.apache.iotdb.commons.udf.builtin.UDTFAbs|
|                            ACOS|  built-in UDTF|                        org.apache.iotdb.commons.udf.builtin.UDTFAcos|
|                            ASIN|  built-in UDTF|                        org.apache.iotdb.commons.udf.builtin.UDTFAsin|
|                            ATAN|  built-in UDTF|                        org.apache.iotdb.commons.udf.builtin.UDTFAtan|
|                        BOTTOM_K|  built-in UDTF|                     org.apache.iotdb.commons.udf.builtin.UDTFBottomK|
|                            CEIL|  built-in UDTF|                        org.apache.iotdb.commons.udf.builtin.UDTFCeil|
|                   CHANGE_POINTS|  built-in UDTF|                org.apache.iotdb.commons.udf.builtin.UDTFChangePoints|
|                          CONCAT|  built-in UDTF|               org.apache.iotdb.commons.udf.builtin.String.UDTFConcat|
|                           CONST|  built-in UDTF|                       org.apache.iotdb.commons.udf.builtin.UDTFConst|
|                             COS|  built-in UDTF|                         org.apache.iotdb.commons.udf.builtin.UDTFCos|
|                            COSH|  built-in UDTF|                        org.apache.iotdb.commons.udf.builtin.UDTFCosh|
|                         DEGREES|  built-in UDTF|                     org.apache.iotdb.commons.udf.builtin.UDTFDegrees|
|                      DERIVATIVE|  built-in UDTF|            org.apache.iotdb.commons.udf.builtin.UDTFCommonDerivative|
|                      DIFFERENCE|  built-in UDTF|       org.apache.iotdb.commons.udf.builtin.UDTFCommonValueDifference|
|                               E|  built-in UDTF|                      org.apache.iotdb.commons.udf.builtin.UDTFConstE|
|                        ENDSWITH|  built-in UDTF|             org.apache.iotdb.commons.udf.builtin.String.UDTFEndsWith|
|    EQUAL_SIZE_BUCKET_AGG_SAMPLE|  built-in UDTF|    org.apache.iotdb.commons.udf.builtin.UDTFEqualSizeBucketAggSample|
|     EQUAL_SIZE_BUCKET_M4_SAMPLE|  built-in UDTF|     org.apache.iotdb.commons.udf.builtin.UDTFEqualSizeBucketM4Sample|
|EQUAL_SIZE_BUCKET_OUTLIER_SAMPLE|  built-in UDTF|org.apache.iotdb.commons.udf.builtin.UDTFEqualSizeBucketOutlierSample|
| EQUAL_SIZE_BUCKET_RANDOM_SAMPLE|  built-in UDTF| org.apache.iotdb.commons.udf.builtin.UDTFEqualSizeBucketRandomSample|
|                             EXP|  built-in UDTF|                         org.apache.iotdb.commons.udf.builtin.UDTFExp|
|                           FLOOR|  built-in UDTF|                       org.apache.iotdb.commons.udf.builtin.UDTFFloor|
|                        IN_RANGE|  built-in UDTF|                     org.apache.iotdb.commons.udf.builtin.UDTFInRange|
|                            JEXL|  built-in UDTF|                        org.apache.iotdb.commons.udf.builtin.UDTFJexl|
|                          LENGTH|  built-in UDTF|            org.apache.iotdb.commons.udf.builtin.String.UDTFStrLength|
|                              LN|  built-in UDTF|                         org.apache.iotdb.commons.udf.builtin.UDTFLog|
|                          LOCATE|  built-in UDTF|            org.apache.iotdb.commons.udf.builtin.String.UDTFStrLocate|
|                           LOG10|  built-in UDTF|                       org.apache.iotdb.commons.udf.builtin.UDTFLog10|
|                           LOWER|  built-in UDTF|                org.apache.iotdb.commons.udf.builtin.String.UDTFLower|
|                              M4|  built-in UDTF|                          org.apache.iotdb.commons.udf.builtin.UDTFM4|
|                   MASTER_REPAIR|  built-in UDTF|                org.apache.iotdb.commons.udf.builtin.UDTFMasterRepair|
|         NON_NEGATIVE_DERIVATIVE|  built-in UDTF|       org.apache.iotdb.commons.udf.builtin.UDTFNonNegativeDerivative|
|         NON_NEGATIVE_DIFFERENCE|  built-in UDTF|  org.apache.iotdb.commons.udf.builtin.UDTFNonNegativeValueDifference|
|                  NON_ZERO_COUNT|  built-in UDTF|                org.apache.iotdb.commons.udf.builtin.UDTFNonZeroCount|
|               NON_ZERO_DURATION|  built-in UDTF|             org.apache.iotdb.commons.udf.builtin.UDTFNonZeroDuration|
|                          ON_OFF|  built-in UDTF|                       org.apache.iotdb.commons.udf.builtin.UDTFOnOff|
|                              PI|  built-in UDTF|                     org.apache.iotdb.commons.udf.builtin.UDTFConstPi|
|                         RADIANS|  built-in UDTF|                     org.apache.iotdb.commons.udf.builtin.UDTFRadians|
|                            SIGN|  built-in UDTF|                        org.apache.iotdb.commons.udf.builtin.UDTFSign|
|                             SIN|  built-in UDTF|                         org.apache.iotdb.commons.udf.builtin.UDTFSin|
|                            SINH|  built-in UDTF|                        org.apache.iotdb.commons.udf.builtin.UDTFSinh|
|                            SQRT|  built-in UDTF|                        org.apache.iotdb.commons.udf.builtin.UDTFSqrt|
|                      STARTSWITH|  built-in UDTF|           org.apache.iotdb.commons.udf.builtin.String.UDTFStartsWith|
|                          STRCMP|  built-in UDTF|           org.apache.iotdb.commons.udf.builtin.String.UDTFStrCompare|
|                 STRING_CONTAINS|  built-in UDTF|                    org.apache.iotdb.commons.udf.builtin.UDTFContains|
|                  STRING_MATCHES|  built-in UDTF|                     org.apache.iotdb.commons.udf.builtin.UDTFMatches|
|                             TAN|  built-in UDTF|                         org.apache.iotdb.commons.udf.builtin.UDTFTan|
|                            TANH|  built-in UDTF|                        org.apache.iotdb.commons.udf.builtin.UDTFTanh|
|                 TIME_DIFFERENCE|  built-in UDTF|              org.apache.iotdb.commons.udf.builtin.UDTFTimeDifference|
|                           TOP_K|  built-in UDTF|                        org.apache.iotdb.commons.udf.builtin.UDTFTopK|
|                            TRIM|  built-in UDTF|                 org.apache.iotdb.commons.udf.builtin.String.UDTFTrim|
|                           UPPER|  built-in UDTF|                org.apache.iotdb.commons.udf.builtin.String.UDTFUpper|
|                      ZERO_COUNT|  built-in UDTF|                   org.apache.iotdb.commons.udf.builtin.UDTFZeroCount|
|                   ZERO_DURATION|  built-in UDTF|                org.apache.iotdb.commons.udf.builtin.UDTFZeroDuration|
|                         VAR_POP|         native|                                                                     |
|                      LAST_VALUE|         native|                                                                     |
|                           COUNT|         native|                                                                     |
|                     STDDEV_SAMP|         native|                                                                     |
|                        VAR_SAMP|         native|                                                                     |
|                             SUM|         native|                                                                     |
|                      STDDEV_POP|         native|                                                                     |
|                        MIN_TIME|         native|                                                                     |
|                            MODE|         native|                                                                     |
|                      COUNT_TIME|         native|                                                                     |
|                       MIN_VALUE|         native|                                                                     |
|                             AVG|         native|                                                                     |
|                        VARIANCE|         native|                                                                     |
|                     FIRST_VALUE|         native|                                                                     |
|                   TIME_DURATION|         native|                                                                     |
|                        MAX_TIME|         native|                                                                     |
|                          STDDEV|         native|                                                                     |
|                         EXTREME|         native|                                                                     |
|                        COUNT_IF|         native|                                                                     |
|                       MAX_VALUE|         native|                                                                     |
|                            CAST|built-in scalar|                                                                     |
|                           ROUND|built-in scalar|                                                                     |
|                         REPLACE|built-in scalar|                                                                     |
|                            DIFF|built-in scalar|                                                                     |
|                       SUBSTRING|built-in scalar|                                                                     |
+--------------------------------+---------------+---------------------------------------------------------------------+
Total line number = 79
It costs 0.099s

What did you expect to see?

Make the MAX BY function usable as a user manual.

What did you see instead?

Msg: org.apache.iotdb.jdbc.IoTDBSQLException: 701: Error occurred during inferring UDF data type: java.lang.RuntimeException: Failed to reflect UDF instance, because UDF MAX_BY has not been registered.

Anything else?

nothing

Are you willing to submit a PR?

github-actions[bot] commented 3 months ago

Hi, this is your first issue in IoTDB project. Thanks for your report. Welcome to join the community!

HTHou commented 3 months ago

https://github.com/apache/iotdb/releases/tag/v1.3.2 这个函数是 1.3.2 版本中新增的