elementary-data/dbt-data-reliability

[FEATURE] support postgresql

cons0l3 opened this issue · 1 comments

Thanks for all the work involved in creating a cool tool!

I would love to see support for "postgres".

  • OR -

I have setup my dbt profiles.yml to type "postgres". Elementary should check the current/active dbt profile for the configured type and "threw an exception"/"log an error" if the current type is unsupported.

repoduce

  1. install postgres 14, configure your dbt profiles.yml to point to the postgres
  2. run dbt run -s elementary
    OR
  3. run dbt test. I have a test set-up which uses the 'accepted_values' built-in test:
      - name: c_mktsegment
        tests:
          - not_null
          - accepted_values:
              values: ['MACHINERY', 'AUTOMOBILE', 'BUILDING', 'FURNITURE', 'HOUSEHOLD' ]

log of 2.

11:46:03  8 of 21 START table model dev_elementary.dbt_tests ............................. [RUN]
11:46:04  8 of 21 ERROR creating table model dev_elementary.dbt_tests .................... [ERROR in 0.51s]
11:46:04  9 of 21 START incremental model dev_elementary.elementary_test_results ......... [RUN]
[...]
11:46:05  13 of 21 START view model dev_elementary.metrics_anomaly_score ................. [RUN]
11:46:05  Warning: the `current_timestamp` macro is deprecated and will be removed in a future version of the package, once equivalent functionality is implemented in dbt Core. The elementary.metrics_anomaly_score model triggered this warning.
11:46:05  13 of 21 ERROR creating view model dev_elementary.metrics_anomaly_score ........ [ERROR in 0.11s]
[...]
11:46:05  Running 2 on-run-end hooks
11:46:05  1 of 2 START hook: elementary.on-run-end.0 ..................................... [RUN]
11:46:05  1 of 2 OK hook: elementary.on-run-end.0 ........................................ [OK in 0.00s]
11:46:06  Database error while running on-run-end
11:46:06  Encountered an error:
Database Error
  syntax error at or near "dummy_string"
  LINE 6: ...t\n            \n                \n        cast(\'dummy_stri...
[...]
dbt.exceptions.DatabaseException: Database Error
  syntax error at or near "dummy_string"
  LINE 6: ...t\n            \n                \n        cast(\'dummy_stri...

log for 3.

11:48:03  Running 2 on-run-end hooks
11:48:04  Database error while running on-run-end
11:48:04  Encountered an error:
Database Error
  syntax error at or near "MACHINERY"
  LINE 6: ...rom all_values\nwhere value_field not in (\n    \'MACHINERY\...
                                                               ^
11:48:04  Traceback (most recent call last):
  File ".conda\envs\dbt-play\lib\site-packages\dbt\adapters\postgres\connections.py", line 65, in exception_handler
    yield
  File ".conda\envs\dbt-play\lib\site-packages\dbt\adapters\sql\connections.py", line 70, in add_query
    cursor.execute(sql, bindings)
psycopg2.errors.SyntaxError: syntax error at or near "MACHINERY"
LINE 6: ...rom all_values\nwhere value_field not in (\n    \'MACHINERY\...

Hi @cons0l3,
Thank you for opening the issue!
We try to maintain all issues on the main repo so we could easily track them, so I copied what you wrote and replied here:
elementary-data/elementary#61