Skip to content

Home

Development

IDEs

API Explorer

Cassandra query editor

The Cassandra query editor (or CQL query editor), is Martini's dedicated editor for CQL statements. This editor becomes visible in when you open a CQL file (.cql).

Cassandra query editor

This editor is comprised of the following user interface elements:

  1. Connection dropdown, which allows you to select which Cassandra database connection will receive the query.
  2. Keyspace dropdown, which allows you to select which Cassandra keyspace will be used for the query.
  3. Statement text area, where you the provide CQL statement(s) you want to execute; features content-assist and syntax highlighting for ease of use.

    Format your CQL query

    You can format your query by right clicking on the statement text area and selecting Format, or by using the shortcut .

    Formatting CQL query

  4. Run button, which allows you to execute the written CQL command.

  5. Refresh button, which allows you to fetch the latest list of available connections.
  6. Results panel, where the results of your query will be displayed.

Export a CQL query to a Gloop Cassandra service

You can create a Gloop Cassandra service from a CQL file by right clicking the latter from the Database Navigator and then choosing Export > Gloop Cassandra Service from the appearing context menu.

Exporting a CQL to Gloop service in Martini Desktop

Keyspace

Cassandra uses the concept of a keyspace. A keyspace holds data objects, and allows you to specify options for data partitioning and replication strategy. A keyspace is often likened to a SQL schema/database.

You can create your own keyspace using the following command (called employees in the example below):

1
CREATE KEYSPACE employees WITH replication = {'class':'SimpleStrategy','replication_factor':1};

Upon execution, click the refresh button. By then, you'll be able to see the keyspace you created in the Keyspace dropdown.

Creating a new Cassandra keyspace

Creating a new CQL query

To create a new CQL query, right-click on the queries directory of the server which contains the connection you would like to query against, and choose New > CQL Query. If you're in the Database perspective, the queries directory will appear under the server itself in the Database Navigator, otherwise it will appear in the core package of the server in the Navigator.

Creating a new CQL query

Content-assist

The Cassandra query editor lets you write CQL statements faster through content-assist. With content-assist, possible query fragments will be suggested as you write.

To trigger content-assist, press . A pop-up will appear right under the line where you pressed the shortcut. This pop-up is composed of a search text field and a list of proposals.

Proposals are possible content that can be injected based on the current context; they have a name and a category. Proposals can be searched by their complete names or short names. You can use the and arrow keys to navigate through the proposals whilst still having focus on the search text so you can search and select at the same time.

Query results

The Results panel lets you view CQL statement results. Results are paginated for your convenience; just use the next and previous button to navigate through the entries. To view the complete content of a cell, click the button beside the cell. A dialog will appear, displaying the requested content.

Editor hotkeys

Pressing while the editor has focus will execute the query in the editor.

Exporting a keyspace table to a Gloop model

You can also export existing keyspace tables into Gloop models from the Database perspective. In order to do that, follow the steps below:

  1. Open the Database perspective.
  2. In the Database Navigator tree, expand the Cassandra connection that contains the keyspace with the table you would like to export.
  3. Right click on the table of your choice and select Export > Keyspace Table to Gloop Model.
  4. In the dialog that appears, specify the location and name of your model. The Location and Name fields are pre-populated by default, and set to the code directory and the name of the schema table respectively.
  5. Click Finish.

Exporting a CQL table to Gloop model