[ https://issues.apache.org/jira/browse/IMPALA-7939?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16719234#comment-16719234 ]
ASF subversion and git services commented on IMPALA-7939: --------------------------------------------------------- Commit 00ddac32dc8ae49e49e4ba0b417779117522d870 in impala's branch refs/heads/master from [~fredyw] [ https://git-wip-us.apache.org/repos/asf?p=impala.git;h=00ddac3 ] IMPALA-7939: Fix issue where CTE is categorized as DML statement The logic that checks whether a CTE is DML or SELECT uses shlex that splits the statement into tokens and check if any of the tokens matches the DML regular expression. Before this patch, the shlex was set to posix=True, which means the quotes are stripped from the token, e.g. select a from foo where a = 'update' becomes ['select', 'a', 'from', 'foo', 'where', 'a', '=', 'update']. As a result, any token that contains "insert", "delete", "upsert", and "update" in it will be categorized as DML even though the token is part of string literal value. This patch fixes the issue by setting posix=False in shlex that preserves the quotes. For example: ['select', 'a', 'from', 'foo', 'where', 'a', '=', '"update"'] Testing: - Added a new shell test - Ran all shell tests Change-Id: I011b8e73a0477ac6b2357725452458f972785ae7 Reviewed-on: http://gerrit.cloudera.org:8080/12052 Reviewed-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenk...@cloudera.com> > Impala shell not displaying results for a CTE query. > ---------------------------------------------------- > > Key: IMPALA-7939 > URL: https://issues.apache.org/jira/browse/IMPALA-7939 > Project: IMPALA > Issue Type: Bug > Affects Versions: Impala 3.1.0 > Reporter: Anuj Phadke > Assignee: Fredy Wijaya > Priority: Critical > Fix For: Impala 3.2.0 > > > {noformat} > 1. > [localhost:21000] > CREATE TABLE test (cp_master_id STRING, data_status > STRING) stored as parquet; > Query: CREATE TABLE test (cp_master_id STRING, data_status STRING) stored as > parquet > Fetched 0 row(s) in 0.03s > 2. > [localhost:21000] > insert into test (cp_master_id, data_status) values > ('11111111111','NEWREC'); > Query: insert into test (cp_master_id, data_status) values > ('11111111111','NEWREC') > Query submitted at: 2018-12-06 14:02:21 (Coordinator: > [http://anuj-OptiPlex-9020:25000|http://anuj-optiplex-9020:25000/]) > Query progress can be monitored at: > [http://anuj-OptiPlex-9020:25000/query_plan?query_id=14182abf0a7e4bb:8788cdab00000000|http://anuj-optiplex-9020:25000/query_plan?query_id=14182abf0a7e4bb:8788cdab00000000] > Modified 1 row(s) in 4.14s > *********************************************************************************** > 3. > [localhost:21000] > WITH tbl_incoming > > AS > > ( > > SELECT cp_master_id, data_status FROM test WHERE (data_status = 'NEWREC' > OR data_status='UPDATE') > > ) > > select * from test; > Query: WITH tbl_incoming > AS > ( > SELECT cp_master_id, data_status FROM test WHERE (data_status = 'NEWREC' OR > data_status='UPDATE') > ) > select * from test > Modified 0 row(s) in 0.12s > [localhost:21000] > > > 4. > [localhost:21000] > SELECT cp_master_id, data_status FROM test WHERE > (data_status = 'NEWREC' OR data_status='UPDATE'); > Query: SELECT cp_master_id, data_status FROM test WHERE (data_status = > 'NEWREC' OR data_status='UPDATE') > Query submitted at: 2018-12-06 14:05:48 (Coordinator: > [http://anuj-OptiPlex-9020:25000|http://anuj-optiplex-9020:25000/]) > Query progress can be monitored at: > [http://anuj-OptiPlex-9020:25000/query_plan?query_id=4b49d50ec0b973c1:ce474a1500000000|http://anuj-optiplex-9020:25000/query_plan?query_id=4b49d50ec0b973c1:ce474a1500000000] > +----------------+-----------+ > |cp_master_id|data_status| > +----------------+-----------+ > |11111111111|NEWREC| > +----------------+-----------+ > Fetched 1 row(s) in 0.12s > {noformat} > > I think the bug is in the regex here - > https://github.com/apache/impala/blob/master/shell/impala_shell.py#L1157 > It matches for "UPDATE" - > https://github.com/apache/impala/blob/master/shell/impala_shell.py#L139 -- 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