Transformation rules and actions
You use the transformation actions to specify any transformations you want to apply to the selected schema, table, or view. Transformation rules are optional.
Limitations
- You cannot apply more than one transformation rule action against the same object (schema, table, column, table-tablespace, or index-tablespace). You can apply several transformation rule actions on any level as long as each transformation action is applied against a different object. However, this restriction is not applicable when using data masking transformation rules where you can have another transformation like - ADD-COLUMNor- CHANGE-DATA-TYPEfor the same column.
- Table names and column names in transformation rules are case-sensitive. For example, you must provide table names and column names for an Oracle or Db2 database in upper-case. 
- Transformations are not supported for column names with Right-to-Left languages. 
- Transformations cannot be performed on columns that contain special characters (e.g. #, \, /, -) in their name. 
- The only supported transformation for columns that are mapped to BLOB/CLOB data types is to drop the column on the target. 
- AWS DMS doesn't support replicating two source tables to a single target table. AWS DMS replicates records from table to table, and from column to column, according to the replication task’s transformation rules. The object names must be unique to prevent overlapping. - For example, a source table has a column named - IDand the corresponding target table has a pre-existing column called- id. If a rule uses an- ADD-COLUMNstatement to add a new column called- id, and a SQLite statement to populate the column with custom values, this creates a duplicate, ambiguous object named- idand is not supported.
- When creating a transformation rule, we recommend using the - data-typeparameter only when the selection rules specify multiple columns, for instance, when you set- column-nameto- %. We don't recommend using- data-typefor selecting a single column.
- 
                    AWS DMS does not support transformation rules where source and target objects (tables) are on the same database/schema. Using the same table as both source and target in a transformation rule can lead to unexpected and potentially harmful results, including but not limited to unintended alterations to the table data, modification of table structures or even tables getting dropped. 
Values
For table-mapping rules that use the transformation rule type, you can apply the following values.
| Parameter | Possible values | Description | 
|---|---|---|
| rule-type | transformation | A value that applies the rule to each object
                                specified by the selection rule. Use transformationunless otherwise noted. | 
| rule-id | A numeric value. | A unique numeric value to identify the rule. If you specify multiple transformation rules for the same object (schema, table, column, inter-table space, or index table space), AWS DMS applies the transformation rule with the lower rule-id. | 
| rule-name | An alphanumeric value. | A unique name to identify the rule. | 
| object-locator | An object with the following parameters: 
 | The name of each schema, table or view, table tablespace,
                                    index tablespace, and column to which the rule applies. You can
                                    use the "%" percent sign as a wildcard for all or part
                                    of the value of each  
 Also, the  
 | 
| rule-action | 
 
 
 
 
 
 
 
 
 
 
 | The transformation you want to apply to the object. All transformation rule actions are case-sensitive. The  When used with the  The  The  You can't use a  For an existing task, transformation rule actions which alter the target table schema such as
                                     The  | 
| rule-target | schema,table,column,table-tablespace,index-tablespace | The type of object that you're
                                    transforming. The  Make sure to specify a
                                    value for the parameter that you specify as part of the
                                         | 
| value | An alphanumeric value that follows the naming rules for the target type. | The new value for actions that require input, such
                                as rename. | 
| old-value | An alphanumeric value that follows the naming rules for the target type. | The old value for actions that require
                                replacement, such as replace-prefix. | 
| data-type | 
 Or, the name of the replacement data type when
                                         AWS DMS supports column data type transformations for the
                                    following DMS data types:  NoteAWS DMS can apply transformations from one type to another
                                        ONLY in supported formats. E.g. DATE should be represented
                                        in  
 
 
 | The following is an example of a  
 Here, the  | 
| expression | An alphanumeric value that follows SQLite syntax. | When used with the  When used with the  Note that only expressions are supported for this parameter. Operators and commands are not supported. For more information about using expressions for transformation rules, see Using transformation rule expressions to define column content. For more information about SQLite expressions, see Using SQLite functions to build expressions. | 
| primary-key-def | An object with the following parameters: 
 | This parameter can define the name, type, and
                                content of a unique key on the transformed table or view. It does so
                                when the rule-actionis set todefine-primary-keyand therule-targetis set totable. By default, the unique key is defined
                                as a primary key. | 
| before-image-def | An object with the following parameters: 
 | This parameter defines a naming convention to identify the
                                    before-image columns and specifies a filter to identify which
                                    source columns can have before-image columns created for them on
                                    the target. You can specify this parameter when the
                                         Don't set both  For  
 NoteThe  For more information about before-image support for AWS DMS target endpoints, see: | 
Examples
Example Rename a schema
The following example renames a schema from Test in your source
                    to Test1 in your target.
{ "rules": [ { "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "Test", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "2", "rule-name": "2", "rule-action": "rename", "rule-target": "schema", "object-locator": { "schema-name": "Test" }, "value": "Test1" } ] }
Example Rename a table
The following example renames a table from Actor in your
                        source to Actor1 in your target.
{ "rules": [ { "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "Test", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "2", "rule-name": "2", "rule-action": "rename", "rule-target": "table", "object-locator": { "schema-name": "Test", "table-name": "Actor" }, "value": "Actor1" } ] }
Example Rename a column
The following example renames a column in table Actor from
                            first_name in your source to fname in your
                        target.
{ "rules": [ { "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "test", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "4", "rule-name": "4", "rule-action": "rename", "rule-target": "column", "object-locator": { "schema-name": "test", "table-name": "Actor", "column-name" : "first_name" }, "value": "fname" } ] }
Example Rename an Oracle table tablespace
The following example renames the table tablespace named
                            SetSpace for a table named Actor in your
                        Oracle source to SceneTblSpace in your Oracle target
                        endpoint.
{ "rules": [ { "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "Play", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "2", "rule-name": "2", "rule-action": "rename", "rule-target": "table-tablespace", "object-locator": { "schema-name": "Play", "table-name": "Actor", "table-tablespace-name": "SetSpace" }, "value": "SceneTblSpace" } ] }
Example Rename an Oracle index tablespace
The following example renames the index tablespace named
                            SetISpace for a table named Actor in your
                        Oracle source to SceneIdxSpace in your Oracle target
                        endpoint.
{ "rules": [ { "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "Play", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "2", "rule-name": "2", "rule-action": "rename", "rule-target": "table-tablespace", "object-locator": { "schema-name": "Play", "table-name": "Actor", "table-tablespace-name": "SetISpace" }, "value": "SceneIdxSpace" } ] }
Example Add a column
The following example adds a datetime column to the table
                            Actor in schema test.
{ "rules": [ { "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "test", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "2", "rule-name": "2", "rule-action": "add-column", "rule-target": "column", "object-locator": { "schema-name": "test", "table-name": "actor" }, "value": "last_updated", "data-type": { "type": "datetime", "precision": 6 } } ] }
Example Remove a column
The following example transforms the table named Actor in
                        your source to remove all columns starting with the characters
                            col from it in your target.
{ "rules": [{ "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "test", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "2", "rule-name": "2", "rule-action": "remove-column", "rule-target": "column", "object-locator": { "schema-name": "test", "table-name": "Actor", "column-name": "col%" } }] }
Example Convert to lowercase
The following example converts a table name from ACTOR in
                        your source to actor in your target.
{ "rules": [{ "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "test", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "2", "rule-name": "2", "rule-action": "convert-lowercase", "rule-target": "table", "object-locator": { "schema-name": "test", "table-name": "ACTOR" } }] }
Example Convert to uppercase
The following example converts all columns in all tables and all schemas from lowercase in your source to uppercase in your target.
{ "rules": [ { "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "test", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "2", "rule-name": "2", "rule-action": "convert-uppercase", "rule-target": "column", "object-locator": { "schema-name": "%", "table-name": "%", "column-name": "%" } } ] }
Example Add a prefix
The following example transforms all tables in your source to add the
                        prefix DMS_ to them in your target.
{ "rules": [{ "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "test", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "2", "rule-name": "2", "rule-action": "add-prefix", "rule-target": "table", "object-locator": { "schema-name": "test", "table-name": "%" }, "value": "DMS_" }] }
Example Replace a prefix
The following example transforms all columns containing the prefix
                            Pre_ in your source to replace the prefix with
                            NewPre_ in your target.
{ "rules": [ { "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "test", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "2", "rule-name": "2", "rule-action": "replace-prefix", "rule-target": "column", "object-locator": { "schema-name": "%", "table-name": "%", "column-name": "%" }, "value": "NewPre_", "old-value": "Pre_" } ] }
Example Remove a suffix
The following example transforms all tables in your source to remove the
                        suffix _DMS from them in your target.
{ "rules": [{ "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "test", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "2", "rule-name": "2", "rule-action": "remove-suffix", "rule-target": "table", "object-locator": { "schema-name": "test", "table-name": "%" }, "value": "_DMS" }] }
Example Define a primary key
The following example defines a primary key named
                            ITEM-primary-key on three columns of the ITEM
                        table migrated to your target endpoint.
{ "rules": [{ "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "inventory", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "2", "rule-name": "2", "rule-action": "define-primary-key", "rule-target": "table", "object-locator": { "schema-name": "inventory", "table-name": "ITEM" }, "primary-key-def": { "name": "ITEM-primary-key", "columns": [ "ITEM-NAME", "BOM-MODEL-NUM", "BOM-PART-NUM" ] } }] }
Example Define a unique index
The following example defines a unique index named
                            ITEM-unique-idx on three columns of the ITEM
                        table migrated to your target endpoint.
{ "rules": [{ "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "inventory", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "2", "rule-name": "2", "rule-action": "define-primary-key", "rule-target": "table", "object-locator": { "schema-name": "inventory", "table-name": "ITEM" }, "primary-key-def": { "name": "ITEM-unique-idx", "origin": "unique-index", "columns": [ "ITEM-NAME", "BOM-MODEL-NUM", "BOM-PART-NUM" ] } }] }
Example Change data type of target column
The following example changes the data type of a target column named
                            SALE_AMOUNT from an existing data type to
                        int8.
{ "rule-type": "transformation", "rule-id": "1", "rule-name": "RuleName 1", "rule-action": "change-data-type", "rule-target": "column", "object-locator": { "schema-name": "dbo", "table-name": "dms", "column-name": "SALE_AMOUNT" }, "data-type": { "type": "int8" } }
Example Add a before image column
For a source column named emp_no, the transformation rule in
                        the example following adds a new column named BI_emp_no in the
                        target.
{ "rules": [{ "rule-type": "selection", "rule-id": "1", "rule-name": "1", "object-locator": { "schema-name": "%", "table-name": "%" }, "rule-action": "include" }, { "rule-type": "transformation", "rule-id": "2", "rule-name": "2", "rule-target": "column", "object-locator": { "schema-name": "%", "table-name": "employees" }, "rule-action": "add-before-image-columns", "before-image-def": { "column-prefix": "BI_", "column-suffix": "", "column-filter": "pk-only" } } ] }
Here, the following statement populates a BI_emp_no column in the
                    corresponding row with 1.
UPDATE employees SET emp_no = 3 WHERE BI_emp_no = 1;
When writing CDC updates to supported AWS DMS targets, the
                        BI_emp_no column makes it possible to tell which rows have
                    updated values in the emp_no column.