From 548ab6452c05f2a6c37d0fcd569e4d0382f896bb Mon Sep 17 00:00:00 2001 From: Doug Guthrie Date: Mon, 27 May 2024 11:23:05 -0600 Subject: [PATCH] Format query, add requiresMetricTime field --- dbtc/client/semantic_layer.py | 149 +++++++++++++++++----------------- docs/guide/semantic_layer.md | 2 +- 2 files changed, 76 insertions(+), 75 deletions(-) diff --git a/dbtc/client/semantic_layer.py b/dbtc/client/semantic_layer.py index 3d09ca0..62260ff 100644 --- a/dbtc/client/semantic_layer.py +++ b/dbtc/client/semantic_layer.py @@ -68,101 +68,102 @@ class _SemanticLayerClient(_Client): query GetMetrics($environmentId: BigInt!) { metrics(environmentId: $environmentId) { description + requiresMetricTime measures { - agg - aggTimeDimension - expr - name + agg + aggTimeDimension + expr + name } entities { - description - expr - name - role - type + description + expr + name + role + type } filter { - whereSqlTemplate + whereSqlTemplate } label name queryableGranularities type typeParams { - denominator { - alias - filter { - whereSqlTemplate + denominator { + alias + filter { + whereSqlTemplate + } + name + offsetToGrain + offsetWindow { + count + granularity + } } - name - offsetToGrain - offsetWindow { - count - granularity - } - } - expr - grainToDate - inputMeasures { - alias - filter { - whereSqlTemplate + expr + grainToDate + inputMeasures { + alias + filter { + whereSqlTemplate + } + name } - name - } - measure { - alias - filter { - whereSqlTemplate - } - name - } - metrics { - alias - filter { - whereSqlTemplate + measure { + alias + filter { + whereSqlTemplate + } + name } - name - offsetToGrain - offsetWindow { - count - granularity + metrics { + alias + filter { + whereSqlTemplate + } + name + offsetToGrain + offsetWindow { + count + granularity + } } - } - numerator { - alias - filter { - whereSqlTemplate + numerator { + alias + filter { + whereSqlTemplate + } + name + offsetToGrain + offsetWindow { + count + granularity + } } - name - offsetToGrain - offsetWindow { - count - granularity + window { + count + granularity } } - window { - count - granularity - } - } dimensions { - description - expr - isPartition - label - name - qualifiedName - queryableGranularities - type - typeParams { - timeGranularity - validityParams { - isEnd - isStart + description + expr + isPartition + label + name + qualifiedName + queryableGranularities + type + typeParams { + timeGranularity + validityParams { + isEnd + isStart + } } } - } } } """, diff --git a/docs/guide/semantic_layer.md b/docs/guide/semantic_layer.md index 8ed6a46..bebca1a 100644 --- a/docs/guide/semantic_layer.md +++ b/docs/guide/semantic_layer.md @@ -128,7 +128,7 @@ client = dbtCloudClient(environment_id=1, host="emea.dbt.com") Assuming that `client` is an instance of `dbtCloudClient` ```py query_result = client.sl.query( - metrics=["] + metrics=["total_revenue", "total_profit"], group_by=["customer__region"], )