Looking at CQL Data Types descriptions compared to SQL Server Data Types, here are some mappings, but there's no guarantees (not overly confident considering the typos in the CQL Data Types reference) they are accurate.
The comparison doesn't consider settings on SQL Server that alter data type representation such as collation sets with character data types or how you are converting and passing this data to SQL Server.
I'm making the comparison based on the values that can be represented by both types. Pay close attention to the comments.
CQL Data Type | Match? | SQL Server Data Type | Comment ------------------------------------------------------------------------------------- list N none A collection; no native SQL equivalent. Perhaps sql_variant or XML could be used but operations on list in CQL wouldn't apply in SQL Server. Custom data types and CLR integrations would most likely be required map N none Similar to above except as of SQL Server 2016, [JSON Data](https://msdn.microsoft.com/en-gb/library/dn921897.aspx) handling has been introduced so it's possible it could parse CQL maps set N none " int Y int Both represent 32-bit signed integers bigint Y bigint Both represent 64-bit signed integers varint ? smallint Not clear if varint storage size will change, so if precision was -32768 to 32767, would it take 2 bytes? Also, if varint has values outside of smallint range, you may run into overflow errors. From smallint to varint, there's no indication in the above links varint ? tinyint Similar to above except if precision was 0 to 255, would it take 1 bytes? float Y float decimal ? decimal Not clear of the precision and scaling limits of CQL decimal ascii ? char, varchar Not clear this mapping is accurate, more an assumption. Limits and conversion behaviour are not known text ? ntext Based on UTF-8 encoding and that CQL seems to have varchar/text as does SQL. So it's likely text represents larger length text strings varchar ? nchar, nvarchar Based on UTF-8 encoding supported by both. Not clear what varchar limits are or the conversion behaviour timestamp ? datetime Not clear what timestamp limits are or the conversion behaviour boolean ? bit Not clear on conversion behaviour blob ? binary, varbinary Not clear what the limits are on length of a CQL blob uuid ? uniqueidentifier uuid follows standard UUID format, most likely 128 bits (16 bytes) which is the same storage size as uniqueidentifier. Not clear on the conversion behaviour
I think, from a pragmatic point of view, that it is wise to get a back-of-the-envelope estimate of worst case using the formulae in the ds220 course up-front at design time. The effect of compression often varies depending on algorithms and patterns in the data. From ds220 and http://cassandra.apache.org/doc/latest/cql/types.html:
uuid: 16 bytes
timeuuid: 16 bytes
timestamp: 8 bytes
bigint: 8 bytes
counter: 8 bytes
double: 8 bytes
time: 8 bytes
inet: 4 bytes (IPv4) or 16 bytes (IPV6)
date: 4 bytes
float: 4 bytes
int 4 bytes
smallint: 2 bytes
tinyint: 1 byte
boolean: 1 byte (hopefully.. no source for this)
ascii: equires an estimate of average # chars * 1 byte/char
text/varchar: requires an estimate of average # chars * (avg. # bytes/char for language)
map/list/set/blob: an estimate
hope it helps
Which seems informative, but on closer inspection, multiple distinct datatypes can map to the same validator value.
If this is the case, as for example with varchar and text, I believe that the data types map on one another and are interchangeable. Anyone else correct me if I am wrong.
Is there a way I can pull the data type info as entered in the `CREATE TABLE' statement, or at least find some distinction between the types?
The only way I know would be:
DESC TABLE users;
Also, I'm curious as to why the validator data has the 'org.apache.cassandra...' prepended to it, and couldn't find an explanation, so if anybody knows why that is, I'd be very interested to know.
Cassandra is implemented in Java and this is the full path to the Class that implements the data type.
More info:
http://docs.datastax.com/en/cql/3.0/cql/cql_reference/cql_data_types_c.html
https://github.com/apache/cassandra/tree/trunk/src/java/org/apache/cassandra/db/marshal