Skip to content

Commit

Permalink
Merge pull request #9 from TeoMeWhy/feat/silver
Browse files Browse the repository at this point in the history
Feat/silver
  • Loading branch information
TeoCalvo authored Jul 15, 2024
2 parents 2d532fd + 3d7e85b commit 264b4a5
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/silver/cliente.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SELECT
idCustomer AS idCliente,
PointsCustomer AS nrPontosCliente,
flEmail AS flEmailCliente

FROM bronze.upsell.customers
15 changes: 15 additions & 0 deletions src/silver/ingestao.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Databricks notebook source
def import_query(path):
with open(path, "r") as open_file:
return open_file.read()

tablename = dbutils.widgets.get("tablename")

query = import_query(f"{tablename}.sql")

(spark.sql(query)
.write
.format("delta")
.mode("overwrite")
.option("overwriteSchema", "true")
.saveAsTable(f"silver.upsell.{tablename}"))
3 changes: 3 additions & 0 deletions src/silver/produtos.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT DISTINCT NameProduct
FROM bronze.upsell.transactions_product
ORDER BY 1
7 changes: 7 additions & 0 deletions src/silver/transacao_produto.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SELECT
idTransactionCart AS idTransacaoProduto,
idTransaction AS idTransacao,
NameProduct AS descNomeProduto,
QuantityProduct AS nrQuantidadeProduto

FROM bronze.upsell.transactions_product
6 changes: 6 additions & 0 deletions src/silver/transacoes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SELECT idTransaction AS idTransacao,
idCustomer AS idCliente,
dtTransaction AS dtTransacao,
pointsTransaction AS nrPontosTransacao

FROM bronze.upsell.transactions
84 changes: 80 additions & 4 deletions src/workflows/upsell.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"quartz_cron_expression": "00 00 7 * * ?",
"timezone_id": "America/Sao_Paulo",
"pause_status": "UNPAUSED"
},
},
"max_concurrent_runs": 1,
"tasks": [
{
Expand All @@ -26,7 +26,7 @@
},
"source": "GIT"
},
"existing_cluster_id": "0809-155233-nc569ju7",
"existing_cluster_id": "0704-112023-u2kusxyv",
"timeout_seconds": 0,
"email_notifications": {},
"notification_settings": {
Expand All @@ -48,7 +48,7 @@
},
"source": "GIT"
},
"existing_cluster_id": "0809-155233-nc569ju7",
"existing_cluster_id": "0704-112023-u2kusxyv",
"timeout_seconds": 0,
"email_notifications": {},
"notification_settings": {
Expand All @@ -70,7 +70,7 @@
},
"source": "GIT"
},
"existing_cluster_id": "0809-155233-nc569ju7",
"existing_cluster_id": "0704-112023-u2kusxyv",
"timeout_seconds": 0,
"email_notifications": {},
"notification_settings": {
Expand All @@ -79,6 +79,82 @@
"alert_on_last_attempt": false
},
"webhook_notifications": {}
},
{
"task_key": "silver_cliente",
"depends_on": [
{
"task_key": "bronze_customers"
}
],
"run_if": "ALL_SUCCESS",
"notebook_task": {
"notebook_path": "src/silver/ingestao",
"base_parameters": {
"tablename": "cliente"
},
"source": "GIT"
},
"existing_cluster_id": "0704-112023-u2kusxyv",
"timeout_seconds": 0,
"email_notifications": {}
},
{
"task_key": "silver_produtos",
"depends_on": [
{
"task_key": "bronze_transactions_product"
}
],
"run_if": "ALL_SUCCESS",
"notebook_task": {
"notebook_path": "src/silver/ingestao",
"base_parameters": {
"tablename": "produtos"
},
"source": "GIT"
},
"existing_cluster_id": "0704-112023-u2kusxyv",
"timeout_seconds": 0,
"email_notifications": {}
},
{
"task_key": "silver_transacao_produto",
"depends_on": [
{
"task_key": "bronze_transactions_product"
}
],
"run_if": "ALL_SUCCESS",
"notebook_task": {
"notebook_path": "src/silver/ingestao",
"base_parameters": {
"tablename": "transacao_produto"
},
"source": "GIT"
},
"existing_cluster_id": "0704-112023-u2kusxyv",
"timeout_seconds": 0,
"email_notifications": {}
},
{
"task_key": "silver_transacoes",
"depends_on": [
{
"task_key": "bronze_transactions"
}
],
"run_if": "ALL_SUCCESS",
"notebook_task": {
"notebook_path": "src/silver/ingestao",
"base_parameters": {
"tablename": "transacoes"
},
"source": "GIT"
},
"existing_cluster_id": "0704-112023-u2kusxyv",
"timeout_seconds": 0,
"email_notifications": {}
}
],
"git_source": {
Expand Down

0 comments on commit 264b4a5

Please sign in to comment.