I'm running `meltano invoke dbt-postgres:run` with...
# troubleshooting
j
I'm running
meltano invoke dbt-postgres:run
with an apparently well configured transform on my PostgreSQL target using the
analytics
schema:
Copy code
2022-06-21T16:50:25.279019Z [info     ] Environment 'dev' is active
16:50:28  Running with dbt=1.0.8
16:50:28  Found 1 model, 0 tests, 0 snapshots, 0 analyses, 165 macros, 0 operations, 0 seed files, 1 source, 0 exposures, 0 metrics
16:50:28  
16:50:29  Concurrency: 2 threads (target='dev')
16:50:29  
16:50:29  1 of 1 START view model analytics.events_per_day................................ [RUN]
16:50:29  1 of 1 OK created view model analytics.events_per_day........................... [CREATE VIEW in 0.28s]
16:50:29  
16:50:29  Finished running 1 view model in 1.01s.
16:50:29  
16:50:29  Completed successfully
16:50:29  
16:50:29  Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1
and here is my model:
Copy code
$ cat transform/models/tap_postgres/events_per_day.sql
SELECT
  CAST("timestamp" AS date) AS "timestamp"
  , event
  , distinct_id
  , COUNT(*) as "count"
FROM {{ source('tap_postgres', 'telemetry_events') }}
GROUP BY
  CAST("timestamp" AS date)
  , event
  , distinct_id
however, I don't see any new tables in the target. I would have expected this query to run for much longer by the way, since the source table is quite big. any way to debug what's happening here? (edit: solved βœ”οΈ )
v
Copy code
16:50:29  1 of 1 OK created view model analytics.events_per_day........................... [CREATE VIEW in 0.28s]
Created a view so no processing needed, that's why it's fast. Lots of debug options with DBT, check out
./transform/logs
if you'd like to really dig You have an analytics schema in postgres
j
You have an analytics schema in postgres
yep, that one is present, but apparently empty. I'll check the logs
v
try
select * from analytics.events_per_day
How do you know it's empty? I recommend dbeaver for folks and then make sure to check views and not just tables. Could be something else of course but this one looks pretty straight forward!
j
oh well, I think I might be missing some key PSQL knowledge here. indeed
select * from analytics.events_per_day
returns stuff, but I was confused because there were no tables listed in
SELECT * FROM <http://pg_catalog.pg|pg_catalog.pg>_tables
with that name, nor
select * from pg_matviews
. I was missing "views" (which are not "materialized views"), hence
select * from information_schema.views
). glad I sorted this out quickly, thanks!
v
np πŸ˜„
j
niceeeeeeeeee I understand everything now 🀯
c
@juan_luis_cano_rodriguez oh, so you are into Meltano too! Let’s talk about it on our next meeting of pydata! πŸ™‚
c
oh well, I think I might be missing some key PSQL knowledge here
Yes, default relation type in DBT is a view, not a table. You can quickly list your views in
psql
with the
\dv
command. (e.g.
\dv analytics.*
v
@christoph awesome πŸ˜„ I rely on dbeaver but knowing
\dv
is nice πŸ˜„
c
I try not to leave the terminal if possible ... 😁 (Always trying to avoid the associated lag of switching from CLI to GUI ...)
j
yay @cesar_garcia_saez, the world is small! πŸ˜„
good tip, thanks @christoph!