Search docs.molo17.com
    Configuration guide Pipelines

    Transform columns with field functions

    Source and target tables rarely match column for column. A target may need a masked copy of personal data, a date written as text, a flag instead of a boolean, a constant that tells where the row came from, or one name built from two columns. Field functions do this in the Fields Editor, with no code, and a custom field function covers what the catalog does not. This guide maps one table to another with all of them and checks the result after a snapshot and live changes.

    In this guide

    You will learn how to map source columns to target columns with arrows, read the errors the Fields Editor reports, apply the built-in field functions that mask, convert, trim and truncate values, fill target columns that have no source, join two source columns into one with a custom field function, and verify the target with SQL after a snapshot and change data capture (CDC).

    The steps were run on PostgreSQL 16 for both the source and the target.

    Quick information

    Goal

    Fill every target column of an entity with the right value: masked, converted, cleaned, constant, or composed from several source columns

    Audience

    Data engineers who configure pipelines in the Control Plane

    Level

    Beginner to intermediate; the custom field function step needs basic Java

    Time required

    About 30 minutes

    Area

    Control Plane → Pipelines → entity → Field mapping → fx

    Applies to

    Gluesync 2.3

    Before you begin

    Make sure that:

    1. A pipeline has a source and a target that Core Hub can read, and you can add or edit its entities. In this guide the pipeline is CRM sync, from PostgreSQL to PostgreSQL;

    2. The target table already exists with the columns you want to fill. The demo tables are in the optional first step;

    3. The entity is not started, or you accept that saving its mapping stops it;

    4. You can run SQL on the target database, in Query Studio or any SQL client.

    Choose the right tool

    Pick the lightest tool that does the job:

    Tool Use it when In this guide

    Built-in field function

    One source column feeds one target column (1:1), or a target column has no source, and the transformation is in the catalog.

    Mask an email, a phone number and a card number; write a boolean as Y or N; write a date as text; trim and truncate text; write a constant and a timestamp.

    Custom field function

    Several source columns feed one target column (N:1), or you need your own logic for one column, shared by the entities of the pipeline.

    Join first_name and last_name into full_name.

    UDF

    You need the whole record: split one value into several columns, skip a row, or decide by operation type.

    Not needed. The guide Write and test a UDF for conversions covers it.

    Guide steps

    Optional: create the demo tables

    SQL

    Skip this step if you use your own tables. Otherwise create a source table with personal data, a boolean, a date and free text, and a target table that expects masked, converted and extra columns.

    1. In the source database, run:

      CREATE TABLE public.customers (
        customer_id   integer PRIMARY KEY,
        first_name    varchar(50),
        last_name     varchar(50),
        email         varchar(120),
        phone         varchar(30),
        card_number   varchar(25),
        is_active     boolean,
        signup_date   date,
        credit_limit  numeric(12,2),
        notes         varchar(200),
        company       varchar(80)
      );
      INSERT INTO public.customers VALUES
       (1, 'Anna',   'Rossi',   'anna.rossi@example.com',    '+39 02 1234 5678', '4111-1111-1111-1111', true,  '2024-03-15',  2500.00, '  VIP customer  ', 'Rossi Costruzioni S.p.A.'),
       (2, 'Marco',  'Bianchi', 'marco.bianchi@example.com', '+39 06 9876 5432', '5500 0000 0000 0004', false, '2023-11-02',   800.50, '  ',               'Bianchi'),
       (3, 'Giulia', 'Verdi',   'giulia.verdi@example.org',  '3331234567',       '340000000000009',     true,  '2025-07-30', 12000.00, 'Prefers email ',   'Verdi Logistica e Trasporti S.r.l.');
    2. In the target database, run:

      CREATE TABLE public.crm_customers (
        customer_id    integer PRIMARY KEY,
        full_name      varchar(120),
        email_masked   varchar(120),
        phone_masked   varchar(30),
        card_masked    varchar(25),
        active_flag    char(1),
        signup_date    varchar(10),
        credit_limit   numeric(12,2),
        notes          varchar(200),
        company_short  varchar(12),
        source_system  varchar(20),
        replicated_at  timestamp
      );

    What each target column receives in this guide:

    Source column Target column How

    customer_id, credit_limit

    customer_id, credit_limit

    Copied as they are

    first_name and last_name

    full_name

    Custom field function full_name_function (N:1)

    email

    email_masked

    Mask Email

    phone

    phone_masked

    Mask Phone Number

    card_number

    card_masked

    Mask Credit Card

    is_active

    active_flag

    Convert Boolean to String (Y/N)

    signup_date

    signup_date

    Convert Date to String, pattern dd/MM/yyyy

    notes

    notes

    Trim String

    company

    company_short

    Truncate String, 12 characters

    none

    source_system

    Fixed string webshop

    none

    replicated_at

    Local Timestamp

    Open the Fields Editor and read the proposed arrows

    UI

    1. Open the pipeline, and select Entities +;

    2. In the Object browser, expand the schema and check the source table, here public and customers. The Field mapping dialog, the Fields Editor, opens;

    3. Under Target, select the Target Table, here crm_customers.

    Field mapping dialog with the banner There are multiple errors
    Figure 1. Arrows are proposed for the columns with the same name. The red fx marks a target column with no source, and signup_date is in error because a date cannot go into a varchar as it is.
    Expected result

    The editor proposes arrows by name: customer_id, signup_date, credit_limit and notes. The banner reads There are multiple errors and the Error tab counts them. Confirm stays disabled until the count is 0.

    The PII tags on first_name, email, phone and the other personal columns are informational: they do not mask anything in the replicated rows. Masking the values on their way to the target is what the field functions in the next step do. See PII discovery and masking.

    Draw the missing 1:1 arrows

    UI

    Drag from the dot at the right of each source column to the dot at the left of its target column:

    1. email to email_masked;

    2. phone to phone_masked;

    3. card_number to card_masked;

    4. is_active to active_flag;

    5. company to company_short.

    Expected result

    Five more arrows. The arrows of is_active and signup_date are red: a boolean cannot go into a character (1) and a date cannot go into a character varying (10) without a conversion. company (80 characters) into company_short (12 characters) is not flagged; the next step truncates it, or the target database refuses the longer values.

    To remove an arrow drawn by mistake, point at it and select its trash button.

    Mask the personal data

    UI

    1. In the target table, select the fx button at the end of the row email_masked. The panel Apply a field function opens, with the chips Built-in (7) and My functions (0);

    2. Open Functions collection and select Mask Email. Select map to expression shows *, the mask character; keep it or type another one;

    3. Select the fx button of email_masked again to close the panel;

    4. Repeat for phone_masked with Mask Phone Number, and for card_masked with Mask Credit Card.

    Apply a field function panel with Mask Email selected in Functions collection
    Figure 2. Mask Email on email_masked. The panel describes what the function keeps visible.
    Expected result

    The three fx buttons turn blue. For a text column fed by a text column, the list holds the seven functions Trim String, Truncate String, Mask Credit Card, Mask String, Mask Email, Mask Phone Number and Mask IBAN.

    What each mask keeps visible, as seen in the target after the snapshot (source value, then target value):

    Mask Email         anna.rossi@example.com   ->  a*********@example.com
    Mask Phone Number  +39 02 1234 5678         ->  +39 ** **** 5678
                       3331234567               ->  ******4567
    Mask Credit Card   4111-1111-1111-1111      ->  ****-****-****-1111
                       5500 0000 0000 0004      ->  **** **** **** 0004

    Mask Credit Card masks numbers of 16 digits, in four groups of four with or without separators, and keeps the last four digits. A number of another length, such as the 15-digit 340000000000009, is written unmasked. Mask Phone Number keeps the international prefix and the last four digits. Check the target with your own data before you rely on a mask.

    Convert the types and clean the text

    UI

    1. Select the fx button of active_flag, open Functions collection, and select Convert Boolean to String (Y/N);

    2. Select the fx button of signup_date, select Convert Date to String, then open Select map to expression and select dd/MM/yyyy;

    3. Select the fx button of notes and select Trim String;

    4. Select the fx button of company_short and select Truncate String. Select map to expression is filled with 12, the length of the target column; keep it.

    Field mapping dialog with the banners Field function is required or define a UDF and Data type mismatch detected
    Figure 3. Convert Date to String with the pattern dd/MM/yyyy. The banners now say a field function is still required somewhere, and that the data types differ.
    Expected result

    The red arrows turn yellow and the Error count goes down: the type errors become warnings, and the banner Data type mismatch detected stays, because the source and target types still differ and the functions convert them. The list offers only the functions that fit the two types: for active_flag, Convert Boolean to String (T/F), (true/false) and (Y/N); for signup_date, Convert Date to String alone.

    The patterns offered for a date are yyyy-MM-dd, dd-MM-yyyy, dd/MM/yyyy, yyyy/MM/dd, yyyyMMdd, ddMM, yyyy-MM, yyyy/MM, MM/dd/yyyy, MM-dd-yyyy, dd MMM yyyy and dd MMMM yyyy. Choose one whose result fits the target column: dd MMMM yyyy does not fit in 10 characters.

    Fill the columns that have no source

    UI

    source_system and replicated_at exist only in the target, so no arrow reaches them.

    1. Select the fx button of source_system, select Fixed string, and type webshop in Select map to expression;

    2. Select the fx button of replicated_at and select Local Timestamp.

    Apply a field function panel of source_system with Built-in (2)
    Figure 4. A target column without an arrow offers the functions that create a value. Fixed string writes the same text in every row.
    Expected result

    For source_system the list holds Fixed string and Target scalar function (text); for replicated_at, Local Timestamp and Target scalar function (date and time). After both, one error is left, on full_name.

    Local Timestamp is the time of the machine that runs Core Hub when it writes the row, without a time zone. In a container that runs on UTC, the value is in UTC. To keep a time zone, use a timestamp with time zone column and Timestamp with Offset, listed in Field functions.

    Join two columns with a custom field function

    UI

    1. Draw an arrow from first_name to full_name, then a second arrow from last_name to full_name;

    2. Read the banner, which now says A custom field function is required for this relation, or define a UDF;

    3. Select the fx button of full_name. The panel reads No field function found: built-in functions take one source column. Select Add a custom field function.

    Field mapping dialog with the banner A custom field function is required for this relation
    Figure 5. Two arrows into full_name (N:1) need a function that takes both values.

    The dialog Custom functions collection opens, for the whole pipeline. It holds one Java class named after the pipeline, here CRMSync, with a function already declared for full_name: full_name_function(String first_name, String last_name), which only throws Not implemented yet.

    1. Replace the code in the editor with:

      package com.molo17.gluesync.collections;
      
      import com.molo17.gluesync.commons.function.GsFunction;
      
      public class CRMSync {
      
          @GsFunction(
              name = "full_name_function",
              description = "Joins a first name and a last name into one full name"
          )
          public static String full_name_function(String first_name, String last_name) {
              String first = first_name == null ? "" : first_name.trim();
              String last = last_name == null ? "" : last_name.trim();
              String full = (first + " " + last).trim().replaceAll("\\s+", " ");
              return full.isEmpty() ? null : full;
          }
      }
    2. Select the compile button (the wrench) at the top of the editor. Output reads Compiled as v1 and Function exported: full_name_function(String arg1, String arg2): String;

    3. Select Publish. The dialog Publish v1? says that nothing uses these functions yet, so no entity is stopped; select Publish;

    4. Under Try a function within CRMSync, type Anna and Rossi in the two Sample value boxes, and select Run dry-test.

    Custom functions collection dialog with the tags compiled and active
    Figure 6. After Publish, the tags read active. The dry-test runs the published function on the sample values; nothing is read from or written to the databases.
    Expected result

    Output reads Custom Field Functions v1 published successfully. and No entity needed to be restarted. The two arguments are bound to the source columns first_name and last_name in the order of the arrows. Results show Current Anna Rossi, Return type java.lang.String and Gluesync type STRING. Versions lists each compiled version, with the published one marked active.

    1. Close the dialog with the X at the top right.

    Field mapping dialog with Error (0)
    Figure 7. Back in Field mapping, full_name uses the new function, My functions counts one, and Error is 0.

    The version number grows at every compile, published or not, so your first published version may be v2 or later if you compiled more than once. The last five versions are kept, and Roll back returns to one of them.

    Save the entity and start it

    UI

    1. In Field mapping, select Confirm. The entity shows the tag FF;

    2. Select Confirm and continue;

    3. On the pipeline page, select the start button of the entity. The dialog Sync changes (CDC) opens;

    4. Keep Full copy and Keep and merge, and select Start entity.

    Expected result

    The entity becomes active after the copy, and its Features column shows fx.

    Verify the target after the snapshot

    SQL

    In the target database, run:

    SELECT customer_id, full_name, email_masked, phone_masked, card_masked,
           active_flag, signup_date, '[' || notes || ']' AS notes,
           company_short, source_system, replicated_at
    FROM public.crm_customers
    ORDER BY customer_id;
    Expected result

    Three rows, each with the time it was written in replicated_at (left out here):

     customer_id |   full_name   |       email_masked        |   phone_masked   |     card_masked     | active_flag | signup_date |      notes      | company_short | source_system
    -------------+---------------+---------------------------+------------------+---------------------+-------------+-------------+-----------------+---------------+---------------
               1 | Anna Rossi    | a*********@example.com    | +39 ** **** 5678 | ****-****-****-1111 | Y           | 15/03/2024  | [VIP customer]  | Rossi Costru  | webshop
               2 | Marco Bianchi | m************@example.com | +39 ** **** 5432 | **** **** **** 0004 | N           | 02/11/2023  | []              | Bianchi       | webshop
               3 | Giulia Verdi  | g***********@example.org  | ******4567       | 340000000000009     | Y           | 30/07/2025  | [Prefers email] | Verdi Logist  | webshop

    Trim String writes a value of spaces only as an empty string, not as NULL (row 2). Truncate String keeps the first 12 characters. Row 3 shows that a 15-digit card number is not masked.

    Verify live changes

    SQL

    1. In the source database, run an insert, an update and a delete:

      INSERT INTO public.customers VALUES
       (4, 'Luca', NULL, 'luca@example.net', '+44 20 7946 0958', '5105 1051 0510 5100', true, '2026-11-20', 300.00, ' new ', 'Neri Consulting Group');
      UPDATE public.customers SET is_active = false, email = 'a.rossi@example.it' WHERE customer_id = 1;
      DELETE FROM public.customers WHERE customer_id = 2;
    2. Run the query of the previous step again.

    Pipeline page of CRM sync with one entity active
    Figure 8. The entity is active and its Features column shows fx. The fx button of the toolbar opens the custom functions of the pipeline.
    Expected result

    After a few seconds:

     customer_id |  full_name   |       email_masked       |   phone_masked   |     card_masked     | active_flag | signup_date |      notes      | company_short | source_system
    -------------+--------------+--------------------------+------------------+---------------------+-------------+-------------+-----------------+---------------+---------------
               1 | Anna Rossi   | a******@example.it       | +39 ** **** 5678 | ****-****-****-1111 | N           | 15/03/2024  | [VIP customer]  | Rossi Costru  | webshop
               3 | Giulia Verdi | g***********@example.org | ******4567       | 340000000000009     | Y           | 30/07/2025  | [Prefers email] | Verdi Logist  | webshop
               4 | Luca         | l***@example.net         | +44 ** **** 0958 | **** **** **** 5100 | Y           | 20/11/2026  | [new]           | Neri Consult  | webshop
    • Row 4 is new. A NULL last name gives a full name with no trailing space.

    • Row 1 has the new masked email, N, and a new replicated_at: the functions run on every change.

    • Row 2 is gone.

    Optional: change a custom field function in use

    UI

    1. On the pipeline page, select the fx button of the toolbar. The dialog shows the tag used by 1 entity;

    2. Edit the code, select the compile button, then Publish.

    Expected result

    Because an entity uses the function, the publish dialog warns: Publishing stops the affected entities, updates the active Custom Field Functions, and restarts those entities. This may take several minutes. After Publish, Output reads Custom Field Functions vN published successfully. and 1 entities restarted., and the next changes use the new code.

    A compile error keeps Publish disabled. Output names the file and the line, for example:

    com/molo17/gluesync/collections/CRMSync.java:15 cannot find symbol
      symbol:   variable length
      location: variable full of type java.lang.String
    Verify the result

    You have transformed the columns successfully if:

    • Field mapping shows Error (0) and the entity has the FF tag;

    • the target has masked emails, phones and 16-digit card numbers, Y and N flags, dates as dd/MM/yyyy, trimmed notes and 12-character company names;

    • every row has webshop and a timestamp, and full_name joins the two name columns;

    • inserts, updates and deletes in the source reach the target with the same transformations.

    Troubleshooting

    Problem Possible cause What to do

    Field function is required or define a UDF, and Confirm is disabled

    A checked target column has no arrow and no field function

    Draw an arrow to it, give it a field function such as Fixed string, or uncheck it

    A custom field function is required for this relation, or define a UDF

    Two or more arrows end on the same target column (N:1), and built-in functions take one column

    Select Add a custom field function in its fx panel, or remove the extra arrows

    A red arrow and a type error on a column, for example boolean into character (1)

    The types cannot be converted without a function

    Apply a conversion function from the fx panel; the error becomes a warning

    Data type mismatch detected stays after the functions are applied

    It is a warning: the source and target types still differ, and the functions convert them

    Nothing to do; Confirm is enabled

    The function you want is not in the list

    The list shows only the functions that fit the source and target types. A target column fed by one source column that also feeds another column (1:N) gets no built-in function

    Check the target type, or use a custom field function or a UDF

    Output: CRMSync.java:15 cannot find symbol, and Publish is disabled

    The Java code does not compile

    Fix the line named in the message and compile again

    My functions (0) in the fx panel

    No custom field function version is published yet

    Open the custom functions from the toolbar fx button, compile and select Publish

    A card number is written unmasked

    Mask Credit Card masks 16-digit numbers only

    Use Mask String, or a custom field function, for other lengths

    replicated_at is hours away from your local time

    Local Timestamp uses the clock of the machine that runs Core Hub, often UTC in a container

    Use a timestamp with time zone column with Timestamp with Offset, or read the column as UTC

    The target refuses a value that is too long

    The target column is shorter than the source values

    Apply Truncate String with the target length, or make the target column wider

    Contact MOLO17 Support if you need assistance with field functions.