I have two SQL scripts and am trying to translate them to DBT.
Problem Statment is as below:-
Current Solution
SQL script No.1 creates the table and SQL script No.2 update the table with the following query
UPDATE T1
SET C4 = 3.3 WHERE C1 = 'US'
Now, I want to move these creation and updation job(Script1 and Script 2) to DBT.
DBT Solution
I have created a model called T1.sql in DBT which creates Table T1 in the database and its contents are as follows:-
SELECT * FROM member;
Now for updating the table as per the above-mentioned criteria, I wrote the SELECT statement as
Select c1,c2,c3,
case when c1 = ‘US’ then 3.3 else c4 end as c4
from t1
Now the question is where do I put this above the SELECT statement. I cannot put in file T1.sql as each DBT model file should have only one SELECT statement. If new file, then what should be the file name. I cannot have multiple files with the name 'T1.sql'.
Is there any way we can include both these operations in T1.sql file so that we need not to create any other new tables to achieve this?