30 | {/*
{data}
*/}
31 |
32 | Time series
33 |
34 |
35 | - return column named time (in UTC), as a unix time stamp or any sql native date data type. You can use the macros below.
36 |
37 | - any other columns returned will be the time point values.
38 |
39 | Optional:
40 |
41 | - return column named metric to represent the series name.
42 |
43 | - If multiple value columns are returned the metric column is used as prefix.
44 |
45 | - If no column named metric is found the column name of the value column is used as series name
46 |
47 |
48 | Resultsets of time series queries need to be sorted by time.
49 |
50 |
51 |
52 | Table:
53 |
54 | - return any set of columns
55 |
56 |
57 |
58 | Variables:
59 |
60 | - ${variable_name} - > in the dashboard's setting, you select 'Variables' and create a new one with the name `variable_name` (with values can be user-input or retrieved as a result of a CloudSQL Query), then you can reference to the selected value in the query using the above syntax: dollar sign, open curly brance, name and closing curly brace.
61 |
62 | NOTE: For string-value, put that into the double-quote, i.e. "${variable_name}"
63 |
64 |
65 |
66 | Macros:
67 |
68 | - $__source -> the datasource as provided in DataSource setting
69 |
70 | - $__source_test -> the fake time-series datasource, e.g. $__source_test(TS) or $__source_test(MTS)
71 |
72 | - $__dest[(format [,suffix])] -> the location to store data as provided in DataSource setting, e.g. $__dest, $__dest(), $__dest(csv), $__dest(CSV), $__dest(parquet, a/b/c)
73 |
74 | Example you want to save queried data to the TARGET_COS_URL with suffix 'a/b/c' in the format 'PARQUET:
75 |
76 | SELECT * FROM $__source INTO $__dest(parquet, a/b/c)
77 |
78 |
79 | - $__source_prev -> reference to the output from a previous query in the same dashboard/panel, e.g. $__source_prev(A)
80 |
81 | - $__timeFilter() -> time_column BETWEEN '2017-04-21T05:01:17Z' AND '2017-04-21T05:01:17Z'
82 | - $__timeFilterColumn(column-name, [type]) -> add time filter using the given column name (1st argument), and its type (2nd argument)
83 |
84 |
85 |
86 | Cloud SQL:
87 |
88 | DISTRIBUTE BY, SORT BY and CLUSTER BY only have an effect during your SQL query execution and do not influence the query result written back to Cloud Object Storage. Use these clauses only in execution of subqueries in order to optimize the outer query execution that works on the intermediate result sets produced by the sub queries.
89 |
90 |
91 |