Skip to content

Commit

Permalink
configuring local tests to run on user credentials. Dropping a relati…
Browse files Browse the repository at this point in the history
…on correctly based on its type
  • Loading branch information
prdpsvs committed Nov 27, 2024
1 parent a650d99 commit 9c85649
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests-azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: # yamllint disable-line rule:truthy
workflow_dispatch:
pull_request:
branches:
- oidc_connect
- main

jobs:
integration-tests-fabric-dw:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on: # yamllint disable-line rule:truthy
branches:
- main
- v*
- oidc_connect

jobs:
publish-docker-client:
Expand Down
26 changes: 9 additions & 17 deletions dbt/include/fabric/macros/adapters/show.sql
Original file line number Diff line number Diff line change
@@ -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 %}
25 changes: 15 additions & 10 deletions dbt/include/fabric/macros/materializations/models/table/table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}

Expand Down
5 changes: 1 addition & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9c85649

Please sign in to comment.