diff --git a/.github/workflows/tdengine-test.yml b/.github/workflows/tdengine-test.yml index 15904436807..d90ba3cf9d3 100644 --- a/.github/workflows/tdengine-test.yml +++ b/.github/workflows/tdengine-test.yml @@ -10,7 +10,6 @@ on: paths-ignore: - 'packaging/**' - 'docs/**' - - '!docs/examples/**' - 'tools/tdgpt/**' - 'source/libs/executor/src/forecastoperator.c' - 'source/libs/executor/src/anomalywindowoperator.c' diff --git a/docs/en/07-develop/09-udf.md b/docs/en/07-develop/09-udf.md index 2c4e05af956..2f0d2b15994 100644 --- a/docs/en/07-develop/09-udf.md +++ b/docs/en/07-develop/09-udf.md @@ -241,7 +241,7 @@ To better operate the above data structures, some convenience functions are prov ### C UDF Example Code -#### Scalar Function Example +#### Scalar Function Example [bit_and](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/bit_and.c) `bit_and` implements the bitwise AND function for multiple columns. If there is only one column, it returns that column. `bit_and` ignores null values. @@ -249,12 +249,12 @@ To better operate the above data structures, some convenience functions are prov bit_and.c ```c -{{#include docs/examples/udf/bit_and.c}} +{{#include tests/script/sh/bit_and.c}} ``` -#### Aggregate Function Example 1 Returning Numeric Type +#### Aggregate Function Example 1 Returning Numeric Type [l2norm](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/l2norm.c) `l2norm` implements the second-order norm of all data in the input columns, i.e., squaring each data point, then summing them up, and finally taking the square root. @@ -262,12 +262,12 @@ To better operate the above data structures, some convenience functions are prov l2norm.c ```c -{{#include docs/examples/udf/l2norm.c}} +{{#include tests/script/sh/l2norm.c}} ``` -#### Aggregate Function Example 2 Returning String Type +#### Aggregate Function Example 2 Returning String Type [max_vol](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/max_vol.c) `max_vol` implements finding the maximum voltage from multiple input voltage columns, returning a composite string value consisting of the device ID + the position (row, column) of the maximum voltage + the maximum voltage value. @@ -293,12 +293,12 @@ select max_vol(vol1, vol2, vol3, deviceid) from battery; max_vol.c ```c -{{#include docs/examples/udf/max_vol.c}} +{{#include tests/script/sh/max_vol.c}} ``` -#### Aggregate Function Example 3 Split string and calculate average value +#### Aggregate Function Example 3 Split string and calculate average value [extract_avg](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/extract_avg.c) The `extract_avg` function converts a comma-separated string sequence into a set of numerical values, counts the results of all rows, and calculates the final average. Note when implementing: @@ -327,14 +327,14 @@ select extract_avg(valStr) from scores; Generate `.so` file ```bash -gcc -g -O0 -fPIC -shared extract_avg.c -o libextract_avg.so +gcc -g -O0 -fPIC -shared extract_vag.c -o libextract_avg.so ```
-extract_avg.c +max_vol.c ```c -{{#include docs/examples/udf/extract_avg.c}} +{{#include tests/script/sh/max_vol.c}} ```
@@ -866,7 +866,7 @@ Through this example, we learned how to define aggregate functions and print cus ### More Python UDF Example Code -#### Scalar Function Example +#### Scalar Function Example [pybitand](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/pybitand.py) `pybitand` implements the bitwise AND function for multiple columns. If there is only one column, it returns that column. `pybitand` ignores null values. @@ -874,32 +874,32 @@ Through this example, we learned how to define aggregate functions and print cus pybitand.py ```python -{{#include docs/examples/udf/pybitand.py}} +{{#include tests/script/sh/pybitand.py}} ``` -#### Aggregate Function Example +#### Aggregate Function Example [pyl2norm](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/pyl2norm.py) `pyl2norm` calculates the second-order norm of all data in the input column, i.e., squares each data point, then sums them up, and finally takes the square root.
pyl2norm.py -```python -{{#include docs/examples/udf/pyl2norm.py}} +```c +{{#include tests/script/sh/pyl2norm.py}} ```
-#### Aggregate Function Example +#### Aggregate Function Example [pycumsum](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/pycumsum.py) `pycumsum` uses numpy to calculate the cumulative sum of all data in the input column.
pycumsum.py -```python -{{#include docs/examples/udf/pycumsum.py}} +```c +{{#include tests/script/sh/pycumsum.py}} ```
diff --git a/docs/zh/07-develop/09-udf.md b/docs/zh/07-develop/09-udf.md index 63f416877c7..6ee9a955f67 100644 --- a/docs/zh/07-develop/09-udf.md +++ b/docs/zh/07-develop/09-udf.md @@ -245,7 +245,7 @@ typedef struct SUdfInterBuf { ### C UDF 示例代码 -#### 标量函数示例 +#### 标量函数示例 [bit_and](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/bit_and.c) bit_and 实现多列的按位与功能。如果只有一列,返回这一列。bit_and 忽略空值。 @@ -253,12 +253,12 @@ bit_and 实现多列的按位与功能。如果只有一列,返回这一列。 bit_and.c ```c -{{#include docs/examples/udf/bit_and.c}} +{{#include tests/script/sh/bit_and.c}} ``` -#### 聚合函数示例 1 返回值为数值类型 +#### 聚合函数示例 1 返回值为数值类型 [l2norm](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/l2norm.c) l2norm 实现了输入列的所有数据的二阶范数,即对每个数据先平方,再累加求和,最后开方。 @@ -266,12 +266,12 @@ l2norm 实现了输入列的所有数据的二阶范数,即对每个数据先 l2norm.c ```c -{{#include docs/examples/udf/l2norm.c}} +{{#include tests/script/sh/l2norm.c}} ``` -#### 聚合函数示例 2 返回值为字符串类型 +#### 聚合函数示例 2 返回值为字符串类型 [max_vol](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/max_vol.c) max_vol 实现了从多个输入的电压列中找到最大电压,返回由设备 ID + 最大电压所在(行,列)+ 最大电压值 组成的组合字符串值 @@ -297,12 +297,12 @@ select max_vol(vol1, vol2, vol3, deviceid) from battery; max_vol.c ```c -{{#include docs/examples/udf/max_vol.c}} +{{#include tests/script/sh/max_vol.c}} ``` -#### 聚合函数示例 3 切分字符串求平均值 +#### 聚合函数示例 3 切分字符串求平均值 [extract_avg](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/extract_avg.c) `extract_avg` 函数是将一个逗号分隔的字符串数列转为一组数值,统计所有行的结果,计算最终平均值。实现时需注意: @@ -338,7 +338,7 @@ gcc -g -O0 -fPIC -shared extract_vag.c -o libextract_avg.so extract_avg.c ```c -{{#include docs/examples/udf/extract_avg.c}} +{{#include tests/script/sh/extract_avg.c}} ``` @@ -346,7 +346,7 @@ gcc -g -O0 -fPIC -shared extract_vag.c -o libextract_avg.so ## 用 Python 语言开发 UDF ### 准备环境 - + 准备环境的具体步骤如下: - 第 1 步,准备好 Python 运行环境。本地编译安装 python 注意打开 `--enable-shared` 选项,不然后续安装 taospyudf 会因无法生成共享库而导致失败。 @@ -869,40 +869,40 @@ close log file: spread.log ### 更多 Python UDF 示例代码 -#### 标量函数示例 +#### 标量函数示例 [pybitand](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/pybitand.py) pybitand 实现多列的按位与功能。如果只有一列,返回这一列。pybitand 忽略空值。
pybitand.py -```python -{{#include docs/examples/udf/pybitand.py}} +```Python +{{#include tests/script/sh/pybitand.py}} ```
-#### 聚合函数示例 +#### 聚合函数示例 [pyl2norm](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/pyl2norm.py) pyl2norm 实现了输入列的所有数据的二阶范数,即对每个数据先平方,再累加求和,最后开方。
pyl2norm.py -```python -{{#include docs/examples/udf/pyl2norm.py}} +```c +{{#include tests/script/sh/pyl2norm.py}} ```
-#### 聚合函数示例 +#### 聚合函数示例 [pycumsum](https://github.com/taosdata/TDengine/blob/3.0/tests/script/sh/pycumsum.py) pycumsum 使用 numpy 计算输入列所有数据的累积和。
pycumsum.py -```python -{{#include docs/examples/udf/pycumsum.py}} +```c +{{#include tests/script/sh/pycumsum.py}} ```
@@ -965,7 +965,7 @@ show functions; ``` ### 查看函数信息 - + 同名的 UDF 每更新一次,版本号会增加 1。 ```sql diff --git a/docs/examples/udf/bit_and.c b/tests/script/sh/bit_and.c similarity index 100% rename from docs/examples/udf/bit_and.c rename to tests/script/sh/bit_and.c diff --git a/docs/examples/udf/extract_avg.c b/tests/script/sh/extract_avg.c similarity index 100% rename from docs/examples/udf/extract_avg.c rename to tests/script/sh/extract_avg.c diff --git a/docs/examples/udf/l2norm.c b/tests/script/sh/l2norm.c similarity index 100% rename from docs/examples/udf/l2norm.c rename to tests/script/sh/l2norm.c diff --git a/docs/examples/udf/max_vol.c b/tests/script/sh/max_vol.c similarity index 100% rename from docs/examples/udf/max_vol.c rename to tests/script/sh/max_vol.c diff --git a/docs/examples/udf/pybitand.py b/tests/script/sh/pybitand.py similarity index 100% rename from docs/examples/udf/pybitand.py rename to tests/script/sh/pybitand.py diff --git a/docs/examples/udf/pycumsum.py b/tests/script/sh/pycumsum.py similarity index 100% rename from docs/examples/udf/pycumsum.py rename to tests/script/sh/pycumsum.py diff --git a/docs/examples/udf/pyl2norm.py b/tests/script/sh/pyl2norm.py similarity index 100% rename from docs/examples/udf/pyl2norm.py rename to tests/script/sh/pyl2norm.py