Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

Commit

Permalink
YACHT-1026: Repair of SLI query - partition_id on both sides of join …
Browse files Browse the repository at this point in the history
…are now 'null' string in case of null
  • Loading branch information
radkomateusz committed Sep 17, 2018
1 parent 3eda44b commit 2204489
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
6 changes: 3 additions & 3 deletions terraform/SLI_3_days_views.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ resource "google_bigquery_table" "SLI_3_days_view" {
ON
census.projectId=last_backups.source_project_id AND
census.datasetId=last_backups.source_dataset_id AND
census.tableId=last_backups.source_table_id
census.tableId=last_backups.source_table_id AND
census.partitionId=last_backups.source_partition_id
WHERE
(last_backups.source_partition_id IS NULL OR last_backups.source_partition_id=census.partitionId)
AND projectId != "${var.bbq_project}"
projectId != "${var.bbq_project}"
AND projectId != "${var.bbq_restoration_project}"
AND partitionId != "__UNPARTITIONED__"
AND IFNULL(last_backups.backup_created, MSEC_TO_TIMESTAMP(0)) < TIMESTAMP(DATE_ADD(CURRENT_TIMESTAMP(), -3 , "DAY"))
Expand Down
6 changes: 3 additions & 3 deletions terraform/SLI_4_days_views.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ resource "google_bigquery_table" "SLI_4_days_view" {
ON
census.projectId=last_backups.source_project_id AND
census.datasetId=last_backups.source_dataset_id AND
census.tableId=last_backups.source_table_id
census.tableId=last_backups.source_table_id AND
census.partitionId=last_backups.source_partition_id
WHERE
(last_backups.source_partition_id IS NULL OR last_backups.source_partition_id=census.partitionId)
AND projectId != "${var.bbq_project}"
projectId != "${var.bbq_project}"
AND projectId != "${var.bbq_restoration_project}"
AND partitionId != "__UNPARTITIONED__"
AND IFNULL(last_backups.backup_created, MSEC_TO_TIMESTAMP(0)) < TIMESTAMP(DATE_ADD(CURRENT_TIMESTAMP(), -4 , "DAY"))
Expand Down
6 changes: 3 additions & 3 deletions terraform/SLI_5_days_views.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ resource "google_bigquery_table" "SLI_5_days_view" {
ON
census.projectId=last_backups.source_project_id AND
census.datasetId=last_backups.source_dataset_id AND
census.tableId=last_backups.source_table_id
census.tableId=last_backups.source_table_id AND
census.partitionId=last_backups.source_partition_id
WHERE
(last_backups.source_partition_id IS NULL OR last_backups.source_partition_id=census.partitionId)
AND projectId != "${var.bbq_project}"
projectId != "${var.bbq_project}"
AND projectId != "${var.bbq_restoration_project}"
AND partitionId != "__UNPARTITIONED__"
AND IFNULL(last_backups.backup_created, MSEC_TO_TIMESTAMP(0)) < TIMESTAMP(DATE_ADD(CURRENT_TIMESTAMP(), -5 , "DAY"))
Expand Down
6 changes: 3 additions & 3 deletions terraform/SLI_7_days_views.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ resource "google_bigquery_table" "SLI_7_days_view" {
ON
census.projectId=last_backups.source_project_id AND
census.datasetId=last_backups.source_dataset_id AND
census.tableId=last_backups.source_table_id
census.tableId=last_backups.source_table_id AND
census.partitionId=last_backups.source_partition_id
WHERE
(last_backups.source_partition_id IS NULL OR last_backups.source_partition_id=census.partitionId)
AND projectId != "${var.bbq_project}"
projectId != "${var.bbq_project}"
AND projectId != "${var.bbq_restoration_project}"
AND partitionId != "__UNPARTITIONED__"
AND IFNULL(last_backups.backup_created, MSEC_TO_TIMESTAMP(0)) < TIMESTAMP(DATE_ADD(CURRENT_TIMESTAMP(), -7 , "DAY"))
Expand Down
15 changes: 10 additions & 5 deletions terraform/datastore_export_views_legacy_dataset_with_views.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ resource "google_bigquery_table" "last_table_view" {

view {
query = <<EOF
SELECT project_id, dataset_id, table_id, partition_id, last_checked, __key__.id AS id
FROM TABLE_QUERY(
[${local.datastore_export_project}:${var.datastore_export_dataset}],
'table_id=(SELECT MAX(table_id) FROM [${local.datastore_export_project}:${var.datastore_export_dataset}.__TABLES__] WHERE LEFT(table_id, 6) = "Table_")'
)
SELECT
project_id,
dataset_id,
table_id,
IFNULL(partition_id,'null') as partition_id,
last_checked,
__key__.id AS id
FROM
TABLE_QUERY( [${local.datastore_export_project}:${var.datastore_export_dataset}],
'table_id=(SELECT MAX(table_id) FROM [${local.datastore_export_project}:${var.datastore_export_dataset}.__TABLES__] WHERE LEFT(table_id, 6) = "Table_")' )
EOF
use_legacy_sql = true
}
Expand Down

0 comments on commit 2204489

Please sign in to comment.