dremio / dbt-dremio

dbt (data build tool) adapter for the Dremio
Apache License 2.0
44 stars 21 forks source link

[Bug]: Twin strategy 'allow' is not working as expected #150

Closed ravjotbrar closed 1 year ago

ravjotbrar commented 1 year ago

Is there an existing issue for this?

Current Behavior

When specifying twin_strategy as allow, the table with the same name as the view is actually being dropped instead of allowed to exist.

The macro where this logic exists is in twin_strategy.sql:

{%- if target_relation.type == 'view' -%}
    {%- if twin_strategy != 'allow' -%}
      {%- set table_relation = api.Relation.create(
          identifier=generate_alias_name_impl(model.name, config.get('file', validator=validation.any[basestring]), model),
          schema=generate_schema_name_impl(target.root_path, config.get('root_path', validator=validation.any[basestring]), model),
          database=generate_database_name_impl(target.datalake, config.get('datalake', validator=validation.any[basestring]), model),
          type='table') -%}
      {{ adapter.drop_relation(table_relation) }}

Expected Behavior

The expected behaviour should be that the table with the same name as the new view should continue to exist.

Steps To Reproduce

  1. In your dremio object storage source, create a table with any name
  2. Using the current adapter create a new project
  3. Create a model (view) in this new project with the configuration block like the following: {{ config(materialized='view', twin_strategy='allow') }} and the same name as the table created above
  4. Do a dbt run and check to see if the table still exists

Environment

- OS: 
- dbt-dremio: 1.3.2
- Dremio Software:
- Dremio Cloud: Yes

Relevant log output

No response

ravjotbrar commented 1 year ago

Closing as this is not an issue.