Setup
Step 1: Create your computed field function (plugin)
Check the following documentation to learn more about Plugin development. Bellow are some precisions about specific Computed fields Function implementation.
Develop the plugin with the SDK and create a build from it
OnUpdate functions
These 3 functions are triggered during the initialization of the Computed Field Function and whenever a new activity, profile update, or computed field modification occurs, updating the State
accordingly.
You can find the list of all the methods to be developed here.
Although onUpdateComputedField
has not been released yet, it is still required to be implemented in your plugin. In the meantime, simply return the State
directly to avoid any errors.
BuildResult
This function returns the result of the computed field function for a specific State
. The Result
will be stored for a defined duration, and querying the field will return the stored value during that period.
You can find all the details about this method here.
Create a plugin and a version
Follow the standard procedure to create a plugin with the type COMPUTED_FIELD_FUNCTION
. Once the plugin is created, you can generate a new version from the build.
Step 2: Create your computed field within the platform
In the Navigator > Settings > Datamart, navigate to Computed Fields.
Add a new computed field.
Select the plugin and version of the new instance you want to use.
Complete the necessary fields:
Name
Name of the computed field
Description
(Optional) Describe the computed field
Technical name
Name of the computed field used in the schema
Compute period (in days)
Maximal duration before the periodic update of the Result
in days.
Events filter
GraphQL selector query to filter the activity which will trigger the State
updates
This will set up the computed field linked to your computedfield function for use in the schema.
Step 3: Declare your computed field in your schema
After creating the computed field, you need to connect it to your schema:
Use the directive
@ComputedField(technical_name = "...")
at the appropriate level of your schema.Ensure the technical name matches the one used when creating the computed field.
This will integrate the computed field into your schema and make it available for use in queries and operations.
// Example in your schema
type UserPoint {
id: ID!
accounts: [UserAccount]
…
rfm_score: RfmScore @ComputedField(technical_name = “RfmScore”) @TreeIndex(index:"USER_INDEX")
}
type RfmScore {
…
}
A schema validation will be triggered when you click Save. It will ensure that your Datamart has access to all the declared computed fields and verify their integration with the schema.
The computed field must be in the UserPoint object.
Step 4: Wait until the end of the initial loading
Once your schema is validated, our service will run a job to initialize your computed field and set the state to match the current status of the timeline. For each user point in your Datamart, we will process their timeline and execute the OnUpdateXXX() function.
To monitor the progress:
Go to the Computing Console > Computed Fields.
Check if your computed field is ready or if the initial loading is still in progress.
Please note, this process may take some time to complete (up to 72h) as it computes the timelines for all user points.
Avoid using your computed field until the initial loading is complete. While the query will not return an error, the result may be inaccurate during this process.
Step 5: Use your computed field
Once the initial loading is complete, you can start using your computed field just like any other standard field in mediarithmics features.
For example, in query tools or any OTQL query:
SELECT { rfm_score } FROM UserPoint
If your computed field is indexed, you can also perform queries like:
SELECT { id } FROM UserPoint WHERE rfm_score = "PASSIVE"
This allows you to incorporate the computed field into your data analysis and queries once it's fully initialized.
Last updated
Was this helpful?