columninfo
Retrieve column information from ApacheCassandradatabase table
Syntax
Description
Examples
Return Column Information from Cassandra Database Table
Using a Cassandra® database connection, return column information for a Cassandra database table. Specify the keyspace and the name of the table. In this case, the Cassandra database has theemployeedata
keyspace, which contains theemployees_by_job
database table.
Create a Cassandra database connection using the local host address.conn
is acassandra
object.
contactPoints =“localhost”; conn = cassandra(contactPoints);
Return column information for theemployees_by_job
database table in theemployeedata
keyspace.
keyspace ="employeedata"; tablename ="employees_by_job"; cols = columninfo(conn,keyspace,tablename);
Display the first few rows of column information.
head(cols)
ans=8×4 table数据类型名称PartitionKey ClusteringColumn __________________ ________ ____________ ________________ "job_id" "text" true "" "hire_date" "date" false "DESC" "employee_id" "int" false "ASC" "commission_pct" "double" false "" "department_id" "int" false "" "email" "text" false "" "first_name" "text" false "" "last_name" "text" false ""
cols
is a table with these variables:
Name
— Cassandra database column nameDataType
— Cassandra Query Language (CQL) data type of the Cassandra database columnPartitionKey
— Partition key indicatorClusteringColumn
— Clustering column indicator
Close the Cassandra database connection.
close(conn)
Return Partition Key Values from Cassandra Database Table
Using a Cassandra® database connection, return partition key values for a Cassandra database table. Specify the keyspace and name of the table. In this case, the Cassandra database has theemployeedata
keyspace, which contains theemployees_by_job
database table.
Create a Cassandra database connection using the local host address.conn
is acassandra
object.
contactPoints =“localhost”; conn = cassandra(contactPoints);
Return column information for theemployees_by_job
database table in theemployeedata
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)
ans=8×1 tablejob_id __________ "ST_CLERK" "SA_MAN" "HR_REP" "IT_PROG" "FI_MGR" "PR_REP" "PU_MAN" "AD_PRES"
job_id
is the only partition key in theemployees_by_job
database table. Each row is a partition key value that is a unique partition inemployees_by_job
.
Use the partition key values with thepartitionRead
function to import data from a Cassandra database table.
Close the Cassandra database connection.
close(conn)
Input Arguments
conn
—Cassandra database connection
cassandra
object
Cassandra database connection, specified as acassandra
object.
keyspace
—Keyspace
character vector|string scalar
Keyspace, specified as a character vector or string scalar. If you do not know the keyspace, then access theKeyspaces
property of thecassandra
object using dot notation to view the keyspaces in the Cassandra database.
Example:"employeedata"
Data Types:char
|string
tablename
—Cassandra database table name
character vector|string scalar
Cassandra database table name, specified as a character vector or string scalar. If you do not know the name of the table, then use thetablenames
function to find it.
Example:"employees_by_job"
Data Types:char
|string
Output Arguments
cols
— Column information
table
Column information from a Cassandra database table, returned as a MATLAB®table containing these variables.
Variable Name | Variable Description | Variable Data Type |
---|---|---|
|
Cassandra database column name |
|
|
CQL data type of the Cassandra database column |
|
|
Whether the Cassandra database table column is a partition key ( |
|
|
Whether the Cassandra database table column is a clustering column ( |
|
If the data type of a column in a Cassandra database table is a collection (for example, alist
,map
, and so on), then the value of theDataType
variable contains angle brackets (<>
). These angle brackets surround the data type of the items in the collection. The value for user-defined types (UDTs) contains the type name. For example, if the UDT isperson
, then the value of theDataType
variable isperson
in the MATLAB table. For details about valid CQL data types, seeCQL data types.
keyValues
— Partition key values
table
Partition key values, returned as a table. The MATLAB table contains one variable for each partition key in the Cassandra database table. Each row in the MATLAB table represents a unique partition in the Cassandra database table.
You can use the partition key values with thepartitionRead
function to import data from a Cassandra database table.
For details about the MATLAB data types of the partition key values, seeConvert CQL Data Types to MATLAB Data Types.
Introduced in R2018b
Open Example
A modified version of this example exists on your system. Do you want to open this version instead?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(Español)
- Canada(English)
- United States(English)
Europe
- Belgium(English)
- Denmark(English)
- Deutschland(Deutsch)
- España(Español)
- Finland(English)
- France(Français)
- Ireland(English)
- Italia(Italiano)
- Luxembourg(English)
- Netherlands(English)
- Norway(English)
- Österreich(Deutsch)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)