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.
The Cube schema currently exposes
orders- andcustomers-grain measures in theorder_detailsview while also traversing theorders -> paymentsone_to_manyjoin.That means queries against
order_detailscan return inflated parent-grain measures whenever anypayments_*field is included, because orders with multiple payment rows get counted multiple times.Examples from the current schema:
orders.countorders.gift_countorders.avg_prioritycustomers.countcustomers.active_countWhy this is a problem:
order_detailsincludesorders.paymentsin the same view as those order/customer measures.Affected files:
dev-environment/cube/model/views/order_details.ymldev-environment/cube/model/cubes/orders.ymldev-environment/cube/model/cubes/customers.ymlSuggested fix:
order_details, orone_to_manyjoin for the intended view grain.Note:
grafana-playfor theplay.grafanaCube demo setup, so once fixed here they should be updated there as well.