nidhi_kakulawaram
10/19/2023, 9:25 PMmeltano run tap-snowflake target-snowflake
matt_elgazar
10/19/2023, 9:59 PMnidhi_kakulawaram
10/19/2023, 10:00 PMmatt_elgazar
10/19/2023, 10:03 PMsegment
into the schema `analytics`… Then why can’t you use dbt to do this?
{{ config(materialized='table', schema='analytics') }}
select
timestamp,
event,
...
from
{{ source('segment', <my_table>) }}
matt_elgazar
10/19/2023, 10:05 PMnidhi_kakulawaram
10/19/2023, 10:05 PMmatt_elgazar
10/19/2023, 10:07 PMnidhi_kakulawaram
10/20/2023, 12:20 AMmatt_elgazar
10/20/2023, 2:18 AM# once you cd inside /my_dbt_folder/models/sub_directory/transformed_segment_data.sql
{{ config(materialized='incremental', schema='analytics') }}
select * from {{ source('segment', <my_table>) }}
{% if is_incremental() %}
where timestamp > (select max(timestamp) from {{this}})
{% endif %}
^^ This will create a table called transformed_segment_data
inside the schema analytics
on snowflake and build it incrementally without fully loading the entire table each time. I don’t find it necessary to build a meltano tap to create a table within the same data warehouse. If it’s a big table, that’s even more reason to use dbt since extracting and loading that amount of data from snowflake isn’t cheap.
Not using meltano or dbt you can do this with a few lines of python as well
class SnowflakeConnect():
def connect():
<connect to db>
return self
def run_sql():
<sqlalchemy code to execute sql code>
db = SnowflakeConnect()
db.run_sql("create table if not exists <my table> as select * from <table>")
mark_estey
10/20/2023, 2:10 PMmark_estey
10/20/2023, 2:19 PM