Search code examples
javasynchronizationtransformationbeanshellsymmetricds

SymmetricDS how to filter rows during a transformation


I am using SymmetricDS with many store nodes and a corp node.

I have to do a transformation sync between a table in the store node to a table in the corp node and successfully configured a transformation between them using sym_transform_table and sym_transform_column . Now all the rows of the source table is transformed or copied to the target table in the corp node. I want to prevent or filter some rows from the source table from moving to the target table. Any idea to achieve this.

Practical Scenario: Customer with a certain age (a subset of rows in the customer table) in a store have to be copy transformed to a master_customer table in corp node which have different column names.


Solution

  • Routers are used for filtering data. Instead of a default router use a lookup, subselect, or BSH router.

    Lookup will be the fastest but requires creating a separate lookup table in your DB to reference which ages can be sent and which ones can't.

    BSH will take a little bit longer but can handle logic like if (age < 65 && age >= 18).

    Subselect router will take the longest since it will have to query the DB each time a record needs to be routed. This query can select a value from the DB to compare against or just be the same type of logic you could have put in the BSH router expression.

    If your filtering depends on a value after your transform, make sure the transform occurs at the source node and not the target (TRANSFORM_POINT='EXTRACT'). If you want to filter before the transform, make sure the transform takes place at the target (TRANSFORM_POINT='LOAD'). If it doesn't matter, you probably want the transforms to happen at EXTRACT to offload the processing work from the server.