mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-24 12:45:45 +00:00
[feat] Support Hive Conn (#1215)
Co-authored-by: xiuzhu <edy@dodge-pro.local>
This commit is contained in:
parent
0f3ad67c85
commit
54ba663646
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
BIN
dbgpt/app/static/icons/hive.png
Normal file
BIN
dbgpt/app/static/icons/hive.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
@ -9,6 +9,7 @@ from dbgpt.datasource.rdbms.base import RDBMSDatabase
|
||||
from dbgpt.datasource.rdbms.conn_clickhouse import ClickhouseConnect
|
||||
from dbgpt.datasource.rdbms.conn_doris import DorisConnect
|
||||
from dbgpt.datasource.rdbms.conn_duckdb import DuckDbConnect
|
||||
from dbgpt.datasource.rdbms.conn_hive import HiveConnect
|
||||
from dbgpt.datasource.rdbms.conn_mssql import MSSQLConnect
|
||||
from dbgpt.datasource.rdbms.conn_mysql import MySQLConnect
|
||||
from dbgpt.datasource.rdbms.conn_postgresql import PostgreSQLDatabase
|
||||
|
58
dbgpt/datasource/rdbms/conn_hive.py
Normal file
58
dbgpt/datasource/rdbms/conn_hive.py
Normal file
@ -0,0 +1,58 @@
|
||||
from typing import Any, Optional
|
||||
from urllib.parse import quote
|
||||
from urllib.parse import quote_plus as urlquote
|
||||
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
from dbgpt.datasource.rdbms.base import RDBMSDatabase
|
||||
|
||||
|
||||
class HiveConnect(RDBMSDatabase):
|
||||
"""db type"""
|
||||
|
||||
db_type: str = "hive"
|
||||
"""db driver"""
|
||||
driver: str = "hive"
|
||||
"""db dialect"""
|
||||
dialect: str = "hive"
|
||||
|
||||
@classmethod
|
||||
def from_uri_db(
|
||||
cls,
|
||||
host: str,
|
||||
port: int,
|
||||
user: str,
|
||||
pwd: str,
|
||||
db_name: str,
|
||||
engine_args: Optional[dict] = None,
|
||||
**kwargs: Any,
|
||||
) -> RDBMSDatabase:
|
||||
"""Construct a SQLAlchemy engine from uri database.
|
||||
Args:
|
||||
host (str): database host.
|
||||
port (int): database port.
|
||||
user (str): database user.
|
||||
pwd (str): database password.
|
||||
db_name (str): database name.
|
||||
engine_args (Optional[dict]):other engine_args.
|
||||
"""
|
||||
db_url: str = f"{cls.driver}://{host}:{str(port)}/{db_name}"
|
||||
if user and pwd:
|
||||
db_url: str = f"{cls.driver}://{quote(user)}:{urlquote(pwd)}@{host}:{str(port)}/{db_name}"
|
||||
return cls.from_uri(db_url, engine_args, **kwargs)
|
||||
|
||||
def table_simple_info(self):
|
||||
return []
|
||||
|
||||
def get_users(self):
|
||||
return []
|
||||
|
||||
def get_grants(self):
|
||||
return []
|
||||
|
||||
def get_collation(self):
|
||||
"""Get collation."""
|
||||
return "UTF-8"
|
||||
|
||||
def get_charset(self):
|
||||
return "UTF-8"
|
@ -20,6 +20,7 @@ class DBType(Enum):
|
||||
StarRocks = DbInfo("starrocks")
|
||||
Spark = DbInfo("spark", True)
|
||||
Doris = DbInfo("doris")
|
||||
Hive = DbInfo("hive")
|
||||
|
||||
def value(self):
|
||||
return self._value_.name
|
||||
|
3
setup.py
3
setup.py
@ -568,6 +568,9 @@ def all_datasource_requires():
|
||||
"mysqlclient==2.1.0",
|
||||
"pydoris>=1.0.2,<2.0.0",
|
||||
"clickhouse-connect",
|
||||
"pyhive",
|
||||
"thrift",
|
||||
"thrift_sasl",
|
||||
]
|
||||
|
||||
|
||||
|
BIN
web/public/icons/hive.png
Normal file
BIN
web/public/icons/hive.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
@ -64,5 +64,6 @@ export const dbMapper: Record<DBType, { label: string; icon: string; desc: strin
|
||||
desc: 'Powerful open-source relational database with extensibility and SQL standards.',
|
||||
},
|
||||
spark: { label: 'Spark', icon: '/icons/spark.png', desc: 'Unified engine for large-scale data analytics.' },
|
||||
hive: { label: 'Hive', icon: '/icons/hive.png', desc: 'A distributed fault-tolerant data warehouse system.' },
|
||||
space: { label: 'Space', icon: '/icons/knowledge.png', desc: 'knowledge analytics.' },
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user