Skip to content

fix(fabric): widen tinyint integer precision to smallint - #4307

Open
sdebruyn wants to merge 1 commit into
dlt-hub:develfrom
sdebruyn:fix/4306-fabric-tinyint-smallint
Open

fix(fabric): widen tinyint integer precision to smallint#4307
sdebruyn wants to merge 1 commit into
dlt-hub:develfrom
sdebruyn:fix/4306-fabric-tinyint-smallint

Conversation

@sdebruyn

@sdebruyn sdebruyn commented Aug 4, 2026

Copy link
Copy Markdown

Fixes #4306

Summary

  • Override to_db_integer_type in FabricTypeMapper so a bigint column with precision <= 8 maps to smallint instead of tinyint
  • Copy the column before adjusting it, so the widening does not leak back into the caller's schema

Root cause

Fabric Warehouse has no tinyint; smallint is its narrowest integer type. sql_database reflects a SQL Server TINYINT as dlt type bigint with precision=8, and MsSqlTypeMapper.to_db_integer_type maps that to tinyint. FabricTypeMapper inherits that through SynapseTypeMapper and previously overrode only the datetime and string mappings, so CREATE TABLE failed with a DatabaseTerminalException. Being terminal, the load was not retried and every subsequent run failed on the same table.

Widening is safe: TINYINT values (0-255) all fit in smallint. Nothing changes for mssql or synapse, where tinyint is valid.

Test plan

  • Added test_fabric_type_mapper_integer_precision, parametrized over no precision, 8, 16, 32 and 64, asserting bigint, smallint, smallint, int, bigint. It also asserts the input column is left untouched.
  • Verified on devel before the change that precision 8 yields tinyint, so the test is a real regression guard.
  • tests/load/fabric: 20 passed, 1 skipped (the table builder module skips without an ODBC driver).
  • mypy, ruff, flake8 (including the docstring pass over impl/**/factory.py) and black all clean.

@anuunchin
anuunchin self-requested a review August 7, 2026 13:30
@anuunchin anuunchin self-assigned this Aug 7, 2026
@sdebruyn
sdebruyn force-pushed the fix/4306-fabric-tinyint-smallint branch from 4fbc676 to c563cc9 Compare August 13, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(fabric): TINYINT source columns emit unsupported tinyint DDL and fail the load step

2 participants