<@U04LL1R52GK> I just read through your post. Back...
# support
c
@creamy-table-83685 I just read through your post. Back in January 2023. Have you successfully integrated the dbt with BiqQuery? I'm currently considering the build with Azure. Any expericne you can share would be great. Feel free to DM me.
m
Hey There! πŸ‘‹ Your message has been received by the RudderStack team. We will forward this request to your Technical Account Manager, and they will get back to you shortly. Please use the thread for any additional comments.
c
@calm-state-78410 yes I got the first touch and user stitching DBT examples to work
The issue with big query/google sql is they have some different syntax that maybe less standard. The user stitch dbt was written for Snowflake and worked out of the box but Snowflake required a lot more setup to keep cost down…
c
@creamy-table-83685 I just added the user-stitch package to my project and then noticed it doesn’t support bigquery. Are you able to share how you got it to work? Maybe a new package? πŸ™‚
c
Pretty sure I posted in this slack as well as a comment on the GitHub what needs to be changed and where
c
@creamy-table-83685 thank you for the feedback. within your scheme is 'session_end_time' and 'session_start_time' being populated? I'm not seeing those datetimes being pushed to my warehouse. *, TIMESTAMP_DIFF(session_end_time, session_start_time, SECOND) as session_length
c
My setup uses that library, combined with the user stitch
Fortunately this library was written for BigQuery and I don't think I had to make any edits to it
@chilly-television-36470 - link to the comment I posted on the GitHub: https://github.com/rudderlabs/dbt-id-stitching/issues/10
note.. the first time I'd ever even heard of BigQuery or DBT was when I set out to try to deliver a report of revenue by first touch... I'm mostly a copy/paste coder from the land of WordPress... but with Chat GPT and some early support from RS staff showing me a bit how to use the Compile button to generate the SQL, then paste the generated SQL into a BigQuery query tab to better understand the errors, then feed those errors to Chat GPT...managed to finally get it all to work.
so this is about as useful as I can be... am far from an expert in this stuff
c
ha now worries. i haven't gone down the path yet of connecting the dbt packages. i'm first making sure I have everything before going down that path.
c
@creamy-table-83685 Did you fork this package and make your updates to the code? Might try this out soon. Assuming all is going well with your changes? πŸ™‚
c
@chilly-television-36470.. no I didn't make a fork.. just made changes on my own setup and have some other stuff specific to our business/use case in there as well so it wouldn't be much easier to work with.
c
@creamy-table-83685 Thanks. Appreciate it. Are you able to report the below line - been playing around but keep getting syntax errors in my queries.sql: SELECT β€œSELECT DISTINCT CAST(β€œ|| a.cn ||” AS STRING) AS edge_a, β€˜β€ || a.cn || β€œ' AS edge_a_label, ” || b.cn || ” AS edge_b, β€˜β€ || b.cn || β€œ' AS edge_b_label FROM ” || a.tn || ” WHERE COALESCE(CAST(” || a.cn || ” AS STRING), β€˜β€™) != β€˜β€™ AND COALESCE(CAST(” || b.cn || ” AS STRING), β€˜β€™) != β€˜β€™β€ AS sql_to_run
Actually its this line that is throwing the error: `FROM `project.my_data_set.INFORMATION_SCHEMA.COLUMNS``
c
Here is my queries.sql:
Copy code
WITH columns AS (
    SELECT
        column_name AS cn,
        table_catalog || '.' || table_schema || '.' || table_name AS tn
    FROM `my_data_set.INFORMATION_SCHEMA.COLUMNS`
  WHERE
        LOWER(column_name) IN {{ var('id-columns') }}
        {% if var('schemas-to-include') != '()' %}
        AND LOWER(table_schema) IN {{ var('schemas-to-include') }}
        {% endif %}
        {% if var('schemas-to-exclude') != '()' %}
        AND NOT LOWER(table_schema) IN {{ var('schemas-to-exclude') }}
        {% endif %}
        {% if var('tables-to-include') != '()' %}
        AND LOWER(table_name) IN {{ var('tables-to-include') }}
        {% endif %}
        {% if var('tables-to-exclude') != '()' %}
        AND NOT LOWER(table_name) IN {{ var('tables-to-exclude') }}
        {% endif %}
        AND NOT LOWER(table_name) LIKE 'snapshot_%'
        AND NOT LOWER(table_name) LIKE 'sync_data_%'
        AND NOT LOWER(table_name) LIKE 'failed_records_%'
)

SELECT "SELECT DISTINCT CAST("|| a.cn ||" AS STRING) AS edge_a, '" || a.cn || "' AS edge_a_label, " || b.cn || " AS edge_b, '" || b.cn || "' AS edge_b_label FROM " || a.tn || " WHERE COALESCE(CAST(" || a.cn || " AS STRING), '') != '' AND COALESCE(CAST(" || b.cn || " AS STRING), '') != ''" AS sql_to_run

FROM columns AS a
INNER JOIN columns AS b
    ON a.tn = b.tn
        AND a.cn > b.cn
Note, I don't include the project name in there... maybe that is the issue.
Also, what this query is meant to do is to build a table that contains the name of each table you have inside of my_data_set, and then to get the column names of each of those tables.
so be sure all your tables and column names are valid and exist etc.
you must also have in your .yml file the schemas to include and exclude.
ah.. I remember now:
checkout the schema.yml in your project... here's mine:
Copy code
version: 2sources:  - name: rudder    description: All shopify data tables that would be generated by RudderStack SDK and webhook.    database: "{{var ('rs_database')}}"    schema: "{{var ('rs_schema')}}"    tables:      - name: tracks      - name: pages      - name: identifies      - name: screens  - name: information_schema    tables:      - name: columnsmodels:  - name: queries    columns:      - name: sql_to_run        tests:          - unique          - not_null  - name: edges    columns:      - name: rudder_id        tests:          - not_null      - name: original_rudder_id        tests:          - not_null      - name: edge_a        tests:          - not_null      - name: edge_a_label        tests:          - not_null      - name: edge_b        tests:          - not_null      - name: edge_b_label        tests:          - not_null      - name: edge_timestamp        tests:          - not_null  - name: check_edges    columns:      - name: consolidation_needed        tests:          - not_null      - name: rows_to_update        tests:          - not_null  - name: id_graph    columns:      - name: rudder_id        tests:          - not_null      - name: edge        tests:          - unique          - not_null      - name: labels        tests:          - not_null      - name: latest_timestamp        tests:          - not_null
specifically this bit:
Copy code
tables:      - name: tracks      - name: pages      - name: identifies      - name: screens
If these tables do not exist, then it will fail.
You must have a
tracks
,
pages
,
identifies
and
screens
tables in your my_data_set folder.
I believe you can remove from the 'tables' any table you don't actually have... but these tables should all be created by rudderstack by default when you use the stock .js source (meaning some webpage or app page is loading the rudderstack library).. but if you have never executed an identify call, you won't have an identifies table
My dbt_project.yml actually does not define the schemas to include or exclude, but the following lines are present: schemas-to-include: () schemas-to-exclude: () tables-to-include: () tables-to-exclude: ()
I did however define these variables in the dbt_project.yml: # All below variables pertain to table names and column names. If the event tracking plan is followed perfectly, it ideally shouldn't need any modifications below. #table rudder identifies tbl_rudder_identifies: "{{ source('rudder', 'identifies') }}" #table rudder tracks tbl_rudder_tracks: "{{ source('rudder', 'tracks') }}" #table rudder pages tbl_rudder_pages: "{{ source('rudder', 'pages') }}" ##table rudder screens #tbl_rudder_pages: "{{ source('rudder', 'screens') }}"
note I have commented out the screens table and it still works...
I also supplied in the dbt_project.yml what columns I want it to look for: id-columns: ('anonymous_id', 'user_id', 'email', 'identity', 'phone', 'payload_email', 'context_traits_email')
^ some of these columns are unique to my setup
context_traits_email for example is a default column from one of the tables automatically created by the rudderstack .js source as is anonymous_id.. but 'identity' for example is specific to my setup.. I have data in a mysql table which one of the columns is "identity"
(that identity column is copied over/updated into bigquery)... I don't have dbt connecting directly to my sql database... everything is in BQ
m
I have raised a ticket for DBT support for Azure as well. Not sure when it will be available though.