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

[Feature] Allow specifying an alias for each group-by and metric in the saved query #1560

Open
3 tasks done
siljamardla opened this issue Dec 6, 2024 · 0 comments
Open
3 tasks done
Labels
enhancement New feature or request triage Tasks that need to be triaged

Comments

@siljamardla
Copy link

Is this your first time submitting a feature request?

  • I have read the expectations for open source contributors
  • I have searched the existing issues, and I could not find an existing issue for this feature
  • I am requesting a straightforward extension of existing metricflow functionality, rather than a Big Idea better suited to a discussion

Describe the feature

If you have a saved query like this (from here):

saved_queries:
  - name: order_metrics
    description: Relevant order metrics
    query_params:
      metrics:
        - orders
        - large_order
        - food_orders
        - order_total
      group_by:
        - Entity('order_id')
        - TimeDimension('metric_time', 'day')
        - Dimension('customer__customer_name')
        - ... # Additional group_by
      where:
        - "{{TimeDimension('metric_time')}} > current_timestamp - interval '1 week'"
         - ... # Additional where clauses
    exports:
      - name: order_metrics
        config:
          export_as: table # Options available: table, view
          schema: YOUR_SCHEMA # Optional - defaults to deployment schema
          alias: SOME_TABLE_NAME # Optional - defaults to Export name

then your export table will have MetricFlow-specific column names, something like this:

order_id metric_time__day customer__customer_name orders large_order food_orders order_total

Since the person who writes the saved query and needs the export might now have full control over the naming conventions used in the semantic model, they may end up with badly named columns (from their perspective). Currently, they would be able to correct the columns by... maintaining a view on top of the export?

How about allowing to configure an alias for every metric and group by in the saved query? Something like this:

saved_queries:
  - name: order_metrics
    description: Relevant order metrics
    query_params:
      metrics:
        - orders
          alias: count_orders
        - large_order
          alias: count_large_orders
        - food_orders
        - order_total
      group_by:
        - Entity('order_id')
        - TimeDimension('metric_time', 'day')
          alias: calendar_date
        - Dimension('customer__customer_name')
          alias: customer_name
        - ... # Additional group_by
      where:
        - "{{TimeDimension('metric_time')}} > current_timestamp - interval '1 week'"
         - ... # Additional where clauses
    exports:
      - name: order_metrics
        config:
          export_as: table # Options available: table, view
          schema: YOUR_SCHEMA # Optional - defaults to deployment schema
          alias: SOME_TABLE_NAME # Optional - defaults to Export name

Describe alternatives you've considered

An independent view on top of the export?

Who will this benefit?

Anyone using saved queries

Are you interested in contributing this feature?

Happy to test it out in preview

Anything else?

No response

@siljamardla siljamardla added enhancement New feature or request triage Tasks that need to be triaged labels Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage Tasks that need to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant