Custom functions (UDF) can reduce the complexity of applications or achieve functionalities that preset query functions cannot implement. I judge that Lua is the most suitable language for this mission. This is because the original intention of Lua’s design is to integrate with C language, and the two can be considered a perfect match.
Currently, TDengine has officially implemented a framework for user-defined functions, based on Lua 5.1 to implement a basic model, and integrated Lua 5.1. Due to the fragmented state of the Lua community, the preset Lua development libraries have brought some minor troubles to my development work. Users certainly cannot use two Lua versions at the same time, so ultimately, it is necessary to integrate both Lua 5.1 and a higher version (the upcoming version is Lua 5.4.4) in TDengine, relying on macro switches to select one Lua version for compilation.
In terms of specific implementation, it is necessary to design interfaces for the C API of both versions. Each version upgrade of Lua brings some functional changes and upgrades, so whether it is possible to abstract a set of common interfaces to shield Lua users from differences is a question I hold a rather pessimistic attitude towards.
This is a summary of my experiences using TDengine. Currently, the connector has been deployed in our production environment and has undergone two large-scale production activities, easily completing its mission. Next, I will continue to improve the issues mentioned above in the project application, and supporting the use of Lua to implement UDF will be my next focus, which will further reduce the complexity of applications.
👇 Clickto read the original text to learn more about the experience of TDengine!