In this article, we will discuss several functions that are supported by CQL in Cassandra which can help in converting one value type into another new value directly by using the function.
In Cassandra, there are several functions that are supported by CQL which helps in many ways such that there is a scenario where we want to find the TTL value of a column with the help of TTL function we can easily do that.
Let’s discuss WRITETIME function.
The WRITETIME function is very useful in Cassandra query language when write occurred then we can retrieve the date/time of writes to the columns.
We can use WRITETIME function in the select statement followed by the non-partitioning column in parenthesis. In Cassandra Query Language a table contains the timestamp to represents date and time that a write occurred to a column. After return the query it gives WRITETIME function value in microseconds and then we can convert it into date/time formats.
Let’s understand with an example.
CREATE TABLE function_test ( Id int, Name text, Address text, PRIMARY KEY(Id) );
To insert data into the table used the following CQL query.
INSERT INTO function_test (Id, Name, Address) VALUES (201, 'Ashish', 'Delhi'); INSERT INTO function_test (Id, Name, Address) VALUES (202, 'Rana', 'Mumbai'); INSERT INTO function_test (Id, Name, Address) VALUES (203, 'Abi', 'Noida');
To read the data used the following CQL query.
SELECT * FROM function_test;
To determine the WRITETIME function Value used the following CQL query.
SELECT WRITETIME (Address) FROM function_test;
To determine the WRITETIME function by using WHERE clause used the following CQL query.
SELECT WRITETIME (Address) FROM function_test where Id=201;
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Database Roles in CQL (Cassandra Query Language)
- Virtual machine installation for Cassandra CQL query
- Useful CQL query in Cassandra
- Finding Additional functional dependencies in a relation
- Aggregate functions in Cassandra
- UUID and Timeuuid functions in Cassandra
- Structured Query Language (SQL)
- Neo4j Query Cypher Language
- Features of Structured Query Language (SQL)
- SQL | Functions (Aggregate and Scalar Functions)
- Static type using batch in Cassandra
- Role of keys in Cassandra
- High Availability Mechanism in Cassandra
- Apache Cassandra tools
- Blob conversion function in Cassandra
- Designing models in Cassandra
- Introduction to Apache Cassandra
- Apache Cassandra (NOSQL database)
- Architecture of Apache Cassandra
- Overview of User Defined Type (UDT) in Cassandra
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Ashish_rana