Skip to content

Bug: Fabric create_external_table macro references columns.tests instead of column.tests #407

Description

@arijitroy003

Description

In macros/plugins/fabric/create_external_table.sql, the nullity check on line 12 references columns.tests (the entire collection) instead of column.tests (the current loop variable). This causes all columns to receive identical nullity settings regardless of their individual test configurations.

Current behavior

{% for column in columns %}
    {%- set nullity = 'NOT NULL' if 'not_null' in columns.tests else 'NULL'-%}

The columns variable is the full source_node.columns.values() collection. Checking columns.tests evaluates the same value on every loop iteration, so every column gets the same NOT NULL or NULL designation.

Expected behavior

{% for column in columns %}
    {%- set nullity = 'NOT NULL' if 'not_null' in column.tests else 'NULL'-%}

The check should reference column.tests (the individual loop variable) so each column's nullity is determined by its own test configuration.

Steps to reproduce

  1. Define a Fabric external source with multiple columns
  2. Add a not_null test to only one column
  3. Run dbt run-operation stage_external_sources
  4. Observe that all columns get NOT NULL (or all get NULL), rather than only the tested column

Environment

  • dbt-external-tables (main branch)
  • Adapter: Fabric

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions