Tutorial: Analyze data in a notebook

Applies to: ✅ SQL analytics endpoint and Warehouse in Microsoft Fabric

In this tutorial, learn how to analyze data with notebooks in a Warehouse.

Note

This tutorial forms part of an end-to-end scenario. In order to complete this tutorial, you must first complete these tutorials:

  1. Create a workspace
  2. Create a Warehouse
  3. Ingest data into a Warehouse

Create a T-SQL notebook

In this task, learn how to create a T-SQL notebook.

  1. Ensure that the workspace you created in the first tutorial is open.

  2. On the Home ribbon, open the New SQL query dropdown, and then select New SQL query in notebook.

    Screenshot of the New SQL query in notebook option on the ribbon.

  3. In the Explorer pane, select Warehouses to reveal the objects of the Wide World Importers warehouse.

  4. To generate a SQL template to explore data, to the right of the dimension_city table, select the ellipsis (…), and then select SELECT TOP 100.

    Screenshot of Explorer pane, highlighting the selection of the SELECT TOP 100 option.

  5. To run the T-SQL code in this cell, select the Run cell button for the code cell.

    Screenshot of the notebook, highlighting the Run cell button for the code cell.

  6. Review the query result in the results pane.

Create a lakehouse shortcut and analyze data with a notebook

In this task, learn how to create a lakehouse shortcut and analyze data with a notebook.

  1. Open the Data Warehouse Tutorial workspace landing page.

  2. Select + New Item to display the full list of available item types.

  3. From the list, in the Store data section, select the Lakehouse item type.

  4. In the New lakehouse window, enter the name Shortcut_Exercise.

    Screenshot of the New lakehouse window, highlighting the entered name.

  5. Select Create.

  6. When the new lakehouse opens, in the landing page, select the New shortcut option.

    Screenshot of lakehouse landing page, highlighting the New shortcut button.

  7. In the New shortcut window, select the Microsoft OneLake option.

    Screenshot of the New shortcut window, highlighting the Microsoft OneLake internal source.

  8. In the Select a data source type window, select the Wide World Importers warehouse that you created in the Create a Warehouse tutorial, and then select Next.

  9. In the OneLake object browser, expand Tables, expand the dbo schema, and then select the checkbox for the dimension_customer table.

    Screenshot of the New shortcut window, highlighting the selection of the dimension customer table.

  10. Select Next.

  11. Select Create.

  12. In the Explorer pane, select the dimension_customer table to preview the data, and then review the data retrieved from the dimension_customer table in the warehouse.

  13. To create a notebook to query the dimension_customer table, on the Home ribbon, in the Open notebook dropdown, select New notebook.

    Screenshot of the New notebook option on the ribbon.

  14. In the Explorer pane, select Lakehouses.

  15. Drag the dimension_customer table to the open notebook cell.

    Screenshot of the Explorer pane, highlighting the dimension customer table drag to the notebook cell.

  16. Notice the PySpark query that was added to the notebook cell. This query retrieves the first 1,000 rows from the Shortcut_Exercise.dimension_customer shortcut. This notebook experience is similar to Visual Studio Code Jupyter notebook experience. You can also open the notebook in VS Code.

    Screenshot of the notebook query, showing the automatically generated PySpark query.

  17. On the Home ribbon, select the Run all button.

    Screenshot of the Home ribbon, highlighting the Run all button.

  18. Review the query result in the results pane.

Next step