Create and run notebook cells in DataStax Studio

Each notebook is made up of multiple cells. A cell is a multi-line text input field that can contain Markdown text, CQL statements, Gremlin code, or Spark SQL statements.

Run a cell

There are four ways to execute a cell’s contents:

  • Press Shift+Enter with focus on the cell

  • Click Run Cell

  • In the menu, click Cell, and then select Run

  • Highlight a single statement within a cell, and then click Run Cell to execute only the selected statement

Cell types and execution behavior

The cell language determines the cell’s execution behavior and whether you can customize the run behavior.

By default, every cell is a code cell. To change a cell’s type, select a different cell language or use Keyboard shortcuts in DataStax Studio.

  • Gremlin

  • CQL

  • Spark SQL

  • Markdown

Limited execution configurations are available to define the run behavior:

  • Real-time (default): Execute statements using the real-time (transactional) engine for OLTP (online transaction processing), traversal source g.

  • Analytic: Execute statements using the analytic engine (Spark) for OLAP (online analytical processing), traversal source a.

The notebook’s connection defines the graph and assigned graph traversal. For more information, see DataStax Graph QuickStart.

You can manipulate the output format using results controls.

When code is running in a Gremlin cell, you can cancel the execution to terminate the Gremlin session. This is helpful when you want to make a change to the code, and you don’t want to wait until a long running query finishes. To do this, click Kill Session, and then confirm the termination. After you cancel a Gremlin execution, the message The Gremlin Session associated with the notebook was killed confirms that the session was terminated. Then, you can edit and rerun the cell.

Use execution configurations to define the run behavior. The following default configurations are available, and custom configurations are supported.

LOCAL.ONE (default for DSE)
  • Consistency level: ONE

  • Timeout (MS): 10000

  • Max Results: 5000

  • CQL Tracing: Disabled

LOCAL.QUORUM (default for Astra)
  • Consistency level: QUORUM

  • Timeout (MS): 10000

  • Max Results: 5000

  • CQL Tracing: Disabled

LOCAL.QUORUM.TRACE
  • Consistency level: QUORUM

  • Timeout (MS): 10000

  • Max Results: 5000

  • CQL Tracing: Enabled

You can manipulate the output format using results controls.

The execution configuration cannot be changed. Running a Spark SQL cell executes the statement using the Spark SQL query engine with AlwaysOn SQL service.

Use Markdown to document the computational process in a literate way, alternating descriptive text with code. Supported styles include italics, bold, lists, and headings. Anchored links between sections are also supported.

Click Run Cell to preview the rendered Markdown. The execution configuration cannot be changed.

Set execution configurations

Execution configurations contain high-level settings that define how the code in a cell is executed, such as the consistency level and timeout. Execution configurations are persistent so you can reuse them across notebooks and cells.

  1. In the upper-right corner of a code cell, hover over Run Cell, and then select Configurations to switch and manage execution configurations.

    The Run Cell label changes based on the default or selected execution configuration:

    • In CQL cells, the default execution configuration is LOCAL.ONE.

    • In Gremlin cells, the default execution configuration is Real-time.

    • In Spark SQL cells, all statements are executed with Spark SQL query engine with AlwaysOn SQL service.

  2. Select Manage Configurations to inspect and create configurations.

  3. Select an existing configuration to view or edit its details.

  4. To add a new configuration, click Add New Configuration, and then enter the required settings:

    • Name: A descriptive name for the configuration

    • Consistency level: ANY, ONE, TWO, THREE, QUORUM, ALL, LOCAL_QUORUM, EACH_QUORUM, SERIAL, LOCAL_SERIAL, LOCAL_ONE

    • Timeout (MS): An integer representing a timeout threshold in milliseconds

    • Max Results: An integer representing a number of records

    • CQL Tracing: Enable or disable CQL tracing

Cell controls

  • Add Cell: Add a cell in the current location.

  • Run Cell: Display the markdown or run the code and display the results.

  • Hide Code Editor: Hide the code editor.

  • Editor Validations: Toggle to enable (on) or disable (off) editor validations.

  • Maximize Cell: Maximize the cell.

  • Other Cell Actions: Access additional cell controls, including delete, move, copy link, and clear results.

    The Copy Cell Link option generates a URL that you can use to share and reference a specific cell in a notebook. The cell URL is copied to the clipboard in the format http://HOST:9091/notebooks/NOTEBOOK_ID/cell/CELL_ID. To go directly to that cell, navigate to the URL in your web browser.

CQL and Gremlin results controls

Use these controls to change the presentation of results from the last statement executed in a CQL or Gremlin cell. These controls aren’t available for all cell languages.

  • JSON

  • Table

  • Pie Chart

  • Bar

  • Line

  • Area

  • Scatter

  • Graph

  • Settings

Code editor support for Gremlin cells

Studio’s code editor supports the Groovy programming language in Gremlin code cells, and it provides aliases, validation, and completion assistance unique to Gremlin code cells.

Gremlin aliases

Studio’s code editor provides the following pre-defined alias variables:

  • graph: The variable that refers to the graph. A Gremlin notebook’s graph name is derived from the notebook’s cluster connection.

  • g: The traversal source associated with the graph for OLTP graph traversals.

  • a: The traversal source associated with the graph for OLAP graph traversals.

These aliases can be suggested by content assistance.

predefined variables

Code validation

Studio validates code as you enter it into a cell. To disable validation for a specific cell, disable the Editor Validations cell control.

A red underline indicates that Studio has determined that the code is invalid or uses unsupported Groovy syntax. However, notebook cells have no Gremlin session scope context; they rely on an implicit scope based on their order in the notebook. Validation occurs from top to bottom starting with the first cell in the notebook. If your cells execute code out of order, validation errors can occur even if the code is technically correct.

Studio supports the following validations for Gremlin cells:

Groovy syntax

The code in a Gremlin cell is executed within DSE Graph as Groovy. Studio’s Groovy syntax support is designed to help you write valid Groovy code for most use cases. However, it might not catch all syntax errors, and it can throw false positives for valid Groovy syntax that is supported by DSE Graph but not Studio.

validation syntax error

For more information, see Groovy language support.

Type-checking

The code in a cell is checked for type.

validation type checking error

If you try to call a method on an object of the wrong type, or pass a parameter of an invalid type, then a validation error appears.

validation type argument error
Domain-specific

Common errors in code are pointed out when possible.

validation domain error

Groovy language support

Syntax validation is supported for the following subset of the Apache Groovy™ programming language:

Supported syntax
  • Method invocations

  • Optional semicolons to complete statements

  • Generics

  • Strings in either single or double quotes.

  • For loops, including basic and for-in syntax

  • While loops

  • If-else statements

  • Switch statements

  • Casting in either style ((SomeType) foo or foo as SomeType)

  • List literals

Partially supported syntax
  • Variable declarations are supported as shell-style variables and in Groovy styles (def foo, def SomeType foo, SomeType foo). However, advanced variable assignments, like multi-variable assignment and object deconstruction, aren’t supported.

  • Try-catch-finally statements require a type to catch the exception. Multi-catch isn’t supported.

Unsupported syntax
  • Closures

  • Import statements are explicitly disabled

  • Map literals and other complex type literals that aren’t supported by Java

Content assistance

The code editor provides content assistance that suggests methods and variables based on the current cursor and cell context.

content assistance

To activate content assistance, place the cursor where you want to insert code and press Ctrl+Space.

Press Return to select the highlighted choice from the assistance list.

You can filter suggestions by typing characters to filter the dropdown menu.

Press Shift+Tab to return to the beginning of the current line.

Schema assistance

In addition to visual schema representation through the notebook controls, Studio’s code editor also provides schema-assist suggestions. Studio examines the schema and suggests Vertex/Edge Labels and Property Keys based on the underlying graph schema.

Studio’s schema assistance suggesting vertex labels and vertex property keys for a Gremlin traversal

Depending on your Gremlin code and current schema, Studio provides context-aware suggestions.

In the preceding example, Studio’s suggestions were based on the following logic:

  • Studio used type inference to determine that this was a Vertex-based traversal, and then it limited the suggestions to Vertex Labels and Vertex Property Keys.

  • The code had multiple has methods, causing Studio to generate suggestions for all variations of these methods.

  • Studio made concrete suggestions for each possible property key.

Default Gremlin imports

Studio performs the following imports automatically for Gremlin cells. These imports aren’t configurable.

Static imports
  • org.apache.tinkerpop.gremlin.process.traversal.SackFunctions.Barrier.*

  • org.apache.tinkerpop.gremlin.util.TimeUtil.*

  • org.apache.tinkerpop.gremlin.structure.Direction.*

  • org.apache.tinkerpop.gremlin.process.traversal.Pop.*

  • org.apache.tinkerpop.gremlin.process.traversal.step.TraversalOptionParent.Pick.*

  • org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality.*

  • org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource.*

  • org.apache.tinkerpop.gremlin.process.traversal.P.*

  • org.apache.tinkerpop.gremlin.process.traversal.Order.*

  • org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*

  • org.apache.tinkerpop.gremlin.structure.io.IoCore.*

  • org.apache.tinkerpop.gremlin.process.traversal.Scope.*

  • org.apache.tinkerpop.gremlin.structure.Column.*

  • org.apache.tinkerpop.gremlin.structure.T.*

  • org.apache.tinkerpop.gremlin.process.traversal.Operator.*

Imports
  • groovy.grape.Grape

  • org.apache.commons.configuration.*

  • org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.*

  • org.apache.tinkerpop.gremlin.process.computer.bulkloading.*

  • org.apache.tinkerpop.gremlin.process.computer.traversal.*

  • org.apache.tinkerpop.gremlin.util.function.*

  • org.apache.tinkerpop.gremlin.structure.io.*

  • org.apache.tinkerpop.gremlin.process.computer.ranking.pagerank.*

  • org.apache.tinkerpop.gremlin.groovy.loaders.*

  • groovy.json.*

  • org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.*

  • org.apache.tinkerpop.gremlin.structure.*

  • org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.*

  • org.apache.tinkerpop.gremlin.process.traversal.engine.*

  • org.apache.tinkerpop.gremlin.structure.io.gryo.*

  • org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.*

  • org.apache.tinkerpop.gremlin.process.traversal.step.util.event.*

  • org.apache.tinkerpop.gremlin.util.*

  • org.apache.tinkerpop.gremlin.structure.util.*

  • org.apache.tinkerpop.gremlin.structure.io.graphml.*

  • org.apache.tinkerpop.gremlin.process.computer.*

  • org.apache.tinkerpop.gremlin.process.traversal.strategy.finalization.*

  • org.apache.tinkerpop.gremlin.process.computer.clustering.peerpressure.*

  • org.apache.tinkerpop.gremlin.structure.util.detached.*

  • org.apache.tinkerpop.gremlin.structure.io.graphson.*

  • org.apache.tinkerpop.gremlin.process.traversal.*

  • org.apache.tinkerpop.gremlin.process.computer.bulkdumping.*

  • org.apache.tinkerpop.gremlin.process.traversal.util.*

  • org.apache.tinkerpop.gremlin.groovy.function.*

Extra imports
  • com.datastax.bdp.graph.api.*

  • com.datastax.bdp.graph.api.schema.*

  • com.datastax.bdp.graph.api.id.*

  • com.datastax.bdp.graph.api.config.*

  • org.apache.cassandra.db.marshal.geometry.*

  • com.datastax.bdp.graph.api.system.*

  • java.time.*

To get a list of all imports from within a Gremlin cell, enter the following code and then run the cell:

DseGraphImports.getInstance().getAllImports()

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2025 DataStax, an IBM Company | Privacy policy | Terms of use | Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com