|
| 1 | +test_name: test_explain_all_saved_queries_from_external_manifest |
| 2 | +test_filename: test_external_manifest.py |
| 3 | +docstring: |
| 4 | + Test generated SQL for all saved queries in a JSON-serialized manifest. |
| 5 | +--- |
| 6 | +query_0b295dd4: |
| 7 | + status: PASS |
| 8 | + explain_sql: |
| 9 | + -- Constrain Output with WHERE |
| 10 | + -- Pass Only Elements: ['__bookings', '__instant_bookings', 'listing__capacity_latest', 'metric_time__day'] |
| 11 | + -- Aggregate Inputs for Simple Metrics |
| 12 | + -- Compute Metrics via Expressions |
| 13 | + -- Write to DataTable |
| 14 | + SELECT |
| 15 | + metric_time__day |
| 16 | + , listing__capacity_latest |
| 17 | + , SUM(bookings) AS bookings |
| 18 | + , SUM(instant_bookings) AS instant_bookings |
| 19 | + FROM ( |
| 20 | + -- Join Standard Outputs |
| 21 | + -- Pass Only Elements: ['__bookings', '__instant_bookings', 'listing__capacity_latest', 'metric_time__day'] |
| 22 | + SELECT |
| 23 | + subq_1.metric_time__day AS metric_time__day |
| 24 | + , subq_4.capacity_latest AS listing__capacity_latest |
| 25 | + , subq_1.__bookings AS bookings |
| 26 | + , subq_1.__instant_bookings AS instant_bookings |
| 27 | + FROM ( |
| 28 | + -- Read Elements From Semantic Model 'bookings_source' |
| 29 | + -- Metric Time Dimension 'ds' |
| 30 | + SELECT |
| 31 | + DATE_TRUNC('day', CAST('2020-01-01' AS TIMESTAMP)) AS metric_time__day |
| 32 | + , 1 AS listing |
| 33 | + , 1 AS __bookings |
| 34 | + , 1 AS __instant_bookings |
| 35 | + FROM simple_semantic_manifest.dummy_table bookings_source_src_10000 |
| 36 | + ) subq_1 |
| 37 | + LEFT OUTER JOIN ( |
| 38 | + -- Read Elements From Semantic Model 'listings_latest' |
| 39 | + -- Metric Time Dimension 'ds' |
| 40 | + -- Pass Only Elements: ['capacity_latest', 'listing'] |
| 41 | + SELECT |
| 42 | + 1 AS listing |
| 43 | + , '1' AS capacity_latest |
| 44 | + FROM simple_semantic_manifest.dummy_table listings_latest_src_10000 |
| 45 | + ) subq_4 |
| 46 | + ON |
| 47 | + subq_1.listing = subq_4.listing |
| 48 | + ) subq_6 |
| 49 | + WHERE (listing__capacity_latest IS NOT NULL) |
| 50 | + GROUP BY |
| 51 | + metric_time__day |
| 52 | + , listing__capacity_latest |
| 53 | + |
| 54 | +query_1ee34d0e: |
| 55 | + status: PASS |
| 56 | + explain_sql: |
| 57 | + -- Combine Aggregated Outputs |
| 58 | + -- Write to DataTable |
| 59 | + WITH cm_3_cte AS ( |
| 60 | + -- Constrain Output with WHERE |
| 61 | + -- Pass Only Elements: ['__bookings', 'listing__capacity_latest'] |
| 62 | + -- Aggregate Inputs for Simple Metrics |
| 63 | + -- Compute Metrics via Expressions |
| 64 | + SELECT |
| 65 | + listing__capacity_latest |
| 66 | + , SUM(bookings) AS bookings |
| 67 | + FROM ( |
| 68 | + -- Join Standard Outputs |
| 69 | + -- Pass Only Elements: ['__bookings', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] |
| 70 | + SELECT |
| 71 | + subq_1.metric_time__day AS metric_time__day |
| 72 | + , subq_4.is_lux_latest AS listing__is_lux_latest |
| 73 | + , subq_4.capacity_latest AS listing__capacity_latest |
| 74 | + , subq_1.__bookings AS bookings |
| 75 | + FROM ( |
| 76 | + -- Read Elements From Semantic Model 'bookings_source' |
| 77 | + -- Metric Time Dimension 'ds' |
| 78 | + SELECT |
| 79 | + DATE_TRUNC('day', CAST('2020-01-01' AS TIMESTAMP)) AS metric_time__day |
| 80 | + , 1 AS listing |
| 81 | + , 1 AS __bookings |
| 82 | + FROM simple_semantic_manifest.dummy_table bookings_source_src_10000 |
| 83 | + ) subq_1 |
| 84 | + LEFT OUTER JOIN ( |
| 85 | + -- Read Elements From Semantic Model 'listings_latest' |
| 86 | + -- Metric Time Dimension 'ds' |
| 87 | + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing'] |
| 88 | + SELECT |
| 89 | + 1 AS listing |
| 90 | + , '1' AS is_lux_latest |
| 91 | + , '1' AS capacity_latest |
| 92 | + FROM simple_semantic_manifest.dummy_table listings_latest_src_10000 |
| 93 | + ) subq_4 |
| 94 | + ON |
| 95 | + subq_1.listing = subq_4.listing |
| 96 | + ) subq_6 |
| 97 | + WHERE ((listing__is_lux_latest IS NOT NULL)) AND ((metric_time__day IS NOT NULL)) |
| 98 | + GROUP BY |
| 99 | + listing__capacity_latest |
| 100 | + ) |
| 101 | + |
| 102 | + , cm_4_cte AS ( |
| 103 | + -- Constrain Output with WHERE |
| 104 | + -- Pass Only Elements: ['__views', 'listing__capacity_latest'] |
| 105 | + -- Aggregate Inputs for Simple Metrics |
| 106 | + -- Compute Metrics via Expressions |
| 107 | + SELECT |
| 108 | + listing__capacity_latest |
| 109 | + , SUM(views) AS views |
| 110 | + FROM ( |
| 111 | + -- Join Standard Outputs |
| 112 | + -- Pass Only Elements: ['__views', 'listing__capacity_latest', 'listing__is_lux_latest', 'metric_time__day'] |
| 113 | + SELECT |
| 114 | + subq_12.metric_time__day AS metric_time__day |
| 115 | + , subq_14.is_lux_latest AS listing__is_lux_latest |
| 116 | + , subq_14.capacity_latest AS listing__capacity_latest |
| 117 | + , subq_12.__views AS views |
| 118 | + FROM ( |
| 119 | + -- Read Elements From Semantic Model 'views_source' |
| 120 | + -- Metric Time Dimension 'ds' |
| 121 | + SELECT |
| 122 | + DATE_TRUNC('day', CAST('2020-01-01' AS TIMESTAMP)) AS metric_time__day |
| 123 | + , 1 AS listing |
| 124 | + , 1 AS __views |
| 125 | + FROM simple_semantic_manifest.dummy_table views_source_src_10000 |
| 126 | + ) subq_12 |
| 127 | + LEFT OUTER JOIN ( |
| 128 | + -- Read Elements From Semantic Model 'listings_latest' |
| 129 | + -- Metric Time Dimension 'ds' |
| 130 | + -- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing'] |
| 131 | + SELECT |
| 132 | + 1 AS listing |
| 133 | + , '1' AS is_lux_latest |
| 134 | + , '1' AS capacity_latest |
| 135 | + FROM simple_semantic_manifest.dummy_table listings_latest_src_10000 |
| 136 | + ) subq_14 |
| 137 | + ON |
| 138 | + subq_12.listing = subq_14.listing |
| 139 | + ) subq_16 |
| 140 | + WHERE ((listing__is_lux_latest IS NOT NULL)) AND ((metric_time__day IS NOT NULL)) |
| 141 | + GROUP BY |
| 142 | + listing__capacity_latest |
| 143 | + ) |
| 144 | + |
| 145 | + SELECT |
| 146 | + COALESCE(cm_3_cte.listing__capacity_latest, cm_4_cte.listing__capacity_latest, subq_23.listing__capacity_latest) AS listing__capacity_latest |
| 147 | + , MAX(cm_3_cte.bookings) AS bookings |
| 148 | + , MAX(cm_4_cte.views) AS views |
| 149 | + , MAX(CAST(subq_23.bookings AS DOUBLE) / CAST(NULLIF(subq_23.views, 0) AS DOUBLE)) AS bookings_per_view |
| 150 | + FROM cm_3_cte |
| 151 | + FULL OUTER JOIN |
| 152 | + cm_4_cte |
| 153 | + ON |
| 154 | + cm_3_cte.listing__capacity_latest = cm_4_cte.listing__capacity_latest |
| 155 | + FULL OUTER JOIN ( |
| 156 | + -- Combine Aggregated Outputs |
| 157 | + SELECT |
| 158 | + COALESCE(cm_3_cte.listing__capacity_latest, cm_4_cte.listing__capacity_latest) AS listing__capacity_latest |
| 159 | + , MAX(cm_3_cte.bookings) AS bookings |
| 160 | + , MAX(cm_4_cte.views) AS views |
| 161 | + FROM cm_3_cte |
| 162 | + FULL OUTER JOIN |
| 163 | + cm_4_cte |
| 164 | + ON |
| 165 | + cm_3_cte.listing__capacity_latest = cm_4_cte.listing__capacity_latest |
| 166 | + GROUP BY |
| 167 | + COALESCE(cm_3_cte.listing__capacity_latest, cm_4_cte.listing__capacity_latest) |
| 168 | + ) subq_23 |
| 169 | + ON |
| 170 | + COALESCE(cm_3_cte.listing__capacity_latest, cm_4_cte.listing__capacity_latest) = subq_23.listing__capacity_latest |
| 171 | + GROUP BY |
| 172 | + COALESCE(cm_3_cte.listing__capacity_latest, cm_4_cte.listing__capacity_latest, subq_23.listing__capacity_latest) |
| 173 | + |
| 174 | +query_25c402a1: |
| 175 | + status: PASS |
| 176 | + explain_sql: |
| 177 | + -- Combine Aggregated Outputs |
| 178 | + -- Order By ['metric_time__day', 'listing__capacity_latest', 'bookings', 'views'] Limit 10 |
| 179 | + -- Write to DataTable |
| 180 | + WITH sma_10014_cte AS ( |
| 181 | + -- Read Elements From Semantic Model 'listings_latest' |
| 182 | + -- Metric Time Dimension 'ds' |
| 183 | + SELECT |
| 184 | + 1 AS listing |
| 185 | + , '1' AS capacity_latest |
| 186 | + FROM simple_semantic_manifest.dummy_table listings_latest_src_10000 |
| 187 | + ) |
| 188 | + |
| 189 | + SELECT |
| 190 | + COALESCE(subq_9.metric_time__day, subq_18.metric_time__day) AS metric_time__day |
| 191 | + , COALESCE(subq_9.listing__capacity_latest, subq_18.listing__capacity_latest) AS listing__capacity_latest |
| 192 | + , MAX(subq_9.bookings) AS bookings |
| 193 | + , MAX(subq_18.views) AS views |
| 194 | + FROM ( |
| 195 | + -- Join Standard Outputs |
| 196 | + -- Pass Only Elements: ['__bookings', 'listing__capacity_latest', 'metric_time__day'] |
| 197 | + -- Pass Only Elements: ['__bookings', 'listing__capacity_latest', 'metric_time__day'] |
| 198 | + -- Aggregate Inputs for Simple Metrics |
| 199 | + -- Compute Metrics via Expressions |
| 200 | + SELECT |
| 201 | + subq_1.metric_time__day AS metric_time__day |
| 202 | + , sma_10014_cte.capacity_latest AS listing__capacity_latest |
| 203 | + , SUM(subq_1.__bookings) AS bookings |
| 204 | + FROM ( |
| 205 | + -- Read Elements From Semantic Model 'bookings_source' |
| 206 | + -- Metric Time Dimension 'ds' |
| 207 | + SELECT |
| 208 | + DATE_TRUNC('day', CAST('2020-01-01' AS TIMESTAMP)) AS metric_time__day |
| 209 | + , 1 AS listing |
| 210 | + , 1 AS __bookings |
| 211 | + FROM simple_semantic_manifest.dummy_table bookings_source_src_10000 |
| 212 | + ) subq_1 |
| 213 | + LEFT OUTER JOIN |
| 214 | + sma_10014_cte |
| 215 | + ON |
| 216 | + subq_1.listing = sma_10014_cte.listing |
| 217 | + GROUP BY |
| 218 | + subq_1.metric_time__day |
| 219 | + , sma_10014_cte.capacity_latest |
| 220 | + ) subq_9 |
| 221 | + FULL OUTER JOIN ( |
| 222 | + -- Join Standard Outputs |
| 223 | + -- Pass Only Elements: ['__views', 'listing__capacity_latest', 'metric_time__day'] |
| 224 | + -- Pass Only Elements: ['__views', 'listing__capacity_latest', 'metric_time__day'] |
| 225 | + -- Aggregate Inputs for Simple Metrics |
| 226 | + -- Compute Metrics via Expressions |
| 227 | + SELECT |
| 228 | + subq_11.metric_time__day AS metric_time__day |
| 229 | + , sma_10014_cte.capacity_latest AS listing__capacity_latest |
| 230 | + , SUM(subq_11.__views) AS views |
| 231 | + FROM ( |
| 232 | + -- Read Elements From Semantic Model 'views_source' |
| 233 | + -- Metric Time Dimension 'ds' |
| 234 | + SELECT |
| 235 | + DATE_TRUNC('day', CAST('2020-01-01' AS TIMESTAMP)) AS metric_time__day |
| 236 | + , 1 AS listing |
| 237 | + , 1 AS __views |
| 238 | + FROM simple_semantic_manifest.dummy_table views_source_src_10000 |
| 239 | + ) subq_11 |
| 240 | + LEFT OUTER JOIN |
| 241 | + sma_10014_cte |
| 242 | + ON |
| 243 | + subq_11.listing = sma_10014_cte.listing |
| 244 | + GROUP BY |
| 245 | + subq_11.metric_time__day |
| 246 | + , sma_10014_cte.capacity_latest |
| 247 | + ) subq_18 |
| 248 | + ON |
| 249 | + ( |
| 250 | + subq_9.listing__capacity_latest = subq_18.listing__capacity_latest |
| 251 | + ) AND ( |
| 252 | + subq_9.metric_time__day = subq_18.metric_time__day |
| 253 | + ) |
| 254 | + GROUP BY |
| 255 | + COALESCE(subq_9.metric_time__day, subq_18.metric_time__day) |
| 256 | + , COALESCE(subq_9.listing__capacity_latest, subq_18.listing__capacity_latest) |
| 257 | + ORDER BY metric_time__day DESC, listing__capacity_latest, bookings DESC, views |
| 258 | + LIMIT 10 |
| 259 | + |
| 260 | +query_788497ac: |
| 261 | + status: PASS |
| 262 | + explain_sql: |
| 263 | + -- Join Self Over Time Range |
| 264 | + -- Pass Only Elements: ['__revenue', 'metric_time__day'] |
| 265 | + -- Pass Only Elements: ['__revenue', 'metric_time__day'] |
| 266 | + -- Aggregate Inputs for Simple Metrics |
| 267 | + -- Compute Metrics via Expressions |
| 268 | + -- Compute Metrics via Expressions |
| 269 | + -- Write to DataTable |
| 270 | + SELECT |
| 271 | + subq_3.ds AS metric_time__day |
| 272 | + , SUM(subq_1.__revenue) AS trailing_2_months_revenue |
| 273 | + FROM simple_semantic_manifest.time_spine subq_3 |
| 274 | + INNER JOIN ( |
| 275 | + -- Read Elements From Semantic Model 'revenue' |
| 276 | + -- Metric Time Dimension 'ds' |
| 277 | + SELECT |
| 278 | + DATE_TRUNC('day', CAST('2020-01-01' AS TIMESTAMP)) AS metric_time__day |
| 279 | + , 1 AS __revenue |
| 280 | + FROM simple_semantic_manifest.dummy_table revenue_src_10000 |
| 281 | + ) subq_1 |
| 282 | + ON |
| 283 | + ( |
| 284 | + subq_1.metric_time__day <= subq_3.ds |
| 285 | + ) AND ( |
| 286 | + subq_1.metric_time__day > subq_3.ds - INTERVAL 2 month |
| 287 | + ) |
| 288 | + GROUP BY |
| 289 | + subq_3.ds |
| 290 | + |
| 291 | +query_d4073379: |
| 292 | + status: PASS |
| 293 | + explain_sql: |
| 294 | + -- Join Standard Outputs |
| 295 | + -- Pass Only Elements: ['listing__capacity_latest', 'metric_time__month'] |
| 296 | + -- Pass Only Elements: ['listing__capacity_latest', 'metric_time__month'] |
| 297 | + -- Write to DataTable |
| 298 | + SELECT |
| 299 | + DATE_TRUNC('month', time_spine_src_10006.ds) AS metric_time__month |
| 300 | + , subq_0.listing__capacity_latest AS listing__capacity_latest |
| 301 | + FROM ( |
| 302 | + -- Read Elements From Semantic Model 'listings_latest' |
| 303 | + SELECT |
| 304 | + '1' AS listing__capacity_latest |
| 305 | + FROM simple_semantic_manifest.dummy_table listings_latest_src_10000 |
| 306 | + ) subq_0 |
| 307 | + CROSS JOIN |
| 308 | + simple_semantic_manifest.time_spine time_spine_src_10006 |
| 309 | + GROUP BY |
| 310 | + DATE_TRUNC('month', time_spine_src_10006.ds) |
| 311 | + , subq_0.listing__capacity_latest |
0 commit comments