dbt
Fintech payments
Events
Events model for fintech payments.
inferred
Blocks
events.sql · 50 lines
inferred
-- models/events.sql
{{ config(materialized='view') }}
WITH transaction_events AS (
SELECT pk
, customer_fk
, merchant_fk
, payment_method_fk
, created_at
, 'Credit' AS type
, amount_authorized
, amount_submitted_for_settlement
, authorization_acquired
, credit_card_details_type
FROM generic_looker_test.transactions AS t
UNION ALL
SELECT pk
, customer_fk
, merchant_fk
, payment_method_fk
, created_at
, 'Sale' AS type
, amount_authorized
, amount_submitted_for_settlement
, authorization_acquired
, credit_card_details_type
FROM generic_looker_test.transactions AS tt
)
SELECT *
, DENSE_RANK() OVER(PARTITION BY customer_fk ORDER BY created_at) AS customer_sequence
, DENSE_RANK() OVER(PARTITION BY merchant_fk ORDER BY created_at) AS merchant_sequence
FROM transaction_events
# models/schema.yml
version: 2
models:
- name: events
columns:
- name: pk
- name: customer_fk
- name: merchant_fk
- name: payment_method_fk
- name: customer_transaction_sequence
- name: merchant_transaction_sequence
- name: type
- name: amount_authorized
- name: amount_submitted_for_settlement
- name: authorization_acquired
- name: credit_card_details_type
Assumptions
- materialized='view' is the default; no persist hint found.
- schema.yml columns come from view dimensions; a primary_key dimension gets unique + not_null tests.
events.sql · 29 lines
source-preserved
validation: parses
WITH transaction_events AS (
SELECT pk
, customer_fk
, merchant_fk
, payment_method_fk
, created_at
, 'Credit' AS type
, amount_authorized
, amount_submitted_for_settlement
, authorization_acquired
, credit_card_details_type
FROM generic_looker_test.transactions AS t
UNION ALL
SELECT pk
, customer_fk
, merchant_fk
, payment_method_fk
, created_at
, 'Sale' AS type
, amount_authorized
, amount_submitted_for_settlement
, authorization_acquired
, credit_card_details_type
FROM generic_looker_test.transactions AS tt
)
SELECT *
, DENSE_RANK() OVER(PARTITION BY customer_fk ORDER BY created_at) AS customer_sequence
, DENSE_RANK() OVER(PARTITION BY merchant_fk ORDER BY created_at) AS merchant_sequence
FROM transaction_events
events.view.lkml · 103 lines
inferred
view: events {
derived_table: {
sql: WITH transaction_events AS (
SELECT pk
, customer_fk
, merchant_fk
, payment_method_fk
, created_at
, 'Credit' AS type
, amount_authorized
, amount_submitted_for_settlement
, authorization_acquired
, credit_card_details_type
FROM generic_looker_test.transactions AS t
UNION ALL
SELECT pk
, customer_fk
, merchant_fk
, payment_method_fk
, created_at
, 'Sale' AS type
, amount_authorized
, amount_submitted_for_settlement
, authorization_acquired
, credit_card_details_type
FROM generic_looker_test.transactions AS tt
)
SELECT *
, DENSE_RANK() OVER(PARTITION BY customer_fk ORDER BY created_at) AS customer_sequence
, DENSE_RANK() OVER(PARTITION BY merchant_fk ORDER BY created_at) AS merchant_sequence
FROM transaction_events ;;
}
dimension: pk {
type: int
sql: ${TABLE}.pk ;;
}
dimension: customer_fk {
type: int
hidden: yes
sql: ${TABLE}.customer_fk ;;
}
dimension: merchant_fk {
type: int
hidden: yes
sql: ${TABLE}.merchant_fk ;;
}
dimension: payment_method_fk {
type: int
hidden: yes
sql: ${TABLE}.payment_method_fk ;;
}
dimension: customer_transaction_sequence {
type: number
sql: ${TABLE}.customer_sequence ;;
}
dimension: merchant_transaction_sequence {
type: number
sql: ${TABLE}.merchant_sequence ;;
}
dimension: type {
sql: ${TABLE}.type ;;
}
dimension: amount_authorized {
type: number
sql: ${TABLE}.amount_authorized ;;
}
dimension: amount_submitted_for_settlement {
type: number
sql: ${TABLE}.amount_submitted_for_settlement ;;
}
dimension: authorization_acquired {
sql: ${TABLE}.authorization_acquired ;;
}
dimension: credit_card_details_type {
sql: ${TABLE}.credit_card_details_type ;;
}
dimension_group: created_at {
type: time
timeframes: [time, date, week, month]
sql: ${TABLE}.created_at ;;
}
measure: count {
type: count
}
measure: total_amount_authorized {
type: sum
sql: ${amount_authorized} ;;
}
}
events.view.lookml · 78 lines
source-preserved
- view: events
derived_table:
sql: WITH transaction_events AS (
SELECT pk
, customer_fk
, merchant_fk
, payment_method_fk
, created_at
, 'Credit' AS type
, amount_authorized
, amount_submitted_for_settlement
, authorization_acquired
, credit_card_details_type
FROM generic_looker_test.transactions AS t
UNION ALL
SELECT pk
, customer_fk
, merchant_fk
, payment_method_fk
, created_at
, 'Sale' AS type
, amount_authorized
, amount_submitted_for_settlement
, authorization_acquired
, credit_card_details_type
FROM generic_looker_test.transactions AS tt
)
SELECT *
, DENSE_RANK() OVER(PARTITION BY customer_fk ORDER BY created_at) AS customer_sequence
, DENSE_RANK() OVER(PARTITION BY merchant_fk ORDER BY created_at) AS merchant_sequence
FROM transaction_events
fields:
- dimension: pk
type: int
sql: ${TABLE}.pk
- dimension: customer_fk
type: int
hidden: true
sql: ${TABLE}.customer_fk
- dimension: merchant_fk
type: int
hidden: true
sql: ${TABLE}.merchant_fk
- dimension: payment_method_fk
type: int
hidden: true
sql: ${TABLE}.payment_method_fk
- dimension: customer_transaction_sequence
type: number
sql: ${TABLE}.customer_sequence
- dimension: merchant_transaction_sequence
type: number
sql: ${TABLE}.merchant_sequence
- dimension: type
sql: ${TABLE}.type
- dimension: amount_authorized
type: number
sql: ${TABLE}.amount_authorized
- dimension: amount_submitted_for_settlement
type: number
sql: ${TABLE}.amount_submitted_for_settlement
- dimension: authorization_acquired
sql: ${TABLE}.authorization_acquired
- dimension: credit_card_details_type
sql: ${TABLE}.credit_card_details_type
- dimension_group: created_at
type: time
timeframes:
- time
- date
- week
- month
sql: ${TABLE}.created_at
- measure: count
type: count
- measure: total_amount_authorized
type: sum
sql: ${amount_authorized}
Contents
- events.sql
- events.sql
- events.view.lkml
- events.view.lookml