Does Scylla reorder columns in newly created tables?

I am creating tracking.tracking_data as:
CREATE TABLE tracking_data (
first_name text,
last_name text,
timestamp timestamp,
location varchar,
speed double,
heat double,
telepathy_powers int,
primary key((first_name, last_name), timestamp))
AND COMPACTION = {‘class’: ‘TimeWindowCompactionStrategy’,
‘base_time_seconds’: 3600,
‘max_sstable_age_days’: 1};

But when I describe the table, the columns are in a different sequence:
cqlsh:tracking> describe keyspace tracking;

CREATE KEYSPACE tracking WITH replication = {‘class’: ‘NetworkTopologyStrategy’, ‘DC1’: ‘3’} AND durable_writes = true;

CREATE TABLE tracking.tracking_data (
first_name text,
last_name text,
timestamp timestamp,
heat double,
location text,
speed double,
telepathy_powers int,
PRIMARY KEY ((first_name, last_name), timestamp)
AND bloom_filter_fp_chance = 0.01
AND caching = {‘keys’: ‘ALL’, ‘rows_per_partition’: ‘ALL’}
AND comment = ‘’
AND compaction = {‘base_time_seconds’: ‘3600’, ‘class’: ‘TimeWindowCompactionStrategy’, ‘max_sstable_age_days’: ‘1’}
AND compression = {‘sstable_compression’: ‘’}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.0
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = ‘99.0PERCENTILE’;

Good question.
AFAIK in ScyllaDB (and Apache Cassandra), there is no guarantee regarding the order of the columns unless they are part of the Primary Key.
The logic behind this has to do with the way that data is represented under the hood. This is (at some level) explained in the Basic Data Modeling lesson in Scylla University (mostly in the Importance of Primary Key Selection
and the Importance of the Clustering Key lesson).
That means you should not rely on a particular order for the storage.
Instead, you can define how the data will be presented at the application level.

Internally, columns are ordered alphabetically, except primary key columns, those are ordered as they were specified in the initial table definition.

1 Like

Ok, thanks for the clarification.