diff --git a/include/libs/function/taosudf.h b/include/libs/function/taosudf.h index 5be9c159001ef2c2ce0131e477e1b29806b98e36..ee3d85b43392b0a733815a2b1b9c10f133f3c72d 100644 --- a/include/libs/function/taosudf.h +++ b/include/libs/function/taosudf.h @@ -73,7 +73,6 @@ typedef struct SUdfDataBlock { SUdfColumn **udfCols; } SUdfDataBlock; -// TODO: deprecate SUdfInterBuf.numOfResult typedef struct SUdfInterBuf { int32_t bufLen; char *buf; diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index ec49c39c0e6a9eaf38bd0aea4585f21636166d24..4e16d5e70853f9c4bf69fb0e48175507944dfaad 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -308,8 +308,8 @@ void udfdInitializeCPlugin(SUdfScriptPlugin *plugin) { plugin->udfAggMergeFunc = udfdCPluginUdfAggMerge; plugin->udfAggFinishFunc = udfdCPluginUdfAggFinish; - SScriptUdfEnvItem items[0]; - plugin->openFunc(items, 0); + SScriptUdfEnvItem items[1] = {{"LD_LIBRARY_PATH", tsUdfdLdLibPath}}; + plugin->openFunc(items, 1); return; } diff --git a/source/libs/function/test/udf2.c b/source/libs/function/test/udf2.c index e24789d0fb4095f2fdc75d8d1ce3e8dc1355e4c6..faf4daa4e53cacd70cbfd4ff319178c2cdbb8a56 100644 --- a/source/libs/function/test/udf2.c +++ b/source/libs/function/test/udf2.c @@ -12,12 +12,15 @@ DLL_EXPORT int32_t udf2_destroy() { return 0; } DLL_EXPORT int32_t udf2_start(SUdfInterBuf* buf) { *(int64_t*)(buf->buf) = 0; buf->bufLen = sizeof(double); - buf->numOfResult = 0; + buf->numOfResult = 1; return 0; } DLL_EXPORT int32_t udf2(SUdfDataBlock* block, SUdfInterBuf* interBuf, SUdfInterBuf* newInterBuf) { - double sumSquares = *(double*)interBuf->buf; + double sumSquares = 0; + if (interBuf->numOfResult == 1) { + sumSquares = *(double*)interBuf->buf; + } int8_t numNotNull = 0; for (int32_t i = 0; i < block->numOfCols; ++i) { SUdfColumn* col = block->udfCols[i];