CDM mapping examples
Source and target mapping examples.
The definition pipeline contains the transformation and mapping of endpoint data types to or from the common data model. In the SimpleGoogleSheeets and SimpleSnowflake endpoint examples, you can find the following the following transformation and mapping expressions in the CDM Snap. Hover over the expression to expand it for visibility:

Example expression for SimpleGoogleSheets
Google sheets support a limited set of data types:
{
"defaultDataType": "cdt_string",
"supportedLoadMethods": ["reload"],
"mapDatatypes": {
"varchar": "cdt_string",
"Double": "cdt_float8",
"LocalDate": "cdt_datetime",
"Any": "cdt_string",
"sl_timestamp": "cdt_timestamp"
},
"mapValues": {
"LocalDate": "to_datetime",
"Any": "any_to_string",
"defaultType": "any_to_string"
},
"mapData": {
"to_datetime" : "$value == null ? null : Date.parse($value.toString())",
"any_to_string" : "((typeof($value) == 'array' || typeof($value) == 'object') ? JSON.stringify($value) : $value.toString())"
}
}
Example expression for SimpleSnowflake
The expression for Snowflake maps data from the CDM type and transforms it to the appropriate Snowflake type:
{
"CompareCaseInsensitive": false,
"startQuote": "\"",
"endQuote": "\"",
"defaultDataType": "varchar",
"supportedLoadMethods": ["reload", "upsert"],
"mapDatatypes": {
"cdt_char": "varchar",
"cdt_nchar": "varchar",
"cdt_string": "varchar",
"cdt_nstring": "varchar",
"cdt_date": "date",
"cdt_time": "time",
"cdt_datetime": "timestamp_ntz",
"cdt_timestamp": "timestamp_tz",
"cdt_timestamp_ntz": "timestamp_ntz",
"cdt_bool": "boolean",
"cdt_int8": "number",
"cdt_int16": "number",
"cdt_int24": "number",
"cdt_int32": "number",
"cdt_int64": "number",
"cdt_decimal": "number",
"cdt_float4": "float",
"cdt_float8": "float",
"cdt_binary": "binary",
"cdt_json": "object"
},
"mapValues": {
"cdt_date": "cdt_date",
"cdt_time": "cdt_time",
"cdt_datetime": "cdt_datetime",
"cdt_timestamp_ntz": "cdt_datetime",
"cdt_timestamp": "cdt_timestamp",
"cdt_json": "cdt_json",
"cdt_binary": "cdt_binary"
},
"mapData": {
"null": "$value",
"cdt_date": "$value.toLocaleDateString()",
"cdt_time": "$value.toLocaleTimeString()",
"cdt_datetime": "$value.toLocaleDateTimeString()",
"cdt_timestamp": "$value.toString()",
"cdt_json": "JSON.stringify($value) ",
"cdt_binary": "Base64.encode($value)"
},
"datasize": {
"array": { "min": [null, null], "max": [null, null] },
"binary": { "min": [null, null], "max": [null, null] },
"boolean": { "min": [null, null], "max": [null, null] },
"date": { "min": [null, null], "max": [null, null] },
"datetime": { "min": [null, null], "max": [null, null] },
"float": { "min": [null, null], "max": [null, null] },
"geography": { "min": [null, null], "max": [null, null] },
"number": { "min": [1, 0], "max": [38, 37] },
"object": { "min": [null, null], "max": [null, null] },
"time": { "min": [null, null], "max": [null, null] },
"timestamp_ltz": { "min": [null, null], "max": [null, null] },
"timestamp_ntz": { "min": [null, null], "max": [null, null] },
"timestamp_tz": { "min": [null, null], "max": [null, null] },
"varchar": { "min": [0, null], "max": [16777216, null] },
"variant": { "min": [null, null], "max": [null, null] }
}
}