Trifacta's Wrangler interface provides a wide range of functions to transform your data. However, you may need to define custom functions that are not provided out-of-the-box to meet your specific use cases. To support these specific use cases, Trifacta allows you to create custom user-defined functions.

A user-defined function (UDF) is an externally created function that can be imported into the product for use in your recipe.

Starting v9.0, you can now create user-defined functions (UDFs) in JavaScript to leverage directly against the data. JavaScript UDFs enable users to create customized and consistent functions to meet their specific use cases, all while retaining the same productivity of using the Wrangler interface. Examples of when you may create a UDF:

  • Your enterprise has a specific method for calculating asset deprecation, which must be applied consistently.

  • You use specialized statistical calculations for managing risk.

  • Your industry has commonly used metrics that are not available in the Trifacta application.

Enabling the feature

As a part of v9.1 release, this feature is enabled by default in all Dataprep workspaces and labeled as a Beta feature.

Key Highlights

  • Javascript UDFs are easy to create and modify directly through the Trifacta application.

  • JavaScript UDFs are available through the Search panel and can be referenced in formulas like any other Wrangle function.

  • Execution supported for Trifacta Photon and Dataflow jobs

  • Internationalization is supported through built-in Java libraries. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl.

Creating a Javascript UDF

  1. From the Transformer View's toolbar, select the f(x) menu option and choose Create UDF

-OR-

From the Library, choose User Defined Functions tab, and click the Create UDF button.

2. In the new creation modal:

  1. Name- The name of your function must be unique within the workspace. Avoid using names that correspond to keywords in Wrangle.

  2. Description- Enter a text description for your function.

  3. In the next window-

    1. Paste in the script for your user-defined function.

    2. Click Validate. Fix any errors.

  4. To create the UDF, click Create.

The UDF is now available for use by all users of the workspace.

For more details and examples on how to create Javascript UDFs, see this detailed documentation guide.

Search and Use UDFs in Recipes

Transform Builder

In the Transform Builder:

  • You can search for your UDF by name or by entering UDF.

  • In a Formula field, you can reference the function by name or by entering UDF.

In Transformer, from the f(x) top menu icon, select Insert UDF and choose a UDF from the search panel to add to your recipe.

Job execution

Javascript UDFs are automatically executed as part of jobs on Dataflow and Trifacta Photon.

More Info

Check out this detailed guide of Javascript UDFs



Did this answer your question?