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

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

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

jtdelato avatar image jtdelato commented ·

Thanks Erick!

I appreciate all the help lately!

0 Likes 0 ·
Erick Ramirez avatar image Erick Ramirez ♦♦ jtdelato commented ·

You're welcome. Happy to help. Cheers!

0 Likes 0 ·