IMPALA-3992: bad shell error message when running nonexistent file

Fix the error handling code and add a test.

Change-Id: Iebcf1dc8a1a08b400a2c769a9cff38ea02c8e525
Reviewed-on: http://gerrit.cloudera.org:8080/4022
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: Internal Jenkins
This commit is contained in:
Tim Armstrong
2016-08-17 14:28:45 -07:00
committed by Internal Jenkins
parent 532b1fe118
commit 50e21247d6
2 changed files with 5 additions and 1 deletions

View File

@@ -1232,7 +1232,8 @@ def execute_queries_non_interactive_mode(options):
else:
query_file_handle = open(options.query_file, 'r')
except Exception, e:
print_to_stderr("Could not open file '%s': %s", options.query_file, e)
print_to_stderr("Could not open file '%s': %s" % (options.query_file, e))
sys.exit(1)
query_text = query_file_handle.read()
elif options.query:

View File

@@ -429,3 +429,6 @@ class TestImpalaShell(ImpalaTestSuite):
assert "(Coordinator: " in results.stderr
assert "Query progress can be monitored at: " in results.stderr
def test_missing_query_file(self):
result = run_impala_shell_cmd('-f nonexistent.sql', expect_success=False)
assert "Could not open file 'nonexistent.sql'" in result.stderr