Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] meta field not added to the metric #1365

Open
2 tasks done
saurabh0402 opened this issue Aug 5, 2024 · 3 comments
Open
2 tasks done

[Bug] meta field not added to the metric #1365

saurabh0402 opened this issue Aug 5, 2024 · 3 comments
Labels
bug Something isn't working triage Tasks that need to be triaged

Comments

@saurabh0402
Copy link
Contributor

Is this a new bug in metricflow?

  • I believe this is a new bug in metricflow
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

Scavaging through the documentation, we found two ways of adding metadata for metrics

  • This mentions that meta can be defined at the top-level with a metric. So, something like the following
    metrics:
    - name: new_customers
      type: SIMPLE
      type_params:
        measure: new_customers
      label: "New Customer"
      meta:
        feature: customers
  • This mentions that meta can be added inside the config object. So, something like the following
    metrics:
    - name: new_customers
      type: SIMPLE
      type_params:
        measure: new_customers
      label: "New Customer"
      config:
        meta:
          feature: customers

We tried both syntaxes. But when dbt compile is run, neither the semantic_manifest.json nor the output.json has the value added to the metadata field. As a result, running metricFlowEngine.list_metrics() also does not return any metadata.

Expected Behavior

The value should be added to the metadata field. So, the semantic_manifest.json should have the following.

{
      "name": "new_customers",
      ...
      "metadata": {
            "feature": "customers",
      },
      "label": "New Customer"
    }

And metricFlowEngine.list_metrics() should return the value in metadata field as well.

Steps To Reproduce

  1. Create a metric with the meta field
metrics:
- name: new_customers
  type: SIMPLE
  type_params:
    measure: new_customers
  label: "New Customer"
  meta:
    feature: customers
  1. Run dbt compile and then check the semantic_manifest.json or run metricFlowEngine.list_metrics().
  2. The output won't have any value in metadata field.

Relevant log output

No response

Environment

- OS: MacOS
- Python: 3.11.3
- dbt: 1.8.3
- metricflow: 0.7.1

Which database are you using?

snowflake

Additional Context

No response

@saurabh0402 saurabh0402 added bug Something isn't working triage Tasks that need to be triaged labels Aug 5, 2024
@saurabh0402
Copy link
Contributor Author

Hey @tlento, can you please check this one?
I can try picking this up if it's a bug. If not, please let me know how I can get the metadata field to work?

@tlento
Copy link
Contributor

tlento commented Aug 28, 2024

MetricFlow itself has no notion of a meta field, and as such it won't appear in the semantic_manifest.json. You can see that the protocol we use for metrics doesn't include it.

The metadata field you see in semantic_manifest.json is actually an internal construct for allowing us to produce pointers to locations in the user-defined semantic manifest configuration for where validation errors are discovered. I'm not fundamentally opposed to putting the dbt meta in there but I think it's probably better if we figure out a way to more cleanly separate user-land arbitrary key/value pairs from system-supplied entries. I'm pretty sure there was an issue open to support this, but it hasn't been a priority for us.

As for the dbt output, the dbt core parser should be taking the raw meta field parsed out of the YAML and passing it straight into the metric object it includes in the manifest, which should in turn be serialized inside of the manifest.json.

If this isn't happening that suggests a bug in the core parser.

@tlento
Copy link
Contributor

tlento commented Aug 28, 2024

I think your options are:

  1. Rely on the manifest.json output for the meta attributes you care about. If they aren't appearing that is a bug, and you should open an issue in dbt-core so we can get it fixed.
  2. Add user-meta to the metadata property in the dbt-semantic-interfaces protocols.
  3. Add a new property so we can differentiate between user-metadata and system-metadata, either by moving the system info to some other property or by just appending a user-metadata type property

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Tasks that need to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants