Notebook code editor in Gremlin code cells
The Notebook code editor supports the Groovy programming language 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.

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. Use the slider () to Disable editor
validations to turn off.
Cancel execution
- 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).

- Methods
- Variables
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
- 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.
- 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.
- Domain-specific—Common errors in code are pointed out when possible.
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
Supported:
- 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 syntaxwhile
loopstry
-catch
-finally
: a type is required for catching the exceptionif
-else
statementsswitch
statements- casting in both styles:
(SomeType) foo
andfoo as SomeType
- list literals
Unsupported Groovy language
- closures
- multi-variable assignment and other advanced variable assignments like object deconstruction
import
statements explicitly disabledmap
literals or other complex type literals that are not supported by Javatry
-catch
-finally
: multi-catch is not supported
Notebook information
- 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.
- 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.