diff --git a/.github/workflows/integration-tests-azure.yml b/.github/workflows/integration-tests-azure.yml index dfad12d..bbeed0e 100644 --- a/.github/workflows/integration-tests-azure.yml +++ b/.github/workflows/integration-tests-azure.yml @@ -3,7 +3,7 @@ on: # yamllint disable-line rule:truthy workflow_dispatch: pull_request: branches: - - oidc_connect + - main jobs: integration-tests-fabric-dw: diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index c0a88e8..4ac4004 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -9,7 +9,6 @@ on: # yamllint disable-line rule:truthy branches: - main - v* - - oidc_connect jobs: publish-docker-client: diff --git a/dbt/include/fabric/macros/adapters/show.sql b/dbt/include/fabric/macros/adapters/show.sql index 205fa1f..7b3340e 100644 --- a/dbt/include/fabric/macros/adapters/show.sql +++ b/dbt/include/fabric/macros/adapters/show.sql @@ -1,24 +1,16 @@ {% macro fabric__get_limit_sql(sql, limit) %} {% if limit == -1 or limit is none %} - {% if sql.strip().lower().startswith('with') %} + with model_limit_subq as ( {{ sql }} - {% else -%} - select * - from ( - {{ sql }} - ) as model_limit_subq - {%- endif -%} + ) + select * + from model_limit_subq; {% else -%} - {% if sql.strip().lower().startswith('with') %} - {{ sql }} order by (select null) - offset 0 rows fetch first {{ limit }} rows only - {% else -%} - select * - from ( - {{ sql }} - ) as model_limit_subq order by (select null) - offset 0 rows fetch first {{ limit }} rows only - {%- endif -%} + with model_limit_subq as ( + {{ sql }} + ) + select top {{ limit }} * + from model_limit_subq; {%- endif -%} {% endmacro %} diff --git a/dbt/include/fabric/macros/materializations/models/table/table.sql b/dbt/include/fabric/macros/materializations/models/table/table.sql index 4eb1f4a..6964013 100644 --- a/dbt/include/fabric/macros/materializations/models/table/table.sql +++ b/dbt/include/fabric/macros/materializations/models/table/table.sql @@ -35,20 +35,25 @@ {% if existing_relation is not none and existing_relation.is_table %} - -- making a backup relation, this will come in use when contract is enforced or not - {%- set backup_relation = make_backup_relation(existing_relation, 'table') -%} + -- making a backup relation, this will come in use when contract is enforced or not + {%- set set_backup_relation = adapter.get_relation(database=this.database, schema=this.schema, identifier=this.identifier) -%} + {% if (set_backup_relation != none and set_backup_relation.type == "table") %} + {%- set backup_relation = make_backup_relation(target_relation, 'table') -%} + {% elif (set_backup_relation != none and set_backup_relation.type == "view") %} + {%- set backup_relation = make_backup_relation(target_relation, 'view') -%} + {% endif %} - -- Dropping a temp relation if it exists - {{ adapter.drop_relation(backup_relation) }} + -- Dropping a temp relation if it exists + {{ adapter.drop_relation(backup_relation) }} - -- Rename existing relation to back up relation - {{ adapter.rename_relation(existing_relation, backup_relation) }} + -- Rename existing relation to back up relation + {{ adapter.rename_relation(existing_relation, backup_relation) }} - -- Renaming temp relation as main relation - {{ adapter.rename_relation(temp_relation, target_relation) }} + -- Renaming temp relation as main relation + {{ adapter.rename_relation(temp_relation, target_relation) }} - -- Drop backup relation - {{ adapter.drop_relation(backup_relation) }} + -- Drop backup relation + {{ adapter.drop_relation(backup_relation) }} {%- else %} diff --git a/tests/conftest.py b/tests/conftest.py index adbcbb0..ecb2e67 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -94,13 +94,10 @@ def _profile_user_azure(): **_all_profiles_base(), **{ "host": os.getenv("FABRIC_TEST_HOST"), - "authentication": os.getenv("FABRIC_TEST_AUTH", "auto"), + "authentication": os.getenv("FABRIC_TEST_AUTH", "CLI"), "encrypt": True, "trust_cert": True, "database": os.getenv("FABRIC_TEST_DBNAME"), - "client_id": os.getenv("FABRIC_TEST_CLIENT_ID"), - "client_secret": os.getenv("FABRIC_TEST_CLIENT_SECRET"), - "tenant_id": os.getenv("FABRIC_TEST_TENANT_ID"), }, } return profile