dbt-metricflow-sql 0.3.1__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. dbt_metricflow_sql-0.3.2/.gitignore +2 -0
  2. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/PKG-INFO +5 -3
  3. dbt_metricflow_sql-0.3.2/PYPI.md +5 -0
  4. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/README.md +48 -0
  5. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/pyproject.toml +7 -4
  6. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/src/dbt_metricflow_sql/docs.py +3 -3
  7. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/src/dbt_metricflow_sql/fragment.schema.json +13 -7
  8. dbt_metricflow_sql-0.3.2/src/dbt_metricflow_sql/legacy.py +1286 -0
  9. dbt_metricflow_sql-0.3.2/src/dbt_metricflow_sql/llms-full.txt +1939 -0
  10. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/src/dbt_metricflow_sql/plugin.py +21 -1
  11. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/src/dbt_metricflow_sql/semantics.py +84 -12
  12. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/uv.lock +5 -5
  13. dbt_metricflow_sql-0.3.1/.gitignore +0 -2
  14. dbt_metricflow_sql-0.3.1/PYPI.md +0 -5
  15. dbt_metricflow_sql-0.3.1/src/dbt_metricflow_sql/llms-full.txt +0 -1202
  16. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/LICENSE +0 -0
  17. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/src/dbt_metricflow_sql/__init__.py +0 -0
  18. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/src/dbt_metricflow_sql/cli.py +0 -0
  19. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/src/dbt_metricflow_sql/client.py +0 -0
  20. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/src/dbt_metricflow_sql/dependencies.py +0 -0
  21. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/src/dbt_metricflow_sql/server.py +0 -0
  22. {dbt_metricflow_sql-0.3.1 → dbt_metricflow_sql-0.3.2}/src/dbt_metricflow_sql/sl_config.py +0 -0
@@ -0,0 +1,2 @@
1
+ # The docs', written by `just bundle-docs`.
2
+ src/dbt_metricflow_sql/llms-full.txt
@@ -1,14 +1,16 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: dbt-metricflow-sql
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: dbt v1 plugin for MetricFlow
5
- Project-URL: Documentation, https://congenial-bassoon-7zkjv8w.pages.github.io/
5
+ Project-URL: Documentation, https://docs-internal-git-mfsql-dbt-labs.vercel.app/metricflow
6
6
  License-Expression: LicenseRef-Fivetran
7
7
  License-File: LICENSE
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Requires-Python: >=3.9
10
10
  Requires-Dist: dbt-core>=1.9
11
11
  Requires-Dist: jsonschema>=4.19
12
+ Provides-Extra: compat
13
+ Requires-Dist: sqlglot>=30.27; extra == 'compat'
12
14
  Provides-Extra: sidecar
13
15
  Requires-Dist: metricflow-sql-sidecar; extra == 'sidecar'
14
16
  Description-Content-Type: text/markdown
@@ -17,4 +19,4 @@ Description-Content-Type: text/markdown
17
19
 
18
20
  Something is cooking...
19
21
 
20
- [Documentation](https://congenial-bassoon-7zkjv8w.pages.github.io/), for design partners with access.
22
+ [Documentation](https://docs-internal-git-mfsql-dbt-labs.vercel.app/metricflow), for design partners, with the password we share with them.
@@ -0,0 +1,5 @@
1
+ # dbt-metricflow-sql
2
+
3
+ Something is cooking...
4
+
5
+ [Documentation](https://docs-internal-git-mfsql-dbt-labs.vercel.app/metricflow), for design partners, with the password we share with them.
@@ -191,6 +191,54 @@ warns of keys it doesn't know as custom ones; the plugin declares these to it.
191
191
  naming the redirect's host. That includes the upload's, e.g. S3's for a bucket in another
192
192
  region.
193
193
 
194
+ ## Legacy MetricFlow
195
+
196
+ To try MetricFlow on a project's legacy semantic models and metrics, without rewriting them, install
197
+ the plugin with its `compat` extra, and turn on legacy compatibility:
198
+
199
+ ```sh
200
+ pip install 'dbt-metricflow-sql[compat]'
201
+ ```
202
+
203
+ ```yaml
204
+ # dbt_project.yml
205
+ vars:
206
+ metricflow_legacy_compatibility: true
207
+ ```
208
+
209
+ Parse then converts the project's legacy semantics, as dbt writes them to
210
+ `semantic_manifest.json`, into one more fragment of the bundle, `legacy_semantic_manifest.json`,
211
+ next to the fragments of its MetricFlow semantics. Its objects are in the `legacy` namespace, so
212
+ they don't collide with the project's own, e.g. a semantic model `orders` is the dataset
213
+ `legacy.orders`, beside a MetricFlow dataset `orders`. Every metric is a metric of one
214
+ constellation, `legacy.metrics`:
215
+
216
+ ```sql
217
+ SELECT DATE_TRUNC('month', metric_time), customer.region, AGG(revenue)
218
+ FROM legacy.metrics
219
+ GROUP BY ALL
220
+ ```
221
+
222
+ - A semantic model is a dataset, and each measure one of its calculations, e.g. `msr_revenue`
223
+ of `SUM(amount)`.
224
+ - An entity is an entity of the semantic models that are its primary, unique or natural sources,
225
+ and a relationship from those that reference it, e.g. `customer`. A relationship is prefixed
226
+ only if its semantic model has a column of its name, e.g. `rel_customer_id`. A natural
227
+ entity's validity dimensions make it a slowly changing dimension, read as of each row's
228
+ aggregation time.
229
+ - A dimension is an attribute of its semantic model's primary entity, e.g. legacy's
230
+ `customer__region` is `customer.region`, and `listing__user__home_state` is
231
+ `listing.user.home_state`. A semantic model without its primary entity's key, e.g. a fact
232
+ table, has roles of its dimensions instead, e.g. `is_instant`.
233
+ - `metric_time` is each measure's aggregation time; a grain is `DATE_TRUNC`.
234
+ - Filters, cumulative metrics, offsets and non-additive dimensions become filtered aggregates,
235
+ window functions and `PER`s of the measures' calculations.
236
+
237
+ What can't be converted is left out, with a warning for each: conversion metrics, saved queries,
238
+ filters on metrics, custom granularities, `join_to_timespine`, and cumulative metrics of
239
+ aggregations a running window can't compute, e.g. `count_distinct`. Without a time spine,
240
+ periods without rows are left out of windows, e.g. a trailing 7 days.
241
+
194
242
  ## Setting up dbt Cloud
195
243
 
196
244
  Before the first publish, the dbt Cloud account needs its `experimental-semantic-layer` flag on,
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "dbt-metricflow-sql"
3
3
  # A placeholder: a release sets its tag's version, with scripts/set_version.py.
4
- version = "0.3.1"
4
+ version = "0.3.2"
5
5
  description = "dbt v1 plugin for MetricFlow"
6
6
  # Its PyPI page: README.md is for this repository.
7
7
  readme = "PYPI.md"
@@ -25,16 +25,19 @@ dbtsl = "dbt_metricflow_sql.cli:main"
25
25
  # The MetricFlow server it runs by default, which needs no Python of its own: only projects with
26
26
  # MetricFlow models run one.
27
27
  sidecar = ["metricflow-sql-sidecar"]
28
+ # Legacy compatibility, `metricflow_legacy_compatibility`, which writes the warehouse's SQL for
29
+ # legacy MetricFlow's aggregations, e.g. a percentile.
30
+ compat = ["sqlglot>=30.27"]
28
31
 
29
32
  [project.urls]
30
- Documentation = "https://congenial-bassoon-7zkjv8w.pages.github.io/"
33
+ Documentation = "https://docs-internal-git-mfsql-dbt-labs.vercel.app/metricflow"
31
34
 
32
35
  [build-system]
33
36
  requires = ["hatchling"]
34
37
  build-backend = "hatchling.build"
35
38
 
36
- # The docs site's `llms-full.txt`, for `dbtsl docs`, which `just bundle-docs` copies into the
37
- # package and git ignores. Both targets: `uv build` builds the wheel from the sdist.
39
+ # The docs' `llms-full.txt`, for `dbtsl docs`, which `just bundle-docs` writes into the package,
40
+ # from metricflow_sql/docs, and git ignores. Both targets: `uv build` builds the wheel from the sdist.
38
41
  [tool.hatch.build]
39
42
  artifacts = ["src/dbt_metricflow_sql/llms-full.txt"]
40
43
 
@@ -1,8 +1,8 @@
1
1
  """MetricFlow's docs, as the wheel ships them, for `dbtsl docs`: mostly for AI agents.
2
2
 
3
- The wheel ships the docs site's `llms-full.txt`, every page as Markdown, which the release build
4
- copies into the package with `just bundle-docs`; it isn't checked in. Each page starts with its
5
- title, as a `# ` heading, and has no other: its sections are `## ` and deeper.
3
+ The wheel ships the docs' `llms-full.txt`, every page as Markdown, which the release build writes
4
+ into the package, from metricflow_sql/docs, with `just bundle-docs`; it isn't checked in. Each
5
+ page starts with its title, as a `# ` heading, and has no other: its sections are `## ` and deeper.
6
6
  """
7
7
 
8
8
  from __future__ import annotations
@@ -884,7 +884,7 @@
884
884
  },
885
885
  "Page": {
886
886
  "additionalProperties": false,
887
- "description": "A markdown wiki page.\n\nLinks to other objects are markdown links with a reference as the URL, e.g.\n`[revenue](metric:sales:revenue)` or `[onboarding](page:guides/onboarding)`.",
887
+ "description": "A markdown wiki page, or with a glob `path`, one for each markdown file it matches.\n\n Links to other objects are markdown links with a reference as the URL, e.g.\n `[revenue](metric:sales:revenue)` or `[onboarding](page:guides/onboarding)`. A relative link\n to another page's markdown file, e.g. `[onboarding](guides/onboarding.md)`, becomes a\n reference to that page.\n\n A markdown file may start with YAML frontmatter setting the page's `name`, `label`,\n `description` and `meta`, e.g. `---\nlabel: Onboarding\n---`.",
888
888
  "properties": {
889
889
  "content": {
890
890
  "anyOf": [
@@ -925,8 +925,16 @@
925
925
  "type": "object"
926
926
  },
927
927
  "name": {
928
- "description": "The name, unique among its collection's.",
929
- "type": "string"
928
+ "anyOf": [
929
+ {
930
+ "type": "string"
931
+ },
932
+ {
933
+ "type": "null"
934
+ }
935
+ ],
936
+ "default": null,
937
+ "description": "The name, unique among its collection's. Required with `content`. With a file `path`, it defaults to its frontmatter's, else the file's name without `.md`, e.g. `onboarding` for `wiki/onboarding.md`."
930
938
  },
931
939
  "path": {
932
940
  "anyOf": [
@@ -938,12 +946,10 @@
938
946
  }
939
947
  ],
940
948
  "default": null,
941
- "description": "Path to a markdown file holding the page's content, relative to this fragment file within its bundle. Exclusive with `content`."
949
+ "description": "Path to a markdown file holding the page's content, relative to this fragment file within its bundle. Or a glob, as dbt's `path:` selector: a page for each `.md` file it matches, or that's under a directory it matches, e.g. `wiki` or `wiki/**/*.md`. Each is named by its path within the glob's directory, its leading names without wildcards, without `.md`, e.g. `guides/onboarding` for `wiki/guides/onboarding.md`, unless its frontmatter names it; then the page sets no `name`, `label` or `description`. Exclusive with `content`."
942
950
  }
943
951
  },
944
- "required": [
945
- "name"
946
- ],
952
+ "required": [],
947
953
  "title": "Page",
948
954
  "type": "object"
949
955
  },