Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Explore the results

Using DuckDB locally (or Athena if the output was written to S3):

create table enriched_curs as select * from 'output/**/*.parquet';

select line_item_product_code, product_servicecode,
       round(sum(operational_emissions_co2eq_g)/1000,2) as co2_usage_kg,
       round(sum(embodied_emissions_co2eq_g)/1000, 2) as co2_embodied_kg,
       round(sum(energy_usage_kwh),2) as energy_usage_kwh
       from enriched_curs where operational_emissions_co2eq_g > 0.01
       group by line_item_product_code, product_servicecode
       order by co2_usage_kg desc, co2_embodied_kg desc, energy_usage_kwh desc, product_servicecode;

This should give an output similar to

line_item_product_codeproduct_servicecodeline_item_operationco2_usage_kgenergy_usage_kwhco2_embodied_kg
AmazonEC2AmazonEC2RunInstances538.31220.14303.41
AmazonECSAmazonECSFargateTask181.32399.05NULL
AmazonS3AmazonS3OneZoneIAStorage102.3225.15NULL
AmazonS3AmazonS3GlacierInstantRetrievalStorage75.89167.03NULL
AmazonEC2AmazonEC2CreateVolume-Gp341.6391.62NULL
AmazonS3AmazonS3StandardStorage28.5162.81NULL
AmazonDocDBAmazonDocDBCreateCluster19.7943.56NULL
AmazonECSAmazonECSECSTask-EC29.2620.37NULL
AmazonS3AmazonS3IntelligentTieringAIAStorage2.335.13NULL
AmazonEC2AmazonEC2CreateSnapshot2.315.82NULL
AmazonEC2AmazonEC2RunInstances:SV0011.793.940.78
AmazonS3AmazonS3StandardIAStorage1.192.61NULL
AmazonS3AWSDataTransferGetObjectForRepl1.172.58NULL
AmazonS3AWSDataTransferUploadPartForRepl1.012.22NULL
AmazonS3AmazonS3OneZoneIASizeOverhead0.891.96NULL
AmazonEC2AmazonEC2CreateVolume-Gp20.841.84NULL
AmazonEC2AWSDataTransferRunInstances0.180.39NULL
AmazonS3AWSDataTransferPutObjectForRepl0.160.36NULL
AmazonS3AmazonS3DeleteObject0.160.35NULL
AWSBackupAWSBackupStorage0.10.49NULL
AmazonMQAmazonMQCreateBroker:00010.020.04NULL
AmazonECRAWSDataTransferdownloadLayer0.010.01NULL
AmazonS3AWSDataTransferPutObject0.00.0NULL

To measure the proportion of the costs for which emissions where calculated

select
  round(covered * 100 / "total costs", 2) as percentage_costs_covered
from (
  select
    sum(line_item_unblended_cost) as "total costs",
    sum(line_item_unblended_cost) filter (where operational_emissions_co2eq_g is not null) as covered
  from
    enriched_curs
  where
    line_item_line_item_type like '%Usage'
);