Custom Functions
Last updated
Last updated
© Copyright 2023, Astera Software
The custom function functionality in Astera Data Stack allows users to integrate new functions, which may not already exist in Astera's library of available functions, to match their uses cases.
Employing this functionality requires a basic understanding of .NET and programming in general.
For our use case, we will be creating a custom function that allows us to calculate the total price after applying taxes and discounts.
First, we will create a new .NET project in Visual Studio or any compiler which supports the .NET framework. We will name our project CustomFunctionCalculator_plugin.
Note: Astera Data Stack will only load assemblies with output assemblies suffixed plugin.
Next, we will create a new class in our project. We will name it TotalPriceCalculator. Here, we will be writing our code for the custom function that we want to create and deploy.
Next, we will add assembly references to our project. To do this, we will right-click on our project and select Add > Project Reference.
The only .dll file which we need to reference here is the Astera.DataContracts.dll. This can be found in Astera Data Stack’s Server installation folder.
Next, we will make sure that our class consists of the following custom attributes and Astera Data Stack references for a successful deployment of our custom function:
Astera Data Stack Reference: Make sure that the using Astera.Core; statement is added at the top of the file.
Custom Attributes:
Next, we will write our custom function which we would like to deploy. The following is a sample code for a function which calculates the total price after applying discounts and tax to a specified value.
Now, we will compile our custom function. To do this we will right-click on our project and select Build from the drop-down menu.
A .dll file with the same name as our project will be created in the bin > debug folder of the file location specified.
Next, we will copy this .dll file and paste it in the Server, as well as the Client directories.
Note: This is a crucial step in making sure the deployment of the new custom function is successful.
Now, if we open Astera's data integration tool, in the Function Transformations section of the Toolbox, a new Custom Function tab will appear. Upon expanding this tab, you can see that our custom function has been successfully created and deployed.
This concludes creating and deploying a Custom Function in Astera Data Stack.