Exercise 7
Create View for Europe Big Three Emissions
Use the source table co2_emissions_and_temperatures_by_country
to create a view for the emissions data of the three major European countries: France, Germany, and the United Kingdom.
To create the view europe_big_three_emissions
with the desired columns in the carbon_emissions
schema:
- Open your dbt project and navigate to the appropriate schema directory (e.g.,
models/carbon_emissions
). - Create a new file named
europe_big_three_emissions.sql
(or any desired name) in the schema directory. - In the
europe_big_three_emissions.sql
file, write the dbt model definition for the view. - Define the
europe_big_three_emissions
model using theview
materialization type. - Perform the necessary data transformations to reshape the data to meet the requirements.
- Select the following columns for the output view:
Year
: IntegerFrance_TotalEmissions
: FloatFrance_PerCapitaEmissions
: FloatGermany_TotalEmissions
: FloatGermany_PerCapitaEmissions
: FloatUnitedKingdom_TotalEmissions
: FloatUnitedKingdom_PerCapitaEmissions
: Float
By following these instructions and executing the appropriate dbt commands, you will create the view europe_big_three_emissions
in the carbon_emissions
schema. The view will contain the emissions data for the three major European countries, with the specified columns as outlined above.