01. Functions - Concept

With the implementation of the General Data Protection Law (LGPD) in Brazil, we recognized the need to assist our clients in enhancing the privacy protection of the data that Kondado integrates into their data destinations. For this purpose, functions were created.

What are functions?

The functions are processes applied to the data even before it is written to the destination. For example, you can choose to apply a function that transforms the text to uppercase. This way, a text like "hello, world!" would be converted to "HELLO, WORLD!".

Functions's chaining

Kondado's functions are granular, meaning they perform one operation at a time. As a result, you can chain them, allowing the functions to be applied sequentially.

Returning to the example of the field "hello, world!", you can use the function to transform the text to uppercase and then apply a function to remove spaces. This would result in the following flow:

In the source: "hello, world!"
First function (uppercase): "HELLO, WORLD!"
Second function (remove spaces between words): "HELLO,WORLD!"
In the destination: "HELLO,WORLD!"

Function's categories

In Kondado, functions are classified into three (3) categories:

1. **Transformation**: Applies a process to the field that still allows its identification in a simple way. Examples include functions to remove spaces or convert text to uppercase.

2. **Anonymization**: Applies a process to the field that has no relation to its original value. For instance, a function that replaces a value with a random UUID.

3. **Pseudonymization**: Applies a process to the field that retains some relationship with the original value. However, reversing the field to its original value would be computationally expensive or would require additional values. For example, you might need to know the record ID that was pseudonymized to look up its original value elsewhere or deduce the original value through multiple associations.

Typing

Some functions will change the original data type. For example, using a function that replaces a field with a random UUID will convert any data type into text.

Additionally, some functions are limited to certain data types. For instance, a function that extracts the year from a date can only be applied to fields of the type "timestamps" or "dates."

With function chaining, the data type for subsequent functions is always based on the type generated by the last applied function (or the original field type, in the case of the first function in the chain). For example, consider a field of type "date" in the source as "2020-09-10." You can apply a transformation function that changes the field type to "text," followed by a function that removes special characters (which is only applicable to "text" fields). This process will occur as follows:

---

1. Original Field:
  - Type: Date
  - Value: `2020-09-10`

2. First Function:
  - Transformation: Convert the date to text.
  - Type After Transformation: Text
  - Value: `"2020-09-10"`

3. Second Function:
  - Transformation: Remove special characters.
  - Type After Transformation: Text
  - Value: `"20200910"`

This chaining ensures that the data type is adjusted dynamically at each step to support the operations applied by subsequent functions.