From 3c4a4ef87ceb587d5b6bc1e92cc0feb92eb7cd65 Mon Sep 17 00:00:00 2001 From: jdesouza Date: Wed, 10 Apr 2024 12:09:09 -0300 Subject: [PATCH] Added partitioned column to improve billing BigQuery (#891) * Added partinioned column to improve billing BigQuery * Fixed version * Bumped version --- plugins/cloud-costs/CHANGELOG.md | 3 +++ plugins/cloud-costs/cloud-costs.sh | 2 +- plugins/cloud-costs/version.txt | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/cloud-costs/CHANGELOG.md b/plugins/cloud-costs/CHANGELOG.md index 62d926ff7..87bfe7274 100644 --- a/plugins/cloud-costs/CHANGELOG.md +++ b/plugins/cloud-costs/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.2.0 +* Added partition column to GCP big query + ## 0.1.10 * Fixed AWS file name diff --git a/plugins/cloud-costs/cloud-costs.sh b/plugins/cloud-costs/cloud-costs.sh index 8a529a5d5..b76a25fe3 100755 --- a/plugins/cloud-costs/cloud-costs.sh +++ b/plugins/cloud-costs/cloud-costs.sh @@ -176,7 +176,7 @@ if [[ "$provider" == "gcp" ]]; then echo "Google bigquey is running......" - sql="SELECT main.* FROM \`$table\` AS main LEFT JOIN UNNEST(labels) as labels WHERE labels.key = '$tagkey' AND labels.value = '$tagvalue' and usage_start_time >= '$initial_date_time' AND usage_start_time < '$final_date_time' order by usage_start_time desc" + sql="SELECT main.* FROM \`$table\` AS main LEFT JOIN UNNEST(labels) as labels WHERE labels.key = '$tagkey' AND labels.value = '$tagvalue' and usage_start_time >= '$initial_date_time' AND usage_start_time < '$final_date_time' AND TIMESTAMP_TRUNC(_PARTITIONTIME, DAY) >= '$initial_date_time' AND TIMESTAMP_TRUNC(_PARTITIONTIME, DAY) <= '$final_date_time' order by usage_start_time desc" bq --format=prettyjson query --max_rows=10000000 --nouse_legacy_sql "$sql" > /output/cloudcosts-tmp.json echo "Google bigquey finished......" diff --git a/plugins/cloud-costs/version.txt b/plugins/cloud-costs/version.txt index 345f8cc03..341cf11fa 100644 --- a/plugins/cloud-costs/version.txt +++ b/plugins/cloud-costs/version.txt @@ -1 +1 @@ -0.1.10 \ No newline at end of file +0.2.0 \ No newline at end of file