SQL Tran Docs
  • Overview
    • About
    • Getting started
    • Object lifecycle
    • Why is there no AI inside?
    • Performance considerations
    • Security considerations
    • Assessment
    • Unlocking projects
    • Interface walk-through
    • Translation scenarios
    • Prerequisites for Azure Marketplace deployment
  • Emulation scenarios
    • Emulation in SQL Tran
    • SQL Server to Fabric Warehouse
      • Data types
      • Case sensitivity
      • Cursors
        • Basic cursor loop
        • Cursor types
        • Fetch direction modes
        • Cursors in control flow
        • Nested cursors
        • Data modification cursors
        • Multiple cursors
        • Subqueries and filtering
      • Named procedure parameters
      • Result set limiting
      • MERGE statements
      • Computed columns
      • Temporary tables
      • External tables
      • Identity columns
      • Default values
      • Sequences
      • Unsupported system features
    • Synapse Analytics to Fabric Warehouse
      • Data types
      • Case sensitivity
      • Named procedure parameters
      • Result set limiting
      • MERGE statements
      • Temporary tables
      • External tables
      • Identity columns
      • Default values
      • Materialized views
      • Create table as select (CTAS)
      • Unsupported system features
    • SQL Server to Synapse Analytics
    • Oracle to PostgreSQL
  • Project wizard
    • Source database
    • Target database
    • Wrapping up
  • Projects
    • Project list
    • Overview
    • Workspace
    • Reports
    • Tests
    • Scratch pad
    • Settings
      • Project name
      • Mapping
      • Database connections
    • Navigation
    • Object complexity
    • Static analysis
    • Translation errors
    • Exporting and importing projects
  • Workspace
    • Object tree
    • Data lineage
    • Code
    • Actions
      • Overriding source
      • Overriding target
      • Ignoring objects
  • Tests
    • Workflow
    • Configure SQL Tran
    • Connecting to databases
      • Fabric Warehouse
      • Synapse Dedicated SQL Pool
      • Azure SQL Database, Azure SQL Managed Instance, Microsoft SQL Server
    • Tables
    • Views
    • Procedures
    • Functions
    • Triggers
    • Performance tests
  • Scripter
    • About
    • Supported databases
    • SQL Server
    • Azure SQL
    • Synapse Dedicated Pool
    • Oracle
    • PostgreSQL
    • MySQL
  • Microsoft training - SQL Tran
    • Introduction
    • Licensing plans
    • Deploying and activating
    • Creating a new project
    • Exploring the "Overview" screen
Powered by GitBook
On this page
  • Emulation context
  • Emulation strategy
  • Code example
  • Important notes
  1. Emulation scenarios
  2. Synapse Analytics to Fabric Warehouse

Materialized views

Emulation context

In Azure Synapse Analytics (dedicated SQL pools), materialized views are used to persist the results of a query for performance optimization. They are defined using the CREATE MATERIALIZED VIEW syntax and typically include a WITH clause specifying a distribution strategy (e.g., ROUND_ROBIN, HASH(column)).

For example:

CREATE MATERIALIZED VIEW QueueStats
WITH (DISTRIBUTION = ROUND_ROBIN)
AS
SELECT
    QueueID,
    COUNT(*) AS QueueLength
FROM ServiceQueue
GROUP BY QueueID;

Materialized views in Synapse:

  • Improve query performance by storing precomputed results.

  • Automatically update when underlying tables change.

  • Support features like aggregation, filtering, and window functions.

Materialized views in Synapse must also follow specific restrictions:

  • The query must include at least one aggregate or a GROUP BY.

  • Views cannot reference other views.

  • Certain aggregate functions such as COUNT(DISTINCT ...) are not supported.

  • Only HASH and ROUND_ROBIN distribution strategies are allowed.

However, Microsoft Fabric Warehouse does not support materialized views. Fabric only supports logical views (CREATE VIEW) and does not persist query results or maintain physical storage for view outputs. There is no equivalent to CREATE MATERIALIZED VIEW in Fabric SQL.


Emulation strategy

SQL Tran does not attempt to emulate materialized views in Fabric. Instead, it performs the following:

  • Converts CREATE MATERIALIZED VIEW into CREATE VIEW, preserving the original view definition.

  • Comments out the MATERIALIZED keyword and any WITH (DISTRIBUTION = ...) clause using /* SQLTRAN FIX */.

  • Preserves all query logic, including aggregations, joins, filtering, DISTINCT, TOP, ORDER BY, window functions, subqueries, and nested aggregates.

  • Adds /* SQLTRAN FIX: Subquery */ to nested queries to flag complex constructs.

  • Retains references to other views, even though these are not allowed in Synapse materialized views.

  • Does not emit diagnostics or warnings about the lack of persistence or refresh behavior in Fabric.

This approach ensures that translated views remain syntactically valid and reflect the original query logic, while signaling the unsupported materialization feature through comments. The actual behavior of query result caching or automatic refresh is not replicated.


Code example

Synapse Analytics:

CREATE MATERIALIZED VIEW SalesSummary
WITH (
	DISTRIBUTION = ROUND_ROBIN
)
AS
SELECT
	SalesPersonID,
	SUM(TotalDue) AS TotalSales,
	COUNT_BIG(*) AS NumberOfOrders
FROM Sales.SalesOrderHeader
GROUP BY SalesPersonID;

Fabric Warehouse (generated by SQL Tran):

CREATE /* SQLTRAN FIX: MATERIALIZED */ VIEW SalesSummary
/* SQLTRAN FIX: WITH (
	DISTRIBUTION = ROUND_ROBIN
) */
AS
SELECT
	SalesPersonID,
	SUM(TotalDue) AS TotalSales,
	COUNT_BIG(*) AS NumberOfOrders
FROM Sales.SalesOrderHeader
GROUP BY SalesPersonID;

Important notes

  • Materialization is not preserved: Fabric views do not store query results. Translated views must be considered logical only, and no performance benefit from materialization is retained.

  • Optimizer substitution not preserved: In Synapse, the optimizer may automatically substitute a materialized view during query execution. This behavior does not exist in Fabric. Queries must explicitly reference any precomputed logic if needed.

  • Distribution clause is removed: The WITH (DISTRIBUTION = ...) metadata is commented out because Fabric does not support specifying distribution on views.

  • Query logic fully preserved: SQL Tran retains all constructs inside the view body:

    • GROUP BY, COUNT_BIG, SUM, JOIN

    • DISTINCT

    • TOP and ORDER BY

    • Window functions (RANK(), DENSE_RANK())

    • Subqueries and nested aggregates

  • Subqueries flagged for traceability: SQL Tran adds /* SQLTRAN FIX: Subquery */ to subqueries in FROM clauses to indicate nesting. These annotations are informational and may help users identify areas for optimization.

  • No refresh behavior: Materialized views in Synapse are automatically refreshed when the base tables change. In Fabric, views are re-evaluated on each execution and do not persist data between queries.

  • Manual optimization required: Users may need to manually replicate materialized view functionality using CTAS (Create Table As Select) patterns or scheduled refresh logic if persistent precomputed data is needed.

  • Manual review recommended: Queries relying on precomputed performance should be manually evaluated to determine if alternative mechanisms (e.g., preloading, ETL staging) are needed in Fabric.

PreviousDefault valuesNextCreate table as select (CTAS)

Last updated 18 days ago

Materialized view emulation in SQL Tran