Skip to content

Fabric/T-SQL: temp table cleanup DROP does not run (no adapter variant of get_clean_elementary_test_tables_queries) #1029

Description

@tderk

Adapter

dbt-fabric (Microsoft Fabric Warehouse); the same applies to dbt-sqlserver.

Summary

Even when per-test temp tables are registered for cleanup, the on-run-end DROP does not remove them on Fabric.

Root cause

get_clean_elementary_test_tables_queries (macros/edr/tests/test_utils/clean_elementary_test_tables.sql) has no fabric__/sqlserver__ variant, so Fabric falls back to default__get_transaction_clean_elementary_test_tables_queries:

BEGIN TRANSACTION;
DROP TABLE IF EXISTS [db].[schema].[table];   -- 3-part name
COMMIT;

On Fabric this does not drop the tables:

  • DDL must run in the owning database's context; a cross-DB 3-part DROP is not honoured when the elementary schema lives in a different database than the connection.
  • wrapping DDL in BEGIN TRANSACTION / COMMIT is unreliable on Fabric Warehouse.

This also prevents the registration fix in #1008 from having any effect.

Expected

A fabric__/sqlserver__get_clean_elementary_test_tables_queries that drops each relation in its own DB context without a transaction wrapper, e.g. EXEC [<db>]..sp_executesql N'drop table if exists [<schema>].[<id>]'.

Repro

Register a test temp table for cleanup and run on Fabric; the table remains after on-run-end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions