Simulate the DUAL table in YCQL

In YugabyteDB YCQL, the SELECT statement must have a FROM clause. However, some queries don’t require any table.

Example:

				
					ycqlsh> SELECT currenttimestamp();
SyntaxException: Feature Not Supported
SELECT currenttimestamp();
At location: (1.26)
 (ql error -14)
				
			

If you are familiar with Oracle, then you’ll know that for this situation it provides you with the DUAL table which is a special table that belongs to the schema of the user SYS but it is accessible to all users.

There isn’t a DUAL table in YCQL, but you can use the system.local table instead. It will always return a single row and is a perfect replacement for the DUAL table.

				
					ycqlsh> SELECT currenttimestamp() FROM system.local;

 currenttimestamp()
---------------------------------
 2022-06-22 13:39:02.142000+0000

(1 rows)
				
			

Have Fun!