This is an automated email from the ASF dual-hosted git repository.
nextdreamblue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 23e83f263b7 [fix](session) fix select * from variables system table
(#34529)
23e83f263b7 is described below
commit 23e83f263b7c889c1bfe40842aba9d27e44f86ae
Author: xueweizhang <[email protected]>
AuthorDate: Fri Aug 2 17:03:18 2024 +0800
[fix](session) fix select * from variables system table (#34529)
after #23017, information_schema.session_variables and
information_schema.global_variables had 2 new columns, but
SchemaVariablesScanner just 2 columns. when select * from *_variables, will
get 'no match column for this column' error
Signed-off-by: nextdreamblue <[email protected]>
---
.../schema_scanner/schema_variables_scanner.cpp | 29 +++++++++++++++++++---
.../apache/doris/service/FrontendServiceImpl.java | 11 +++-----
gensrc/thrift/FrontendService.thrift | 2 +-
.../data/variable_p0/set_and_unset_variable.out | 6 +++++
.../variable_p0/set_and_unset_variable.groovy | 4 +++
5 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/be/src/exec/schema_scanner/schema_variables_scanner.cpp
b/be/src/exec/schema_scanner/schema_variables_scanner.cpp
index 9ebd4d7781f..ad4d5d072cb 100644
--- a/be/src/exec/schema_scanner/schema_variables_scanner.cpp
+++ b/be/src/exec/schema_scanner/schema_variables_scanner.cpp
@@ -40,7 +40,8 @@ std::vector<SchemaScanner::ColumnDesc>
SchemaVariablesScanner::_s_vars_columns =
// name, type, size
{"VARIABLE_NAME", TYPE_VARCHAR, sizeof(StringRef), false},
{"VARIABLE_VALUE", TYPE_VARCHAR, sizeof(StringRef), false},
-};
+ {"DEFAULT_VALUE", TYPE_VARCHAR, sizeof(StringRef), false},
+ {"CHANGED", TYPE_VARCHAR, sizeof(StringRef), false}};
SchemaVariablesScanner::SchemaVariablesScanner(TVarType::type type)
: SchemaScanner(_s_vars_columns, TSchemaTableType::SCH_VARIABLES),
_type(type) {}
@@ -94,7 +95,7 @@ Status
SchemaVariablesScanner::_fill_block_impl(vectorized::Block* block) {
std::vector<StringRef> strs(row_num);
int idx = 0;
for (auto& it : _var_result.variables) {
- strs[idx] = StringRef(it.first.c_str(), it.first.size());
+ strs[idx] = StringRef(it[0].c_str(), it[0].size());
datas[idx] = strs.data() + idx;
++idx;
}
@@ -105,12 +106,34 @@ Status
SchemaVariablesScanner::_fill_block_impl(vectorized::Block* block) {
std::vector<StringRef> strs(row_num);
int idx = 0;
for (auto& it : _var_result.variables) {
- strs[idx] = StringRef(it.second.c_str(), it.second.size());
+ strs[idx] = StringRef(it[1].c_str(), it[1].size());
datas[idx] = strs.data() + idx;
++idx;
}
RETURN_IF_ERROR(fill_dest_column_for_range(block, 1, datas));
}
+ // default value
+ {
+ std::vector<StringRef> strs(row_num);
+ int idx = 0;
+ for (auto& it : _var_result.variables) {
+ strs[idx] = StringRef(it[2].c_str(), it[2].size());
+ datas[idx] = strs.data() + idx;
+ ++idx;
+ }
+ RETURN_IF_ERROR(fill_dest_column_for_range(block, 2, datas));
+ }
+ // changed
+ {
+ std::vector<StringRef> strs(row_num);
+ int idx = 0;
+ for (auto& it : _var_result.variables) {
+ strs[idx] = StringRef(it[3].c_str(), it[3].size());
+ datas[idx] = strs.data() + idx;
+ ++idx;
+ }
+ RETURN_IF_ERROR(fill_dest_column_for_range(block, 3, datas));
+ }
return Status::OK();
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
index 5f59f4c1a69..47bcff7c6f5 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
@@ -957,18 +957,15 @@ public class FrontendServiceImpl implements
FrontendService.Iface {
@Override
public TShowVariableResult showVariables(TShowVariableRequest params)
throws TException {
TShowVariableResult result = new TShowVariableResult();
- Map<String, String> map = Maps.newHashMap();
- result.setVariables(map);
+ List<List<String>> vars = Lists.newArrayList();
+ result.setVariables(vars);
// Find connect
ConnectContext ctx = exeEnv.getScheduler().getContext((int)
params.getThreadId());
if (ctx == null) {
return result;
}
- List<List<String>> rows =
VariableMgr.dump(SetType.fromThrift(params.getVarType()),
ctx.getSessionVariable(),
- null);
- for (List<String> row : rows) {
- map.put(row.get(0), row.get(1));
- }
+ vars = VariableMgr.dump(SetType.fromThrift(params.getVarType()),
ctx.getSessionVariable(), null);
+ result.setVariables(vars);
return result;
}
diff --git a/gensrc/thrift/FrontendService.thrift
b/gensrc/thrift/FrontendService.thrift
index cce9e93fcc9..07ed2c37369 100644
--- a/gensrc/thrift/FrontendService.thrift
+++ b/gensrc/thrift/FrontendService.thrift
@@ -105,7 +105,7 @@ struct TShowVariableRequest {
// Results of a call to describeTable()
struct TShowVariableResult {
- 1: required map<string, string> variables
+ 1: required list<list<string>> variables
}
// Valid table file formats
diff --git a/regression-test/data/variable_p0/set_and_unset_variable.out
b/regression-test/data/variable_p0/set_and_unset_variable.out
index 33dd8af7bc1..506542ea754 100644
--- a/regression-test/data/variable_p0/set_and_unset_variable.out
+++ b/regression-test/data/variable_p0/set_and_unset_variable.out
@@ -134,6 +134,9 @@ deprecated_enable_local_exchange true true 0
-- !cmd --
show_hidden_columns false false 0
+-- !cmd --
+show_hidden_columns false false 0
+
-- !cmd --
0
@@ -161,6 +164,9 @@ deprecated_enable_local_exchange true true 0
-- !cmd --
show_hidden_columns false false 0
+-- !cmd --
+show_hidden_columns false false 0
+
-- !cmd --
read_only true true 0
diff --git a/regression-test/suites/variable_p0/set_and_unset_variable.groovy
b/regression-test/suites/variable_p0/set_and_unset_variable.groovy
index c637d3ae223..0ad043cb96c 100644
--- a/regression-test/suites/variable_p0/set_and_unset_variable.groovy
+++ b/regression-test/suites/variable_p0/set_and_unset_variable.groovy
@@ -73,6 +73,8 @@ suite("set_and_unset_variable") {
qt_cmd """show session variables like 'deprecated_enable_local_exchange'"""
qt_cmd """show session variables like 'show_hidden_columns'"""
+ qt_cmd """select * from information_schema.session_variables where
variable_name = 'show_hidden_columns'"""
+
// test UNSET GLOBAL VARIABLE ALL
qt_cmd """set global runtime_filter_type='BLOOM_FILTER'"""
qt_cmd """set global experimental_enable_agg_state='true'"""
@@ -84,6 +86,8 @@ suite("set_and_unset_variable") {
qt_cmd """show global variables like 'deprecated_enable_local_exchange'"""
qt_cmd """show global variables like 'show_hidden_columns'"""
+ qt_cmd """select * from information_schema.global_variables where
variable_name = 'show_hidden_columns'"""
+
// test read_only
qt_cmd """show variables like 'read_only'"""
test {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]