This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created views with cost estimations #26
- Loading branch information
1 parent
8f3d1d8
commit 86fc6b1
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
bq_schemas/bigquery_views/datasets_cost_estimation_v1_0.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#standardSQL | ||
-- This view provides BigQuery datasets current estimated costs, which might differ to those provided by GCP billing | ||
SELECT | ||
projectId, | ||
datasetId, | ||
ROUND(SUM(numBytes/(1024*1024*1024)), 3) AS totalStorageInGB, | ||
ROUND(SUM(numLongTermBytes/(1024*1024*1024)), 3) AS longTermStorageInGB, | ||
ROUND(SUM(numBytes/(1024*1024*1024))-SUM(numLongTermBytes/(1024*1024*1024)), 3) AS activeStorageInGB, | ||
ROUND( ((SUM(numBytes/(1024*1024*1024))-SUM(numLongTermBytes/(1024*1024*1024))) * 0.02 + (SUM(numLongTermBytes/(1024*1024*1024))) * 0.01), 3) AS estimatedMonthlyCostInUSD, | ||
SUM(numRows) AS numRows, | ||
COUNT(tableId) AS tableCount | ||
FROM | ||
`$PROJECT_ID.bigquery_views.table_metadata_v1_0` | ||
GROUP BY | ||
projectId, | ||
datasetId |
15 changes: 15 additions & 0 deletions
15
bq_schemas/bigquery_views_legacy_sql/datasets_cost_estimation_v1_0.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-- This view provides BigQuery datasets current estimated costs, which might differ to those provided by GCP billing | ||
SELECT | ||
projectId, | ||
datasetId, | ||
ROUND(SUM(numBytes/(1024*1024*1024)), 3) AS totalStorageInGB, | ||
ROUND(SUM(numLongTermBytes/(1024*1024*1024)), 3) AS longTermStorageInGB, | ||
ROUND(SUM(numBytes/(1024*1024*1024))-SUM(numLongTermBytes/(1024*1024*1024)), 3) AS activeStorageInGB, | ||
ROUND( ((SUM(numBytes/(1024*1024*1024))-SUM(numLongTermBytes/(1024*1024*1024))) * 0.02 + (SUM(numLongTermBytes/(1024*1024*1024))) * 0.01), 3) AS estimatedMonthlyCostInUSD, | ||
SUM(numRows) AS numRows, | ||
COUNT(tableId) AS tableCount | ||
FROM | ||
[bigquery_views_legacy_sql.table_metadata_v1_0] | ||
GROUP BY | ||
projectId, | ||
datasetId |