Edit

Share via


Get started with materialized lake views

In this article, you learn how to get started with materialized lake views by creating one in a Microsoft Fabric lakehouse.

Prerequisites

Create your first materialized lake view

  1. Go to your lakehouse and select Manage materialized lake views.

    Screenshot that shows the menu item for managing materialized lake views.

  2. Select New materialized lake view, and then select New notebook.

    Screenshot of selections for opening a new notebook to create a materialized lake view.

    A new notebook opens.

    Screenshot that shows a notebook template to create a materialized lake view.

  3. Create the sample source tables products and orders. Run the following commands in the notebook:

       CREATE SCHEMA IF NOT EXISTS bronze;
    
       CREATE TABLE IF NOT EXISTS bronze.products (
        product_id INT,
        product_name STRING,
        price DOUBLE
       );
    
       INSERT INTO bronze.products VALUES
       (101, 'Laptop', 1200.50),
       (102, 'Smartphone', 699.99),
       (103, 'Tablet', 450.00);
    
    
       CREATE TABLE IF NOT EXISTS bronze.orders (
         order_id INT,
         product_id INT,
         quantity INT,
         order_date DATE
        );
       INSERT INTO bronze.orders VALUES
        (1001, 101, 2, '2025-06-01'),
        (1002, 103, 1, '2025-06-02'),
        (1003, 102, 3, '2025-06-03');
    
  4. Create materialized lake views by using the source tables. Run the following commands in the notebook:

       CREATE SCHEMA IF NOT EXISTS SILVER;
    
       CREATE MATERIALIZED LAKE VIEW IF NOT EXISTS silver.cleaned_order_data AS
       SELECT 
           o.order_id,
           o.order_date,
           o.product_id,
           p.product_name,
           o.quantity,
           p.price,
           o.quantity * p.price AS revenue
       FROM bronze.orders o
       JOIN bronze.products p
       ON o.product_id = p.product_id;
    
       CREATE SCHEMA IF NOT EXISTS GOLD;
    
       CREATE MATERIALIZED LAKE VIEW IF NOT EXISTS gold.product_sales_summary AS
       SELECT
           product_id,
           product_name,
           SUM(quantity) AS total_quantity_sold,
           SUM(revenue) AS total_revenue,
           ROUND(AVG(revenue), 2) AS average_order_value
       FROM
           silver.cleaned_order_data
       GROUP BY
           product_id,
           product_name;
    
  5. Open the lakehouse explorer to view all created tables and materialized lake views.

    Screenshot that shows materialized lake views created in a lakehouse.

  6. In your lakehouse, go to Manage materialized lake views to view the autogenerated lineage.

    Screenshot that shows lineage.

  7. Schedule the lineage execution.

    Screenshot of the pane for scheduling lineage.

  8. Select the ongoing run to monitor progress after the schedule starts.

    Screenshot that shows the progress of an ongoing run.

  9. After the run succeeds, the status of the lineage is Completed.

    Screenshot that shows a completed lineage run.