Data Lake Analytics (DLA) CU Edition allows you to access ApsaraDB for Cassandra databases. This topic describes how to access an ApsaraDB for Cassandra database and query data from the database by using DLA CU Edition.

Prerequisites

DLA CU Edition is activated. Only DLA CU Edition allows you to access ApsaraDB for Cassandra databases. For more information, see Use the DLA Presto-compatible Presto CU edition.
Note When you create a virtual cluster (VC), make sure that the data source and the ApsaraDB for Cassandra cluster must belong to the same VPC.

Procedure

  1. Log on to the DLA console.
  2. In the left-side navigation pane, choose Serverless Presto > Execute. On the Execute page, click Log on to DMS to execute SQL and perform the following operations to create an ApsaraDB for Cassandra database and a table and query data from this table.
    Note To create an ApsaraDB for Cassandra database and a table and query data from this table, you can also use a MySQL client or program code to connect to DLA and execute the following statements.
    1. Create an ApsaraDB for Cassandra database.
      create database cassandra_it_db with dbproperties(
          catalog = 'cassandra',
          location = 'cds-test-1-core-001.cassandra.rds.aliyuncs.com,cds-test-1-core-002.cassandra.rds.aliyuncs.com,cds-test-1-core-003.cassandra.rds.aliyuncs.com',
          port = '9042',
          keyspace = 'test_keyspace',
          user = 'test',
          password = 'test'
      );
      Parameter Description
      catalog The catalog of the database. cassandra indicates the ApsaraDB for Cassandra database that you want to create.
      location The virtual private cloud (VPC) endpoint of the ApsaraDB for Cassandra cluster that you want to access.
      port The CQL port of the ApsaraDB for Cassandra cluster that you want to access.
      keyspace The keyspace of the ApsaraDB for Cassandra cluster that you want to access.
      user The username of the keyspace of the ApsaraDB for Cassandra cluster that you want to access.
      password The password of the keyspace of the ApsaraDB for Cassandra cluster that you want to access.
    2. Create a table.
      create external table cassandra_it_db.test_user (
          first_name string,
          last_name string
      );
  3. Query or access data.
    Only compute units (CUs) can access the network where the ApsaraDB for Cassandra cluster resides. Therefore, you must add hint: /*+cluster=your-vc-name*/ to the SQL statement that you want to execute to access the ApsaraDB for Cassandra table.
    Example:
    mysql> /*+cluster=vc-test*/select * from test_user where first_name = 'james';
    +------------+-----------+
    | first_name | last_name |
    +------------+-----------+
    | james      | bond      |
    +------------+-----------+
    1 row in set (1.79 sec)