Notebook code editor in DataStax Studio

The Notebook code editor supports a subset of the Apache Groovy™ programming language.

A notebook connects to a DSE cluster based on the connection information. Each notebook has only one connection. One piece of information 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 assistance on a blank line in the editor.

predefinedvariables
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.

Content assistance

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

contentAssistance
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 performs validation as code is entered into the cell. You can turn off validation on a per-cell basis. To turn off validation in a cell, move the slider to Disable editor validations.

The notebook editor supports these validations:

Groovy syntax

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

validationSyntaxError
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.

validationTypeCheckingError
Validation Type Checking Error
validationArgTypeError
Validation Arg Type Error
Domain-specific

Common errors in code are pointed out when possible.

validationDomainError
Validation Domain Error

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 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.

information
Information

Notebook schema

Selecting Information displays the current graph schema for the notebook.

schema
Schema

In addition to visual schema representation, the code-assist feature also provides schema-assist proposals.

Schema Assist

schemaAssist

That’s a lot of proposals. Let’s break them down:

  • The editor is intelligent enough to know that this is a Vertex-based traversal (because of type inference) and 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, info@datastax.com