Fredy Wijaya has posted comments on this change. ( http://gerrit.cloudera.org:8080/10876 )
Change subject: IMPALA-6223: Gracefully handle malformed 'with' queries in impala-shell ...................................................................... Patch Set 2: (2 comments) http://gerrit.cloudera.org:8080/#/c/10876/2/shell/impala_shell.py File shell/impala_shell.py: http://gerrit.cloudera.org:8080/#/c/10876/2/shell/impala_shell.py@1147 PS2, Line 1147: > nit: our convention is to use 2 space indentation I kinda prefer to still send the query to the Impala parser even on error and so that the parser can print a useful message. try: lexer = shlex.shlex(sqlparse.format(query.query.lstrip(), strip_comments=True) .encode('utf-8'), posix=True) lexer.escapedquotes += "'" # Because the WITH clause may precede DML or SELECT queries, # just checking the first token is insufficient. is_dml = False tokens = list(lexer) if filter(self.DML_REGEX.match, tokens): is_dml = True return self._execute_stmt(query, is_dml=is_dml, print_web_link=True) except: return self._execute_stmt(query, print_web_link=True) [localhost:21000] default> with v as (select 1) select foo('\\\\'), ('bar \n; Query: with v as (select 1) select foo('\\\\'), ('bar \n Query submitted at: 2018-07-05 19:16:51 (Coordinator: http://impala-dev:25000) ERROR: AnalysisException: Syntax error in line 1: with v as (select 1) select foo('\\\\'), ('bar \n ^ Encountered: Unexpected character Expected: ADD, ALTER, AND, ARRAY, AS, ASC, BETWEEN, BIGINT, BINARY, BLOCK_SIZE, BOOLEAN, CACHED, CASCADE, CHANGE, CHAR, COMMENT, COMPRESSION, CROSS, DATE, DATETIME, DECIMAL, DEFAULT, DESC, DIV, REAL, DROP, ELSE, ENCODING, END, FLOAT, FOLLOWING, FROM, FULL, GROUP, IGNORE, HAVING, ILIKE, IN, INNER, INTEGER, IREGEXP, IS, JOIN, LEFT, LIKE, LIMIT, LOCATION, MAP, NOT, NULL, NULLS, OFFSET, ON, OR, ORDER, PARTITION, PARTITIONED, PRECEDING, PRIMARY, PURGE, RANGE, RECOVER, REGEXP, RENAME, REPLACE, RESTRICT, RIGHT, RLIKE, ROW, ROWS, SELECT, SET, SMALLINT, SORT, STORED, STRAIGHT_JOIN, STRING, STRUCT, TABLESAMPLE, TBLPROPERTIES, THEN, TIMESTAMP, TINYINT, TO, UNCACHED, UNION, USING, VALUES, VARCHAR, WHEN, WHERE, WITH, COMMA, IDENTIFIER CAUSED BY: Exception: Syntax error http://gerrit.cloudera.org:8080/#/c/10876/2/tests/shell/test_shell_commandline.py File tests/shell/test_shell_commandline.py: http://gerrit.cloudera.org:8080/#/c/10876/2/tests/shell/test_shell_commandline.py@655 PS2, Line 655: nit: Python's docstring convention is to not have a space after """, similarly with the end comment. -- To view, visit http://gerrit.cloudera.org:8080/10876 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ibb1e9238ac67b8ad3b2caa1748a18b04f384802d Gerrit-Change-Number: 10876 Gerrit-PatchSet: 2 Gerrit-Owner: Pooja Nilangekar <[email protected]> Gerrit-Reviewer: Bikramjeet Vig <[email protected]> Gerrit-Reviewer: Fredy Wijaya <[email protected]> Gerrit-Reviewer: Pooja Nilangekar <[email protected]> Gerrit-Comment-Date: Fri, 06 Jul 2018 02:27:50 +0000 Gerrit-HasComments: Yes
