-2

I am mapping some data types from SQL server to cassandra, such as int to bigint, real to float, varchar to text. Where can I get the mappings from SQL server to cassandra?

1
  • You have to determine what datatypes to use. There is not standard for this kind of thing.
    – Sean Lange
    Aug 26, 2016 at 18:17

1 Answer 1

2

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.