1 Answer
- Newest
- Most votes
- Most comments
0
Thanks for contacting AWS.
The error you are facing is because the column names should start with $ in the transformation rule, therefore the correct value should be '$_doc'.
In AWS documentation you can see examples of using $ [+] https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Tasks.CustomizingTasks.TableMapping.SelectionTransformation.Expressions.html
Further, on testing following could be seen:
- With below transformation rule, DMS is creating a column named 'field' however, even without using json_extract function i.e., only '$_doc' as expression, the column on target was empty. This is because DMS converts the source data type to CLOB and as per limitation with transformation rule, "The only supported transformation for columns that are mapped to BLOB/CLOB data types is to drop the column on the target." [+] https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Tasks.CustomizingTasks.TableMapping.SelectionTransformation.Transformations.html Therefore, any expression to add column which is mapped to lob data types will not work.
{
"rule-type": "transformation",
"rule-id": "425815267",
"rule-name": "extract-field",
"rule-action": "add-column",
"rule-target": "column",
"object-locator": {
"table-name": "new",
"schema-name": "catalog"
},
"value": "field",
"expression": "$_doc",
"data-type": {
"type": "string",
"length": 15
}
}
> select * from new;
+--------------------------+------------------------------------------------------------------------------------+-------+
| _id | _doc | field |
+--------------------------+------------------------------------------------------------------------------------+-------+
| 652caea3a4d85c5d6af773cc | { "_id" : { "$oid" : "652caea3a4d85c5d6af773cc" }, "item" : "card", "qty" : 15.0 } | NULL |
| 652caeaaa4d85c5d6af773cd | { "_id" : { "$oid" : "652caeaaa4d85c5d6af773cd" }, "item" : "card", "qty" : 15.0 } | NULL |
+--------------------------+------------------------------------------------------------------------------------+-------+
2 rows in set (0.00 sec)
- When changed the expression to '$_id', the column was migrated.
{
"rule-type": "transformation",
"rule-id": "425815267",
"rule-name": "extract-field",
"rule-action": "add-column",
"rule-target": "column",
"object-locator": {
"table-name": "new",
"schema-name": "catalog"
},
"value": "field",
"expression": "$_id",
"data-type": {
"type": "string",
"length": 15
}
}
> select * from new;
+--------------------------+------------------------------------------------------------------------------------+-----------------+
| _id | _doc | field |
+--------------------------+------------------------------------------------------------------------------------+-----------------+
| 652caea3a4d85c5d6af773cc | { "_id" : { "$oid" : "652caea3a4d85c5d6af773cc" }, "item" : "card", "qty" : 15.0 } | 652caea3a4d85c5 |
| 652caeaaa4d85c5d6af773cd | { "_id" : { "$oid" : "652caeaaa4d85c5d6af773cd" }, "item" : "card", "qty" : 15.0 } | 652caeaaa4d85c5 |
+--------------------------+------------------------------------------------------------------------------------+-----------------+
2 rows in set (0.00 sec)
- Having said that, unfortunately this type of transformation will not be possible with document mode. Hence, as a workaround you can consider using 'table mode' in the source endpoint in order to normalize the data into a relational structure. [+] https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Source.MongoDB.html
> select * from new;
+--------------------------+------+------+
| oid__id | item | qty |
+--------------------------+------+------+
| 652caea3a4d85c5d6af773cc | card | 15 |
| 652caeaaa4d85c5d6af773cd | card | 15 |
+--------------------------+------+------+
2 rows in set (0.00 sec)
Relevant content
- asked 10 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 7 months ago