This is an automated email from the ASF dual-hosted git repository.
liuhangyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new 1dacadb [BUG] Fix DATA_TYPE in information_schema.columns is not
compatible to mysql meta (#4648)
1dacadb is described below
commit 1dacadb01524205350e2ce4f06d56b34af3d1df2
Author: HangyuanLiu <[email protected]>
AuthorDate: Fri Sep 25 13:38:09 2020 +0800
[BUG] Fix DATA_TYPE in information_schema.columns is not compatible to
mysql meta (#4648)
Describe the bug
DATA_TYPE in information_schema.columns is not compatible to mysql meta
To Reproduce
Steps to reproduce the behavior:
select * from information_schema.columns
Expected behavior
the result of data_type is (int, decimal, char, varchar, ...),but doris
data_type is (int(11), varchar(20), ...)
Excess number will affect some BI systems or upper system can't get right
type
---
.../exec/schema_scanner/schema_columns_scanner.cpp | 38 +++++++++++++++++++++-
.../exec/schema_scanner/schema_columns_scanner.h | 1 +
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/be/src/exec/schema_scanner/schema_columns_scanner.cpp
b/be/src/exec/schema_scanner/schema_columns_scanner.cpp
index b3fbb80..f18fc52 100644
--- a/be/src/exec/schema_scanner/schema_columns_scanner.cpp
+++ b/be/src/exec/schema_scanner/schema_columns_scanner.cpp
@@ -93,6 +93,42 @@ Status SchemaColumnsScanner::start(RuntimeState *state) {
return Status::OK();
}
+//For compatibility with mysql the result of DATA_TYPE in
information_schema.columns
+std::string SchemaColumnsScanner::to_mysql_data_type_string(TColumnDesc &desc)
{
+ switch (desc.columnType) {
+ case TPrimitiveType::BOOLEAN:
+ return "tinyint";
+ case TPrimitiveType::TINYINT:
+ return "tinyint";
+ case TPrimitiveType::SMALLINT:
+ return "smallint";
+ case TPrimitiveType::INT:
+ return "int";
+ case TPrimitiveType::BIGINT:
+ return "bigint";
+ case TPrimitiveType::LARGEINT:
+ return "bigint unsinged";
+ case TPrimitiveType::FLOAT:
+ return "float";
+ case TPrimitiveType::DOUBLE:
+ return "double";
+ case TPrimitiveType::VARCHAR:
+ return "varchar";
+ case TPrimitiveType::CHAR:
+ return "char";
+ case TPrimitiveType::DATE:
+ return "date";
+ case TPrimitiveType::DATETIME:
+ return "datetime";
+ case TPrimitiveType::DECIMALV2:
+ case TPrimitiveType::DECIMAL: {
+ return "decimal";
+ }
+ default:
+ return "unknown";
+ }
+}
+
std::string SchemaColumnsScanner::type_to_string(TColumnDesc &desc) {
switch (desc.columnType) {
case TPrimitiveType::BOOLEAN:
@@ -208,7 +244,7 @@ Status SchemaColumnsScanner::fill_one_row(Tuple *tuple,
MemPool *pool) {
{
void *slot = tuple->get_slot(_tuple_desc->slots()[7]->tuple_offset());
StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
- std::string buffer =
type_to_string(_desc_result.columns[_column_index].columnDesc);
+ std::string buffer =
to_mysql_data_type_string(_desc_result.columns[_column_index].columnDesc);
str_slot->len = buffer.length();
str_slot->ptr = (char *)pool->allocate(str_slot->len);
memcpy(str_slot->ptr, buffer.c_str(), str_slot->len);
diff --git a/be/src/exec/schema_scanner/schema_columns_scanner.h
b/be/src/exec/schema_scanner/schema_columns_scanner.h
index c7c5396..3ff0c14 100644
--- a/be/src/exec/schema_scanner/schema_columns_scanner.h
+++ b/be/src/exec/schema_scanner/schema_columns_scanner.h
@@ -36,6 +36,7 @@ private:
Status fill_one_row(Tuple *tuple, MemPool *pool);
Status get_new_desc();
Status get_create_table(std::string *result);
+ std::string to_mysql_data_type_string(TColumnDesc &desc);
std::string type_to_string(TColumnDesc &desc);
int _db_index;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]