You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2021/07/21 02:51:10 UTC

[incubator-doris] branch master updated: [ODBC] Support ODBC external table of SQLServer and revise the doc. (#6223)

This is an automated email from the ASF dual-hosted git repository.

morningman 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 8ae1299  [ODBC] Support ODBC external table of SQLServer and revise the doc. (#6223)
8ae1299 is described below

commit 8ae129967e26f7b13eb585425b46b4e0ae40d333
Author: HappenLee <ha...@hotmail.com>
AuthorDate: Tue Jul 20 21:50:56 2021 -0500

    [ODBC] Support ODBC external table of SQLServer and revise the doc. (#6223)
    
    Support ODBC external table of SQLServer
---
 docs/en/extending-doris/odbc-of-doris.md            | 21 +++++++++++++++++++--
 docs/zh-CN/extending-doris/odbc-of-doris.md         | 21 +++++++++++++++++++--
 .../java/org/apache/doris/catalog/OdbcTable.java    | 10 ++++++++++
 3 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/docs/en/extending-doris/odbc-of-doris.md b/docs/en/extending-doris/odbc-of-doris.md
index f300031..1be271d 100644
--- a/docs/en/extending-doris/odbc-of-doris.md
+++ b/docs/en/extending-doris/odbc-of-doris.md
@@ -212,15 +212,32 @@ There are different data types among different databases. Here, the types in eac
 |   DATETIME  | DATETIME |  |
 |   NUMBER  | DECIMAL |  |
 
+### SQLServer
+
+|  SQLServer  | Doris  |             Alternation rules              |
+| :------: | :----: | :-------------------------------: |
+|  BOOLEAN  | BOOLEAN  |                         |
+|   CHAR   |  CHAR  |            Only UTF8 encoding is supported            |
+| VARCHAR | VARCHAR |       Only UTF8 encoding is supported      |
+|   DATE/   |  DATE  |                                   |
+|  REAL   |  FLOAT  |                                   |
+|   TINYINT   | TINYINT |  |
+|   SMALLINT  | SMALLINT |  |
+|   INT  | INT |  |
+|   BIGINT  | BIGINT |  |
+|   FLOAT  | DOUBLE |  |
+|   DATETIME/DATETIME2  | DATETIME |  |
+|   DECIMAL/NUMERIC | DECIMAL |  |
+
 ## Q&A
 
 1. Relationship with the original external table of MySQL?
 
 After accessing the ODBC external table, the original way to access the MySQL external table will be gradually abandoned. If you have not used the MySQL external table before, it is recommended that the newly accessed MySQL tables use ODBC external table directly.
     
-2. Besides MySQL and Oracle, can doris support more databases?
+2. Besides MySQL, Oracle, SQLServer, PostgreSQL, can doris support more databases?
 
-Currently, Doris only adapts to MySQL and Oracle. The adaptation of other databases is under planning. In principle, any database that supports ODBC access can be accessed through the ODBC external table. If you need to access other databases, you are welcome to modify the code and contribute to Doris.
+Currently, Doris only adapts to MySQL, Oracle, SQLServer, PostgreSQL. The adaptation of other databases is under planning. In principle, any database that supports ODBC access can be accessed through the ODBC external table. If you need to access other databases, you are welcome to modify the code and contribute to Doris.
 
 3. When is it appropriate to use ODBC external tables?
 
diff --git a/docs/zh-CN/extending-doris/odbc-of-doris.md b/docs/zh-CN/extending-doris/odbc-of-doris.md
index 2e3480e..ba6b922 100644
--- a/docs/zh-CN/extending-doris/odbc-of-doris.md
+++ b/docs/zh-CN/extending-doris/odbc-of-doris.md
@@ -208,15 +208,32 @@ set enable_odbc_transcation = true;
 |   DATETIME  | DATETIME |  |
 |   NUMBER  | DECIMAL |  |
 
+### SQLServer
+
+| SQLServer  | Doris  |             替换方案              |
+| :------: | :----: | :-------------------------------: |
+|  BOOLEAN  | BOOLEAN  |                         |
+|   CHAR   |  CHAR  |            当前仅支持UTF8编码            |
+| VARCHAR | VARCHAR |       当前仅支持UTF8编码       |
+|   DATE   |  DATE  |                                   |
+|  REAL   |  FLOAT  |                                   |
+|   TINYINT   | TINYINT |  |
+|   SMALLINT  | SMALLINT |  |
+|   INT  | INT |  |
+|   BIGINT  | BIGINT |  |
+|   FLOAT  | DOUBLE |  |
+|   DATETIME/DATETIME2  | DATETIME |  |
+|   DECIMAL/NUMERIC | DECIMAL |  |
+
 ## Q&A
 
 1. 与原先的MySQL外表的关系
 
     在接入ODBC外表之后,原先的访问MySQL外表的方式将被逐渐弃用。如果之前没有使用过MySQL外表,建议新接入的MySQL表直接使用ODBC的MySQL外表。
     
-2. 除了MySQL,Oracle,PostgreSQL, 是否能够支持更多的数据库
+2. 除了MySQL,Oracle,PostgreSQL,SQLServer是否能够支持更多的数据库
 
-    目前Doris只适配了MySQL,Oracle,PostgreSQL,关于其他的数据库的适配工作正在规划之中,原则上来说任何支持ODBC访问的数据库都能通过ODBC外表来访问。如果您有访问其他外表的需求,欢迎修改代码并贡献给Doris。
+    目前Doris只适配了MySQL,Oracle,PostgreSQL,SQLServer,关于其他的数据库的适配工作正在规划之中,原则上来说任何支持ODBC访问的数据库都能通过ODBC外表来访问。如果您有访问其他外表的需求,欢迎修改代码并贡献给Doris。
 
 3. 什么场合适合通过外表访问
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/OdbcTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/OdbcTable.java
index 835e3c1..05d2ee6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/OdbcTable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/OdbcTable.java
@@ -63,6 +63,7 @@ public class OdbcTable extends Table {
         tempMap.put("oracle", TOdbcTableType.ORACLE);
         tempMap.put("mysql", TOdbcTableType.MYSQL);
         tempMap.put("postgresql", TOdbcTableType.POSTGRESQL);
+        tempMap.put("sqlserver", TOdbcTableType.SQLSERVER);
         TABLE_TYPE_MAP = Collections.unmodifiableMap(tempMap);
     }
 
@@ -293,6 +294,15 @@ public class OdbcTable extends Table {
                         getPasswd(),
                         "utf8");
                 break;
+            case SQLSERVER:
+                connectString = String.format("Driver=%s;Server=%s,%s;DataBase=%s;Uid=%s;Pwd=%s",
+                                getOdbcDriver(),
+                                getHost(),
+                                getPort(),
+                                getOdbcDatabaseName(),
+                                getUserName(),
+                                getPasswd());
+                break;
             default:
         }
         return connectString;

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