-
Notifications
You must be signed in to change notification settings - Fork 211
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
refine ai pipelines #310
refine ai pipelines #310
Conversation
cyyeh
commented
May 23, 2024
•
edited
Loading
edited
- follow-up improvement
ceacff0
to
078bfb4
Compare
078bfb4
to
4d28294
Compare
"metrics": [ | ||
{ | ||
"name": "Revenue", | ||
"baseObject": "orders", | ||
"dimension": [ | ||
{ | ||
"name": "PurchaseTimestamp", | ||
"type": "TIMESTAMP" | ||
}, | ||
{ | ||
"name": "CustomerId", | ||
"type": "VARCHAR" | ||
}, | ||
{ | ||
"name": "Status", | ||
"type": "VARCHAR" | ||
}, | ||
{ | ||
"name": "Size", | ||
"type": "BIGINT" | ||
}, | ||
{ | ||
"name": "IsReviewed", | ||
"type": "BOOLEAN" | ||
} | ||
], | ||
"measure": [ | ||
{ | ||
"name": "Price", | ||
"type": "DOUBLE", | ||
"expression": "sum(order_items.Price)" | ||
}, | ||
{ | ||
"name": "MoM_Price", | ||
"type": "DOUBLE", | ||
"expression": "sum(order_items.Price) - COALESCE(LAG(sum(order_items.Price)) OVER (ORDER BY date_trunc('MONTH', PurchaseTimestamp)), 0) / COALESCE(LAG(sum(order_items.Price)) OVER (ORDER BY date_trunc('MONTH', PurchaseTimestamp)), 1)" | ||
}, | ||
{ | ||
"name": "NumberOfOrders", | ||
"type": "BIGINT", | ||
"expression": "count(OrderId)" | ||
}, | ||
{ | ||
"name": "Peak", | ||
"type": "DOUBLE", | ||
"expression": "max(TotalValue)" | ||
} | ||
], | ||
"timeGrain": [ | ||
{ | ||
"name": "PurchaseTimestamp", | ||
"refColumn": "PurchaseTimestamp", | ||
"dateParts": [ | ||
"YEAR", | ||
"MONTH", | ||
"DAY" | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"metrics": [], | ||
"cumulativeMetrics": [], | ||
"views": [ | ||
{ | ||
"name": "total_items_view", | ||
"statement": "WITH customer_order_items AS (SELECT c.State, oi.ItemNumber FROM customers c JOIN orders o ON c.Id = o.CustomerId JOIN order_items oi ON o.OrderId = oi.OrderId) SELECT State, COUNT(ItemNumber) AS Total_Items_Purchased FROM customer_order_items GROUP BY State", | ||
"properties": { | ||
"question": "How many items have been purchased in orders placed by customers in each state?", | ||
"summary": "The query counts the total number of items purchased by customers in each state.", | ||
"viewId": "20b69c05-e9a3-4c4d-a421-06ba7e7a385a" | ||
} | ||
} | ||
], | ||
"macros": [ | ||
{ | ||
"name": "MoM", | ||
"definition": "(calculation: Expression, timestamp: Expression) => ({{ calculation }} - COALESCE(LAG({{ calculation }}) OVER (ORDER BY {{ timestamp }}), 0)) / COALESCE(LAG({{ calculation }}) OVER (ORDER BY {{ timestamp }}), 1)" | ||
} | ||
], | ||
"views": [], | ||
"macros": [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curiously, why remove them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after an offline discussion with @cyyeh, we will keep the MDL file the same as the sample dataset, and add another MDL file with the views and other items section.