My data source gives me a json which represents a ...
# troubleshooting
t
My data source gives me a json which represents a 'prefix'. There is an array of strings on there called 'tags'. I want tags to be a table. I then need to create a linking table between tags and prefixes for a many to many relationship. Here's me creating the tags table
Copy code
{{
	config(materialized='table')
}}

SELECT
	id,
	DISTINCT jsonb_array_elements_text(tags) AS tag
FROM {{ source("nipap", "ip_net_plan") }}
What is recommended I use for the ID of each tag? Could I just assign an auto increment number? Would that cause problem with subsequent runs of my pipeline? Do I even need an ID? Couldn't I just put the string in my linking table? Might not be as performant.
a
As you're in DBT world already: I tend to use dbt surrogate key macro here, just in case you ever need to expand out to a composite key of two columns, move to a scd2 situation etc. https://docs.getdbt.com/blog/sql-surrogate-keys But the tag name could be just fine too
1