Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The implementation of default__list_schema results in double-quoting if databse quoting is true #2267

Closed
1 of 5 tasks
beckjake opened this issue Mar 30, 2020 · 5 comments
Closed
1 of 5 tasks
Labels
bug Something isn't working
Milestone

Comments

@beckjake
Copy link
Contributor

Describe the bug

When the quoting config database: true is set, and a plugin doesn't override list_schema, the list_schemas adapter method ends up double-quoting the database name (once in-method, once in the macro).

Steps To Reproduce

  • Create a plugin
  • set the default database quoting to true or set it in your project
  • get errors about double-quoting the name (""memory"".INFORMATION_SCHEMA, in the case of local testing on presto)

Expected behavior

I expect this to work! We should remove the quoting call from default__information_schema_name, at least!

System information

Which database are you using dbt with?

  • postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: presto 0.16.x)

The output of dbt --version:

dbt==0.16.0

The operating system you're using:
N/A

The output of python --version:
N/A

Additional context

The workaround is to implement presto__information_schema_name with a macro that doesn't quote.

@beckjake beckjake added bug Something isn't working triage labels Mar 30, 2020
@drewbanin drewbanin removed the triage label Mar 30, 2020
@drewbanin drewbanin added this to the 0.16.1 milestone Mar 30, 2020
beckjake added a commit that referenced this issue Apr 1, 2020
…on-schema

do not double-quote the database name (#2267)
@drewbanin
Copy link
Contributor

fixed in #2281

@joemirizio
Copy link

I'm using 0.16.1rc1 and still having a quoting issue with list_schema. When I run with the default database quoting (database: True), it looks like the where clause still uses the quoted value.

If I turn off database quoting it seems to work fine.

Debug output (quoting: database: True):

On list_MY_SCHEMA: /* {"app": "dbt", "dbt_version": "0.16.1rc1", "profile_name": "myprofile", "target_name": "mytarget", "connection_name": "list_MY_SCHEMA"} */

    select distinct schema_name
    from "MY_SCHEMA".INFORMATION_SCHEMA.SCHEMATA
    where catalog_name ilike '"MY_SCHEMA"'

Debug output (quoting: database: False):

On list_MY_SCHEMA: /* {"app": "dbt", "dbt_version": "0.16.1rc1", "profile_name": "myprofile", "target_name": "mytarget", "connection_name": "list_MY_SCHEMA"} */

    select distinct schema_name
    from MY_SCHEMA.INFORMATION_SCHEMA.SCHEMATA
    where catalog_name ilike 'MY_SCHEMA'

@drewbanin
Copy link
Contributor

Thanks for letting us know @joemirizio! @beckjake can you check this one out?

@drewbanin drewbanin reopened this Apr 8, 2020
@beckjake
Copy link
Contributor Author

beckjake commented Apr 8, 2020

Yeah, this is a real issue. I will have to consider how we're going to approach this, but it's going to require a change to how we call list_schemas. A bad temporary workaround is to override {adapter_name}__list_schemas to strip the quotes off database in the ilike.

@drewbanin
Copy link
Contributor

Ok - in that case, do you mind making a new issue for the change and linking it here? I'd like to leave this one closed insofar as it resulted in a code change that's going out for 0.16.1, even if it's imperfect.

@joemirizio the path of least resistance here is indeed going to be to overrride the list_schemas macro with a database-specific implementation! The full change here will be a good one to make, but we're not going to be able to do it for 0.16.1 :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants