Hi... I'm sooo close to getting rudder-event-analy...
# support
c
Hi... I'm sooo close to getting rudder-event-analytics to work... I'm in my dbt cloud, I've successfully connected dbt to my BigQuery via using the json credentials... but I'm getting an error when I run the dbt build. Here's a screencast followed by a writeup... thank you thank you thank you... https://www.loom.com/share/e6ea737a73dd4144aa14685ae0962d4c Database Error in model rs_stg_user_first_touch (models/intermediate/rs_stg_user_first_touch.sql) Syntax error: Illegal escape sequence: \. at [31:76] Is this is either because I've not entered the right values for
rs_database
and
rs_schema
in the dbt_project.yml? Or my little test set of data has something corrupt? (the test data set was created by rudderstack it sent to my big query from the standard .js tracking script source, and the pages and pages_view tables look normal/have data. for BigQuery.. what should the rs_database name be? (I've tried a bunch of permutations.. but I assume it's the name of the bigquery which has inside it all of the datasets... and for rs_schema, I just supply the name of the dataset that rudderstack created, which contains the pages and page_view tables ( when clicking the 3 dots next to the dataset, choosing 'copy id' I get database.dataset < not my actual names).. but for schema I've tried dataset, database.dataset and all kinds of things)... thank you so much for your help!! Once I can do this, I can then get onto user stitching and everything else... just stumbling here on the basics. I've loaded up the rudder-event-analytics git, replaced the
rs_database
and
rs_schema
vars.... but maybe not properly for BigQuery? When I run dbt build... at first it seems to go OK,, the running node model, acquiring new bigqueryconnection is all going... then it goes to this step: `create or replace table
cschatbot
.
csDevAnalytics
.`rs_stg_user_first_touch`` below that shows OPTIONS()... and shows all the code etc... then below that: Database Error in model rs_stg_user_first_touch (models/intermediate/rs_stg_user_first_touch.sql) Syntax error: Illegal escape sequence: \. at [31:76] I looked at what's on rs_stg_user_first_touch.sql at that spot and it's:
first_value(source_medium) over (
... rest of that function... As far as I can tell... this means something invalid was passed in as source_medium? I have like 5 rows of data from just testing out the .js snippet, which Rudderstack successfully wrote into the DB... so either one of the rows is corrupt (how? I just followed the tutorials.. and loaded this and that page with some urls like .local?utm_source="testing" etc... and some URL's with no UTMs.) Or... it's not getting anything? The docs say to put in the 'database name' for the var
rs_database
but I'm actually not sure which thing in BigQuery to use.. For the database name is that the dataset, or databasename.dataset? I was assuming I'd go to the dataset, click the 3 dot menu then use the copy ID which gives me cschatbot.credit_suite_com where cschatbot is the name of the bigquery, and credit_suite_com is the dataset rudderstack created when it synced my events from the .js source.
Hmm diving more into the readme.. if I'm understanding it, after running dbt deps, there should be now
tracks
and
identifies
tables added (there is already a
pages
and
pages_view
tables from the first sync I did from rudderstack.. I did not get any errors in dbt from running dbt deps .. however there are no tracks or identifies tables in the dataset that currently contains the pages and pages_view tables...
c
Interesting tracks table is not created. Identifies table get created only if atleast any identify event is sent. https://www.rudderstack.com/docs/event-spec/standard-events/track/ https://www.rudderstack.com/docs/event-spec/standard-events/identify/
@creamy-table-83685 Please share your workspaceID … you can DM me as well. This will help us check your configurations.
c
creditsuite-jason I have not yet incorporated any identify calls, I've only installed the .js tracker.. my first phase was to get a table with UTM's... phase 2 was going to be setting up the identify calls in the .js + start sending identifiers from my database, then implementing the user stitching tutorial
p
Hi Jason, the tracks and identifies tables should first be created for this to work, because rs_stg_all_events looks for data from all those tables. Make sure to generate track and identify events first from your site so the tables can be created in BQ before running dbt.
Please let us know if that helps in anyway
c
@plain-parrot-49913 - oddly, it didn’t change the error.
@plain-parrot-49913 - as I step through and try to get up to speed on how to speak DBT/debug the github.. I noticed this from the DBT Tutorial.. when working in big query:
Copy code
with customers as (

    select
        id as customer_id,
        first_name,
        last_name

    from `dbt-tutorial`.jaffle_shop.customers

),
telling DBT where the table is requires prepending the BigQuery table name inside of `` followed by the dataset, followed by the table name. If I look at their copy/paste code for redshift for example, that same code just directly states the schema.table:
Copy code
with customers as (

    select
        id as customer_id,
        first_name,
        last_name

    from jaffle_shop.customers

),
and/or if I'm using DBT cloud.. don't I also have to change the profile name in the dbt_project.yml file?
tried something I should have tried at first.. I changed the vars for the schema and database names to foop and boop (which of course do not exist)... and the error is exactly the same.. def the issue is getting DBT finding the rudderstack tables
now I've tried just hard coding the db and schema names into /sources/schema.yml and if I run dbt build --rs_stf_all_events it runs ok
but the build still fails
the overall build I mean
p
@creamy-table-83685 is it the same error as before?
c
yes...
I was looking to see if maybe the regex could be failing somehow
p
Happy to get on a call today or tomorrow to look at this
c
am avail now?
p
as I think it may be easier
will DM you a zoom link
c
thanks!
In case anyone out there is trying to make rudder-event-analytics dbt work on BigQuery... (unless/until they push a new version).. you must make the following changes to the files: 1. timestamp_macros.sql line 47, add {{timestamp_col}}
Copy code
{% macro to_date(timestamp_col) %}
   {{timestamp_col}}
{% if target.type == 'snowflake' %}
    to_date({{timestamp_col}})
{% elif target.type == 'redshift' %}
2. in rs_stg_session_metrics, change line 4 to:
Copy code
*, TIMESTAMP_DIFF(session_end_time, session_start_time, SECOND) as session_length
3. in reporting_dims.sql, escape the escapes in the regex
Copy code
regexp_replace(
                        regexp_replace({{ var('col_referring_domain') }}, '^www\\.', ''),
                        '\\.com(\\.\\w+)?$|\\.co(\\.\\w+)?$|\\.org$',
                        ''
                    )
... I'm pretty sure that's it... also heads up.. utm_campaign and utm_term are not considered in the original, and there are also some assumptions around what your team may use for utm_medium that will get converted to "paid search" for example.. those are pretty easy to find/fix... and adding in utm_campaign as a column in the rs_stg_user_first_touch output table wasn't too hard either.. I think I'm going to add in the utm_term as well... or use snowflake and it works with no fuss! thanks to Sara for her time, and highly recommend ask Chat GPT why things don't work lol. It's surprisingly capable.
🙌 1
g
Thank you for sharing the solution with the community @creamy-table-83685 🙏
c
Note to any who find this thread… if you plan on using any other cool stuff seen in tutorials like the DBT user stitching… I’m finding nothing works in BigQuery so the real solution may be to use a different data warehouse if you are not super skilled/like me are looking for more plug and play.
I’m abandoning BQ for snowflake everything seems to just work by following the instructions and making the simple edits to config files. BigQuery brining back my nightmares trying to make website CSS compatible with microsoft Internet Exploder