All Products
Search
Document Center

DataWorks:Test, publish, and use a function

Last Updated:Mar 27, 2026

Test a function to verify its behavior, publish it to make it available, and attach it to an API as a pre-filter or post-filter.

Prerequisites

Before you begin, make sure that you have:

Step 1: Test the function

  1. Go to the DataService Studio page. Log on to the DataWorks console. In the top navigation bar, select the region. In the left-side navigation pane, choose Data Analysis and Service > DataService Studio. Select the workspace from the drop-down list and click Go to DataService Studio.

  2. In the left-side navigation pane of the Service Development page, find and double-click the function.

  3. On the configuration tab of the function, click Test in the upper-right corner.

    image

  4. In the Function Test dialog box, specify the input parameters and click OK. The Execution results tab at the bottom of the page shows the running status and output of the test. If the test fails, check the error message, update the function, and run the test again.

Step 2: Publish the function

After you test a function, you can publish the function.

  1. In the left-side navigation pane of Service Development, find and double-click the function you tested.

  2. On the configuration tab, click Submit in the top toolbar.

  3. In the right-side navigation pane, click Version. Find the version in the Can Be Published state and click Publish in the Actions column.

After publishing, click Version in the right-side navigation pane to view the publishing history. In the Actions column, you can click Version Details to view version information or click Roll Back to revert to a previous version.

Step 3: Use the function as a filter for an API

A function can intercept and transform data flowing through an API:

  • Pre-filter: Preprocesses the request parameters before the API executes.

  • Post-filter: Processes and reconstructs the API response after the API executes.

Limitations

  • If you attach both a pre-filter and a post-filter to the same API, all filters must be the same function type — either all Aviator functions or all Python functions. You cannot mix function types on a single API.

  • The Python function filter feature is currently being optimized. Creating, cloning, or publishing new Python functions is not supported.

Attach a function to an API

  1. In the Service Development pane, click business process > API.

  2. Find and double-click the API. The configuration tab of the API opens.

  3. In the right-side navigation pane, click Filter.

  4. On the Filter tab, select Use Pre-filter or Use Post-filter based on your requirements. The default Function Type is Aviator Function. Select one or more functions from the drop-down list. If you select multiple functions, they process the request parameters or responses in the order you selected them.

    Note

    If a function does not appear in the drop-down list, it has not been published yet. Publish the function first. See Publish a function.

  5. Click Preview Responses Returned by API Operation to verify that the output from the selected functions meets your expectations.