%% Return Partition Key Values from Cassandra Database Table
% Using an Apache Cassandra® database connection and the Apache Cassandra database C++ interface, return partition key values for a Cassandra database table. Specify the keyspace and name of the table. In this case, the Cassandra database has the employeedata keyspace, which contains the employees_by_job database table.
%
% Create a Cassandra database connection using the configured data source CassandraDataSource and a blank user name and password. The apacheCassandra function returns conn as a connection object.

datasource = "CassandraDataSource";
username = "";
password = "";
conn = apacheCassandra(datasource,username,password);

%
% Return column information for the employees_by_job database table in the employeedata keyspace.

keyspace = "employeedata";
tablename = "employees_by_job";
[cols,keyValues] = columninfo(conn,keyspace,tablename);

% keyValues is a table that contains a variable for each partition key. The rows are partition key values.
%
% Display the first few partition key values of the Cassandra database table.

head(keyValues)

% job_id is the only partition key in the employees_by_job database table. Each row is a partition key value that is a unique partition in employees_by_job.
% Use the partition key values with the partitionRead function to import data from a Cassandra database table.
%
% Close the Cassandra database connection.

close(conn)

% Copyright 2020 The MathWorks, Inc.