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

Fredy Wijaya commented on IMPALA-2751:
--------------------------------------

Ah the infamous unicode issue in Python 2.6. I don't have access to the build 
machines. Can you try to add .encode('utf-8') in the sqlparse.format result and 
run the tests again?

I built Python 2.6.9 manually from the source and added .encode('utf-8')
{noformat}
 
>>> query="with y as (values(7)) insert into 
>>> test_kudu_dml_reporting_256dcf63.dml_test (id) select * from y"
>>> formatted_query = sqlparse.format(query.lstrip(), 
>>> strip_comments=True).encode('utf-8')
 
>>> lexer = shlex.shlex(formatted_query, posix=True)

>>> print(list(lexer)) ['with', 'y', 'as', '(', 'values', '(', '7', ')', ')', 
>>> 'insert', 'into', 'test_kudu_dml_reporting_256dcf63', '.', 'dml_test', '(', 
>>> 'id', ')', 'select', '*', 'from', 'y']{noformat}
 

> quote in WITH block's comment breaks shell
> ------------------------------------------
>
>                 Key: IMPALA-2751
>                 URL: https://issues.apache.org/jira/browse/IMPALA-2751
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Clients
>    Affects Versions: Impala 2.2
>         Environment: CDH5.4.8
>            Reporter: Marcell Szabo
>            Assignee: Fredy Wijaya
>            Priority: Minor
>              Labels: impala-shell, shell, usability
>             Fix For: Impala 2.13.0, Impala 3.1.0
>
>
> Steps to reproduce:
> $ cat > test.sql
> with a as (
> select 'a'
> -- shouldn't matter
> ) 
> select * from a; 
> $ impala-shell -f test.sql 
> /usr/bin/impala-shell: line 32: warning: setlocale: LC_CTYPE: cannot change 
> locale (UTF-8): No such file or directory
> /usr/bin/impala-shell: line 32: warning: setlocale: LC_CTYPE: cannot change 
> locale (UTF-8): No such file or directory
> Starting Impala Shell without Kerberos authentication
> Connected to host:21000
> Server version: impalad version 2.2.0-cdh5 RELEASE (build 
> 1d0b017e2441dd8950924743d839f14b3995e259)
> Traceback (most recent call last):
>   File "/usr/lib/impala-shell/impala_shell.py", line 1006, in <module>
>     execute_queries_non_interactive_mode(options)
>   File "/usr/lib/impala-shell/impala_shell.py", line 922, in 
> execute_queries_non_interactive_mode
>     if shell.onecmd(query) is CmdStatus.ERROR:
>   File "/usr/lib64/python2.6/cmd.py", line 219, in onecmd
>     return func(arg)
>   File "/usr/lib/impala-shell/impala_shell.py", line 762, in do_with
>     tokens = list(lexer)
>   File "/usr/lib64/python2.6/shlex.py", line 269, in next
>     token = self.get_token()
>   File "/usr/lib64/python2.6/shlex.py", line 96, in get_token
>     raw = self.read_token()
>   File "/usr/lib64/python2.6/shlex.py", line 172, in read_token
>     raise ValueError, "No closing quotation"
> ValueError: No closing quotation
> Also, copy-pasting the query interactively, the line never closes.
> Strangely, the issue only seems to occur in presence of the WITH block.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscr...@impala.apache.org
For additional commands, e-mail: issues-all-h...@impala.apache.org

Reply via email to