Fix/databend params (#5937)

* fix: databend params

* add databend logo

* fix log

* fix log

* Update redash/query_runner/databend.py

Co-authored-by: Arik Fraimovich <arik@arikfr.com>

---------

Co-authored-by: Arik Fraimovich <arik@arikfr.com>
This commit is contained in:
Jeremy 2023-03-28 04:08:53 +08:00 committed by GitHub
parent 35b2430ff9
commit 0b86c76552
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 10 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -20,11 +20,11 @@ class Databend(BaseQueryRunner):
"type": "object",
"properties": {
"host": {"type": "string", "default": "localhost"},
"port": {"type": "int", "default": 8000},
"port": {"type": "string", "default": "8000"},
"username": {"type": "string"},
"password": {"type": "string", "default": ""},
"database": {"type": "string"},
"secure": {"type": "string", "default": False},
"secure": {"type": "boolean", "default": False},
},
"order": ["username", "password", "host", "port", "database"],
"required": ["username", "database"],
@ -37,7 +37,7 @@ class Databend(BaseQueryRunner):
@classmethod
def type(cls):
return "Databend"
return "databend"
@classmethod
def enabled(cls):
@ -61,12 +61,12 @@ class Databend(BaseQueryRunner):
return TYPE_STRING
def run_query(self, query, user):
host = (self.configuration.get("host") or "localhost"),
port = (self.configuration.get("port") or 8000),
username = (self.configuration.get("username") or None),
password = (self.configuration.get("password") or None),
database = (self.configuration.get("database") or None),
secure = (self.configuration.get("secure") or False),
host = self.configuration.get("host") or "localhost"
port = self.configuration.get("port") or "8000"
username = self.configuration.get("username") or "root"
password = self.configuration.get("password") or ""
database = self.configuration.get("database") or "default"
secure = self.configuration.get("secure") or False
connection = connector.connect(f"databend://{username}:{password}@{host}:{port}/{database}?secure={secure}")
cursor = connection.cursor()
@ -87,6 +87,33 @@ class Databend(BaseQueryRunner):
return json_data, error
def get_schema(self, get_stats=False):
query = """
SELECT TABLE_SCHEMA,
TABLE_NAME,
COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA NOT IN ('information_schema', 'system')
"""
results, error = self.run_query(query, None)
if error is not None:
self._handle_run_query_error(error)
schema = {}
results = json_loads(results)
for row in results["rows"]:
table_name = "{}.{}".format(row["table_schema"], row["table_name"])
if table_name not in schema:
schema[table_name] = {"name": table_name, "columns": []}
schema[table_name]["columns"].append(row["column_name"])
return list(schema.values())
def _get_tables(self):
query = """
SELECT TABLE_SCHEMA,

View File

@ -41,7 +41,7 @@ cmem-cmempy==21.2.3
xlrd==2.0.1
openpyxl==3.0.7
firebolt-sdk
databend-sqlalchemy
databend-sqlalchemy==0.2.4
pandas==1.3.4
nzpy>=1.15
nzalchemy