Skip to content

Fix mixed-grain measures in Cube order_details view #197

@samjewell

Description

@samjewell

The Cube schema currently exposes orders- and customers-grain measures in the order_details view while also traversing the orders -> payments one_to_many join.

That means queries against order_details can return inflated parent-grain measures whenever any payments_* field is included, because orders with multiple payment rows get counted multiple times.

Examples from the current schema:

  • orders.count
  • orders.gift_count
  • orders.avg_priority
  • customers.count
  • customers.active_count

Why this is a problem:

  • order_details includes orders.payments in the same view as those order/customer measures.
  • Some orders have multiple payments, so the view becomes payment-grain as soon as a payments field participates in the query.
  • That makes the parent-grain measures payment-weighted rather than order- or customer-weighted.

Affected files:

  • dev-environment/cube/model/views/order_details.yml
  • dev-environment/cube/model/cubes/orders.yml
  • dev-environment/cube/model/cubes/customers.yml

Suggested fix:

  • Either remove the parent-grain measures from order_details, or
  • redefine them in a way that is safe across the one_to_many join for the intended view grain.

Note:

  • These same cube/view definitions are also being reused in grafana-play for the play.grafana Cube demo setup, so once fixed here they should be updated there as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions