Manage notebook cells

Updated at:

Notebook cells are the fundamental building blocks for creating and organizing content in a Notebook. Different cell types support different operations and features. This topic describes the use cases and management actions for each cell type.

Background information

For details on the Markdown syntax currently supported in Markdown cells, see https://www.markdownguide.org/extended-syntax/ and https://www.markdownguide.org/basic-syntax/.

The following syntax is not yet supported:

  • HTML

  • Definition Lists

  • Emoji

  • Highlight

  • Subscript

  • Superscript

Markdown cell

A Markdown cell allows you to add text to your Notebook by using standard Markdown syntax.

image

Area

Description

① Operation area

After you select a Markdown cell, you can manage it from the operation area. Available actions include switching the cell type, adding a new cell, copying the cell, moving the cell up or down, and deleting the cell.

  • Switch Cell: Converts the current cell to another type, such as a Markdown, SQL, or database SQL cell.

  • Add Cell: Adds a new cell below the current one, such as a Markdown, SQL, or database SQL cell.

  • Copy Cell: Creates a copy of the current Markdown cell with the same content below it.

  • Move Cell: Changes the position of the current Markdown cell. You can move it up or down.

  • Delete Cell: Deletes the current Markdown cell.

② Edit area

In the edit area, you can write content by using Markdown syntax. For more information, see Markdown syntax.

SQL cell

A SQL cell allows you to add and run SQL statements on a compute engine.

image

Area

Description

① Operation area

After you select a SQL cell, you can manage it from the operation area. Available actions include running the SQL code, enabling query acceleration, collapsing the cell, formatting the SQL, switching the cell type, adding a new cell, copying the cell, moving the cell, and deleting the cell.

  • Run: Runs the SQL code in the current SQL cell.

  • Query Acceleration: MAXCOMPUTE_SQL cells support query acceleration. If you enable this feature, you must select an acceleration method.

    • Acceleration Source: Accelerates queries using an acceleration source. When you select this method, you must also specify an acceleration source and a resource group.

      • Acceleration Source: You can select an acceleration source that is bound to the current project's compute source. If no acceleration sources are available, click New Acceleration Source to create one.

      • Resource Group (Optional): You can select a configured resource group under the selected acceleration source.

      Note
      • When you use an acceleration source, queries run based on the syntax of the selected source type. Your SQL statements must comply with the corresponding syntax rules. For example, if the acceleration source type is StarRocks, the ad-hoc query task runs based on StarRocks syntax.

      • When using an acceleration source, the system does not create a temporary table for each query.

    • MCQA: Short for MaxCompute Query Acceleration. Each tenant has job and concurrency limits for MCQA, which may cause acceleration failures or execution errors. For more information, see Query Acceleration (MCQA). You can disable MCQA acceleration in Management Center > System Settings > Development Platform > Query Acceleration.

    The supported acceleration methods vary depending on the compute engine and specific scenario.

    For tenants using the MaxCompute compute engine:

    • If you have not purchased a query acceleration plan but have enabled Query Acceleration in the Development Platform, the acceleration method is MCQA.

    • If you have purchased a query acceleration plan, enabled Query Acceleration in the Development Platform, and the compute source for the current project is not bound to an acceleration source, the acceleration method is MCQA.

    • If you have purchased a query acceleration plan and the compute source for the project is bound to an acceleration source, you can select either Acceleration Source or MCQA as the acceleration method.

    For tenants using a Hadoop compute engine: If you have purchased a query acceleration plan and the cluster for the project's compute source is bound to an acceleration source, the acceleration method is Acceleration Source.

  • Collapse Cell: Collapses the code area of the current SQL cell.

  • Format SQL: Formats the SQL code in the current SQL cell.

  • Switch Cell: Converts the current cell to another type, such as a Markdown, SQL, or database SQL cell.

  • Add Cell: Adds a new cell below the current one, such as a Markdown, SQL, or database SQL cell.

  • Copy Cell: Creates a copy of the current SQL cell with the same content below it.

  • Move Cell: Changes the position of the current SQL cell. You can move it up or down.

  • Delete Cell: Deletes the current SQL cell.

② Edit area

You can write SQL code for the compute engine in the edit area.

Database SQL cell

A database SQL cell allows you to add and run SQL statements against a database from your Notebook.

image

Area

Description

① Operation area

After you select a database SQL cell, you can manage it from the operation area. Available actions include running the SQL code, collapsing the cell, formatting the SQL, switching the cell type, adding a new cell, copying the cell, moving the cell, and deleting the cell.

  • Run: Runs the SQL code in the current database SQL cell.

    Note

    When you run a database SQL cell, the system uses the default resource group configured in the selected data source, not the default resource group of the analysis project.

  • Collapse Cell: Collapses the code area of the current database SQL cell.

  • Format SQL: Formats the SQL code in the current database SQL cell.

  • Switch Cell: Switches the current database SQL cell to another type, such as a Markdown, SQL, or database SQL cell.

  • Add Cell: Adds a new cell below the current one, such as a Markdown, SQL, or database SQL cell. For information about the data source types supported by database SQL cells, see .

  • Copy Cell: Creates a copy of the current database SQL cell with the same content below it.

  • Move Cell: Changes the position of the current database SQL cell. You can move it up or down.

  • Delete Cell: Deletes the current database SQL cell.

  • Select Data Source: Selects a data source, including an external data source, to execute the SQL code.

  • Catalog: You must select a Catalog for Presto and Trino data sources.

  • Database/Schema: You must select a Database/Schema for the following data sources: MySQL, PostgreSQL, Hologres, AnalyticDB for PostgreSQL, OceanBase (Oracle tenant mode), Lindorm, Oracle, ClickHouse, DM, openGauss, StarRocks, Doris, SelectDB, Presto, GaussDB (DWS), Trino, PolarDB-X, OushuDB, TDSQL for MySQL, TDSQL for PostgreSQL, TDengine, and GBase 8a.

② Edit area

You can write database SQL code in the edit area.

After you finish writing the code, click Run. The system parses all objects in the code and performs a permission check. If the check fails, a dialog box appears listing the objects for which you lack the required permissions.

The permission check failure dialog box displays the Object name, Object type, Permission type, and Actions.

  • Object name: The name of the object for which you do not have permissions.

  • Object type: Tables and global variables.

  • Permission type: Specifies the permissions required to run the script. For example, data source tables require read permission, and data sources require execution permission.

  • Actions: If the permission check fails, you can apply for permissions for one or more objects.

    • To apply for permissions on a single object: Click the image.png icon in the Actions column for the target object to request the permissions for your account. The default validity period is 30 days.

    • To apply for permissions on multiple objects: Select multiple objects or check Select All Tables, and then click Apply for Permissions.

    For detailed instructions, see Apply for permissions. After you obtain the permissions, you can run the code again.

    Note

    Table-level permission control is supported only for MySQL and Oracle data sources.