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

V1.8.8 draft #251

Merged
merged 57 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
99e45af
Testing OIDC
prdpsvs Nov 22, 2024
e5a6425
Testing OIDC
prdpsvs Nov 22, 2024
193819e
Testing OIDC
prdpsvs Nov 22, 2024
8a37a3d
Testing OIDC
prdpsvs Nov 23, 2024
0f23143
Testing OIDC
prdpsvs Nov 23, 2024
5c016f9
Testing OIDC
prdpsvs Nov 23, 2024
70d7d7a
Testing OIDC
prdpsvs Nov 23, 2024
0e37adb
Testing OIDC
prdpsvs Nov 23, 2024
a8408c1
Testing OIDC
prdpsvs Nov 23, 2024
5b02613
Testing OIDC
prdpsvs Nov 23, 2024
abef333
Testing OIDC
prdpsvs Nov 23, 2024
28eacc1
Testing OIDC
prdpsvs Nov 23, 2024
b438c4a
Testing OIDC
prdpsvs Nov 23, 2024
836c945
Testing OIDC
prdpsvs Nov 23, 2024
3fe221c
Testing OIDC
prdpsvs Nov 23, 2024
a798983
Testing OIDC
prdpsvs Nov 23, 2024
cc9827b
Testing OIDC
prdpsvs Nov 23, 2024
93ca65e
Testing OIDC
prdpsvs Nov 23, 2024
f093217
Testing OIDC
prdpsvs Nov 23, 2024
ef96e1a
Testing OIDC
prdpsvs Nov 23, 2024
15f3c7d
Testing OIDC
prdpsvs Nov 23, 2024
7dbc8a7
Testing OIDC
prdpsvs Nov 23, 2024
a3bf019
Testing OIDC
prdpsvs Nov 23, 2024
955a2f5
Testing OIDC
prdpsvs Nov 23, 2024
5b32d43
Testing OIDC
prdpsvs Nov 23, 2024
0a39666
Testing OIDC
prdpsvs Nov 23, 2024
5825ed2
Testing OIDC
prdpsvs Nov 23, 2024
30c23d7
Testing OIDC
prdpsvs Nov 23, 2024
b66838f
Testing OIDC
prdpsvs Nov 25, 2024
09480c4
Testing OIDC
prdpsvs Nov 25, 2024
050b35b
Testing OIDC
prdpsvs Nov 25, 2024
0961457
Testing OIDC
prdpsvs Nov 25, 2024
3d65834
Testing OIDC
prdpsvs Nov 25, 2024
3cf4060
Testing OIDC
prdpsvs Nov 25, 2024
aa37756
Testing OIDC
prdpsvs Nov 25, 2024
64e1a50
Testing OIDC
prdpsvs Nov 25, 2024
35491f1
Testing OIDC
prdpsvs Nov 25, 2024
3baeb4d
Testing OIDC
prdpsvs Nov 25, 2024
9cb00eb
Testing OIDC
prdpsvs Nov 25, 2024
fbe564d
Testing OIDC
prdpsvs Nov 25, 2024
46f0559
Testing OIDC
prdpsvs Nov 26, 2024
c86e466
Testing OIDC
prdpsvs Nov 26, 2024
6b3115f
Testing OIDC
prdpsvs Nov 26, 2024
6a5c076
Testing OIDC
prdpsvs Nov 26, 2024
61eb419
Testing OIDC
prdpsvs Nov 26, 2024
4e738e6
Testing OIDC
prdpsvs Nov 26, 2024
a650d99
Testing OIDC
prdpsvs Nov 26, 2024
9c85649
configuring local tests to run on user credentials. Dropping a relati…
prdpsvs Nov 27, 2024
19ff404
Addressing #243, #221, #228, #229, #232, #235 issues
prdpsvs Nov 28, 2024
bdb4b81
Updated test helper with ephemeral
prdpsvs Dec 1, 2024
899a990
Updated unit tests
prdpsvs Dec 1, 2024
4d94cdd
Updated get_pyodbc_attrs_before_credentials method
prdpsvs Dec 1, 2024
dd918ed
include only lines that start with order by
prdpsvs Dec 1, 2024
3725fcb
Addressed issue #249,#240,#238,#233,#180,#168,#186,#52
prdpsvs Dec 23, 2024
f0ffd7d
Ensure Testview Name Uniqueness with MD5 of Model Name and Invocation
prdpsvs Dec 23, 2024
9428022
Updating integration tests
prdpsvs Dec 23, 2024
ae81110
Merge branch 'main' into v1.8.8-draft
prdpsvs Dec 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/integration-tests-azure.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Integration tests on Fabric DW
on: # yamllint disable-line rule:truthy
workflow_dispatch:
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/fabric/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "1.8.8"
version = "1.8.9"
3 changes: 3 additions & 0 deletions dbt/adapters/fabric/fabric_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ def get_rows_different_sql(
names = sorted((self.quote(n) for n in column_names))
columns_csv = ", ".join(names)

if columns_csv == "":
columns_csv = "*"

sql = COLUMNS_EQUAL_SQL.format(
columns=columns_csv,
relation_a=str(relation_a),
Expand Down
8 changes: 5 additions & 3 deletions dbt/adapters/fabric/fabric_connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ def open(cls, connection: Connection) -> Connection:
con_str.append(f"SERVER={credentials.host}")

con_str.append(f"Database={credentials.database}")
con_str.append("Pooling=true")

# Enabling trace flag
if credentials.trace_flag:
Expand Down Expand Up @@ -395,8 +396,8 @@ def open(cls, connection: Connection) -> Connection:
con_str.append(f"APP={application_name}")

try:
if int(credentials.retries) > 0:
con_str.append(f"ConnectRetryCount={credentials.retries}")
con_str.append("ConnectRetryCount=3")
con_str.append("ConnectRetryInterval=10")

except Exception as e:
logger.debug(
Expand Down Expand Up @@ -427,7 +428,7 @@ def open(cls, connection: Connection) -> Connection:

def connect():
logger.debug(f"Using connection string: {con_str_display}")

pyodbc.pooling = True
if credentials.authentication == "ActiveDirectoryAccessToken":
attrs_before = get_pyodbc_attrs_before_accesstoken(credentials.access_token)
else:
Expand Down Expand Up @@ -567,3 +568,4 @@ def execute(
while cursor.nextset():
pass
return response, table

2 changes: 1 addition & 1 deletion dbt/adapters/fabric/fabric_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FabricCredentials(Credentials):
authentication: Optional[str] = "ActiveDirectoryServicePrincipal"
encrypt: Optional[bool] = True # default value in MS ODBC Driver 18 as well
trust_cert: Optional[bool] = False # default value in MS ODBC Driver 18 as well
retries: int = 1
retries: int = 3
schema_authorization: Optional[str] = None
login_timeout: Optional[int] = 0
query_timeout: Optional[int] = 0
Expand Down
260 changes: 135 additions & 125 deletions dbt/include/fabric/macros/adapters/catalog.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% macro fabric__get_catalog(information_schemas, schemas) -%}

{% set query_label = apply_label() %}
{%- call statement('catalog', fetch_result=True) -%}

Expand Down Expand Up @@ -126,144 +127,153 @@
{%- endmacro %}

{% macro fabric__get_catalog_relations(information_schema, relations) -%}

{% set query_label = apply_label() %}
{%- call statement('catalog', fetch_result=True) -%}
{%- set distinct_databases = relations | map(attribute='database') | unique | list -%}

with
principals as (
select
name as principal_name,
principal_id as principal_id
from
sys.database_principals {{ information_schema_hints() }}
),
{%- if distinct_databases | length == 1 -%}
{%- call statement('catalog', fetch_result=True) -%}
{{ get_use_database_sql(distinct_databases[0]) }}
with
principals as (
select
name as principal_name,
principal_id as principal_id
from
sys.database_principals {{ information_schema_hints() }}
),

schemas as (
select
name as schema_name,
schema_id as schema_id,
principal_id as principal_id
from
sys.schemas {{ information_schema_hints() }}
),
schemas as (
select
name as schema_name,
schema_id as schema_id,
principal_id as principal_id
from
sys.schemas {{ information_schema_hints() }}
),

tables as (
select
object_id,
name as table_name,
schema_id as schema_id,
principal_id as principal_id,
'BASE TABLE' as table_type
from
sys.tables {{ information_schema_hints() }}
),
tables as (
select
object_id,
name as table_name,
schema_id as schema_id,
principal_id as principal_id,
'BASE TABLE' as table_type
from
sys.tables {{ information_schema_hints() }}
),

tables_with_metadata as (
select
object_id,
table_name,
schema_name,
coalesce(tables.principal_id, schemas.principal_id) as owner_principal_id,
table_type
from
tables
join schemas on tables.schema_id = schemas.schema_id
),
tables_with_metadata as (
select
object_id,
table_name,
schema_name,
coalesce(tables.principal_id, schemas.principal_id) as owner_principal_id,
table_type
from
tables
join schemas on tables.schema_id = schemas.schema_id
),

views as (
select
object_id,
name as table_name,
schema_id as schema_id,
principal_id as principal_id,
'VIEW' as table_type
from
sys.views {{ information_schema_hints() }}
),
views as (
select
object_id,
name as table_name,
schema_id as schema_id,
principal_id as principal_id,
'VIEW' as table_type
from
sys.views {{ information_schema_hints() }}
),

views_with_metadata as (
select
object_id,
table_name,
schema_name,
coalesce(views.principal_id, schemas.principal_id) as owner_principal_id,
table_type
from
views
join schemas on views.schema_id = schemas.schema_id
),
views_with_metadata as (
select
object_id,
table_name,
schema_name,
coalesce(views.principal_id, schemas.principal_id) as owner_principal_id,
table_type
from
views
join schemas on views.schema_id = schemas.schema_id
),

tables_and_views as (
select
object_id,
table_name,
schema_name,
principal_name,
table_type
from
tables_with_metadata
join principals on tables_with_metadata.owner_principal_id = principals.principal_id
union all
select
object_id,
table_name,
schema_name,
principal_name,
table_type
from
views_with_metadata
join principals on views_with_metadata.owner_principal_id = principals.principal_id
),
tables_and_views as (
select
object_id,
table_name,
schema_name,
principal_name,
table_type
from
tables_with_metadata
join principals on tables_with_metadata.owner_principal_id = principals.principal_id
union all
select
object_id,
table_name,
schema_name,
principal_name,
table_type
from
views_with_metadata
join principals on views_with_metadata.owner_principal_id = principals.principal_id
),

cols as (
cols as (

select
c.object_id,
c.name as column_name,
c.column_id as column_index,
t.name as column_type
from sys.columns as c {{ information_schema_hints() }}
left join sys.types as t on c.system_type_id = t.system_type_id
)
select
c.object_id,
c.name as column_name,
c.column_id as column_index,
t.name as column_type
from sys.columns as c {{ information_schema_hints() }}
left join sys.types as t on c.system_type_id = t.system_type_id
)

select
DB_NAME() as table_database,
tv.schema_name as table_schema,
tv.table_name,
tv.table_type,
null as table_comment,
tv.principal_name as table_owner,
cols.column_name,
cols.column_index,
cols.column_type,
null as column_comment
from tables_and_views tv
join cols on tv.object_id = cols.object_id
where (
{%- for relation in relations -%}
{% if relation.schema and relation.identifier %}
(
upper(tv.schema_name) = upper('{{ relation.schema }}')
and upper(tv.table_name) = upper('{{ relation.identifier }}')
)
{% elif relation.schema %}
(
upper(tv.schema_name) = upper('{{ relation.schema }}')
)
{% else %}
{% do exceptions.raise_compiler_error(
'`get_catalog_relations` requires a list of relations, each with a schema'
) %}
{% endif %}
select
DB_NAME() as table_database,
tv.schema_name as table_schema,
tv.table_name,
tv.table_type,
null as table_comment,
tv.principal_name as table_owner,
cols.column_name,
cols.column_index,
cols.column_type,
null as column_comment
from tables_and_views tv
join cols on tv.object_id = cols.object_id
where (
{%- for relation in relations -%}
{% if relation.schema and relation.identifier %}
(
upper(tv.schema_name) = upper('{{ relation.schema }}')
and upper(tv.table_name) = upper('{{ relation.identifier }}')
)
{% elif relation.schema %}
(
upper(tv.schema_name) = upper('{{ relation.schema }}')
)
{% else %}
{% do exceptions.raise_compiler_error(
'`get_catalog_relations` requires a list of relations, each with a schema'
) %}
{% endif %}

{%- if not loop.last %} or {% endif -%}
{%- endfor -%}
)
{%- if not loop.last %} or {% endif -%}
{%- endfor -%}
)

order by column_index
{{ query_label }}
{%- endcall -%}
order by column_index
{{ query_label }}

{{ return(load_result('catalog').table) }}
{%- endcall -%}
{{ return(load_result('catalog').table) }}
{% else %}
{% do exceptions.raise_compiler_error(
'`get_catalog_relations` can catalog one database at a time'
) %}
{% endif %}

{%- endmacro %}
3 changes: 2 additions & 1 deletion dbt/include/fabric/macros/adapters/metadata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
{% endmacro %}

{%- macro fabric__get_use_database_sql(database) -%}
USE [{{database}}];
USE [{{database | replace('"', '')}}];
{%- endmacro -%}

{% macro fabric__list_schemas(database) %}
{% call statement('list_schemas', fetch_result=True, auto_begin=False) -%}
{{ get_use_database_sql(database) }}
select name as [schema]
from sys.schemas {{ information_schema_hints() }} {{ apply_label() }}
{% endcall %}
Expand Down
3 changes: 2 additions & 1 deletion dbt/include/fabric/macros/adapters/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
{%- endfor %}

{% call statement('drop_schema') -%}
EXEC('DROP SCHEMA IF EXISTS {{ relation.schema }}')
{{ get_use_database_sql(relation.database) }}
EXEC('DROP SCHEMA IF EXISTS {{ relation.schema }}')
{% endcall %}
{% endmacro %}
Loading
Loading