From 190be064cb98e53f18b36be4dc05ec1d66dbfd58 Mon Sep 17 00:00:00 2001 From: jianglai Date: Mon, 27 Mar 2017 13:28:34 -0700 Subject: [PATCH] Add billingAccountId to BillingData table Join RegistrarAccountId table to BillingData to append additional billingAccountId column ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=151362466 --- .../registry/tools/sql/billing_data_view.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/java/google/registry/tools/sql/billing_data_view.sql b/java/google/registry/tools/sql/billing_data_view.sql index e14349fb6..953e3b282 100644 --- a/java/google/registry/tools/sql/billing_data_view.sql +++ b/java/google/registry/tools/sql/billing_data_view.sql @@ -23,6 +23,7 @@ SELECT BillingEvent.eventTime AS eventTime, BillingEvent.clientId AS registrarId, Registrar.billingIdentifier AS billingId, + RegistrarAccount.billingAccountId AS billingAccountId, BillingEvent.tld AS tld, IF( CONCAT(',', BillingEvent.flags, ',') CONTAINS (',ALLOCATION,'), @@ -88,6 +89,19 @@ LEFT JOIN EACH ( ON BillingEvent.clientId = Registrar.clientId +-- Join to pick up currency specific registrar account id from registrar +-- account view. +LEFT JOIN EACH ( + SELECT + registrarId, + billingAccountId, + currency + FROM + [%DEST_DATASET%.RegistrarAccountData]) AS RegistrarAccount +ON + BillingEvent.clientId = RegistrarAccount.registrarId + AND BillingEvent.currency = RegistrarAccount.currency + -- Join to pick up cancellations for billing events. LEFT JOIN EACH ( SELECT