Virtual keyspaces and tables

CASSANDRA-7622 introduced support for virtual keyspaces and virtual tables. Virtual tables are exposed by the server to the users as local tables. They are read-only, but can sometime can support updates. Virtual tables are always part of a virtual keyspaces. The two available virtual keyspaces described in this topic are system_virtual_schema and system_views. These virtual tables are not associated with physical files on disk, have no memtables or SSTables, and do not support secondary indexes or materialized views; they are designed to expose server data such as configuration or metrics in memory.

See Virtual tables for SAI indexes and SSTables for details about the Storage Attached Indexing (SAI) virtual tables that reside in the system_views keyspace.

system_virtual_schema keyspace

The system_virtual_schema contains the information about the existing virtual keyspaces and tables. It contains three virtual tables which expose the definitions of the named data object:

keyspaces
Column name CQL type Column type

keyspace_name

text

partition key

tables
Column name CQL type Column type

keyspace_name

text

partition key

table_name

text

clustering key

comment

text

regular

columns
Column Name CQL Type Column type

keyspace_name

text

partition key

table_name

text

clustering key

column_name

text

clustering key

clustering_order

text

regular

column_name_bytes

blob

regular

position

int

regular

type

text

regular

system_views keyspace

System views expose information about the server internals. The sstable_tasks system view exposes the SSTable tasks that are currently running on the host:

sstable task
Column name CQL type Column type

keyspace_name

text

partition key

table_name

text

clustering key

task_id

uuid

clustering key

kind

text

regular

progress

bigint

regular

total

bigint

regular

unit

text

regular

The remaining amount of work can be computer using total - progress AS remaining in a SELECT clause.

Virtual tables and cqlsh

Virtual tables are exposed as local tables, so cqlsh will display data for the currently connected host. To displace schema for virtual tables, use DESCRIBE FULL SCHEMA to return schema for both the real keyspaces and the virtual ones.

Users are not allowed to create virtual keyspaces or virtual tables.

To see the schema for the virtual table sstable_tasks, use:

DESCRIBE TABLE system_views.sstable_tasks;
Results
WARNING: cqlsh was built against 5.0-beta1, but this server is 5.0.  All features may not work!

/*
Warning: Table system_views.sstable_tasks is a virtual table and cannot be recreated with CQL.
Structure, for reference:
VIRTUAL TABLE system_views.sstable_tasks (
    keyspace_name text,
    table_name text,
    task_id timeuuid,
    completion_ratio double,
    kind text,
    progress bigint,
    sstables int,
    target_directory text,
    total bigint,
    unit text,
    PRIMARY KEY (keyspace_name, table_name, task_id)
) WITH CLUSTERING ORDER BY (table_name ASC, task_id ASC)
    AND comment = 'current sstable tasks';
*/

To discover how much time is remaining for SSTable tasks, use the following query:

SELECT total - progress AS remaining FROM system_views.sstable_tasks;
Results
WARNING: cqlsh was built against 5.0-beta1, but this server is 5.0.  All features may not work!

 remaining
-----------


(0 rows)

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com