Skip to content

Commit c19e20a

Browse files
committed
rename columns
1 parent e5cea81 commit c19e20a

File tree

14 files changed

+98
-98
lines changed

14 files changed

+98
-98
lines changed

.mondrian-schema.xml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@
105105
<Level name="Years" column="years" type="Integer" levelType="Regular" uniqueMembers="true"/>
106106
</Hierarchy>
107107
</Dimension>
108-
<Dimension name="Duration since first order" type="StandardDimension" description="The number of days from the first order of the customer to the placement of this order" foreignKey="duration_since_first_order_fk">
109-
<Hierarchy allMemberName="All duration since first orders" hasAll="true" name="By month">
108+
<Dimension name="Days since first order" type="StandardDimension" description="The number of days from the first order of the customer to the placement of this order" foreignKey="days_since_first_order_fk">
109+
<Hierarchy allMemberName="All days since first orders" hasAll="true" name="By month">
110110
<Table schema="time" name="duration"/>
111111
<Level name="Days" column="days" type="Integer" levelType="Regular" uniqueMembers="true"/>
112112
<Level name="Months" column="months" type="Integer" levelType="Regular" uniqueMembers="true"/>
113113
<Level name="Half years" column="half_years" type="Integer" levelType="Regular" uniqueMembers="true"/>
114114
<Level name="Years" column="years" type="Integer" levelType="Regular" uniqueMembers="true"/>
115115
</Hierarchy>
116-
<Hierarchy allMemberName="All duration since first orders" hasAll="true" name="By week">
116+
<Hierarchy allMemberName="All days since first orders" hasAll="true" name="By week">
117117
<Table schema="time" name="duration"/>
118118
<Level name="Days" column="days" type="Integer" levelType="Regular" uniqueMembers="true"/>
119119
<Level name="Weeks" column="weeks" type="Integer" levelType="Regular" uniqueMembers="true"/>
@@ -223,39 +223,39 @@
223223
</Dimension>
224224
<Measure name="# Orders (lifetime)" description="Number of orders with at-least one product fulfilled by this seller" column="_orders_lifetime_" aggregator="sum" formatString="Standard" datatype="Numeric"/>
225225
<Measure name="# Order items (lifetime)" description="Number of products sold by this seller" column="_order_items_lifetime_" aggregator="sum" formatString="Standard" datatype="Numeric"/>
226-
<Measure name="Lifetime Sales" description="The lifetime revenue generated from products sold by this seller" column="lifetime_sales" aggregator="sum" formatString="Standard" datatype="Numeric"/>
226+
<Measure name="Revenue (lifetime)" description="The lifetime revenue generated from products sold by this seller" column="revenue_lifetime_" aggregator="sum" formatString="Standard" datatype="Numeric"/>
227227
<CalculatedMember name="AOV" dimension="Measures" description="The average revenue per order. Attention: not meaningful when split by product">
228-
<Formula>[Measures].[Lifetime Sales] / [Measures].[# Orders (lifetime)]</Formula>
228+
<Formula>[Measures].[Revenue (lifetime)] / [Measures].[# Orders (lifetime)]</Formula>
229229
<CalculatedMemberProperty name="FORMAT_STRING" value="Standard"/>
230230
</CalculatedMember>
231231
</Cube>
232232
<Cube name="Customers" description="People that made at least one order" defaultMeasure="# Orders (lifetime)">
233233
<Table schema="mondrian" name="customers"/>
234-
<Dimension name="Duration since first order" type="StandardDimension" description="The number of days since the first order was placed" foreignKey="duration_since_first_order_fk">
235-
<Hierarchy allMemberName="All duration since first orders" hasAll="true" name="By month">
234+
<Dimension name="Days since first order" type="StandardDimension" description="The number of days since the first order was placed" foreignKey="days_since_first_order_fk">
235+
<Hierarchy allMemberName="All days since first orders" hasAll="true" name="By month">
236236
<Table schema="time" name="duration"/>
237237
<Level name="Days" column="days" type="Integer" levelType="Regular" uniqueMembers="true"/>
238238
<Level name="Months" column="months" type="Integer" levelType="Regular" uniqueMembers="true"/>
239239
<Level name="Half years" column="half_years" type="Integer" levelType="Regular" uniqueMembers="true"/>
240240
<Level name="Years" column="years" type="Integer" levelType="Regular" uniqueMembers="true"/>
241241
</Hierarchy>
242-
<Hierarchy allMemberName="All duration since first orders" hasAll="true" name="By week">
242+
<Hierarchy allMemberName="All days since first orders" hasAll="true" name="By week">
243243
<Table schema="time" name="duration"/>
244244
<Level name="Days" column="days" type="Integer" levelType="Regular" uniqueMembers="true"/>
245245
<Level name="Weeks" column="weeks" type="Integer" levelType="Regular" uniqueMembers="true"/>
246246
<Level name="Four weeks" column="four_weeks" type="Integer" levelType="Regular" uniqueMembers="true"/>
247247
<Level name="Years" column="years" type="Integer" levelType="Regular" uniqueMembers="true"/>
248248
</Hierarchy>
249249
</Dimension>
250-
<Dimension name="Duration since last order" type="StandardDimension" description="The number of days since the last order was placed" foreignKey="duration_since_last_order_fk">
251-
<Hierarchy allMemberName="All duration since last orders" hasAll="true" name="By month">
250+
<Dimension name="Days since last order" type="StandardDimension" description="The number of days since the last order was placed" foreignKey="days_since_last_order_fk">
251+
<Hierarchy allMemberName="All days since last orders" hasAll="true" name="By month">
252252
<Table schema="time" name="duration"/>
253253
<Level name="Days" column="days" type="Integer" levelType="Regular" uniqueMembers="true"/>
254254
<Level name="Months" column="months" type="Integer" levelType="Regular" uniqueMembers="true"/>
255255
<Level name="Half years" column="half_years" type="Integer" levelType="Regular" uniqueMembers="true"/>
256256
<Level name="Years" column="years" type="Integer" levelType="Regular" uniqueMembers="true"/>
257257
</Hierarchy>
258-
<Hierarchy allMemberName="All duration since last orders" hasAll="true" name="By week">
258+
<Hierarchy allMemberName="All days since last orders" hasAll="true" name="By week">
259259
<Table schema="time" name="duration"/>
260260
<Level name="Days" column="days" type="Integer" levelType="Regular" uniqueMembers="true"/>
261261
<Level name="Weeks" column="weeks" type="Integer" levelType="Regular" uniqueMembers="true"/>
@@ -429,15 +429,15 @@
429429
<Level name="Business type" column="business_type" uniqueMembers="true"/>
430430
</Hierarchy>
431431
</Dimension>
432-
<Dimension name="Duration to closing the deal" type="StandardDimension" description="The number of days it took from first contact with the lead to closing the deal by a Sales Representative and the lead becoming a seller" foreignKey="duration_to_closing_the_deal_fk">
433-
<Hierarchy allMemberName="All duration to closing the deals" hasAll="true" name="By month">
432+
<Dimension name="Days to closing the deal" type="StandardDimension" description="The number of days it took from first contact with the lead to closing the deal by a Sales Representative and the lead becoming a seller" foreignKey="days_to_closing_the_deal_fk">
433+
<Hierarchy allMemberName="All days to closing the deals" hasAll="true" name="By month">
434434
<Table schema="time" name="duration"/>
435435
<Level name="Days" column="days" type="Integer" levelType="Regular" uniqueMembers="true"/>
436436
<Level name="Months" column="months" type="Integer" levelType="Regular" uniqueMembers="true"/>
437437
<Level name="Half years" column="half_years" type="Integer" levelType="Regular" uniqueMembers="true"/>
438438
<Level name="Years" column="years" type="Integer" levelType="Regular" uniqueMembers="true"/>
439439
</Hierarchy>
440-
<Hierarchy allMemberName="All duration to closing the deals" hasAll="true" name="By week">
440+
<Hierarchy allMemberName="All days to closing the deals" hasAll="true" name="By week">
441441
<Table schema="time" name="duration"/>
442442
<Level name="Days" column="days" type="Integer" levelType="Regular" uniqueMembers="true"/>
443443
<Level name="Weeks" column="weeks" type="Integer" levelType="Regular" uniqueMembers="true"/>
@@ -479,9 +479,9 @@
479479
</Hierarchy>
480480
</Dimension>
481481
<Measure name="# Orders (lifetime)" description="Number of orders with at-least one product fulfilled by this seller" column="_orders_lifetime_" aggregator="sum" formatString="Standard" datatype="Numeric"/>
482-
<Measure name="Lifetime sales" description="The lifetime revenue generated from products sold by this seller" column="lifetime_sales" aggregator="sum" formatString="Standard" datatype="Numeric"/>
482+
<Measure name="Revenue (lifetime)" description="The lifetime revenue generated from products sold by this seller" column="revenue_lifetime_" aggregator="sum" formatString="Standard" datatype="Numeric"/>
483483
<CalculatedMember name="AOV" dimension="Measures" description="The average revenue per order. Attention: not meaningful when split by product">
484-
<Formula>[Measures].[Lifetime sales] / [Measures].[# Orders (lifetime)]</Formula>
484+
<Formula>[Measures].[Revenue (lifetime)] / [Measures].[# Orders (lifetime)]</Formula>
485485
<CalculatedMemberProperty name="FORMAT_STRING" value="Standard"/>
486486
</CalculatedMember>
487487
</Cube>

app/pipelines/consistency_checks/e_commerce.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ SELECT util.assert_equal(
1515

1616
SELECT util.assert_equal(
1717
'The number of distinct customer orders should be the same in customer and order dim tables',
18-
'SELECT sum(lifetime_number_of_orders) FROM ec_dim.customer',
18+
'SELECT sum(number_of_orders_lifetime) FROM ec_dim.customer',
1919
'SELECT count(distinct order_fk) FROM ec_dim.order_item');
2020

2121
SELECT util.assert_not_found(
@@ -25,13 +25,13 @@ SELECT util.assert_not_found(
2525
SELECT util.assert_almost_equal(
2626
'The total amount of lifetime revenue should be equal among customer and order-item dim tables',
2727
0.001,
28-
'SELECT sum(lifetime_revenue) FROM ec_dim.customer',
28+
'SELECT sum(revenue_lifetime) FROM ec_dim.customer',
2929
'SELECT sum(product_revenue)+sum(shipping_revenue) FROM ec_dim.order_item'
3030
);
3131

3232
SELECT util.assert_almost_equal(
3333
'The total amount of lifetime revenue should be equal among seller and order-item dim tables',
3434
0.001,
35-
'SELECT sum(lifetime_sales) FROM ec_dim.seller',
35+
'SELECT sum(revenue_lifetime) FROM ec_dim.seller',
3636
'SELECT sum(product_revenue)+sum(shipping_revenue) FROM ec_dim.order_item'
3737
);
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
SELECT util.assert_almost_equal(
22
'The total amount of lifetime revenue should be equal among seller and lead dim tables',
33
0.001,
4-
'SELECT sum(lifetime_sales) FROM m_dim.lead',
5-
'SELECT sum(seller.lifetime_sales) ' ||
4+
'SELECT sum(revenue_lifetime) FROM m_dim.lead',
5+
'SELECT sum(seller.revenue_lifetime) ' ||
66
'FROM ec_dim.seller ' ||
77
'INNER JOIN m_dim.lead ON seller_id = seller_fk'
88
);
99

1010
SELECT util.assert_almost_equal(
1111
'The total amount of lifetime revenue should be equal among order_item and lead dim tables',
1212
0.001,
13-
'SELECT sum(lifetime_sales) FROM m_dim.lead',
13+
'SELECT sum(revenue_lifetime) FROM m_dim.lead',
1414
'SELECT sum(order_item.product_revenue)+sum(order_item.shipping_revenue) ' ||
1515
'FROM ec_dim.order_item ' ||
1616
'INNER JOIN m_dim.lead USING (seller_fk)'
1717
);
1818

1919
SELECT util.assert_equal(
2020
'The total number orders should be equal among order_item and lead dim tables',
21-
'SELECT sum(lifetime_number_of_orders) FROM m_dim.lead',
22-
'SELECT sum(seller.lifetime_number_of_orders) ' ||
21+
'SELECT sum(number_of_orders_lifetime) FROM m_dim.lead',
22+
'SELECT sum(seller.number_of_orders_lifetime) ' ||
2323
'FROM ec_dim.seller ' ||
2424
'INNER JOIN m_dim.lead on seller.seller_id = lead.seller_fk'
2525
);

app/pipelines/e_commerce/transform_customer.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ CREATE TABLE ec_dim_next.customer
1010

1111
days_since_first_order INTEGER,
1212
days_since_last_order INTEGER,
13-
lifetime_number_of_orders INTEGER,
14-
lifetime_revenue DOUBLE PRECISION
13+
number_of_orders_lifetime INTEGER,
14+
revenue_lifetime DOUBLE PRECISION
1515
);
1616

1717
WITH customer_items AS (
1818
SELECT customer_id,
19-
count(DISTINCT order_id) AS lifetime_number_of_orders,
20-
sum(product_revenue) + sum(shipping_revenue) AS lifetime_revenue
19+
count(DISTINCT order_id) AS number_of_orders_lifetime,
20+
sum(product_revenue) + sum(shipping_revenue) AS revenue_lifetime
2121
FROM ec_tmp.order_item
2222
GROUP BY customer_id
2323
),
@@ -61,8 +61,8 @@ SELECT customer_id,
6161
favourite_product_category.favourite_product_category::ec_dim_next.PRODUCT_CATEGORY AS favourite_product_category,
6262
customer_orders.days_since_first_order AS days_since_first_order,
6363
customer_orders.days_since_last_order AS days_since_last_order,
64-
customer_items.lifetime_number_of_orders AS lifetime_number_of_orders,
65-
customer_items.lifetime_revenue AS lifetime_revenue
64+
customer_items.number_of_orders_lifetime AS number_of_orders_lifetime,
65+
customer_items.revenue_lifetime AS revenue_lifetime
6666

6767
FROM ec_tmp.customer
6868
LEFT JOIN customer_items USING (customer_id)

app/pipelines/e_commerce/transform_seller.sql

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ CREATE TABLE ec_dim_next.seller
66
zip_code_fk INTEGER NOT NULL, -- integer representation of a zip_code_prefix
77
first_order_fk TEXT,
88

9-
lifetime_number_of_orders INTEGER,
10-
lifetime_number_of_order_items INTEGER,
11-
lifetime_sales DOUBLE PRECISION
9+
number_of_orders_lifetime INTEGER,
10+
number_of_order_items_lifetime INTEGER,
11+
revenue_lifetime DOUBLE PRECISION
1212
);
1313

1414
WITH seller_items AS (
1515
SELECT seller_id,
16-
count(*) AS lifetime_number_of_order_items,
17-
count(DISTINCT order_item.order_id) AS lifetime_number_of_orders,
18-
sum(product_revenue) + sum(shipping_revenue) AS lifetime_sales
16+
count(*) AS number_of_order_items_lifetime,
17+
count(DISTINCT order_item.order_id) AS number_of_orders_lifetime,
18+
sum(product_revenue) + sum(shipping_revenue) AS revenue_lifetime
1919
FROM ec_tmp.order_item
2020
LEFT JOIN ec_tmp.order USING (order_id)
2121
GROUP BY seller_id
@@ -37,9 +37,9 @@ SELECT seller_id,
3737
seller_orders.first_order_id AS first_order_fk,
3838

3939

40-
seller_items.lifetime_number_of_orders AS lifetime_number_of_orders,
41-
seller_items.lifetime_number_of_order_items AS lifetime_number_of_order_items,
42-
seller_items.lifetime_sales AS lifetime_sales
40+
seller_items.number_of_orders_lifetime AS number_of_orders_lifetime,
41+
seller_items.number_of_order_items_lifetime AS number_of_order_items_lifetime,
42+
seller_items.revenue_lifetime AS revenue_lifetime
4343
FROM ec_tmp.seller
4444
LEFT JOIN seller_items USING (seller_id)
4545
LEFT JOIN seller_orders USING (seller_id);

app/pipelines/marketing/preprocess_lead.sql

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@
44
DROP TABLE IF EXISTS m_tmp.lead CASCADE;
55
CREATE TABLE m_tmp.lead
66
(
7-
lead_id TEXT NOT NULL, --Marketing Qualified Lead id
8-
seller_id TEXT, --Seller id
9-
sdr_id TEXT, --Sales Development Representative id
10-
sr_id TEXT, --Sales Representative
7+
lead_id TEXT NOT NULL, --Marketing Qualified Lead id
8+
seller_id TEXT, --Seller id
9+
sales_development_representative_id TEXT, --Sales Development Representative id
10+
sales_representative_id TEXT, --Sales Representative
1111

12-
deal_date TIMESTAMP WITH TIME ZONE, --Date the deal was closed.
13-
business_segment TEXT, --Lead business segment. Informed on contact.
14-
lead_type TEXT, --Lead type. Informed on contact.
15-
lead_behaviour_profile TEXT, --Lead behaviour profile. SDR identify it on contact
16-
average_stock TEXT, --Lead declared average stock. Informed on contact.
17-
business_type TEXT, --Type of business (reseller/manufacturer etc.)
12+
deal_date TIMESTAMP WITH TIME ZONE, --Date the deal was closed.
13+
business_segment TEXT, --Lead business segment. Informed on contact.
14+
lead_type TEXT, --Lead type. Informed on contact.
15+
lead_behaviour_profile TEXT, --Lead behaviour profile. SDR identify it on contact
16+
average_stock TEXT, --Lead declared average stock. Informed on contact.
17+
business_type TEXT, --Type of business (reseller/manufacturer etc.)
1818

19-
declared_product_catalog_size DOUBLE PRECISION, --Lead declared catalog size. Informed on contact.
20-
declared_monthly_revenue DOUBLE PRECISION, --Lead declared estimated monthly revenue. Informed on contact.
19+
declared_product_catalog_size DOUBLE PRECISION, --Lead declared catalog size. Informed on contact.
20+
declared_monthly_revenue DOUBLE PRECISION, --Lead declared estimated monthly revenue. Informed on contact.
2121

22-
first_contact_date TIMESTAMP WITH TIME ZONE NOT NULL, --Date of the first contact solicitation.
23-
landing_page_id TEXT NOT NULL, --Landing page id where the lead was acquired
24-
advertising_channel TEXT NOT NULL, --Type of media where the lead was acquired
25-
days_to_closing_deal INTEGER
22+
first_contact_date TIMESTAMP WITH TIME ZONE NOT NULL, --Date of the first contact solicitation.
23+
landing_page_id TEXT NOT NULL, --Landing page id where the lead was acquired
24+
advertising_channel TEXT NOT NULL, --Type of media where the lead was acquired
25+
days_to_closing_deal INTEGER
2626
);
2727

2828
INSERT INTO m_tmp.lead
2929
SELECT mql_id AS lead_id,
3030
seller_id,
31-
sdr_id,
32-
sr_id,
31+
sdr_id AS sales_development_representative_id,
32+
sr_id AS sales_representative_id,
3333

3434
won_date AS deal_date,
3535
business_segment AS business_segment,

0 commit comments

Comments
 (0)