Add Registrar Account Data view in BigQuery snapshot

This adds a new view table that contains the registrar id, the currency-specific billing account id and the corresponding currency in latest_billing dataset based on latest_snapshot dataset.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=151363209
This commit is contained in:
jianglai 2017-03-27 13:34:08 -07:00 committed by Ben McIlwain
parent 190be064cb
commit ff9c72097c
2 changed files with 75 additions and 0 deletions

View file

@ -46,6 +46,8 @@ final class MakeBillingTablesCommand extends BigqueryCommand {
private static final SqlTemplate CURRENCY_TABLE_SQL = getSql("currency_table.sql");
private static final SqlTemplate REGISTRAR_DATA_SQL = getSql("registrar_data_view.sql");
private static final SqlTemplate REGISTRAR_ACCOUNT_DATA_SQL =
getSql("registrar_account_data_view.sql");
private static final SqlTemplate REGISTRY_DATA_SQL = getSql("registry_data_view.sql");
private static final SqlTemplate BILLING_DATA_SQL = getSql("billing_data_view.sql");
@ -59,6 +61,7 @@ final class MakeBillingTablesCommand extends BigqueryCommand {
try {
makeCurrencyTable();
makeRegistrarView();
makeRegistrarAccountView();
makeRegistryView();
makeBillingView();
} catch (TableCreationException e) {
@ -99,6 +102,28 @@ final class MakeBillingTablesCommand extends BigqueryCommand {
.build()));
}
/**
* Generates a view of registrar account data, which includes the billing account id and the
* currency used.
*
* <p>The generated view is similar to the one generated by {@link #makeRegistrarView()}, but it
* uses currency-specific billing account id and does not include allowed TLDs.
*/
private void makeRegistrarAccountView() throws Exception {
handleTableCreation(
"registrar account data view",
bigquery()
.query(
REGISTRAR_ACCOUNT_DATA_SQL.put("SOURCE_DATASET", sourceDatasetId).build(),
bigquery()
.buildDestinationTable("RegistrarAccountData")
.description(
"Synthetic view of registrar information "
+ "with currency-specific billing account id.")
.type(TableType.VIEW)
.build()));
}
/** Generates a view of registry data to feed into later views. */
private void makeRegistryView() throws Exception {
handleTableCreation(