The not so spoken about advantage of dbt!
Why choosing an agnostic transformation tool frees you from painful data platform migrations
... or maybe that's a bit of a claim, but at least dbt gets you some of the way there. At least that's what I've been saying to myself (and a couple of colleagues) lately. Fortunatly I got the chance to pressure test my idea at an upcoming #MsBIP meetup at Inspari A/S, so I got to work on proving my claim!
If you don't know what dbt, Snowflake Data Cloud or Fabric is, jump to the end of the article to read more!
The case
The case was simple: How easy is it to switch from a Snowflake backend to a Microsoft Fabric backend (and the other way around).
With the current introduction of MS Fabric the hype train is rolling. We are seeing a lot of customers wanting to investigate what's it all about with or without us helping them, which is very positive move in the market towards a much more scalable technology for what the industry is calling "a data platform".
This case of course comes from some kind of pain point. Many of the people I work with face a migration. Often from homegrown frameworks or frameworks that have been built by a consultancy and then applied in the customers environment. This basically boils down to a build or buy decision; both for customers and consultancies.
With dbt we identify that we get a "framework" (not really, but ok) that is not tying us to any one backend but let's us move freely between backends, opening up new capabilities when moving from one to the other and lets us still consolidate our work with data. Win!
The setup
Finding a Source Dataset
Starting out in Snowflake, I needed a dataset. Readily available is the TPCH dataset, so I picked up the TPCH SF1 dataset as the source of the dimensional model I would create.
Setting up dbt
With dbt you need a couple of objects to get going.
- profiles.yml - this files contains the connection information to use when dbt is going to issue the SQL statements on the backend.

- some models - in dbt all transformations aka SQL statements are called "models".

renamed as (
select
L_COMMENT as comment,
L_COMMITDATE as commit_date,
L_DISCOUNT as discount,
L_EXTENDEDPRICE as extended_price,
L_LINESTATUS as line_status_short_name,
decode(
L_LINESTATUS,
'F', 'Finished',
'O', 'Open',
'Error'
) as line_status,
L_ORDERKEY as order_key,
L_PARTKEY as part_key,
L_QUANTITY as quantity,
L_RECEIPTDATE as receiptdate,
L_RETURNFLAG as return_flag_short_name,
Using some Snowflake specific (the decode) SQL syntax, just to see what happens...
With the profiles.yml and model files ready, we were good to go!
Running it on Snowflake was of course a breeze once everything was debugged and good to go.
Now... on to the dreaded migration to Fabric.
Migrating to Fabric
First, we needed the same data in Fabric. Using a Pipeline in Fabric, we hooked it up to Snowflake, copied over the TPCH datasets into a Fabric Warehouse and made sure that the schema/table names were the same, and then we had the same data foundation to build on. Moving on to the fun part...
So, initially I thought "Is is really just swapping the connection details in the profiles.yml file" - so we tried that.
And it worked... But, we had Snowflake SQL syntax as well a dbt macro that wasn't compatible with Fabric!
Let's fix that.
First issue: Snowflake specific SQL syntax

I put in a couple of roadblocks for myself because it was intially too easy, so using something like decode instead of a CASE statement was used.
Swapping to a CASE statement throughout the SQL statements fixed this.
Second issue: dbt macro not working
This one is bit more spicy. We used the dbt utils generate_surrogate_key macro to generate a HASHed surrogat key. Behind the scenes it's basically doing a CONCAT of the inputted attributes.
With Snowflake, a single inputted attribute is fine and the CONCAT works with no issue. Not so on Fabric.

So, how do we go about it? Well, it was a demo :) So I made sure that all uses of the macro had at least two values. The attribute we needed and a hardcoded string of "empty_value" - maybe not the best way forward, but it proved my point!

Resulted in...

The findings
Basically, it worked as I had imagined.
The findings were
- It just works as you would think it would. Change the connection details in the profiles file and you are good to go.
- Change minor things in the sources file for the TPCH dataset, so we point ot the correct database.
- Fix any syntax specific errors as you go along in the migration.
Note on syntax: From an architectural PoV it would make sense to align on only using ISO (ANSI) standard SQL syntax. The case against this is, that the improvements that e.g. Snowflake (or Fabric) is making to the SQL syntax on top of the ANSI standard would then be lost. So, what to do? I would advise to use the capabilities of the backend to the fullest and let the syntax be a future issue, if a migration is to be done.
Disclosure: I did not do a thourough testing of this more than what the above case shows. There could potentially be more things to consider BUT this proves the point of maneuverability between backends when choosing a backend-agnostic tool.
THANKS FOR READING! This was a fun little demo of the capabilities of dbt.
More posts coming up on Snowflake and dbt in the near future.
What is dbt?
dbt (dbt Labs, data build tool) is a data transformation tool (but also more...) built with the mindset of bringing best practice software development workflows into Data Engineering such a CI/CD, Version Control, native Test framework, etc.
Read more about dbt here: https://www.getdbt.com/
What is Snowflake Data Cloud?
Snowflake Data Cloud is a cloud-native Data Platform (Cloud...) that enables a lot of an organisations Workloads in a single, secure, scalable platform. Snowflake not only does Data Warehousing well (one workload) but also let's Data Eng. and Data Scientist work with Python, AI (ML, LLM, etc.) and soon Containerized services and much, much more.
Read more about Snowflake here: https://inspari.dk/snowflake (in danish)
What is Microsoft Fabric?
Microsoft Fabric is MS latest offering in the Data Platform area. Building on the learnings of Synapse (Workspace) they've made an even more integrated platform with Fabric. People coming from Databricks will feel a very familiar setup with multiple "experiences" such a Notebooks, Spark Jobs (aka a subset of the functionality found in a Workflow/Job in Databricks), Warehouses (aka SQL experience in Databricks), tight integration with Power BI for reporting, etc.
Read more about Fabric here: https://inspari.dk/microsoft-fabric (in danish)