[
https://issues.apache.org/jira/browse/CASSANDRA-12909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15763382#comment-15763382
]
Stefania commented on CASSANDRA-12909:
--------------------------------------
This is a sample
[failure|http://cassci.datastax.com/job/stef1927-12909-cqlsh-2.2-cqlsh-tests/cython=no,label=ctool-lab/2/testReport/junit/junit/cqlsh_tests.cqlsh_copy_tests/CqlshCopyTest/test_all_datatypes_round_trip/]
that we get without calling {{unicode}} in the protectors. The problem is:
{code}
Traceback (most recent call last):
File "/home/automaton/cassandra/bin/../pylib/cqlshlib/copyutil.py", line
2262, in make_statement
return inner_make_statement(query, conv, batch, replicas)
File "/home/automaton/cassandra/bin/../pylib/cqlshlib/copyutil.py", line
2321, in make_non_prepared_batch_statement
statement = SimpleStatement(query % (','.join(batch['rows'][0]),),
consistency_level=self.consistency_level)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 114:
ordinal not in range(128)
{code}
It fails to append arguments to the query string if they are not of type
unicode. The query is of type unicode because it is created by concatenating
the query text to the the column names, which are unicode types. Column names
are wrapped by a call to protect_name, older versions of the driver were
converting unicode column names to utf-8, whilst now protect_name no longer
encodes strings to utf-8. Therefore, in order to avoid converting values to
unicode, we can equivalently encode the query text into utf-8. This shouldn't
be too risky since it was the behavior prior to CASSANDRA-11850. It is also
probably a little bit more efficient, in addition to avoiding the special
casing for ascii types. I only modified the 2.2
[patch|https://github.com/apache/cassandra/compare/trunk...stef1927:12909-cqlsh-2.2],
let me know if you agree with this new approach [~blerer].
CI for 2.2 is pending.
> cqlsh copy cannot parse strings when counters are present
> ---------------------------------------------------------
>
> Key: CASSANDRA-12909
> URL: https://issues.apache.org/jira/browse/CASSANDRA-12909
> Project: Cassandra
> Issue Type: Bug
> Reporter: Stefania
> Assignee: Stefania
> Fix For: 2.2.x, 3.0.x, 3.x
>
>
> We get parse error {{Failed to import 1 rows: ParseError - argument for 's'
> must be a string}} when using the following table and data:
> {code}
> CREATE TABLE ks.test (
> object_id ascii,
> user_id timeuuid,
> counter_id ascii,
> count counter,
> PRIMARY KEY ((object_id, user_id), counter_id)
> )
> {code}
> {code}
> EVT:be3bd2d0-a68d-11e6-90d4-1b2a65b8a28a,f7ce3ac0-a66e-11e6-b58e-4e29450fd577,SA,2
> {code}
> The problem is this line
> [here|https://github.com/apache/cassandra/blob/trunk/pylib/cqlshlib/copyutil.py#L2114],
> strings are serialized as unicode rather than ordinary strings but only for
> non-prepared statements (unsure why).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)