Default values
Emulation context
In Microsoft SQL Server, columns can be assigned default values using the DEFAULT
keyword in a CREATE TABLE
or ALTER TABLE
statement. These defaults are automatically applied when an INSERT
operation omits a value for that column. Common use cases include assigning timestamps (GETDATE()
), default statuses ('Active'
), or generating identifiers (NEWID()
).
For example:
In Fabric Warehouse, column-level default constraints are not supported. The DEFAULT
keyword in table definitions is not honored, and values are not auto-generated during insert unless explicitly provided. This creates a compatibility gap where logic relying on implicit defaults must be rewritten or made explicit.
Emulation strategy
SQL Tran emulates default values by rewriting INSERT
statements that depend on implicit defaults into versions that explicitly supply those values. The emulation process includes:
Removing
DEFAULT
expressions from table definitions. SQL Tran comments out default constraints using/* SQLTRAN FIX: DEFAULT ... */
.Preserving the column structure but stripping unsupported features such as
ROWGUIDCOL
.Rewriting
INSERT
statements that omit defaultable columns by injecting the literal or function values directly (e.g.,GETDATE()
,'Active'
,NEWID()
).Retaining explicit uses of the
DEFAULT
keyword inINSERT ... VALUES
statements when syntactically valid.Expanding
INSERT INTO ... DEFAULT VALUES
into a full column list with literal defaults, when possible.
This transformation ensures that data insertion behavior remains consistent with SQL Server, even though Fabric does not support implicit default application.
Code example
SQL Server:
Fabric Warehouse (generated by SQL Tran):
Important notes
Table defaults not supported: Fabric does not support column-level
DEFAULT
constraints. SQL Tran removes them during translation, preserving the original logic through comment annotations.No impact on updates: Default values apply only during
INSERT
. Updates never trigger default expressions in either SQL Server or Fabric. SQL Tran does not alter update logic in this context.DEFAULT
keyword compatibility: SQL Tran retains use of theDEFAULT
keyword inINSERT
statements when present in the source. In Fabric, this keyword is accepted and inserts the implicit default value for the column data type (e.g.,NULL
for most types), since Fabric does not support default constraints.DEFAULT VALUES
transformed: SQL Tran rewritesINSERT INTO ... DEFAULT VALUES
into a form with explicit column names and manually applied defaults. This avoids runtime failure due to missing required values.Defaults during external data ingestion: When ingesting data using Fabric-supported tools, default expressions defined in the target table schema are not automatically applied. If default values are required, they must be added explicitly as part of the ingestion logic.
Manual review recommended: All logic that previously relied on automatic default assignment should be reviewed to ensure correctness in the translated output and external ingestion processes.
Last updated