This is an automated email from the ASF dual-hosted git repository.
stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
The following commit(s) were added to refs/heads/master by this push:
new 8f79c9583 IMPALA-10120: Add required fields for TGetInfoResp when
error.
8f79c9583 is described below
commit 8f79c958354ac78ba4826d216ae1bad3338d076d
Author: Xiang Yang <[email protected]>
AuthorDate: Fri Aug 11 11:26:04 2023 +0000
IMPALA-10120: Add required fields for TGetInfoResp when error.
TGetInfoResp requires two fields: 'status' and 'infoValue', but impala
server only return the 'status' field when error at ImpalaServer::
GetInfo(), this can cause Beeline hang.
This patch fix this by set the required 'infoValue' field when error.
Testing:
- add an EE test: test_beeline.py.
Change-Id: Ib42bb82735fb4a8e6911b6a19adb8bd84973300b
Reviewed-on: http://gerrit.cloudera.org:8080/20344
Reviewed-by: Impala Public Jenkins <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>
---
be/src/service/impala-hs2-server.cc | 8 +++++--
tests/common/impala_test_suite.py | 17 +++++++++++++--
tests/shell/test_beeline.py | 43 +++++++++++++++++++++++++++++++++++++
3 files changed, 64 insertions(+), 4 deletions(-)
diff --git a/be/src/service/impala-hs2-server.cc
b/be/src/service/impala-hs2-server.cc
index 5b15c1e66..00a93d113 100644
--- a/be/src/service/impala-hs2-server.cc
+++ b/be/src/service/impala-hs2-server.cc
@@ -493,8 +493,12 @@ void ImpalaServer::GetInfo(TGetInfoResp& return_val,
return_val.infoValue.__set_stringValue(GetDaemonBuildVersion());
break;
default:
- HS2_RETURN_ERROR(return_val, "Unsupported operation",
- SQLSTATE_OPTIONAL_FEATURE_NOT_IMPLEMENTED);
+ return_val.status.__set_statusCode(thrift::TStatusCode::ERROR_STATUS);
+ return_val.status.__set_errorMessage(("Unsupported operation"));
+
return_val.status.__set_sqlState((SQLSTATE_OPTIONAL_FEATURE_NOT_IMPLEMENTED));
+ // 'infoValue' is a required field of TGetInfoResp
+ return_val.infoValue.__set_stringValue("");
+ return;
}
return_val.status.__set_statusCode(thrift::TStatusCode::SUCCESS_STATUS);
}
diff --git a/tests/common/impala_test_suite.py
b/tests/common/impala_test_suite.py
index 7b23ae53e..4530aacfa 100644
--- a/tests/common/impala_test_suite.py
+++ b/tests/common/impala_test_suite.py
@@ -1016,11 +1016,22 @@ class ImpalaTestSuite(BaseTestSuite):
# This should never happen.
assert 0, 'Unable to get location for table: ' + table_name
+ def run_impala_stmt_in_beeline(self, stmt, username=None,
default_db='default'):
+ """ Run a statement in impala by Beeline. """
+ url = 'jdbc:hive2://localhost:' + pytest.config.option.impalad_hs2_port +
'/'\
+ + default_db + ";auth=noSasl"
+ return self.run_stmt_in_beeline(url, username, stmt)
+
# TODO(todd) make this use Thrift to connect to HS2 instead of shelling
# out to beeline for better performance
def run_stmt_in_hive(self, stmt, username=None):
+ """Run a statement in Hive by Beeline."""
+ url = 'jdbc:hive2://' + pytest.config.option.hive_server2
+ return self.run_stmt_in_beeline(url, username, stmt)
+
+ def run_stmt_in_beeline(self, url, username, stmt):
"""
- Run a statement in Hive, returning stdout if successful and throwing
+ Run a statement by Beeline, returning stdout if successful and throwing
RuntimeError(stderr) if not.
"""
# Remove HADOOP_CLASSPATH from environment. Beeline doesn't need it,
@@ -1033,8 +1044,10 @@ class ImpalaTestSuite(BaseTestSuite):
env.pop("HADOOP_CLASSPATH", None)
call = subprocess.Popen(
['beeline',
+ # TODO IMPALA-2228: Prevents query output from being confused with
log.
+ '--silent=true',
'--outputformat=csv2',
- '-u', 'jdbc:hive2://' + pytest.config.option.hive_server2,
+ '-u', url,
'-n', username or getuser(),
'-e', stmt],
stdout=subprocess.PIPE,
diff --git a/tests/shell/test_beeline.py b/tests/shell/test_beeline.py
new file mode 100644
index 000000000..d6206e067
--- /dev/null
+++ b/tests/shell/test_beeline.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env impala-python
+# -*- coding: utf-8 -*-
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import absolute_import, division, print_function
+from tests.common.impala_test_suite import ImpalaTestSuite
+
+
+class TestBeeline(ImpalaTestSuite):
+ def test_beeline_compatibility(self, unique_database):
+ stmt = "show tables"
+ assert self.run_impala_stmt_in_beeline(stmt, None, unique_database) ==
"name\n"
+ stmt = "create table test_beeline_compatibility(id int)"
+ assert self.run_impala_stmt_in_beeline(stmt, None, unique_database) == \
+ "summary\nTable has been created.\n"
+ stmt = "show tables"
+ assert self.run_impala_stmt_in_beeline(stmt, None, unique_database) == \
+ "name\ntest_beeline_compatibility\n"
+ stmt = "select count(*) as cnt from test_beeline_compatibility"
+ assert self.run_impala_stmt_in_beeline(stmt, None, unique_database) ==
"cnt\n0\n"
+ stmt = "insert into test_beeline_compatibility values(1), (2), (3)"
+ assert self.run_impala_stmt_in_beeline(stmt, None, unique_database) == ""
+ stmt = "select count(*) as cnt from test_beeline_compatibility"
+ assert self.run_impala_stmt_in_beeline(stmt, None, unique_database) ==
"cnt\n3\n"
+ stmt = "drop table test_beeline_compatibility"
+ assert self.run_impala_stmt_in_beeline(stmt, None, unique_database) == \
+ "summary\nTable has been dropped.\n"