question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dbt jaffle shop demo doesn't work on adapter

See original GitHub issue

Minimum working example

Here’s my directory

.
├── docker-compose.yml
├── dockerfile
├── jaffle_shop  # is this repo https://github.com/fishtown-analytics/jaffle_shop
└── profiles.yml
# dockerfile
FROM python:3.8

RUN \
  export ACCEPT_EULA=Y && \
  apt-get update && \
  apt-get install -y --no-install-recommends curl g++ unixodbc-dev && \
  curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
  curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
  apt-get update && \
  apt-get install -y --no-install-recommends msodbcsql17 && \
  pip install dbt dbt-sqlserver

COPY ./jaffle_shop/ /usr/src/app
COPY profiles.yml /root/.dbt/profiles.yml

WORKDIR /usr/src/app

CMD ["dbt", "debug"]
# profiles.yml
config:
  partial_parse: false
  send_anonymous_usage_stats: false

jaffle_shop:
  target: jaffle
  outputs:
    jaffle:
      type: sqlserver
      driver: 'ODBC Driver 17 for SQL Server'
      server: "{{ env_var('DB_HOST') }}"
      port: "{{ env_var('DB_PORT') | as_number }}"
      database: tempdb
      schema: jaffle
      user: "{{ env_var('DB_USER') }}"
      password: "{{ env_var('DB_PASS') }}"
# docker-compose.yml
version: "3.1"
services:
  db:
    image: mcr.microsoft.com/mssql/server:2017-latest
    environment:
      - ACCEPT_EULA=Y
      - SA_PASSWORD=Password!
  dbt:
    build: .
    depends_on:
      - db
    environment:
      - DB_HOST=db
      - DB_PORT=1433
      - DB_USER=sa
      - DB_PASS=Password!

Steps to reproduce

In one terminal run the following commands in the dbt container. This shows that the profile is setup correctly, it creates the seed tables, and then successfully creates 3 views stg_orders,stg_customers,stg_payments and 2 tables customers, orders

docker compose run dbt /bin/bash
dbt debug # works
dbt seed # works
dbt run # works

So by the end you should see:

# dbt run 
Running with dbt=0.19.1
Found 5 models, 20 tests, 0 snapshots, 0 analyses, 153 macros, 0 operations, 3 seed files, 0 sources, 0 exposures

18:21:54 | Concurrency: 1 threads (target='jaffle')
18:21:54 | 
18:21:54 | 1 of 5 START view model jaffle.stg_orders............................ [RUN]
18:21:54 | 1 of 5 OK created view model jaffle.stg_orders....................... [OK in 0.09s]
18:21:54 | 2 of 5 START view model jaffle.stg_payments.......................... [RUN]
18:21:54 | 2 of 5 OK created view model jaffle.stg_payments..................... [OK in 0.04s]
18:21:54 | 3 of 5 START view model jaffle.stg_customers......................... [RUN]
18:21:54 | 3 of 5 OK created view model jaffle.stg_customers.................... [OK in 0.05s]
18:21:54 | 4 of 5 START table model jaffle.orders............................... [RUN]
18:21:54 | 4 of 5 OK created table model jaffle.orders.......................... [OK in 0.07s]
18:21:54 | 5 of 5 START table model jaffle.customers............................ [RUN]
18:21:54 | 5 of 5 OK created table model jaffle.customers....................... [OK in 0.04s]
18:21:54 | 
18:21:54 | Finished running 3 view models, 2 table models in 0.36s.

Completed successfully

While that is still running, in another terminal run:

docker compose exec db /opt/mssql-tools/bin/sqlcmd -S db -U sa -P Password!
1> select * from jaffle.stg_customers
2> go
# ok
1> select * from jaffle.customers
2> go
# Invalid object name 'jaffle.customers'.

Expected

I was expecting the jaffle.customers table to exist since dbt was successful


I hope the example helps. Have I missed anything?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
owlascommented, Jul 7, 2021

Nice! I’ll try the new pip package

1reaction
dataderscommented, Jun 25, 2021

@owlas sorry for your trouble here – I think the problem is two-fold:

  1. there is something about the repo that isn’t SQL Server compatible out of the box. there have been various versions of the jaffle_shop projects and various forks that are SQL Server compatible:
    1. https://github.com/jacobm001/jaffle_shop_mssql
    2. https://github.com/dbt-msft/jaffle_shop_mssql
  2. there is a bug introduced in dbt-sqlserver version v0.19.1 that doesn’t surface errors happening on the server like it used to.

If you don’t mind could you:

  1. install dbt-sqlserver from github (pip install git+https://github.com/dbt-msft/dbt-sqlserver.git),
  2. try running the jaffle_shop again to see the errors you couldn’t see before
  3. use the other jaffle_shop projects listen above for ideas on how to fix errors
Read more comments on GitHub >

github_iconTop Results From Across the Web

dbt + Materialize demo: Running dbt's jaffle_shop with ...
This tutorial serves as a practical hands-on demonstration of the adapter. In this case, we are using static not streaming data, but the ......
Read more >
Debugging errors - dbt Developer Hub
Learn about errors and the art of debugging them.
Read more >
dbt Guide - GitLab
If you're interested in using dbt, the dbt documentation has a great tutorial on getting setup to work on data from a fictional...
Read more >
pedram on Twitter: "Time for streaming with dbt with the infamous ...
but theres a problem with this flow. ... Why can't our Jaffle Shop run continuously? ... Materialize and dbt work together through the...
Read more >
Quick tip: Using dbt with SingleStoreDB | by Akmal Chaudhri
This short article will show how to set up dbt for use with SingleStoreDB. We'll also quickly apply a dbt example to test...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found