dbt-labs / dbt-adapter-tests

a pytest plugin for dbt adapter test suites
19 stars 11 forks source link

Derived quoting does not work #16

Open aurany opened 3 years ago

aurany commented 3 years ago

My adapter (DB2) has the default False-True-True quoting setting which is configured in the adapter implementation. I am not using any other setting for quotings in the spec-file. When running the tests the quoting gets overwritten by the function _relation_from_name. So when I run with False-True-True it becomes False-True-False and the tests fails (because DB2 tries to use tables that doesn't exist).

It looks like the tables are created correctly with all lowercase names, but when some tests take place they fail. I am pretty sure the error occur in test 2 ("base") step 6 ("relation_rows") when running "select count(*) from {relation}" (see below) because the relation identifier is rendered without quoting (=> uppercase in DB2).

https://github.com/fishtown-analytics/dbt-adapter-tests/blob/a411336e9493a38c228a876e19af24d70ec53d86/pytest_dbt_adapter/spec_file.py#L453-L465

When running the tests with a forked version of this repo (_relation_from_name is only returning the default quoting) all tests pass :) My suggestion is to use the adapter default setting only. Good idea?

jtcohen6 commented 3 years ago

@aurany Appreciate the detailed writeup! What's the change you made in your fork to get this working? I imagine it's a tweak to _relation_from_name here:

https://github.com/fishtown-analytics/dbt-adapter-tests/blob/a411336e9493a38c228a876e19af24d70ec53d86/pytest_dbt_adapter/spec_file.py#L186-L204

aurany commented 3 years ago

@jtcohen6 By overriding quote_policy before returning the values, like

https://github.com/aurany/dbt-adapter-tests/blob/a9ee85f301b6247bee4a5101c9ba9cfb33eaef4b/pytest_dbt_adapter/spec_file.py#L206-L208