Upgrade activity reporting queries to StandardSQL

This also brings the SQL template parameters in-line with the anticipated Bigquery dataset format, and switches from DateTime to the more appropriate LocalDate (since we only need monthly granularity).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162747692
This commit is contained in:
larryruili 2017-07-21 09:13:50 -07:00 committed by Ben McIlwain
parent 8a921f08ed
commit 33eb5f1c87
14 changed files with 160 additions and 171 deletions

View file

@ -14,20 +14,16 @@
-- Query for DNS metrics.
-- Our DNS provider exports logs for all queries received. However, these
-- tables only have a TTL of 7 days. We make daily exports of the data
-- relevant to us, which allows us to get the full month's UDP and TCP
-- queries when generating activity reports.
-- This is a no-op until after we transition to Google Cloud DNS, which
-- will likely export metrics via Stackdriver.
SELECT
-- DNS metrics apply to all tlds, which requires the 'null' magic value.
STRING(NULL) AS tld,
metricName,
-- TODO(b/63388735): Change this to actually query the DNS tables when ready.
-1 AS count,
FROM (
SELECT
'dns-udp-queries' AS metricName),
(
SELECT
'dns-tcp-queries' AS metricName)
-- TODO(b/63388735): Change this to actually query Google Cloud DNS when ready.
-1 AS count
FROM ((
SELECT 'dns-udp-queries' AS metricName)
UNION ALL
(SELECT 'dns-tcp-queries' AS metricName))