Skip to content

Column Mapping - DocumentDB to Postgress

0

Hi, I have a different structure in source (DocumentDB) and target (Postgres) , i would like to map each source column to target table and include format , Please advise. For example , this is my document in source _id 6985a8f1f089ca305dc2dd87 client_id "44354302" rep_id "805C" client_gid "8334342" client_fullname "Gracie Ali Shade" created_date "2026-02-06"

Target table has way more and not in same order, when i am migrating this data using DMS i notice that created_date field is coming null at target. seems like mapping is required or date formate need to be change at target (Created_date is date format in target).

asked 9 months ago135 views

2 Answers
1

When migrating from DocumentDB to PostgreSQL using AWS DMS, you have two migration modes to choose from that affect how your data is mapped:

Table Mode (Recommended for your scenario): In table mode, AWS DMS transforms each top-level field in your DocumentDB document into a column in the target PostgreSQL table. This mode automatically handles the mapping of fields like _id, client_id, rep_id, etc., to corresponding columns in your target table.

For your created_date field appearing as null, this could be due to a few factors:

  1. Data Type Mismatch: Your source has created_date as a string ("2026-02-06"), but your target expects a date format. You may need to use transformation rules to convert the string to a proper date format.

  2. Column Mapping: To handle different structures and ordering between source and target, you can use transformation rules with expressions. You can add transformation rules to:

  • Map specific source columns to target columns
  • Convert data types (like string to date)
  • Handle format conversions
  1. Scanning Documents: AWS DMS scans a specified number of documents (default 1000) to determine the field structure and data types. If your created_date field isn't consistently present in the scanned documents, it might not be properly mapped.

Recommendations:

  • Use table mode for better column-level control
  • Implement transformation rules to handle the date format conversion from string to date type
  • Ensure your transformation rules explicitly map each source field to the corresponding target column
  • Consider using expressions in transformation rules to convert the string date format to the proper date data type expected by PostgreSQL

You can configure these settings when creating your DocumentDB source endpoint using either the Metadata mode option in the console or through extra connection attributes.
Sources
Using Amazon DocumentDB (with MongoDB compatibility) as a source for AWS DMS - AWS Database Migration Service
Using MongoDB as a source for AWS DMS - AWS Database Migration Service
Using transformation rule expressions to define column content - AWS Database Migration Service

answered 9 months ago

EXPERT

reviewed 9 months ago

0

In AWS DMS, DocumentDB→Postgres won’t always auto-convert string dates to a DATE column. If created_date is stored as a string ("2026-02-06"), DMS can land it as NULL unless you transform it.

Fix

  1. Store ISODate in source (best):
db.col.updateMany(
  { created_date: { $type: "string" } },
  [{ $set: { created_date: { $dateFromString: { dateString: "$created_date" } } } }]
)
  1. DMS transformation rule (map + type/format): use task “Transformation rules” to map created_date to target and apply a conversion (string→date). Validate in task logs.

Quick checks

-- Postgres target
SELECT created_date FROM target_table WHERE client_id='44354302';
aws dms describe-table-statistics --replication-task-arn <arn>

answered 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.