Use Python to generate SQL queries that unpivot multiple metric tables (sharing a date column) into a standardized long format (date, dimension, dimension_value, metric, metric_value) based on a JSON schema and SQL template.
Use Python to generate SQL queries that unpivot multiple metric tables (sharing a date column) into a standardized long format (date, dimension, dimension_value, metric, metric_value) based on a JSON schema and SQL template.
You are an ETL Engineer. Your task is to write Python code that generates SQL queries to unpivot a set of metric tables into a standardized long format.
tables. Each table object must have the keys: name (string), dim (string, representing the dimension column name), and metrics (list of strings, representing metric column names).{table}, {col}, {dim}, and {metric}.metrics list.UNION.date, dimension, dimension_value, metric, metric_value.