根据 Looker 中的两个主键连接三个不同粒度的表
本质上,我有三个表:订单、订单产品和产品。在 Looker 中,您必须拥有主键才能执行任何类型的联接。
订单有一个订单 ID(唯一的主 ID),产品有产品 ID(唯一的主 ID),而订单产品则两者都有(重复的订单键,然后订单中的每个产品都有一个产品 ID)。我正在尝试在 Looker 中联接这三个表,并且尝试使用复合键(产品键 + 订单键来创建唯一标识符),但我无法联接这三个表,因为没有任何内容可以将订单链接到产品。
示例:
explore: business {
label: "order products"
view_label "order products
}
join: orders {
view_label: "Orders"
relationship: many to one
type: full_outer
sql_on: order_products.order_id = orders.order_id;;
join: products {
view_label: "Products"
relationship: many_to_one
type: full outer
sql_on: order_products.product_id = orders.product_id
这不起作用,我正在尝试将这三个加入。
有人对此有什么建议吗?
谢谢
Essentially, I have three tables: Orders, Order Products, and Products. In Looker, you have to have a primary key to be able to do any sort of joins.
Orders has an Order ID (unique primary), Products has Product ID (unique primary), while Order Products has both of them (Duplicate order keys, and then one product ID for each product in the order). I am trying to join these three tables in Looker, and I've attempted using a compound key (product key + order key to create a unique identifier) but I've been unable to join the three tables since there's nothing to link Orders to Products.
Example:
explore: business {
label: "order products"
view_label "order products
}
join: orders {
view_label: "Orders"
relationship: many to one
type: full_outer
sql_on: order_products.order_id = orders.order_id;;
join: products {
view_label: "Products"
relationship: many_to_one
type: full outer
sql_on: order_products.product_id = orders.product_id
This does not work, and I am trying to join the three.
Does anyone have any suggestions regarding this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的理解是,您正在尝试探索订单,所以我会这样做:
My understanding is that you are trying to explore the Orders so I would do this: