Skip to content
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

Feat/silver #9

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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