Concept | SQL notebooks#

Watch the video

When to use an SQL notebook#

An SQL Notebook allows you to interact with the tables associated with your Dataiku SQL datasets, through the use of SQL queries.

With SQL notebooks, you can:

  • Perform queries on an SQL dataset for quick prototyping and data analysis.

  • Leverage an SQL engine for in-database computations.

  • Return query outputs without having to write them as new datasets in your SQL database.

When creating an SQL notebook, you must link it to an SQL connection already set up by an administrator in your Dataiku instance.

Linking the notebook to an SQL connection.

The SQL notebook interface#

The main area of the SQL notebook interface is a window for writing queries.

In the left panel, the Queries tab lists all the queries available. When you first create your notebook, this tab is empty. You must click the +Query button to create your first query.

The left panel also contains a Tables tab that lists:

  • The tables available in your connection.

  • Additional information like the list of columns in each table.

  • The column data types.

When you have several tables, you can sort them by table name or dataset name.

By clicking the plus icon next to a table name, a SELECT statement displays within the query window. This is where you can quickly build your query by selecting a column name to add to the query window.

When you run the query, the results display below the query window for you to explore and download.

caption.

The SQL notebook also lets you switch views between full screen and stacked query modes and add a new query or markdown cell.

Available buttons to switch views and add new queries or markdown comments.

You can even add comments, either in plain text or markdown within a markdown cell.

Dataiku stores all queries and comments you create in the Queries tab as distinct cells. Simply click to view them.

As you can see below, each query cell is where you execute and modify a single query. It is recommended to keep a single cell for each query as each cell has its own history and you can rerun any query at a later time.

Example of a query cell.

For better clarity, note that you can name your query.

Field to rename a query cell.

Once back in the Flow, you’ll notice the SQL notebook is not represented by a Flow icon. This is because SQL notebooks are made to write SQL code for experimentation only. It is a Lab object outside of the Flow.

Note

For more information, see SQL notebook in the reference documentation.

Or, learn how to use a query from a notebook in the Flow by turning the query into an SQL code recipe.