mirror of
https://github.com/apache/impala.git
synced 2025-12-23 21:08:39 -05:00
IMPALA-2751: Matching quotes are not required in comments
This patch fixes the issue where non-matching quotes inside comments will cause the shell to not terminate. The fix is to strip any SQL comments before sending to shlex since shlex does not understand SQL comments and will raise an exception when it sees unmatched quotes regardless whether the quotes are in the comments or not. Testing: - Added new shell tests - Ran all end-to-end shell tests on Python 2.6 and Python 2.7 Change-Id: I2feae34026a7e63f3d31489f757f093a73ca5d2c Reviewed-on: http://gerrit.cloudera.org:8080/10541 Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
committed by
Impala Public Jenkins
parent
bf2124bf30
commit
2b05c3c3ca
@@ -515,6 +515,24 @@ class TestImpalaShellInteractive(object):
|
||||
result = run_impala_shell_interactive("select '1\"23\"4'\";\n;\n\";")
|
||||
assert '| 1"23"4 |' in result.stdout
|
||||
|
||||
@pytest.mark.execute_serially
|
||||
def test_comment_with_quotes(self):
|
||||
# IMPALA-2751: Comment does not need to have matching quotes
|
||||
queries = [
|
||||
"select -- '\n1;",
|
||||
'select -- "\n1;',
|
||||
"select -- \"'\n 1;",
|
||||
"select /*'\n*/ 1;",
|
||||
'select /*"\n*/ 1;',
|
||||
"select /*\"'\n*/ 1;",
|
||||
"with a as (\nselect 1\n-- '\n) select * from a",
|
||||
'with a as (\nselect 1\n-- "\n) select * from a',
|
||||
"with a as (\nselect 1\n-- '\"\n) select * from a",
|
||||
]
|
||||
for query in queries:
|
||||
result = run_impala_shell_interactive(query)
|
||||
assert '| 1 |' in result.stdout
|
||||
|
||||
@pytest.mark.execute_serially
|
||||
def test_shell_prompt(self):
|
||||
proc = pexpect.spawn(SHELL_CMD)
|
||||
|
||||
Reference in New Issue
Block a user