Skip to content

Commit

Permalink
Merge pull request #372 from bruin-data/add-new-template
Browse files Browse the repository at this point in the history
add new pipeline template
  • Loading branch information
terzioglub authored Jan 2, 2025
2 parents fc89281 + f9a889d commit 1810345
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 0 deletions.
35 changes: 35 additions & 0 deletions templates/duckdb-example/assets/product_categories.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* @bruin
name: product_categories
type: duckdb.sql
materialization:
type: table
columns:
- name: category_id
type: INTEGER
description: "Unique identifier for the product category"
primary_key: true
checks:
- name: not_null
- name: positive
- name: category_name
type: VARCHAR
description: "Name of the product category"
checks:
- name: not_null
- name: description
type: VARCHAR
description: "Description of the product category"
@bruin */

SELECT
1 AS category_id, 'Electronics' AS category_name, 'Devices like phones, laptops, and monitors' AS description
UNION ALL
SELECT
2 AS category_id, 'Accessories' AS category_name, 'Complementary items like headphones and chargers' AS description
UNION ALL
SELECT
3 AS category_id, 'Appliances' AS category_name, 'Household devices like refrigerators and microwaves' AS description
UNION ALL
SELECT
4 AS category_id, 'Furniture' AS category_name, 'Home and office furniture like desks and chairs' AS description;
45 changes: 45 additions & 0 deletions templates/duckdb-example/assets/product_price_summary.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* @bruin
name: product_price_summary
type: duckdb.sql
materialization:
type: table
depends:
- products
columns:
- name: price_range
type: VARCHAR
description: "Range of product prices"
- name: total_stock
type: INTEGER
description: "Total stock available in the price range"
checks:
- name: non_negative
- name: product_count
type: INTEGER
description: "Number of products in the price range"
checks:
- name: non_negative
@bruin */

WITH price_buckets AS (
SELECT
CASE
WHEN price < 200 THEN 'Below $200'
WHEN price BETWEEN 200 AND 500 THEN '$200 - $500'
WHEN price BETWEEN 501 AND 1000 THEN '$501 - $1000'
ELSE 'Above $1000'
END AS price_range,
stock
FROM products
)

SELECT
price_range,
SUM(stock) AS total_stock,
COUNT(*) AS product_count
FROM price_buckets
GROUP BY price_range
ORDER BY price_range;
36 changes: 36 additions & 0 deletions templates/duckdb-example/assets/products.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* @bruin
name: products
type: duckdb.sql
materialization:
type: table
columns:
- name: product_id
type: INTEGER
description: "Unique identifier for the product"
primary_key: true
- name: product_name
type: VARCHAR
description: "Name of the product"
- name: price
type: FLOAT
description: "Price of the product in USD"
checks:
- name: positive
- name: stock
type: INTEGER
description: "Number of units in stock"
@bruin */

SELECT
1 AS product_id, 'Laptop' AS product_name, 999.99 AS price, 10 AS stock
UNION ALL
SELECT
2 AS product_id, 'Smartphone' AS product_name, 699.99 AS price, 50 AS stock
UNION ALL
SELECT
3 AS product_id, 'Headphones' AS product_name, 199.99 AS price, 100 AS stock
UNION ALL
SELECT
4 AS product_id, 'Monitor' AS product_name, 299.99 AS price, 25 AS stock;
33 changes: 33 additions & 0 deletions templates/duckdb-example/assets/shipping_providers.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* @bruin
name: shipping_providers
type: duckdb.sql
materialization:
type: table
columns:
- name: provider_id
type: INTEGER
description: "Unique identifier for each shipping provider"
primary_key: true
- name: provider_name
type: VARCHAR
description: "Name of the fictional shipping provider"
- name: delivery_speed
type: VARCHAR
description: "Average delivery time (e.g., '2-day', 'Standard')"
- name: service_areas
type: VARCHAR
description: "Regions or countries where the provider operates"
@bruin */

SELECT
1 AS provider_id, 'SwiftCourier' AS provider_name, '2-day' AS delivery_speed, 'North America, Asia' AS service_areas
UNION ALL
SELECT
2 AS provider_id, 'GlobalFreight' AS provider_name, 'Standard' AS delivery_speed, 'Worldwide' AS service_areas
UNION ALL
SELECT
3 AS provider_id, 'BudgetShip' AS provider_name, 'Economy' AS delivery_speed, 'Europe, Africa' AS service_areas
UNION ALL
SELECT
4 AS provider_id, 'ApexLogistics' AS provider_name, 'Overnight' AS delivery_speed, 'North America' AS service_areas;
1 change: 1 addition & 0 deletions templates/duckdb-example/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: duckdb-example-pipeline

0 comments on commit 1810345

Please sign in to comment.