Notebook code editor in Gremlin code cells

The Notebook code editor supports the Apache Groovy™ programming language in Gremlin code cells. Syntax validation supported for a subset of Groovy.

A notebook connects to a DSE cluster based on the connection information. Each notebook has only one connection. One piece of information that a connection specifies is its Graph Name.

The code editor provides pre-defined alias variables:

  • graph

    The variable that refers to the graph.

  • g

    The traversal source associated with the graph for OLTP graph traversals.

  • a

    The traversal source associated with the graph for OLAP graph traversals.

A drop-down list shows for content-assist on a blank line in the editor.

predefined Variables

The code editor supports inline code validation. If some code is invalid or uses Groovy syntax that the editor does not support, the invalid code is displayed with a red underlining. Adjust the slider editor validations on to disable editor validations, like this editor validations off.

Cancel execution

When code is running in a Gremlin cell, you can cancel the execution to kill the gremlin session. This cancel execution is helpful when you want to make a change to the code and do not want to wait until a long running query finishes.

  • Click Kill Session.

    The confirmation dialog appears:

    Gremlin cell executions will be stopped by killing the notebook session. Proceed?
  • Click Yes to proceed, no to cancel.

  • After you cancel execution, this message is shown:

    The Gremlin Session associated with the notebook was killed.
  • You can make code changes to the cell and run the execution again.

Content assistance

The code editor provides content assistance (Ctrl+Space).

content assistance

Content-assistance proposes content based on context:

  • Methods

  • Variables

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

You can filter proposals by typing enough characters to select a line in the pull-down menu.

Use Shift+Tab to return to the beginning of a line.

Code validation

The notebook editor supports these validations:

  • Groovy syntax—​The code in a Gremlin cell is executed within DSE Graph as Groovy. The notebook editor adds enough Groovy syntax support to help you craft Gremlin statements.

    validation syntax error
  • Type-checking—​The code in a cell is also checked for type. If you try to call a method on an object of the wrong type or pass a parameter of an invalid type, a validation error is displayed.

    validation type checking error
    validation type argument error
  • Domain-specific—​Common errors in code are pointed out when possible.

    validation domain error

The notebook editor performs validation as code is entered into the cell. You can turn off validation on a per-cell basis.

The code editor cells in a notebook have no Gremlin session scope context and rely on an implicit scope based on their order. Validation occurs from the top cell down in the order in the notebook. If you execute code out of order, validation errors can occur even if the code executes successfully.

Groovy language support


  • variable declarations in Groovy style:

    • def foo

    • def SomeType foo

    • SomeType foo

    • Shell-style variables

  • method invocations

  • optional semicolons to complete statements

  • generics

  • strings in both forms:

    • '123'

    • "123"

  • for loops: basic and for in syntax

  • while loops

  • try-catch-finally: a type is required for catching the exception

  • if-else statements

  • switch statements

  • casting in both styles: (SomeType) foo and foo as SomeType

  • list literals

Unsupported Groovy language

  • closures

  • multi-variable assignment and other advanced variable assignments like object deconstruction

  • import statements explicitly disabled

  • map literals or other complex type literals that are not supported by Java

  • try-catch-finally: multi-catch is not supported

Notebook information

Selecting Information displays:

  • Connection being used for the notebook.

  • Last update to the notebook.

  • Version of Studio JAR file being run.


Notebook schema

Selecting Information displays the current graph schema for the notebook.


In addition to visual schema representation, the code-assist feature also provides schema-assist proposals. Studio examines the schema and suggests Vertex/Edge Labels and Property Keys based on the underlying graph schema. image::ROOT:studio/schemaAssist.png[alt=schema assist]

That is a lot of proposals. Let us break them down:

  • The editor is intelligent enough to know that this is a Vertex-based traversal because of type inference. The editor presents only the schema proposals that are relevant for vertex properties and keys.

  • Because there are multiple has methods, Studio proposes possibilities for all of these variations.

  • The editor concretely makes a proposal for each possible property key.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

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,