You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2020/10/22 07:57:51 UTC

[GitHub] [incubator-doris] pengxiangyu opened a new pull request #4778: Error happened when open a view in DBeaver

pengxiangyu opened a new pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778


   ## Proposed changes
   
   Fix bug #4777:Error happened when open a view in DBeaver
   
   ## Types of changes
   
   What types of changes does your code introduce to Doris?
   _Put an `x` in the boxes that apply_
   
   - [x] Bugfix (non-breaking change which fixes an issue)
   - [] New feature (non-breaking change which adds functionality)
   - [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
   - [] Documentation Update (if none of the other choices apply)
   - [] Code refactor (Modify the code structure, format the code, etc...)
   
   ## Checklist
   
   _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._
   
   - [x] I have create an issue on (Fix #4777), and have described the bug/feature there in detail
   - [] Compiling and unit tests pass locally with my changes
   - [] I have added tests that prove my fix is effective or that my feature works
   - [] If this change need a document change, I have updated the document
   - [] Any dependent changes have been merged
   
   ## Further comments
   
   Fix bug #4777
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] yangzhg commented on a change in pull request #4778: Error happened when open a view in DBeaver

Posted by GitBox <gi...@apache.org>.
yangzhg commented on a change in pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778#discussion_r511699162



##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java
##########
@@ -281,6 +281,23 @@ public static Builder builder() {
                                                  .column("XA", ScalarType.createVarchar(3))
                                                  .column("SAVEPOINTS", ScalarType.createVarchar(3))
                                                  .build()))
+                    .put("views",
+                        new SchemaTable(
+                                SystemIdGenerator.getNextId(),
+                                "views",
+                                TableType.SCHEMA,
+                                builder()
+                                        .column("TABLE_CATALOG", ScalarType.createVarchar(512))
+                                        .column("TABLE_SCHEMA", ScalarType.createVarchar(64))
+                                        .column("TABLE_NAME", ScalarType.createVarchar(64))
+                                        .column("VIEW_DEFINITION", ScalarType.createVarchar(8096))
+                                        .column("CHECK_OPTION", ScalarType.createVarchar(8))
+                                        .column("IS_UPDATABLE", ScalarType.createVarchar(3))
+                                        .column("DEFINER", ScalarType.createVarchar(77))
+                                        .column("SECURITY_TYPE", ScalarType.createVarchar(7))

Review comment:
       why this column length is 77, you should add a comment, this column in mysql is 288




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] yangzhg commented on a change in pull request #4778: Error happened when open a view in DBeaver

Posted by GitBox <gi...@apache.org>.
yangzhg commented on a change in pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778#discussion_r511698449



##########
File path: be/src/exec/schema_scanner/schema_views_scanner.cpp
##########
@@ -0,0 +1,227 @@
+// 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.
+
+#include "exec/schema_scanner/schema_helper.h"
+#include "exec/schema_scanner/schema_views_scanner.h"
+#include "runtime/primitive_type.h"
+#include "runtime/string_value.h"
+//#include "runtime/datetime_value.h"
+
+namespace doris
+{
+
+SchemaScanner::ColumnDesc SchemaViewsScanner::_s_tbls_columns[] = {
+    //   name,       type,          size,     is_null
+    { "TABLE_CATALOG", TYPE_VARCHAR, sizeof(StringValue), true},
+    { "TABLE_SCHEMA", TYPE_VARCHAR, sizeof(StringValue), false},
+    { "TABLE_NAME",   TYPE_VARCHAR, sizeof(StringValue), false},
+    { "VIEW_DEFINITION",   TYPE_VARCHAR, sizeof(StringValue), true},
+    { "CHECK_OPTION",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "IS_UPDATABLE",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "DEFINER",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "SECURITY_TYPE",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "CHARACTER_SET_CLIENT",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "COLLATION_CONNECTION",       TYPE_VARCHAR, sizeof(StringValue), true},
+};
+
+SchemaViewsScanner::SchemaViewsScanner()
+        : SchemaScanner(_s_tbls_columns,
+                        sizeof(_s_tbls_columns) / sizeof(SchemaScanner::ColumnDesc)),
+        _db_index(0),
+        _table_index(0) {
+}
+
+SchemaViewsScanner::~SchemaViewsScanner() {
+}
+
+Status SchemaViewsScanner::start(RuntimeState *state) {
+    if (!_is_init) {
+        return Status::InternalError("used before initialized.");
+    }
+    TGetDbsParams db_params;
+    if (NULL != _param->db) {
+        db_params.__set_pattern(*(_param->db));
+    }
+    if (NULL != _param->current_user_ident) {
+        db_params.__set_current_user_ident(*(_param->current_user_ident));
+    } else {
+        if (NULL != _param->user) {
+            db_params.__set_user(*(_param->user));
+        }
+        if (NULL != _param->user_ip) {
+            db_params.__set_user_ip(*(_param->user_ip));
+        }
+    }
+
+    if (NULL != _param->ip && 0 != _param->port) {
+        RETURN_IF_ERROR(SchemaHelper::get_db_names(*(_param->ip),
+                    _param->port, db_params, &_db_result));
+    } else {
+        return Status::InternalError("IP or port doesn't exists");
+    }
+    return Status::OK();
+}
+
+Status SchemaViewsScanner::fill_one_row(Tuple *tuple, MemPool *pool) {
+    // set all bit to not null
+    memset((void *)tuple, 0, _tuple_desc->num_null_bytes());
+    const TTableStatus& tbl_status = _table_result.tables[_table_index];
+    // catalog
+    {
+        tuple->set_null(_tuple_desc->slots()[0]->null_indicator_offset());
+    }
+    // schema
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[1]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        std::string db_name = SchemaHelper::extract_db_name(_db_result.dbs[_db_index - 1]);
+        str_slot->ptr = (char *)pool->allocate(db_name.size());
+        str_slot->len = db_name.size();
+        memcpy(str_slot->ptr, db_name.c_str(), str_slot->len);
+    }
+    // name
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[2]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string* src = &tbl_status.name;
+        str_slot->len = src->length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, src->c_str(), str_slot->len);
+    }
+    // definition
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[3]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string* ddl_sql = &tbl_status.ddl_sql;
+        str_slot->len = ddl_sql->length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, ddl_sql->c_str(), str_slot->len);
+    }
+    // check_option
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[4]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string check_option = "NONE";
+        str_slot->len = check_option.length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, check_option.c_str(), str_slot->len);
+    }
+    // is_updatable
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[5]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string is_updatable = "YES";
+        str_slot->len = is_updatable.length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, is_updatable.c_str(), str_slot->len);
+    }
+    // definer
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[6]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string definer = "root@%";
+        str_slot->len = definer.length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, definer.c_str(), str_slot->len);

Review comment:
       length always 6?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman merged pull request #4778: Error happened when open a view in DBeaver

Posted by GitBox <gi...@apache.org>.
morningman merged pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman commented on a change in pull request #4778: Error happened when open a view in DBeaver

Posted by GitBox <gi...@apache.org>.
morningman commented on a change in pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778#discussion_r513537478



##########
File path: be/src/exec/schema_scanner/schema_views_scanner.cpp
##########
@@ -0,0 +1,231 @@
+// 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.
+
+#include "exec/schema_scanner/schema_helper.h"
+#include "exec/schema_scanner/schema_views_scanner.h"
+#include "runtime/primitive_type.h"
+#include "runtime/string_value.h"
+//#include "runtime/datetime_value.h"
+
+namespace doris
+{
+
+SchemaScanner::ColumnDesc SchemaViewsScanner::_s_tbls_columns[] = {
+    //   name,       type,          size,     is_null
+    { "TABLE_CATALOG", TYPE_VARCHAR, sizeof(StringValue), true},
+    { "TABLE_SCHEMA", TYPE_VARCHAR, sizeof(StringValue), false},
+    { "TABLE_NAME",   TYPE_VARCHAR, sizeof(StringValue), false},
+    { "VIEW_DEFINITION",   TYPE_VARCHAR, sizeof(StringValue), true},
+    { "CHECK_OPTION",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "IS_UPDATABLE",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "DEFINER",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "SECURITY_TYPE",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "CHARACTER_SET_CLIENT",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "COLLATION_CONNECTION",       TYPE_VARCHAR, sizeof(StringValue), true},
+};
+
+SchemaViewsScanner::SchemaViewsScanner()
+        : SchemaScanner(_s_tbls_columns,
+                        sizeof(_s_tbls_columns) / sizeof(SchemaScanner::ColumnDesc)),
+        _db_index(0),
+        _table_index(0) {
+}
+
+SchemaViewsScanner::~SchemaViewsScanner() {
+}
+
+Status SchemaViewsScanner::start(RuntimeState *state) {
+    if (!_is_init) {
+        return Status::InternalError("used before initialized.");
+    }
+    TGetDbsParams db_params;
+    if (NULL != _param->db) {
+        db_params.__set_pattern(*(_param->db));
+    }
+    if (NULL != _param->current_user_ident) {
+        db_params.__set_current_user_ident(*(_param->current_user_ident));
+    } else {
+        if (NULL != _param->user) {
+            db_params.__set_user(*(_param->user));
+        }
+        if (NULL != _param->user_ip) {
+            db_params.__set_user_ip(*(_param->user_ip));
+        }
+    }
+
+    if (NULL != _param->ip && 0 != _param->port) {
+        RETURN_IF_ERROR(SchemaHelper::get_db_names(*(_param->ip),
+                    _param->port, db_params, &_db_result));
+    } else {
+        return Status::InternalError("IP or port doesn't exists");
+    }
+    return Status::OK();
+}
+
+Status SchemaViewsScanner::fill_one_row(Tuple *tuple, MemPool *pool) {
+    // set all bit to not null
+    memset((void *)tuple, 0, _tuple_desc->num_null_bytes());
+    const TTableStatus& tbl_status = _table_result.tables[_table_index];
+    // catalog
+    {
+        tuple->set_null(_tuple_desc->slots()[0]->null_indicator_offset());
+    }
+    // schema
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[1]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        std::string db_name = SchemaHelper::extract_db_name(_db_result.dbs[_db_index - 1]);
+        str_slot->ptr = (char *)pool->allocate(db_name.size());
+        str_slot->len = db_name.size();
+        memcpy(str_slot->ptr, db_name.c_str(), str_slot->len);
+    }
+    // name
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[2]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string* src = &tbl_status.name;
+        str_slot->len = src->length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, src->c_str(), str_slot->len);
+    }
+    // definition
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[3]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string* ddl_sql = &tbl_status.ddl_sql;
+        str_slot->len = ddl_sql->length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, ddl_sql->c_str(), str_slot->len);
+    }
+    // check_option
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[4]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        // This is from views in mysql
+        const std::string check_option = "NONE";
+        str_slot->len = check_option.length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, check_option.c_str(), str_slot->len);
+    }
+    // is_updatable
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[5]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        // This is from views in mysql
+        const std::string is_updatable = "YES";

Review comment:
       Better set it to "No". Because we do not support DELETE or UPDATE on view.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] pengxiangyu commented on a change in pull request #4778: Error happened when open a view in DBeaver

Posted by GitBox <gi...@apache.org>.
pengxiangyu commented on a change in pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778#discussion_r512509823



##########
File path: be/src/exec/schema_scanner/schema_views_scanner.cpp
##########
@@ -0,0 +1,227 @@
+// 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.
+
+#include "exec/schema_scanner/schema_helper.h"
+#include "exec/schema_scanner/schema_views_scanner.h"
+#include "runtime/primitive_type.h"
+#include "runtime/string_value.h"
+//#include "runtime/datetime_value.h"
+
+namespace doris
+{
+
+SchemaScanner::ColumnDesc SchemaViewsScanner::_s_tbls_columns[] = {
+    //   name,       type,          size,     is_null
+    { "TABLE_CATALOG", TYPE_VARCHAR, sizeof(StringValue), true},
+    { "TABLE_SCHEMA", TYPE_VARCHAR, sizeof(StringValue), false},
+    { "TABLE_NAME",   TYPE_VARCHAR, sizeof(StringValue), false},
+    { "VIEW_DEFINITION",   TYPE_VARCHAR, sizeof(StringValue), true},
+    { "CHECK_OPTION",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "IS_UPDATABLE",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "DEFINER",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "SECURITY_TYPE",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "CHARACTER_SET_CLIENT",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "COLLATION_CONNECTION",       TYPE_VARCHAR, sizeof(StringValue), true},
+};
+
+SchemaViewsScanner::SchemaViewsScanner()
+        : SchemaScanner(_s_tbls_columns,
+                        sizeof(_s_tbls_columns) / sizeof(SchemaScanner::ColumnDesc)),
+        _db_index(0),
+        _table_index(0) {
+}
+
+SchemaViewsScanner::~SchemaViewsScanner() {
+}
+
+Status SchemaViewsScanner::start(RuntimeState *state) {
+    if (!_is_init) {
+        return Status::InternalError("used before initialized.");
+    }
+    TGetDbsParams db_params;
+    if (NULL != _param->db) {
+        db_params.__set_pattern(*(_param->db));
+    }
+    if (NULL != _param->current_user_ident) {
+        db_params.__set_current_user_ident(*(_param->current_user_ident));
+    } else {
+        if (NULL != _param->user) {
+            db_params.__set_user(*(_param->user));
+        }
+        if (NULL != _param->user_ip) {
+            db_params.__set_user_ip(*(_param->user_ip));
+        }
+    }
+
+    if (NULL != _param->ip && 0 != _param->port) {
+        RETURN_IF_ERROR(SchemaHelper::get_db_names(*(_param->ip),
+                    _param->port, db_params, &_db_result));
+    } else {
+        return Status::InternalError("IP or port doesn't exists");
+    }
+    return Status::OK();
+}
+
+Status SchemaViewsScanner::fill_one_row(Tuple *tuple, MemPool *pool) {
+    // set all bit to not null
+    memset((void *)tuple, 0, _tuple_desc->num_null_bytes());
+    const TTableStatus& tbl_status = _table_result.tables[_table_index];
+    // catalog
+    {
+        tuple->set_null(_tuple_desc->slots()[0]->null_indicator_offset());
+    }
+    // schema
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[1]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        std::string db_name = SchemaHelper::extract_db_name(_db_result.dbs[_db_index - 1]);
+        str_slot->ptr = (char *)pool->allocate(db_name.size());
+        str_slot->len = db_name.size();
+        memcpy(str_slot->ptr, db_name.c_str(), str_slot->len);
+    }
+    // name
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[2]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string* src = &tbl_status.name;
+        str_slot->len = src->length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, src->c_str(), str_slot->len);
+    }
+    // definition
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[3]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string* ddl_sql = &tbl_status.ddl_sql;
+        str_slot->len = ddl_sql->length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, ddl_sql->c_str(), str_slot->len);
+    }
+    // check_option
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[4]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string check_option = "NONE";
+        str_slot->len = check_option.length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, check_option.c_str(), str_slot->len);
+    }
+    // is_updatable
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[5]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string is_updatable = "YES";
+        str_slot->len = is_updatable.length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, is_updatable.c_str(), str_slot->len);
+    }
+    // definer
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[6]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string definer = "root@%";
+        str_slot->len = definer.length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, definer.c_str(), str_slot->len);

Review comment:
       this is column for table views in mysql, palo has no this information, we can only set a default one




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] pengxiangyu commented on a change in pull request #4778: Error happened when open a view in DBeaver

Posted by GitBox <gi...@apache.org>.
pengxiangyu commented on a change in pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778#discussion_r513901005



##########
File path: be/src/exec/schema_scanner/schema_views_scanner.cpp
##########
@@ -0,0 +1,231 @@
+// 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.
+
+#include "exec/schema_scanner/schema_helper.h"
+#include "exec/schema_scanner/schema_views_scanner.h"
+#include "runtime/primitive_type.h"
+#include "runtime/string_value.h"
+//#include "runtime/datetime_value.h"
+
+namespace doris
+{
+
+SchemaScanner::ColumnDesc SchemaViewsScanner::_s_tbls_columns[] = {
+    //   name,       type,          size,     is_null
+    { "TABLE_CATALOG", TYPE_VARCHAR, sizeof(StringValue), true},
+    { "TABLE_SCHEMA", TYPE_VARCHAR, sizeof(StringValue), false},
+    { "TABLE_NAME",   TYPE_VARCHAR, sizeof(StringValue), false},
+    { "VIEW_DEFINITION",   TYPE_VARCHAR, sizeof(StringValue), true},
+    { "CHECK_OPTION",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "IS_UPDATABLE",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "DEFINER",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "SECURITY_TYPE",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "CHARACTER_SET_CLIENT",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "COLLATION_CONNECTION",       TYPE_VARCHAR, sizeof(StringValue), true},
+};
+
+SchemaViewsScanner::SchemaViewsScanner()
+        : SchemaScanner(_s_tbls_columns,
+                        sizeof(_s_tbls_columns) / sizeof(SchemaScanner::ColumnDesc)),
+        _db_index(0),
+        _table_index(0) {
+}
+
+SchemaViewsScanner::~SchemaViewsScanner() {
+}
+
+Status SchemaViewsScanner::start(RuntimeState *state) {
+    if (!_is_init) {
+        return Status::InternalError("used before initialized.");
+    }
+    TGetDbsParams db_params;
+    if (NULL != _param->db) {
+        db_params.__set_pattern(*(_param->db));
+    }
+    if (NULL != _param->current_user_ident) {
+        db_params.__set_current_user_ident(*(_param->current_user_ident));
+    } else {
+        if (NULL != _param->user) {
+            db_params.__set_user(*(_param->user));
+        }
+        if (NULL != _param->user_ip) {
+            db_params.__set_user_ip(*(_param->user_ip));
+        }
+    }
+
+    if (NULL != _param->ip && 0 != _param->port) {
+        RETURN_IF_ERROR(SchemaHelper::get_db_names(*(_param->ip),
+                    _param->port, db_params, &_db_result));
+    } else {
+        return Status::InternalError("IP or port doesn't exists");
+    }
+    return Status::OK();
+}
+
+Status SchemaViewsScanner::fill_one_row(Tuple *tuple, MemPool *pool) {
+    // set all bit to not null
+    memset((void *)tuple, 0, _tuple_desc->num_null_bytes());
+    const TTableStatus& tbl_status = _table_result.tables[_table_index];
+    // catalog
+    {
+        tuple->set_null(_tuple_desc->slots()[0]->null_indicator_offset());
+    }
+    // schema
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[1]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        std::string db_name = SchemaHelper::extract_db_name(_db_result.dbs[_db_index - 1]);
+        str_slot->ptr = (char *)pool->allocate(db_name.size());
+        str_slot->len = db_name.size();
+        memcpy(str_slot->ptr, db_name.c_str(), str_slot->len);
+    }
+    // name
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[2]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string* src = &tbl_status.name;
+        str_slot->len = src->length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, src->c_str(), str_slot->len);
+    }
+    // definition
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[3]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string* ddl_sql = &tbl_status.ddl_sql;
+        str_slot->len = ddl_sql->length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, ddl_sql->c_str(), str_slot->len);
+    }
+    // check_option
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[4]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        // This is from views in mysql
+        const std::string check_option = "NONE";
+        str_slot->len = check_option.length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, check_option.c_str(), str_slot->len);
+    }
+    // is_updatable
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[5]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        // This is from views in mysql
+        const std::string is_updatable = "YES";

Review comment:
       DONE




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] pengxiangyu commented on a change in pull request #4778: Error happened when open a view in DBeaver

Posted by GitBox <gi...@apache.org>.
pengxiangyu commented on a change in pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778#discussion_r512514422



##########
File path: fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
##########
@@ -248,7 +248,19 @@ public TListTableStatusResult listTableStatus(TGetTablesParams params) throws TE
         if (db != null) {
             db.readLock();
             try {
-                for (Table table : db.getTables()) {
+                List<Table> tables = null;
+                if (!params.isSetType() || params.getType() == null || params.getType().isEmpty()) {
+                    tables = db.getTables();
+                } else {
+                    switch (params.getType()) {
+                        case "VIEW":
+                            tables = db.getViews();
+                            break;
+                        default:
+                            tables = db.getTables();
+                    }
+                }

Review comment:
       If type is view, this will call getTables() which is not required. When the count of tables in this db is too many, this will take more time.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] pengxiangyu commented on a change in pull request #4778: Error happened when open a view in DBeaver

Posted by GitBox <gi...@apache.org>.
pengxiangyu commented on a change in pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778#discussion_r512511348



##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java
##########
@@ -281,6 +281,23 @@ public static Builder builder() {
                                                  .column("XA", ScalarType.createVarchar(3))
                                                  .column("SAVEPOINTS", ScalarType.createVarchar(3))
                                                  .build()))
+                    .put("views",
+                        new SchemaTable(
+                                SystemIdGenerator.getNextId(),
+                                "views",
+                                TableType.SCHEMA,
+                                builder()
+                                        .column("TABLE_CATALOG", ScalarType.createVarchar(512))
+                                        .column("TABLE_SCHEMA", ScalarType.createVarchar(64))
+                                        .column("TABLE_NAME", ScalarType.createVarchar(64))
+                                        .column("VIEW_DEFINITION", ScalarType.createVarchar(8096))
+                                        .column("CHECK_OPTION", ScalarType.createVarchar(8))
+                                        .column("IS_UPDATABLE", ScalarType.createVarchar(3))
+                                        .column("DEFINER", ScalarType.createVarchar(77))
+                                        .column("SECURITY_TYPE", ScalarType.createVarchar(7))
+                                        .column("CHARACTER_SET_CLIENT", ScalarType.createVarchar(32))
+                                        .column("COLLATION_CONNECTION", ScalarType.createVarchar(32))

Review comment:
       the sql I got is like this.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] yangzhg commented on a change in pull request #4778: Error happened when open a view in DBeaver

Posted by GitBox <gi...@apache.org>.
yangzhg commented on a change in pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778#discussion_r511699218



##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java
##########
@@ -281,6 +281,23 @@ public static Builder builder() {
                                                  .column("XA", ScalarType.createVarchar(3))
                                                  .column("SAVEPOINTS", ScalarType.createVarchar(3))
                                                  .build()))
+                    .put("views",
+                        new SchemaTable(
+                                SystemIdGenerator.getNextId(),
+                                "views",
+                                TableType.SCHEMA,
+                                builder()
+                                        .column("TABLE_CATALOG", ScalarType.createVarchar(512))
+                                        .column("TABLE_SCHEMA", ScalarType.createVarchar(64))
+                                        .column("TABLE_NAME", ScalarType.createVarchar(64))
+                                        .column("VIEW_DEFINITION", ScalarType.createVarchar(8096))
+                                        .column("CHECK_OPTION", ScalarType.createVarchar(8))
+                                        .column("IS_UPDATABLE", ScalarType.createVarchar(3))
+                                        .column("DEFINER", ScalarType.createVarchar(77))
+                                        .column("SECURITY_TYPE", ScalarType.createVarchar(7))
+                                        .column("CHARACTER_SET_CLIENT", ScalarType.createVarchar(32))
+                                        .column("COLLATION_CONNECTION", ScalarType.createVarchar(32))

Review comment:
       why 32




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] morningman commented on a change in pull request #4778: Error happened when open a view in DBeaver

Posted by GitBox <gi...@apache.org>.
morningman commented on a change in pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778#discussion_r510171611



##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Table.java
##########
@@ -95,6 +95,8 @@
     // table(view)'s comment
     protected String comment = "";
 
+    protected String ddlSql = "";

Review comment:
       Add comment for this new field




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] imay commented on pull request #4778: Error happened when open a view in DBeaver

Posted by GitBox <gi...@apache.org>.
imay commented on pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778#issuecomment-714364816


   It is best to talk about the cause of the problem and the idea of PR change.
   This will allow others to better review the code


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] yangzhg commented on a change in pull request #4778: Error happened when open a view in DBeaver

Posted by GitBox <gi...@apache.org>.
yangzhg commented on a change in pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778#discussion_r511698449



##########
File path: be/src/exec/schema_scanner/schema_views_scanner.cpp
##########
@@ -0,0 +1,227 @@
+// 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.
+
+#include "exec/schema_scanner/schema_helper.h"
+#include "exec/schema_scanner/schema_views_scanner.h"
+#include "runtime/primitive_type.h"
+#include "runtime/string_value.h"
+//#include "runtime/datetime_value.h"
+
+namespace doris
+{
+
+SchemaScanner::ColumnDesc SchemaViewsScanner::_s_tbls_columns[] = {
+    //   name,       type,          size,     is_null
+    { "TABLE_CATALOG", TYPE_VARCHAR, sizeof(StringValue), true},
+    { "TABLE_SCHEMA", TYPE_VARCHAR, sizeof(StringValue), false},
+    { "TABLE_NAME",   TYPE_VARCHAR, sizeof(StringValue), false},
+    { "VIEW_DEFINITION",   TYPE_VARCHAR, sizeof(StringValue), true},
+    { "CHECK_OPTION",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "IS_UPDATABLE",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "DEFINER",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "SECURITY_TYPE",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "CHARACTER_SET_CLIENT",       TYPE_VARCHAR, sizeof(StringValue), true},
+    { "COLLATION_CONNECTION",       TYPE_VARCHAR, sizeof(StringValue), true},
+};
+
+SchemaViewsScanner::SchemaViewsScanner()
+        : SchemaScanner(_s_tbls_columns,
+                        sizeof(_s_tbls_columns) / sizeof(SchemaScanner::ColumnDesc)),
+        _db_index(0),
+        _table_index(0) {
+}
+
+SchemaViewsScanner::~SchemaViewsScanner() {
+}
+
+Status SchemaViewsScanner::start(RuntimeState *state) {
+    if (!_is_init) {
+        return Status::InternalError("used before initialized.");
+    }
+    TGetDbsParams db_params;
+    if (NULL != _param->db) {
+        db_params.__set_pattern(*(_param->db));
+    }
+    if (NULL != _param->current_user_ident) {
+        db_params.__set_current_user_ident(*(_param->current_user_ident));
+    } else {
+        if (NULL != _param->user) {
+            db_params.__set_user(*(_param->user));
+        }
+        if (NULL != _param->user_ip) {
+            db_params.__set_user_ip(*(_param->user_ip));
+        }
+    }
+
+    if (NULL != _param->ip && 0 != _param->port) {
+        RETURN_IF_ERROR(SchemaHelper::get_db_names(*(_param->ip),
+                    _param->port, db_params, &_db_result));
+    } else {
+        return Status::InternalError("IP or port doesn't exists");
+    }
+    return Status::OK();
+}
+
+Status SchemaViewsScanner::fill_one_row(Tuple *tuple, MemPool *pool) {
+    // set all bit to not null
+    memset((void *)tuple, 0, _tuple_desc->num_null_bytes());
+    const TTableStatus& tbl_status = _table_result.tables[_table_index];
+    // catalog
+    {
+        tuple->set_null(_tuple_desc->slots()[0]->null_indicator_offset());
+    }
+    // schema
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[1]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        std::string db_name = SchemaHelper::extract_db_name(_db_result.dbs[_db_index - 1]);
+        str_slot->ptr = (char *)pool->allocate(db_name.size());
+        str_slot->len = db_name.size();
+        memcpy(str_slot->ptr, db_name.c_str(), str_slot->len);
+    }
+    // name
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[2]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string* src = &tbl_status.name;
+        str_slot->len = src->length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, src->c_str(), str_slot->len);
+    }
+    // definition
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[3]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string* ddl_sql = &tbl_status.ddl_sql;
+        str_slot->len = ddl_sql->length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, ddl_sql->c_str(), str_slot->len);
+    }
+    // check_option
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[4]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string check_option = "NONE";
+        str_slot->len = check_option.length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, check_option.c_str(), str_slot->len);
+    }
+    // is_updatable
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[5]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string is_updatable = "YES";
+        str_slot->len = is_updatable.length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, is_updatable.c_str(), str_slot->len);
+    }
+    // definer
+    {
+        void *slot = tuple->get_slot(_tuple_desc->slots()[6]->tuple_offset());
+        StringValue* str_slot = reinterpret_cast<StringValue*>(slot);
+        const std::string definer = "root@%";
+        str_slot->len = definer.length();
+        str_slot->ptr = (char *)pool->allocate(str_slot->len);
+        if (NULL == str_slot->ptr) {
+            return Status::InternalError("Allocate memcpy failed.");
+        }
+        memcpy(str_slot->ptr, definer.c_str(), str_slot->len);

Review comment:
       length always 6 and definer always "root@%" ? why ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] yangzhg commented on a change in pull request #4778: Error happened when open a view in DBeaver

Posted by GitBox <gi...@apache.org>.
yangzhg commented on a change in pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778#discussion_r511700554



##########
File path: fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
##########
@@ -248,7 +248,19 @@ public TListTableStatusResult listTableStatus(TGetTablesParams params) throws TE
         if (db != null) {
             db.readLock();
             try {
-                for (Table table : db.getTables()) {
+                List<Table> tables = null;
+                if (!params.isSetType() || params.getType() == null || params.getType().isEmpty()) {
+                    tables = db.getTables();
+                } else {
+                    switch (params.getType()) {
+                        case "VIEW":
+                            tables = db.getViews();
+                            break;
+                        default:
+                            tables = db.getTables();
+                    }
+                }

Review comment:
       ```suggestion
                  List<Table> tables = db.getTables();
                   if (params.isSetType() && "VIEW".equals(params.getType())) {
                       tables = db. getViews();
                   }
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] pengxiangyu commented on a change in pull request #4778: Error happened when open a view in DBeaver

Posted by GitBox <gi...@apache.org>.
pengxiangyu commented on a change in pull request #4778:
URL: https://github.com/apache/incubator-doris/pull/4778#discussion_r512511118



##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/SchemaTable.java
##########
@@ -281,6 +281,23 @@ public static Builder builder() {
                                                  .column("XA", ScalarType.createVarchar(3))
                                                  .column("SAVEPOINTS", ScalarType.createVarchar(3))
                                                  .build()))
+                    .put("views",
+                        new SchemaTable(
+                                SystemIdGenerator.getNextId(),
+                                "views",
+                                TableType.SCHEMA,
+                                builder()
+                                        .column("TABLE_CATALOG", ScalarType.createVarchar(512))
+                                        .column("TABLE_SCHEMA", ScalarType.createVarchar(64))
+                                        .column("TABLE_NAME", ScalarType.createVarchar(64))
+                                        .column("VIEW_DEFINITION", ScalarType.createVarchar(8096))
+                                        .column("CHECK_OPTION", ScalarType.createVarchar(8))
+                                        .column("IS_UPDATABLE", ScalarType.createVarchar(3))
+                                        .column("DEFINER", ScalarType.createVarchar(77))
+                                        .column("SECURITY_TYPE", ScalarType.createVarchar(7))

Review comment:
       Maybe you get another version of mysql. the sql I got is like this.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org