mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
[SQL Lab] Add function names to autocomplete (#9012)
This commit is contained in:
@@ -19,7 +19,7 @@ import os
|
||||
import re
|
||||
import time
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
from typing import Any, Dict, List, Optional, Tuple, TYPE_CHECKING
|
||||
from urllib import parse
|
||||
|
||||
from sqlalchemy import Column
|
||||
@@ -34,6 +34,10 @@ from superset.db_engine_specs.base import BaseEngineSpec
|
||||
from superset.db_engine_specs.presto import PrestoEngineSpec
|
||||
from superset.utils import core as utils
|
||||
|
||||
if TYPE_CHECKING:
|
||||
# prevent circular imports
|
||||
from superset.models.core import Database # pylint: disable=unused-import
|
||||
|
||||
QueryStatus = utils.QueryStatus
|
||||
config = app.config
|
||||
|
||||
@@ -422,3 +426,14 @@ class HiveEngineSpec(PrestoEngineSpec):
|
||||
): # pylint: disable=arguments-differ
|
||||
kwargs = {"async": async_}
|
||||
cursor.execute(query, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def get_function_names(cls, database: "Database") -> List[str]:
|
||||
"""
|
||||
Get a list of function names that are able to be called on the database.
|
||||
Used for SQL Lab autocomplete.
|
||||
|
||||
:param database: The database to get functions for
|
||||
:return: A list of function names useable in the database
|
||||
"""
|
||||
return database.get_df("SHOW FUNCTIONS")["tab_name"].tolist()
|
||||
|
||||
Reference in New Issue
Block a user