Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying workaround for labeling scheduled queries #105

Merged
merged 7 commits into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions terraform/bigquery_scheduled_data_transfer/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ resource "google_bigquery_data_transfer_config" "default" {
destination_dataset_id = var.destination_dataset_id

params = {
query = templatefile(
var.query_template,
merge(var.query_variables, { interval = try(local.bigquery_interval_mappings[var.interval], var.interval) })
)
destination_table_name_template = var.destination_table_name_template
write_disposition = var.write_disposition
query = join("", [
length(var.labels) > 0 ? format("SET @@query_label = \"%s\";\n\n", join(",", [for key, value in var.labels : format("%s:%s", key, value)])) : "",
templatefile(
var.query_template,
merge(var.query_variables, { interval = try(local.bigquery_interval_mappings[var.interval], var.interval) })
)
])
write_disposition = var.write_disposition
}

# formatting rules are quite hard to generalize, see: https://cloud.google.com/appengine/docs/flexible/scheduling-jobs-with-cron-yaml#cron_yaml_The_schedule_format
Expand Down
Loading