I am very new to Glue and came across to a scenario where we've source table in glue catalog and we need to write it's data to specific columns in pre-existing table in redshift. e.g.
source_table_name[source_table_column_name]. target_table_name[target_table_column_name]
employee[id] resource[resource_id]
employee[name] resource[resource_name]
employee[policy] resource[policy_name]
employee[zip] resource[zipcode]
... ...
... ...
... ...
could you please share how/what glue function can be utilized to write UDF in python which can iterate through given subset of column names from source_table and map/write this data to specified column name in target table (as in example above) in redshift?
For example: write id column data from employee <source table> to resource_id column in resource <target table> in redshift and so on.
I've written following logic to load data in source_dynf:
def load_data(self):
self.logger.info(f"Loading data from Glue Catalog source [{self.source_database}/{self.source_table}]")
source_dynf = self.glue_context.create_dynamic_frame.from_catalog(
database=self.source_database,
table_name=self.source_table,
transformation_ctx=f"load_{self.source_database}_{self.source_table}"
)
return source_dynf
def process_data(self, source_dynf):
###how I can map data as mentioned above and return processed_dynf from here which I can write to redshift target table
def write_data(self):
###write to redshift target table
thanks in advance for suggestions/help!