Querying Daton created tables on RedShift
How to query RedShift tables
RedShift data warehouse does not support nested tables. Hence, Daton creates separate 'child' tables for each nested data present in source schema(or parent table).
For example, if data is present in Listrecommendations.Fulfillmentrecommendations.Member.Itemdimensions.Dimensiondescriptionthen the following tables would be created -
- 1.Listrecommendations (Parent Table)
- 2.Listrecommendations_Fulfillmentrecommendations (Level 1 Child)
- 3.Listrecommendations_Fulfillmentrecommendations_Member (Level 2 Child)
- 4.Listrecommendations_Fulfillmentrecommendations_Member_Itemdimensions (Level 3 Child)
Any nested data present in Itemdimesions would be stored at text and any excess data which does not fit into that field would be truncated.
Data between parent and child tables can be mapped or combined using daton_parent_batch_id and daton_batch_runtime meta fields. The same applies for other levels of child tables.
For example, if API response for ListOrderItems contains data in the following structure
then the following tables would be created by Daton on RedShift
ListOrderItem (Parent Table)
ListOrderItem_ItemPrice (Level 1 Child Table)
In order to fetch Item price for an AmazonOrderId, daton_batch_id and daton_batch_runtime must be used for mapping records
select Amount from listorderitems_itemprice
daton_parent_batch_id = (select daton_batch_id from mws_listorderitems where amazonorderid = 'XXX-7370285-XXXX')
daton_batch_runtime = (select daton_batch_runtime from mws_listorderitems where amazonorderid = 'XXX-7370285-XXXX')