Skip to content

Martini Data Integration Cassandra Service Editor

Cassandra services in Martini allow for the execution of CQL (Cassandra Query Language) statements against a Cassandra database. These services facilitate direct interaction with data stored in Cassandra, enhancing data integration and manipulation capabilities.

Creating a Cassandra Service

To create a Cassandra service, a series of steps guide you through configuring and launching a service that interacts with Cassandra databases.

Step 1: Launch the Cassandra Service Wizard

Initiate the creation of a new Cassandra service by right-clicking on the code directory within the package where you wish to add the service. From the context menu, select New > Cassandra Service. This action opens the service wizard, guiding you through the setup process.

Step 2: Configure Service Details

Within the wizard, you will need to specify several parameters that define the behavior and settings of your Cassandra service:

  • Location: Determine where the Cassandra service file will be stored. The default location is based on where you initiated the wizard.
  • Name: Give your Cassandra service a unique name for identification within your project.
  • Connection Name: Select the database connection your service will use for development purposes and by default at runtime. This should correspond to a pre-configured connection to your Cassandra database.
  • Query Type: Choose the type of CQL statement your service will execute, such as SELECT, INSERT, or UPDATE, defining the interaction with the Cassandra database.
  • Keyspace: Specify the keyspace your service will operate within. A keyspace in Cassandra is similar to a database schema in SQL databases, organizing the data structure.

Step 3: Finalize and Create

After inputting all required details, click Finish to create your Cassandra service. The service is now set up and ready for further development and execution of CQL statements within your Cassandra database.

Quick Wizard Access via Keyboard Shortcut

For a faster workflow, Martini supports keyboard shortcuts to quickly access various functions. To launch the Cassandra service wizard without navigating through the menu, press Mod+N, type cql in the search dialog that appears, and press Enter. This shortcut directly opens the wizard, streamlining the service creation process.

Editing Cassandra Services

Once you create a Cassandra service in Martini, it will open in the Cassandra service editor. This interface allows for the configuration and modification of your Cassandra service. Below is a detailed guide on the primary components of the Cassandra service editor.

Primary Components of the Cassandra Service Editor

  1. Connection Name Drop-Down: Selects the database connection Martini will use when executing the service. Only connections that are registered and active are listed. To change the database connection at runtime, set the $martiniConnectionPool input property to the desired connection name.

  2. Cassandra Service Type Drop-Down: This dropdown allows you to select the specific operation your service will execute. The supported types include:

    Type Description
    Select Single Fetches the first row from the result set of a SELECT statement.
    Select Multi Returns a cursor representing the result set rows from a SELECT statement.
    Insert Inserts a single row into a table.
    Insert Batch Inserts multiple rows into a table. This operation returns an output cursor.
    Update Updates a single row.
    Update Batch Updates multiple rows in a table. This operation returns an output cursor.
    Delete Deletes a single row.
    Delete Batch Deletes multiple rows from a table. This operation returns an output cursor.
  3. Keyspace Drop-Down: Allows for the selection of the default keyspace the Cassandra service will use during runtime.

  4. Show System Checkbox: Determines whether to display Cassandra system keyspaces in the Database Tree.

  5. Database Tree: Provides a navigable view of the database's keyspaces, tables, columns, and their types.

  6. CQL Statement Text Area: Enables editing of the CQL statement for the service according to the selected Service Type. The content-assist menu can be activated with Ctrl+Space for assistance with CQL syntax.

Working with CQL Statements

  • Formatting CQL Queries: Right-click in the statement text area and select Format for automatic formatting, or use the keyboard shortcut Mod+Shift+F.

Testing and Previewing CQL Queries

Martini offers tools for testing and previewing your CQL queries within the Database perspective. You can also export the CQL query from a Cassandra service by right-clicking on the service in the Navigator and selecting Export > CQL Query.

Inputs and Outputs

Cassandra services in Martini, like standard services, have inputs and outputs that dynamically adjust based on the CQL statement in use. Should there be an issue with the CQL statement, such as incorrect syntax or an inability to generate the output model, a warning will be displayed beneath the CQL editor. Hovering over this warning reveals a tooltip providing further details on the error.

Special Input Properties for Cassandra Services

Cassandra services feature several special input properties that can be set to customize their operation:

Property Type Applicable Operations Description
$martiniConnectionPool Input All operations Specifies the database connection name. If omitted, the default database configured in the editor is used.
$keyspace Input All operations Defines the keyspace name. If omitted, the default keyspace from the editor is used.
$consistencyLevel Input All operations Sets the consistency level for this service. If omitted, the default consistency level from the database settings is used.
$serialConsistencyLevel Input All operations Determines the serial consistency level for this service. Defaults to the database setting if not specified.
$idempotent Input All operations Indicates the idempotence for this service. The default setting from the database is used if this is not specified.

Parameterized Queries

Martini supports parameterized CQL queries, enhancing flexibility by avoiding hard-coded arguments. Specify parameter values using a : prefix. For example:

1
2
3
SELECT *
FROM catfood
WHERE item_id = :itemId

As parameters are added to the CQL, the Input/Output view will update to reflect these changes, ensuring your service's inputs and outputs align with the query requirements.

Tips for Efficient CQL Statement Creation

  • Creating Models from Tables: To generate a data model representing a Cassandra table, right-click on the desired table in the Database tree and select Export to Data Model.
  • Auto-generating CQL Statements: Martini can automatically craft CQL statements for you. Right-click on the table or columns you wish to query, then select the appropriate CQL statement type from the context menu. The options available are influenced by the operation type chosen for the service.
  • WHERE Clause Considerations: Due to Cassandra's specific limitations on the WHERE clause, Martini will only include supported columns in the WHERE clause to ensure compatibility.

Enhancing Workflow with Drag-and-Drop

Martini enables the generation of CQL statements by simply dragging and dropping table or column nodes from the Database node in the Navigator view into the editor. This action triggers Martini to construct a CQL statement based on the selected operation type and the provided tables or columns, streamlining the development process.