dbt-snowflake-monitoring icon indicating copy to clipboard operation
dbt-snowflake-monitoring copied to clipboard

Minor discrepancy between model spend and Snowflake actuals

Open aphethean1 opened this issue 2 years ago • 0 comments

When comparing the monthly spend from daily_spend vs Snowflake actuals, there is a minor discrepancy of a few cents.

This is most easily seen on our account by directly selecting metering_history. The correct amount (in terms of matching Snowflake invoice) is achieved by rounding, then sum. Within the model this is also true, but would prefer a test to prove the results.

-- invoice amount April $35.05 -- without rounding April $35.08

SELECT 
  date_trunc(month, convert_timezone('UTC', start_time))::date as month,
  sum(round(credits_used,2)) + sum(round(credits_used_compute,2)) + sum(round(credits_used_cloud_services,2))
FROM snowflake.account_usage.metering_history
WHERE date_trunc(month, start_time)::date = '2022-04-01'
GROUP BY 1;

aphethean1 avatar Nov 21 '22 11:11 aphethean1