Hi! i’ve got a question regarding the C# driver. I’ve been trying to build an export tool for Cassandra based on your C# driver. I’m encountering an issue where, when tables have data with special characters, I dont receive these information within C#. Am I doing something wrong here, or is this a bug?
I’ve tried this on different environments (native cassandra on linux centos 7, docker setup on a windows vm). Both give the same result.
This is the data i put in cassandra:
t*\x10r>\nw@S=
This is what i get out:
t*x10r>nw@S=
Is there a way to get the backslashes as well?
EDIT: When I use the COPY command in cqlsh it does output the special characters.
[UPDATE] This is the method i use for fetching rows:
- public Task<RowSet> GetRowsAsync(ISession session, string table)
- {
- return session.ExecuteAsync(new SimpleStatement($"SELECT * FROM {table}"));
- }
This is the main code:
- _logger.Log("Fetching rows", fullTableName);
- var dataRows = await _cassandraService.GetRowsAsync(session, fullTableName);
- _logger.Log("Fetched rows", fullTableName);
- _logger.Log("Start writing data to CSV", fullTableName);
- TextWriter tw = new StreamWriter($"{_cassandraConfiguration.BackupTargetFolder}/{fullTableName}.csv");
- _counter.Reset();
- foreach (var dataRow in dataRows)
- {
- var stringRow = new string[dataRows.Columns.Length];
- for (int i = 0; i < dataRows.Columns.Length; i++)
- {
- var data = dataRow.GetValue<object>(dataRows.Columns[i].Name);
- if (data == null)
- {
- stringRow[i] = "";
- continue;
- }
- if (data is DateTimeOffset)
- stringRow[i] = ((DateTimeOffset)data).ToString("yyyy-MM-dd HH:mm:ss.fff+0000");
- else if (data is string)
- stringRow[i] = $"\"{data}\"";
- else
- stringRow[i] = data.ToString();
- }
- tw.WriteLine(string.Join(",", stringRow));
- _counter.IncrementCounter();
- }
- tw.Flush();
- tw.Close();
Let me know if something is unclear.