Exercise 4
Create Table for Aggregate Global Emissions and Temperatures
In this exercise, you will use dbt to perform an INNER JOIN between the aggregate_global_emissions
and aggregate_global_temperatures
table to analyze the relationship between global emissions and temperatures. The result of the join will be stored in a table called aggregate_global_emissions_temperatures
in the global_temperatures
schema.
To create the table with the desired columns:
- Open your dbt project and navigate to the appropriate schema directory (e.g.,
models/global_temperatures
). - Create a new file named
aggregate_global_emissions_temperatures.sql
(or any desired name) in the schema directory. - In the
aggregate_global_emissions_temperatures.sql
file, write the dbt model definition for the table. - Define the
aggregate_global_emissions_temperatures
model using thetable
materialization type. - Specify the columns for the table using the
select
statement. - In the
select
statement, perform an INNER JOIN between theaggregate_global_emissions
andaggregate_global_temperatures
table on the "Year" column. - Select the following columns from the joined data:
Year
: IntegerTotalEmissions
: FloatLandAverageTemperature
: FloatLandMaxTemperature
: FloatLandMinTemperature
: FloatLandAndOceanAverageTemperature
: Float
Your output table, aggregate_global_emissions_temperatures
, should have the following columns:
Year
: IntegerTotalEmissions
: FloatLandAverageTemperature
: FloatLandMaxTemperature
: FloatLandMinTemperature
: FloatLandAndOceanAverageTemperature
: Float
By following these instructions and executing the appropriate dbt commands,
you will create a table called aggregate_global_emissions_temperatures
in the global_temperatures
schema.
The table will contain the results of the INNER JOIN between the aggregate_global_emissions
and aggregate_global_temperatures
views, with the specified columns as outlined above.