Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

Sun_P avatar image
Sun_P asked ·

What are the options for migrating data to a new table with a new schema?

If we want to migrate data from old table to new table (new table with schema change) then what are options available ?

old table:-

CREATE TABLE old_table (
  created_date timestamp,
  track_id text,
  name text,
  PRIMARY KEY (created_date)
)

New Table:-

CREATE TABLE new_table (
  created_date timestamp,
  week number,
  message text,
  track_id text,
  name text,
  PRIMARY KEY ( (created_date, week) )
)
migration
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

I recommend you use DataStax Bulk Loader (DSBulk).

With DSBulk, you can load and unload data from a table efficiently in CSV or JSON format. It is 4x faster than the CQL COPY command and doesn't suffer from the same limitations as COPY.

Here are the high-level steps:

  1. Run DSBulk's unload command to export the data from the old table.
  2. Transform the exported data so the columns match the schema of the new table.
  3. Run DSBulk's load command to bulk-load the data to the new table.

Have a look at the reference section of the docs for unloading data and loading data examples. If you're interested, DSBulk also has a count command you could use for verification when you have completed your migration.

Here are some blog posts with detailed examples from Brian Hess you'll find useful:

Cheers!

2 comments Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Thank you for your answer.
0 Likes 0 ·
Happy to help. Cheers!
0 Likes 0 ·