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

jtdelato avatar image
jtdelato asked Erick Ramirez commented

Why does a single quote loaded with DSBulk display as two single quotes in Cassandra?

I am practicing loading data with DSBulk from a CSV file.

I have a table defined as:

CREATE TABLE table_name (
col1 text,
col2 set<text>,
PRIMARY KEY (col1)
);

When I load a pipe-delimited CSV that looks like this:

col1|col2
textValueWithSingleQuote|["collectionTextValueWithSingleQuote"]

The single quote in the text field is displayed correctly in the database, but the single quote in the set<text> field is displayed as two single quotes ''

I have tried escaping the single quote with \' and that is displayed as \'

I have tried escaping the single quote with two single quotes '' and that is displayed as four single quotes ''''

I am guessing it has something to do with how JSON Strings are parsed, but my knowledge of JSON is very limited.

Does anyone have any suggestions for how to work around this?

My initial thought is just to substitute a backtick ` for single quotes, but I would like to better understand what may be happening.

Thanks for any ideas or suggestions!

dsbulk
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 Erick Ramirez commented

You didn't explain how you escaped the single quote.

Try specifying the -escape flag on the command line as follows:

$ dsbulk load -url input.csv -k ks_name -t table_name -escape "\'"

For details, see Loading data examples. 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.

Thanks Erick!

I appreciate all the help lately!

0 Likes 0 ·

You're welcome. Happy to help. Cheers!

0 Likes 0 ·