2022-01-20 02:51:23 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can use, redistribute, and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3
|
|
|
|
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _TD_FUNCTION_MGT_H_
|
|
|
|
|
#define _TD_FUNCTION_MGT_H_
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-02-17 11:30:43 +00:00
|
|
|
#include "function.h"
|
2022-04-26 10:15:06 +00:00
|
|
|
#include "querynodes.h"
|
2022-01-20 02:51:23 +00:00
|
|
|
|
2022-05-28 11:56:06 +00:00
|
|
|
#define FUNC_AGGREGATE_UDF_ID 5001
|
|
|
|
|
#define FUNC_SCALAR_UDF_ID 5002
|
|
|
|
|
|
2024-09-27 10:08:36 +00:00
|
|
|
extern const int32_t funcMgtBuiltinsNum;
|
|
|
|
|
|
2022-02-09 01:03:32 +00:00
|
|
|
typedef enum EFunctionType {
|
|
|
|
|
// aggregate function
|
|
|
|
|
FUNCTION_TYPE_APERCENTILE = 1,
|
|
|
|
|
FUNCTION_TYPE_AVG,
|
|
|
|
|
FUNCTION_TYPE_COUNT,
|
|
|
|
|
FUNCTION_TYPE_ELAPSED,
|
|
|
|
|
FUNCTION_TYPE_IRATE,
|
|
|
|
|
FUNCTION_TYPE_LAST_ROW,
|
|
|
|
|
FUNCTION_TYPE_MAX,
|
|
|
|
|
FUNCTION_TYPE_MIN,
|
|
|
|
|
FUNCTION_TYPE_MODE,
|
|
|
|
|
FUNCTION_TYPE_PERCENTILE,
|
|
|
|
|
FUNCTION_TYPE_SPREAD,
|
|
|
|
|
FUNCTION_TYPE_STDDEV,
|
2022-05-09 11:37:16 +00:00
|
|
|
FUNCTION_TYPE_LEASTSQUARES,
|
2022-02-09 01:03:32 +00:00
|
|
|
FUNCTION_TYPE_SUM,
|
|
|
|
|
FUNCTION_TYPE_TWA,
|
2022-04-28 13:27:46 +00:00
|
|
|
FUNCTION_TYPE_HISTOGRAM,
|
2022-05-17 02:34:59 +00:00
|
|
|
FUNCTION_TYPE_HYPERLOGLOG,
|
feat:[TS-4893] Support MYSQL functions.
Add more functions:
- Numeric Functions: PI(),ROUND(),TRUNC(),EXP(),LN(),SIGN(),DEGREES(),RADIANS().
- String Functions: CHAR(),ASCII(),POSITION(),TRIM(),REPLACE(),REPEAT().
- Date and Time Functions: WEEKDAY(),DAYOFWEEK(),WEEK(),WEEKOFYEAR().
- Aggregate Functions: VAR_POP().
Modify some functions:
- ROUND(): support round to given decimal places.
- CHAR_LENGTH(): support calculate multi-byte character's length.
- TIMEDIFF(): result will be negative when expr1 < expr2.
- STDDEV(): add alias name STDDEV_POP().
- SUBSTR(): add alias name SUBSTRING().
support new syntax SUBSTRING/SUBSTR(expr FROM pos [FOR len]).
2024-07-31 06:42:38 +00:00
|
|
|
FUNCTION_TYPE_STDVAR,
|
2022-02-09 01:03:32 +00:00
|
|
|
|
|
|
|
|
// nonstandard SQL function
|
|
|
|
|
FUNCTION_TYPE_BOTTOM = 500,
|
|
|
|
|
FUNCTION_TYPE_CSUM,
|
|
|
|
|
FUNCTION_TYPE_DERIVATIVE,
|
|
|
|
|
FUNCTION_TYPE_DIFF,
|
|
|
|
|
FUNCTION_TYPE_FIRST,
|
|
|
|
|
FUNCTION_TYPE_INTERP,
|
|
|
|
|
FUNCTION_TYPE_LAST,
|
|
|
|
|
FUNCTION_TYPE_MAVG,
|
|
|
|
|
FUNCTION_TYPE_SAMPLE,
|
|
|
|
|
FUNCTION_TYPE_TAIL,
|
|
|
|
|
FUNCTION_TYPE_TOP,
|
|
|
|
|
FUNCTION_TYPE_UNIQUE,
|
2022-05-10 12:32:03 +00:00
|
|
|
FUNCTION_TYPE_STATE_COUNT,
|
|
|
|
|
FUNCTION_TYPE_STATE_DURATION,
|
2024-10-15 02:00:38 +00:00
|
|
|
FUNCTION_TYPE_FORECAST,
|
2025-09-09 00:31:20 +00:00
|
|
|
FUNCTION_TYPE_IMPUTATION,
|
2022-02-09 01:03:32 +00:00
|
|
|
|
|
|
|
|
// math function
|
|
|
|
|
FUNCTION_TYPE_ABS = 1000,
|
|
|
|
|
FUNCTION_TYPE_LOG,
|
|
|
|
|
FUNCTION_TYPE_POW,
|
2022-03-25 08:24:36 +00:00
|
|
|
FUNCTION_TYPE_SQRT,
|
|
|
|
|
FUNCTION_TYPE_CEIL,
|
|
|
|
|
FUNCTION_TYPE_FLOOR,
|
2022-02-09 01:03:32 +00:00
|
|
|
FUNCTION_TYPE_ROUND,
|
2022-03-25 08:24:36 +00:00
|
|
|
|
2022-02-09 01:03:32 +00:00
|
|
|
FUNCTION_TYPE_SIN,
|
2022-03-25 08:24:36 +00:00
|
|
|
FUNCTION_TYPE_COS,
|
2022-02-09 01:03:32 +00:00
|
|
|
FUNCTION_TYPE_TAN,
|
2022-03-25 08:24:36 +00:00
|
|
|
FUNCTION_TYPE_ASIN,
|
|
|
|
|
FUNCTION_TYPE_ACOS,
|
|
|
|
|
FUNCTION_TYPE_ATAN,
|
feat:[TS-4893] Support MYSQL functions.
Add more functions:
- Numeric Functions: PI(),ROUND(),TRUNC(),EXP(),LN(),SIGN(),DEGREES(),RADIANS().
- String Functions: CHAR(),ASCII(),POSITION(),TRIM(),REPLACE(),REPEAT().
- Date and Time Functions: WEEKDAY(),DAYOFWEEK(),WEEK(),WEEKOFYEAR().
- Aggregate Functions: VAR_POP().
Modify some functions:
- ROUND(): support round to given decimal places.
- CHAR_LENGTH(): support calculate multi-byte character's length.
- TIMEDIFF(): result will be negative when expr1 < expr2.
- STDDEV(): add alias name STDDEV_POP().
- SUBSTR(): add alias name SUBSTRING().
support new syntax SUBSTRING/SUBSTR(expr FROM pos [FOR len]).
2024-07-31 06:42:38 +00:00
|
|
|
FUNCTION_TYPE_PI,
|
|
|
|
|
FUNCTION_TYPE_EXP,
|
|
|
|
|
FUNCTION_TYPE_LN,
|
|
|
|
|
FUNCTION_TYPE_MOD,
|
|
|
|
|
FUNCTION_TYPE_RAND,
|
|
|
|
|
FUNCTION_TYPE_SIGN,
|
|
|
|
|
FUNCTION_TYPE_DEGREES,
|
|
|
|
|
FUNCTION_TYPE_RADIANS,
|
|
|
|
|
FUNCTION_TYPE_TRUNCATE,
|
2025-03-05 10:28:48 +00:00
|
|
|
FUNCTION_TYPE_GREATEST,
|
|
|
|
|
FUNCTION_TYPE_LEAST,
|
2025-03-20 01:27:11 +00:00
|
|
|
FUNCTION_TYPE_CRC32,
|
2022-02-09 01:03:32 +00:00
|
|
|
|
|
|
|
|
// string function
|
2022-03-30 06:03:54 +00:00
|
|
|
FUNCTION_TYPE_LENGTH = 1500,
|
|
|
|
|
FUNCTION_TYPE_CHAR_LENGTH,
|
2022-02-09 01:03:32 +00:00
|
|
|
FUNCTION_TYPE_CONCAT,
|
|
|
|
|
FUNCTION_TYPE_CONCAT_WS,
|
2022-03-30 06:03:54 +00:00
|
|
|
FUNCTION_TYPE_LOWER,
|
|
|
|
|
FUNCTION_TYPE_UPPER,
|
|
|
|
|
FUNCTION_TYPE_LTRIM,
|
|
|
|
|
FUNCTION_TYPE_RTRIM,
|
|
|
|
|
FUNCTION_TYPE_SUBSTR,
|
2024-03-26 03:08:16 +00:00
|
|
|
FUNCTION_TYPE_MD5,
|
feat:[TS-4893] Support MYSQL functions.
Add more functions:
- Numeric Functions: PI(),ROUND(),TRUNC(),EXP(),LN(),SIGN(),DEGREES(),RADIANS().
- String Functions: CHAR(),ASCII(),POSITION(),TRIM(),REPLACE(),REPEAT().
- Date and Time Functions: WEEKDAY(),DAYOFWEEK(),WEEK(),WEEKOFYEAR().
- Aggregate Functions: VAR_POP().
Modify some functions:
- ROUND(): support round to given decimal places.
- CHAR_LENGTH(): support calculate multi-byte character's length.
- TIMEDIFF(): result will be negative when expr1 < expr2.
- STDDEV(): add alias name STDDEV_POP().
- SUBSTR(): add alias name SUBSTRING().
support new syntax SUBSTRING/SUBSTR(expr FROM pos [FOR len]).
2024-07-31 06:42:38 +00:00
|
|
|
FUNCTION_TYPE_CHAR,
|
|
|
|
|
FUNCTION_TYPE_ASCII,
|
|
|
|
|
FUNCTION_TYPE_POSITION,
|
|
|
|
|
FUNCTION_TYPE_TRIM,
|
|
|
|
|
FUNCTION_TYPE_REPLACE,
|
|
|
|
|
FUNCTION_TYPE_REPEAT,
|
|
|
|
|
FUNCTION_TYPE_SUBSTR_IDX,
|
2025-03-30 21:54:43 +00:00
|
|
|
FUNCTION_TYPE_BASE64,
|
2022-02-09 01:03:32 +00:00
|
|
|
|
|
|
|
|
// conversion function
|
|
|
|
|
FUNCTION_TYPE_CAST = 2000,
|
|
|
|
|
FUNCTION_TYPE_TO_ISO8601,
|
2022-04-12 12:02:33 +00:00
|
|
|
FUNCTION_TYPE_TO_UNIXTIMESTAMP,
|
2022-02-09 01:03:32 +00:00
|
|
|
FUNCTION_TYPE_TO_JSON,
|
2023-10-19 03:34:04 +00:00
|
|
|
FUNCTION_TYPE_TO_TIMESTAMP,
|
|
|
|
|
FUNCTION_TYPE_TO_CHAR,
|
2022-02-09 01:03:32 +00:00
|
|
|
|
|
|
|
|
// date and time function
|
|
|
|
|
FUNCTION_TYPE_NOW = 2500,
|
|
|
|
|
FUNCTION_TYPE_TIMEDIFF,
|
|
|
|
|
FUNCTION_TYPE_TIMETRUNCATE,
|
|
|
|
|
FUNCTION_TYPE_TIMEZONE,
|
|
|
|
|
FUNCTION_TYPE_TODAY,
|
feat:[TS-4893] Support MYSQL functions.
Add more functions:
- Numeric Functions: PI(),ROUND(),TRUNC(),EXP(),LN(),SIGN(),DEGREES(),RADIANS().
- String Functions: CHAR(),ASCII(),POSITION(),TRIM(),REPLACE(),REPEAT().
- Date and Time Functions: WEEKDAY(),DAYOFWEEK(),WEEK(),WEEKOFYEAR().
- Aggregate Functions: VAR_POP().
Modify some functions:
- ROUND(): support round to given decimal places.
- CHAR_LENGTH(): support calculate multi-byte character's length.
- TIMEDIFF(): result will be negative when expr1 < expr2.
- STDDEV(): add alias name STDDEV_POP().
- SUBSTR(): add alias name SUBSTRING().
support new syntax SUBSTRING/SUBSTR(expr FROM pos [FOR len]).
2024-07-31 06:42:38 +00:00
|
|
|
FUNCTION_TYPE_WEEK,
|
|
|
|
|
FUNCTION_TYPE_WEEKDAY,
|
|
|
|
|
FUNCTION_TYPE_WEEKOFYEAR,
|
|
|
|
|
FUNCTION_TYPE_DAYOFWEEK,
|
2025-08-21 11:29:37 +00:00
|
|
|
FUNCTION_TYPE_DATE,
|
2022-02-09 01:03:32 +00:00
|
|
|
|
|
|
|
|
// system function
|
|
|
|
|
FUNCTION_TYPE_DATABASE = 3000,
|
|
|
|
|
FUNCTION_TYPE_CLIENT_VERSION,
|
2022-06-29 03:41:32 +00:00
|
|
|
FUNCTION_TYPE_SERVER_VERSION,
|
2022-02-09 01:03:32 +00:00
|
|
|
FUNCTION_TYPE_SERVER_STATUS,
|
|
|
|
|
FUNCTION_TYPE_CURRENT_USER,
|
2022-03-28 11:26:06 +00:00
|
|
|
FUNCTION_TYPE_USER,
|
|
|
|
|
|
|
|
|
|
// pseudo column function
|
|
|
|
|
FUNCTION_TYPE_ROWTS = 3500,
|
|
|
|
|
FUNCTION_TYPE_TBNAME,
|
2022-07-13 07:13:01 +00:00
|
|
|
FUNCTION_TYPE_QSTART,
|
|
|
|
|
FUNCTION_TYPE_QEND,
|
|
|
|
|
FUNCTION_TYPE_QDURATION,
|
|
|
|
|
FUNCTION_TYPE_WSTART,
|
|
|
|
|
FUNCTION_TYPE_WEND,
|
2022-04-20 09:43:02 +00:00
|
|
|
FUNCTION_TYPE_WDURATION,
|
2022-09-27 07:23:24 +00:00
|
|
|
FUNCTION_TYPE_IROWTS,
|
2022-12-14 08:23:49 +00:00
|
|
|
FUNCTION_TYPE_ISFILLED,
|
2022-09-29 08:16:49 +00:00
|
|
|
FUNCTION_TYPE_TAGS,
|
2023-06-26 03:48:47 +00:00
|
|
|
FUNCTION_TYPE_TBUID,
|
|
|
|
|
FUNCTION_TYPE_VGID,
|
2024-02-01 03:37:57 +00:00
|
|
|
FUNCTION_TYPE_VGVER,
|
2024-10-15 02:00:38 +00:00
|
|
|
FUNCTION_TYPE_FORECAST_LOW,
|
|
|
|
|
FUNCTION_TYPE_FORECAST_HIGH,
|
|
|
|
|
FUNCTION_TYPE_FORECAST_ROWTS,
|
2024-12-09 08:21:14 +00:00
|
|
|
FUNCTION_TYPE_COLS,
|
2024-11-28 10:29:20 +00:00
|
|
|
FUNCTION_TYPE_IROWTS_ORIGIN,
|
2025-03-14 12:14:01 +00:00
|
|
|
FUNCTION_TYPE_GROUP_ID,
|
|
|
|
|
FUNCTION_TYPE_IS_WINDOW_FILLED,
|
2025-07-16 06:42:16 +00:00
|
|
|
FUNCTION_TYPE_TPREV_TS, // _tprev_ts
|
|
|
|
|
FUNCTION_TYPE_TCURRENT_TS, // _tcurrent_ts
|
|
|
|
|
FUNCTION_TYPE_TNEXT_TS, // _tnext_ts
|
|
|
|
|
FUNCTION_TYPE_TWSTART, // _twstart
|
|
|
|
|
FUNCTION_TYPE_TWEND, // _twend
|
|
|
|
|
FUNCTION_TYPE_TWDURATION, // _twduration
|
|
|
|
|
FUNCTION_TYPE_TWROWNUM, // _twrownum
|
|
|
|
|
FUNCTION_TYPE_TPREV_LOCALTIME, // _tprev_localtime
|
|
|
|
|
FUNCTION_TYPE_TNEXT_LOCALTIME, // _tnext_localtime
|
|
|
|
|
FUNCTION_TYPE_TLOCALTIME, // _tlocaltime
|
|
|
|
|
FUNCTION_TYPE_TGRPID, // _tgrpid
|
|
|
|
|
FUNCTION_TYPE_PLACEHOLDER_COLUMN, // %%n
|
|
|
|
|
FUNCTION_TYPE_PLACEHOLDER_TBNAME, // %%tbname
|
2025-09-09 00:31:20 +00:00
|
|
|
FUNCTION_TYPE_IMPUTATION_ROWTS,
|
|
|
|
|
FUNCTION_TYPE_IMPUTATION_MARKS,
|
2022-04-20 09:43:02 +00:00
|
|
|
|
2022-05-01 00:38:17 +00:00
|
|
|
// internal function
|
2022-09-27 07:23:24 +00:00
|
|
|
FUNCTION_TYPE_SELECT_VALUE = 3750,
|
2022-06-18 10:37:18 +00:00
|
|
|
FUNCTION_TYPE_BLOCK_DIST, // block distribution aggregate function
|
|
|
|
|
FUNCTION_TYPE_BLOCK_DIST_INFO, // block distribution pseudo column function
|
2022-06-23 10:03:15 +00:00
|
|
|
FUNCTION_TYPE_TO_COLUMN,
|
2022-06-24 12:08:07 +00:00
|
|
|
FUNCTION_TYPE_GROUP_KEY,
|
2022-06-30 02:23:35 +00:00
|
|
|
FUNCTION_TYPE_CACHE_LAST_ROW,
|
2022-10-18 03:38:59 +00:00
|
|
|
FUNCTION_TYPE_CACHE_LAST,
|
2022-11-15 08:38:51 +00:00
|
|
|
FUNCTION_TYPE_TABLE_COUNT,
|
2024-07-22 03:19:11 +00:00
|
|
|
FUNCTION_TYPE_GROUP_CONST_VALUE,
|
2022-05-01 00:38:17 +00:00
|
|
|
|
2022-06-07 03:23:19 +00:00
|
|
|
// distributed splitting functions
|
2022-06-10 10:32:34 +00:00
|
|
|
FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000,
|
2022-06-07 03:23:19 +00:00
|
|
|
FUNCTION_TYPE_APERCENTILE_MERGE,
|
2022-06-08 06:26:45 +00:00
|
|
|
FUNCTION_TYPE_SPREAD_PARTIAL,
|
|
|
|
|
FUNCTION_TYPE_SPREAD_MERGE,
|
2022-06-08 09:38:51 +00:00
|
|
|
FUNCTION_TYPE_HISTOGRAM_PARTIAL,
|
|
|
|
|
FUNCTION_TYPE_HISTOGRAM_MERGE,
|
2022-06-09 02:57:32 +00:00
|
|
|
FUNCTION_TYPE_HYPERLOGLOG_PARTIAL,
|
|
|
|
|
FUNCTION_TYPE_HYPERLOGLOG_MERGE,
|
2022-06-09 11:15:09 +00:00
|
|
|
FUNCTION_TYPE_ELAPSED_PARTIAL,
|
|
|
|
|
FUNCTION_TYPE_ELAPSED_MERGE,
|
2022-06-13 11:35:27 +00:00
|
|
|
|
2022-06-10 10:32:34 +00:00
|
|
|
FUNCTION_TYPE_TOP_PARTIAL,
|
|
|
|
|
FUNCTION_TYPE_TOP_MERGE,
|
2022-06-13 05:38:21 +00:00
|
|
|
FUNCTION_TYPE_BOTTOM_PARTIAL,
|
|
|
|
|
FUNCTION_TYPE_BOTTOM_MERGE,
|
2022-06-13 11:11:28 +00:00
|
|
|
FUNCTION_TYPE_FIRST_PARTIAL,
|
|
|
|
|
FUNCTION_TYPE_FIRST_MERGE,
|
2022-06-14 02:51:00 +00:00
|
|
|
FUNCTION_TYPE_LAST_PARTIAL,
|
|
|
|
|
FUNCTION_TYPE_LAST_MERGE,
|
2022-06-14 07:00:28 +00:00
|
|
|
FUNCTION_TYPE_AVG_PARTIAL,
|
|
|
|
|
FUNCTION_TYPE_AVG_MERGE,
|
feat:[TS-4893] Support MYSQL functions.
Add more functions:
- Numeric Functions: PI(),ROUND(),TRUNC(),EXP(),LN(),SIGN(),DEGREES(),RADIANS().
- String Functions: CHAR(),ASCII(),POSITION(),TRIM(),REPLACE(),REPEAT().
- Date and Time Functions: WEEKDAY(),DAYOFWEEK(),WEEK(),WEEKOFYEAR().
- Aggregate Functions: VAR_POP().
Modify some functions:
- ROUND(): support round to given decimal places.
- CHAR_LENGTH(): support calculate multi-byte character's length.
- TIMEDIFF(): result will be negative when expr1 < expr2.
- STDDEV(): add alias name STDDEV_POP().
- SUBSTR(): add alias name SUBSTRING().
support new syntax SUBSTRING/SUBSTR(expr FROM pos [FOR len]).
2024-07-31 06:42:38 +00:00
|
|
|
FUNCTION_TYPE_STD_PARTIAL,
|
2022-06-14 08:42:05 +00:00
|
|
|
FUNCTION_TYPE_STDDEV_MERGE,
|
feat:[TS-4893] Support MYSQL functions.
Add more functions:
- Numeric Functions: PI(),ROUND(),TRUNC(),EXP(),LN(),SIGN(),DEGREES(),RADIANS().
- String Functions: CHAR(),ASCII(),POSITION(),TRIM(),REPLACE(),REPEAT().
- Date and Time Functions: WEEKDAY(),DAYOFWEEK(),WEEK(),WEEKOFYEAR().
- Aggregate Functions: VAR_POP().
Modify some functions:
- ROUND(): support round to given decimal places.
- CHAR_LENGTH(): support calculate multi-byte character's length.
- TIMEDIFF(): result will be negative when expr1 < expr2.
- STDDEV(): add alias name STDDEV_POP().
- SUBSTR(): add alias name SUBSTRING().
support new syntax SUBSTRING/SUBSTR(expr FROM pos [FOR len]).
2024-07-31 06:42:38 +00:00
|
|
|
FUNCTION_TYPE_STDVAR_MERGE,
|
2023-08-15 04:59:30 +00:00
|
|
|
FUNCTION_TYPE_IRATE_PARTIAL,
|
|
|
|
|
FUNCTION_TYPE_IRATE_MERGE,
|
2023-11-29 11:07:23 +00:00
|
|
|
FUNCTION_TYPE_AVG_STATE,
|
|
|
|
|
FUNCTION_TYPE_AVG_STATE_MERGE,
|
2024-03-08 10:26:38 +00:00
|
|
|
FUNCTION_TYPE_FIRST_STATE,
|
|
|
|
|
FUNCTION_TYPE_FIRST_STATE_MERGE,
|
|
|
|
|
FUNCTION_TYPE_LAST_STATE,
|
|
|
|
|
FUNCTION_TYPE_LAST_STATE_MERGE,
|
2024-03-11 11:29:08 +00:00
|
|
|
FUNCTION_TYPE_SPREAD_STATE,
|
|
|
|
|
FUNCTION_TYPE_SPREAD_STATE_MERGE,
|
feat:[TS-4893] Support MYSQL functions.
Add more functions:
- Numeric Functions: PI(),ROUND(),TRUNC(),EXP(),LN(),SIGN(),DEGREES(),RADIANS().
- String Functions: CHAR(),ASCII(),POSITION(),TRIM(),REPLACE(),REPEAT().
- Date and Time Functions: WEEKDAY(),DAYOFWEEK(),WEEK(),WEEKOFYEAR().
- Aggregate Functions: VAR_POP().
Modify some functions:
- ROUND(): support round to given decimal places.
- CHAR_LENGTH(): support calculate multi-byte character's length.
- TIMEDIFF(): result will be negative when expr1 < expr2.
- STDDEV(): add alias name STDDEV_POP().
- SUBSTR(): add alias name SUBSTRING().
support new syntax SUBSTRING/SUBSTR(expr FROM pos [FOR len]).
2024-07-31 06:42:38 +00:00
|
|
|
FUNCTION_TYPE_STD_STATE,
|
|
|
|
|
FUNCTION_TYPE_STD_STATE_MERGE,
|
2024-03-11 11:29:08 +00:00
|
|
|
FUNCTION_TYPE_HYPERLOGLOG_STATE,
|
|
|
|
|
FUNCTION_TYPE_HYPERLOGLOG_STATE_MERGE,
|
2022-06-07 03:23:19 +00:00
|
|
|
|
2024-12-09 08:21:14 +00:00
|
|
|
|
2023-05-24 07:36:46 +00:00
|
|
|
// geometry functions
|
|
|
|
|
FUNCTION_TYPE_GEOM_FROM_TEXT = 4250,
|
|
|
|
|
FUNCTION_TYPE_AS_TEXT,
|
|
|
|
|
FUNCTION_TYPE_MAKE_POINT,
|
|
|
|
|
FUNCTION_TYPE_INTERSECTS,
|
|
|
|
|
FUNCTION_TYPE_EQUALS,
|
|
|
|
|
FUNCTION_TYPE_TOUCHES,
|
|
|
|
|
FUNCTION_TYPE_COVERS,
|
|
|
|
|
FUNCTION_TYPE_CONTAINS,
|
|
|
|
|
FUNCTION_TYPE_CONTAINS_PROPERLY,
|
|
|
|
|
|
2024-11-12 13:10:17 +00:00
|
|
|
FUNCTION_TYPE_DB_USAGE = 4300,
|
|
|
|
|
FUNCTION_TYPE_DB_USAGE_INFO,
|
|
|
|
|
|
2022-04-20 09:43:02 +00:00
|
|
|
// user defined funcion
|
|
|
|
|
FUNCTION_TYPE_UDF = 10000
|
2022-02-09 01:03:32 +00:00
|
|
|
} EFunctionType;
|
|
|
|
|
|
2022-07-29 10:00:48 +00:00
|
|
|
typedef enum EFuncReturnRows {
|
|
|
|
|
FUNC_RETURN_ROWS_NORMAL = 1,
|
|
|
|
|
FUNC_RETURN_ROWS_INDEFINITE,
|
|
|
|
|
FUNC_RETURN_ROWS_N,
|
|
|
|
|
FUNC_RETURN_ROWS_N_MINUS_1
|
|
|
|
|
} EFuncReturnRows;
|
|
|
|
|
|
2022-01-28 02:44:02 +00:00
|
|
|
struct SqlFunctionCtx;
|
2022-01-20 02:51:23 +00:00
|
|
|
struct SResultRowEntryInfo;
|
|
|
|
|
struct STimeWindow;
|
2022-04-21 05:37:18 +00:00
|
|
|
|
2022-01-20 02:51:23 +00:00
|
|
|
int32_t fmFuncMgtInit();
|
|
|
|
|
|
2022-03-10 11:32:39 +00:00
|
|
|
void fmFuncMgtDestroy();
|
|
|
|
|
|
2022-05-28 11:56:06 +00:00
|
|
|
int32_t fmGetFuncInfo(SFunctionNode* pFunc, char* pMsg, int32_t msgLen);
|
2022-02-09 01:03:32 +00:00
|
|
|
|
2022-07-29 10:00:48 +00:00
|
|
|
EFuncReturnRows fmGetFuncReturnRows(SFunctionNode* pFunc);
|
|
|
|
|
|
2022-08-31 03:36:59 +00:00
|
|
|
bool fmIsBuiltinFunc(const char* pFunc);
|
|
|
|
|
EFunctionType fmGetFuncType(const char* pFunc);
|
2022-05-19 06:26:10 +00:00
|
|
|
|
2022-01-20 02:51:23 +00:00
|
|
|
bool fmIsAggFunc(int32_t funcId);
|
2022-02-09 01:03:32 +00:00
|
|
|
bool fmIsScalarFunc(int32_t funcId);
|
2022-05-23 11:50:08 +00:00
|
|
|
bool fmIsVectorFunc(int32_t funcId);
|
2025-07-23 09:11:16 +00:00
|
|
|
bool fmIsStreamVectorFunc(int32_t funcId);
|
2022-05-23 11:50:08 +00:00
|
|
|
bool fmIsIndefiniteRowsFunc(int32_t funcId);
|
2022-01-20 02:51:23 +00:00
|
|
|
bool fmIsStringFunc(int32_t funcId);
|
2023-04-13 03:22:15 +00:00
|
|
|
bool fmIsDateTimeFunc(int32_t funcId);
|
2022-05-01 00:38:17 +00:00
|
|
|
bool fmIsSelectFunc(int32_t funcId);
|
2022-01-20 02:51:23 +00:00
|
|
|
bool fmIsTimelineFunc(int32_t funcId);
|
|
|
|
|
bool fmIsTimeorderFunc(int32_t funcId);
|
2022-04-02 12:20:26 +00:00
|
|
|
bool fmIsPseudoColumnFunc(int32_t funcId);
|
2022-04-26 10:15:06 +00:00
|
|
|
bool fmIsScanPseudoColumnFunc(int32_t funcId);
|
2022-03-28 11:26:06 +00:00
|
|
|
bool fmIsWindowPseudoColumnFunc(int32_t funcId);
|
|
|
|
|
bool fmIsWindowClauseFunc(int32_t funcId);
|
2025-07-16 06:42:16 +00:00
|
|
|
bool fmIsStreamWindowClauseFunc(int32_t funcId);
|
2022-04-12 05:10:47 +00:00
|
|
|
bool fmIsSpecialDataRequiredFunc(int32_t funcId);
|
|
|
|
|
bool fmIsDynamicScanOptimizedFunc(int32_t funcId);
|
2022-04-15 10:30:01 +00:00
|
|
|
bool fmIsMultiResFunc(int32_t funcId);
|
2022-05-09 12:20:05 +00:00
|
|
|
bool fmIsRepeatScanFunc(int32_t funcId);
|
2022-04-20 09:43:02 +00:00
|
|
|
bool fmIsUserDefinedFunc(int32_t funcId);
|
2022-06-02 02:45:27 +00:00
|
|
|
bool fmIsDistExecFunc(int32_t funcId);
|
2022-06-11 07:44:49 +00:00
|
|
|
bool fmIsForbidFillFunc(int32_t funcId);
|
2023-06-26 10:43:00 +00:00
|
|
|
bool fmIsForbidSysTableFunc(int32_t funcId);
|
2022-06-14 03:54:13 +00:00
|
|
|
bool fmIsIntervalInterpoFunc(int32_t funcId);
|
2022-06-19 11:39:12 +00:00
|
|
|
bool fmIsInterpFunc(int32_t funcId);
|
2022-06-21 11:52:26 +00:00
|
|
|
bool fmIsLastRowFunc(int32_t funcId);
|
2025-03-15 06:10:46 +00:00
|
|
|
bool fmIsLastFunc(int32_t funcId);
|
2024-10-15 02:00:38 +00:00
|
|
|
bool fmIsForecastFunc(int32_t funcId);
|
2025-09-09 00:31:20 +00:00
|
|
|
bool fmIsImputationFunc(int32_t funcId);
|
2022-08-06 22:39:26 +00:00
|
|
|
bool fmIsNotNullOutputFunc(int32_t funcId);
|
2022-08-01 06:15:16 +00:00
|
|
|
bool fmIsSelectValueFunc(int32_t funcId);
|
2022-06-29 03:41:32 +00:00
|
|
|
bool fmIsSystemInfoFunc(int32_t funcId);
|
2022-07-01 05:31:22 +00:00
|
|
|
bool fmIsImplicitTsFunc(int32_t funcId);
|
2022-07-13 10:12:02 +00:00
|
|
|
bool fmIsClientPseudoColumnFunc(int32_t funcId);
|
2022-07-15 08:17:00 +00:00
|
|
|
bool fmIsMultiRowsFunc(int32_t funcId);
|
2022-07-22 03:41:18 +00:00
|
|
|
bool fmIsKeepOrderFunc(int32_t funcId);
|
2022-07-29 10:00:48 +00:00
|
|
|
bool fmIsCumulativeFunc(int32_t funcId);
|
2022-09-27 07:23:24 +00:00
|
|
|
bool fmIsInterpPseudoColumnFunc(int32_t funcId);
|
2024-10-15 02:00:38 +00:00
|
|
|
bool fmIsForecastPseudoColumnFunc(int32_t funcId);
|
2022-11-01 05:34:10 +00:00
|
|
|
bool fmIsGroupKeyFunc(int32_t funcId);
|
2023-02-02 03:57:22 +00:00
|
|
|
bool fmIsBlockDistFunc(int32_t funcId);
|
2024-04-09 01:48:38 +00:00
|
|
|
bool fmIsIgnoreNullFunc(int32_t funcId);
|
2023-08-30 08:51:44 +00:00
|
|
|
bool fmIsConstantResFunc(SFunctionNode* pFunc);
|
2023-09-19 06:56:02 +00:00
|
|
|
bool fmIsSkipScanCheckFunc(int32_t funcId);
|
2024-03-15 10:34:41 +00:00
|
|
|
bool fmIsPrimaryKeyFunc(int32_t funcId);
|
2024-07-04 03:04:59 +00:00
|
|
|
bool fmIsProcessByRowFunc(int32_t funcId);
|
2024-07-22 03:19:11 +00:00
|
|
|
bool fmisSelectGroupConstValueFunc(int32_t funcId);
|
2024-09-12 07:34:57 +00:00
|
|
|
bool fmIsElapsedFunc(int32_t funcId);
|
2024-11-12 13:10:17 +00:00
|
|
|
bool fmIsDBUsageFunc(int32_t funcId);
|
2024-11-28 10:29:20 +00:00
|
|
|
bool fmIsRowTsOriginFunc(int32_t funcId);
|
2024-12-09 08:21:14 +00:00
|
|
|
bool fmIsSelectColsFunc(int32_t funcId);
|
2025-03-14 12:14:01 +00:00
|
|
|
bool fmIsGroupIdFunc(int32_t funcId);
|
2025-07-16 06:42:16 +00:00
|
|
|
bool fmIsPlaceHolderFunc(int32_t funcId);
|
2022-06-02 02:45:27 +00:00
|
|
|
|
2024-11-12 13:10:17 +00:00
|
|
|
void getLastCacheDataType(SDataType* pType, int32_t pkBytes);
|
2024-07-20 09:34:29 +00:00
|
|
|
int32_t createFunction(const char* pName, SNodeList* pParameterList, SFunctionNode** pFunc);
|
2024-10-27 14:41:34 +00:00
|
|
|
int32_t createFunctionWithSrcFunc(const char* pName, const SFunctionNode* pSrcFunc, SNodeList* pParameterList, SFunctionNode** pFunc);
|
2022-10-18 03:38:59 +00:00
|
|
|
|
2024-11-12 13:10:17 +00:00
|
|
|
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMidFunc,
|
|
|
|
|
SFunctionNode** pMergeFunc);
|
2022-02-09 01:03:32 +00:00
|
|
|
|
2022-04-12 05:10:47 +00:00
|
|
|
typedef enum EFuncDataRequired {
|
2022-04-15 10:06:49 +00:00
|
|
|
FUNC_DATA_REQUIRED_DATA_LOAD = 1,
|
2022-11-04 10:46:48 +00:00
|
|
|
FUNC_DATA_REQUIRED_SMA_LOAD,
|
2022-04-15 10:06:49 +00:00
|
|
|
FUNC_DATA_REQUIRED_NOT_LOAD,
|
|
|
|
|
FUNC_DATA_REQUIRED_FILTEROUT,
|
2023-05-12 05:30:17 +00:00
|
|
|
FUNC_DATA_REQUIRED_ALL_FILTEROUT,
|
2022-04-12 05:10:47 +00:00
|
|
|
} EFuncDataRequired;
|
|
|
|
|
|
|
|
|
|
EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
2024-08-27 09:07:13 +00:00
|
|
|
EFuncDataRequired fmFuncDynDataRequired(int32_t funcId, void* pRes, SDataBlockInfo* pBlockInfo);
|
2022-01-20 02:51:23 +00:00
|
|
|
|
2022-02-17 01:34:55 +00:00
|
|
|
int32_t fmGetFuncExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet);
|
|
|
|
|
int32_t fmGetScalarFuncExecFuncs(int32_t funcId, SScalarFuncExecFuncs* pFpSet);
|
2022-04-28 06:43:54 +00:00
|
|
|
int32_t fmGetUdafExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet);
|
2024-01-12 05:49:32 +00:00
|
|
|
|
|
|
|
|
#ifdef BUILD_NO_CALL
|
2022-05-05 11:50:11 +00:00
|
|
|
int32_t fmSetInvertFunc(int32_t funcId, SFuncExecFuncs* pFpSet);
|
|
|
|
|
int32_t fmSetNormalFunc(int32_t funcId, SFuncExecFuncs* pFpSet);
|
2022-05-09 12:20:05 +00:00
|
|
|
bool fmIsInvertible(int32_t funcId);
|
2024-01-12 05:49:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
2024-11-12 13:10:17 +00:00
|
|
|
char* fmGetFuncName(int32_t funcId);
|
2022-01-20 02:51:23 +00:00
|
|
|
|
2023-12-22 06:05:31 +00:00
|
|
|
bool fmIsTSMASupportedFunc(func_id_t funcId);
|
|
|
|
|
int32_t fmCreateStateFuncs(SNodeList* pFuncs);
|
2023-12-27 06:38:02 +00:00
|
|
|
int32_t fmCreateStateMergeFuncs(SNodeList* pFuncs);
|
2023-12-22 06:05:31 +00:00
|
|
|
int32_t fmGetFuncId(const char* name);
|
|
|
|
|
bool fmIsMyStateFunc(int32_t funcId, int32_t stateFuncId);
|
2024-03-11 11:29:08 +00:00
|
|
|
bool fmIsCountLikeFunc(int32_t funcId);
|
2023-11-29 11:07:23 +00:00
|
|
|
|
2025-07-16 06:42:16 +00:00
|
|
|
// typedef enum SStreamPseudoFuncType {
|
|
|
|
|
// STREAM_PSEUDO_FUNC_CURRENT_TS = 0,
|
|
|
|
|
// STREAM_PSEUDO_FUNC_TWSTART = 1,
|
|
|
|
|
// STREAM_PSEUDO_FUNC_TWEND = 2,
|
|
|
|
|
// STREAM_PSEUDO_FUNC_TWDURATION = 3,
|
|
|
|
|
// STREAM_PSEUDO_FUNC_TWROWNUM = 4,
|
|
|
|
|
// STREAM_PSEUDO_FUNC_TLOCALTIME = 5,
|
|
|
|
|
// STREAM_PSEUDO_FUNC_TGRPID = 6,
|
|
|
|
|
// STREAM_PSEUDO_FUNC_PLACEHOLDER_COLUMN = 7,
|
|
|
|
|
// STREAM_PSEUDO_FUNC_PLACEHOLDER_TBNAME = 8,
|
|
|
|
|
|
|
|
|
|
// } SStreamPseudoFuncType;
|
|
|
|
|
|
|
|
|
|
int32_t fmGetStreamPesudoFuncEnv(int32_t funcId, SNodeList* pParamNodes, SFuncExecEnv *pEnv);
|
|
|
|
|
|
|
|
|
|
int32_t fmSetStreamPseudoFuncParamVal(int32_t funcId, SNodeList* pParamNodes, const SStreamRuntimeFuncInfo* pStreamRuntimeInfo);
|
|
|
|
|
|
|
|
|
|
const void* fmGetStreamPesudoFuncVal(int32_t funcId, const SStreamRuntimeFuncInfo* pStreamRuntimeFuncInfo);
|
|
|
|
|
|
|
|
|
|
void fmGetStreamPesudoFuncValTbname(int32_t funcId, const SStreamRuntimeFuncInfo* pStreamRuntimeFuncInfo, void** data, int32_t* dataLen);
|
2022-01-20 02:51:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif // _TD_FUNCTION_MGT_H_
|