[ 
https://issues.apache.org/jira/browse/CASSANDRA-15182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16874266#comment-16874266
 ] 

Michael Shuler commented on CASSANDRA-15182:
--------------------------------------------

Thanks Yuki, that helps! Simplified reproduction - CQL syntax is wrong, but the 
syntax error output encoding is problematic:
{noformat}
ccm create --version=git:cassandra-3.11 --nodes=1 --start test
ccm node1 cqlsh --debug -e "CREATE KEYSPACE test WITH replication = {'class': 
'SimpleStrategy', 'replication_factor': 1};"
ccm node1 cqlsh --debug -e "CREATE TABLE test.scratch (a text, b decimal, 
PRIMARY KEY (a));"
# show syntax error with INSERT:
ccm node1 cqlsh --debug -e "INSERT INTO test.scratch (a, b) VALUES 
('A00888D',);"
# show unicode problem when syntax error is output:
ccm node1 cqlsh --debug -e "INSERT INTO test.scratch (a, b) VALUES 
('黑A00888D',);"
{noformat}

Full output of above:
{noformat}
mshuler@hana:~$ ccm create --version=git:cassandra-3.11 --nodes=1 --start test
https://gitbox.apache.org/repos/asf/cassandra.git git:cassandra-3.11
10:22:53,842 ccm INFO Cloning Cassandra...
10:23:20,346 ccm INFO Cloning Cassandra (from local cache)
10:23:21,129 ccm INFO Checking out requested branch (cassandra-3.11)
10:23:21,927 ccm INFO Compiling Cassandra cassandra-3.11 ...
Current cluster is now: test
mshuler@hana:~$ ccm node1 cqlsh --debug -e "CREATE KEYSPACE test WITH 
replication = {'class': 'SimpleStrategy', 'replication_factor': 1};"Using CQL 
driver: <module 'cassandra' from 
'/home/mshuler/.ccm/repository/gitCOLONcassandra-3.11/bin/../lib/cassandra-driver-internal-only-3.11.0-bb96859b.zip/cassandra-driver-3.11.0-bb96859b/cassandra/__init__.py'>
Using connect timeout: 5 seconds
Using 'utf-8' encoding
Using ssl: False
mshuler@hana:~$ ccm node1 cqlsh --debug -e "CREATE TABLE test.scratch (a text, 
b decimal, PRIMARY KEY (a));"
Using CQL driver: <module 'cassandra' from 
'/home/mshuler/.ccm/repository/gitCOLONcassandra-3.11/bin/../lib/cassandra-driver-internal-only-3.11.0-bb96859b.zip/cassandra-driver-3.11.0-bb96859b/cassandra/__init__.py'>
Using connect timeout: 5 seconds
Using 'utf-8' encoding
Using ssl: False
mshuler@hana:~$ ccm node1 cqlsh --debug -e "INSERT INTO test.scratch (a, b) 
VALUES ('A00888D',);"
Using CQL driver: <module 'cassandra' from 
'/home/mshuler/.ccm/repository/gitCOLONcassandra-3.11/bin/../lib/cassandra-driver-internal-only-3.11.0-bb96859b.zip/cassandra-driver-3.11.0-bb96859b/cassandra/__init__.py'>
Using connect timeout: 5 seconds
Using 'utf-8' encoding
Using ssl: False
<stdin>:1:SyntaxException: line 1:50 no viable alternative at input ')' (..., 
b) VALUES ('A00888D',[)]...)
mshuler@hana:~$ ccm node1 cqlsh --debug -e "INSERT INTO test.scratch (a, b) 
VALUES ('黑A00888D',);"
Using CQL driver: <module 'cassandra' from 
'/home/mshuler/.ccm/repository/gitCOLONcassandra-3.11/bin/../lib/cassandra-driver-internal-only-3.11.0-bb96859b.zip/cassandra-driver-3.11.0-bb96859b/cassandra/__init__.py'>
Using connect timeout: 5 seconds
Using 'utf-8' encoding
Using ssl: False
Traceback (most recent call last):
  File "/home/mshuler/.ccm/repository/gitCOLONcassandra-3.11/bin/cqlsh.py", 
line 925, in onecmd
    self.handle_statement(st, statementtext)
  File "/home/mshuler/.ccm/repository/gitCOLONcassandra-3.11/bin/cqlsh.py", 
line 965, in handle_statement
    return self.perform_statement(cqlruleset.cql_extract_orig(tokens, srcstr))
  File "/home/mshuler/.ccm/repository/gitCOLONcassandra-3.11/bin/cqlsh.py", 
line 999, in perform_statement
    success, future = self.perform_simple_statement(stmt)
  File "/home/mshuler/.ccm/repository/gitCOLONcassandra-3.11/bin/cqlsh.py", 
line 1052, in perform_simple_statement
    self.printerr(unicode(err.__class__.__name__) + u": " + 
err.message.decode(encoding='utf-8'))
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u9ed1' in position 
63: ordinal not in range(128)
{noformat}

> cqlsh utf_8.py, line 16, in decode     return codecs.utf_8_decode(input, 
> errors, True)<stdin>:1:'ascii' codec can't encode character u'\u9ed1' in 
> position 60: ordinal not in range(128)
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-15182
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-15182
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL/Interpreter
>            Reporter: gloCalHelp.com
>            Priority: Normal
>
> I use cqlsh 5.0.1 with cassandra 3.11.3 with python2.7.13 in Centos 6.9.
> when I run this cql command: bin/cqlsh hadoop4 -u dba -p ********** --debug  
> -e "INSERT INTO HYGL_JCSJ.hyjg_ods_yy_gps_novar3 
> (clcph,dwsj,bc,blbs,cjbzh,ckryid,clid,clmc,ddfx,ddrq,fwj,gd,gdjd,gdwd,jsdlc,jszjl,jxzjl,sjid,sjsfzh,sjxm,sssd,xlmc)
>  VALUES 
> ('黑A00888D','2019-06-2509:57:19',0,,'',,,'379-7038',1434,'2019-06-25',275,0,126723690,45726990
>  ,796.0,2205,746,'null','null','null',0,'379');"
> I get the error message as below:
> Using CQL driver: <module 'cassandra' from 
> '/home/cassandra/cas3.11.3/bin/../lib/cassandra-driver-internal-only-3.11.0-bb96859b.zip/cassandra-driver-3.11.0-bb96859b/cassandra/__init__.py'>
> Using connect timeout: 5 seconds
> Using 'utf-8' encoding
> Using ssl: False
> Traceback (most recent call last):
>  File "/home/cassandra/cas3.11.3/bin/cqlsh.py", line 926, in onecmd
>  self.handle_statement(st, statementtext)
>  File "/home/cassandra/cas3.11.3/bin/cqlsh.py", line 966, in handle_statement
>  return self.perform_statement(cqlruleset.cql_extract_orig(tokens, srcstr))
>  File "/home/cassandra/cas3.11.3/bin/cqlsh.py", line 1000, in 
> perform_statement
>  success, future = self.perform_simple_statement(stmt)
>  File "/home/cassandra/cas3.11.3/bin/cqlsh.py", line 1053, in 
> perform_simple_statement
>  self.printerr(unicode(err.__class__.__name__) + u": " + 
> err.message.decode(encoding='utf-8'))
>  File "/usr/local/python27/lib/python2.7/encodings/utf_8.py", line 16, in 
> decode
>  return codecs.utf_8_decode(input, errors, True)
> UnicodeEncodeError: 'ascii' codec can't encode character u'\u9ed1' in 
> position 60: ordinal not in range(128)
>  
> this issue seems different with the select command issue on  
> https://issues.apache.org/jira/browse/CASSANDRA-10875 
> and other method to add "-*- coding: utf-8 -*- " in the head of cqlsh.py ,  
> can anyone hurry up to teach me?
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to