mirror of
https://github.com/apache/superset.git
synced 2026-04-22 01:24:43 +00:00
feat(chart-data): add rowcount, timegrain and column result types (#13271)
* feat(chart-data): add rowcount, timegrain and column result types * break out actions from query_context * rename module
This commit is contained in:
@@ -83,6 +83,7 @@ from sqlalchemy.engine import Connection, Engine
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
from sqlalchemy.sql.type_api import Variant
|
||||
from sqlalchemy.types import TEXT, TypeDecorator
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
import _thread # pylint: disable=C0411
|
||||
from superset.errors import ErrorLevel, SupersetErrorType
|
||||
@@ -100,7 +101,7 @@ except ImportError:
|
||||
pass
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from superset.connectors.base.models import BaseDatasource
|
||||
from superset.connectors.base.models import BaseColumn, BaseDatasource
|
||||
from superset.models.core import Database
|
||||
|
||||
|
||||
@@ -163,10 +164,17 @@ class ChartDataResultType(str, Enum):
|
||||
Chart data response type
|
||||
"""
|
||||
|
||||
COLUMNS = "columns"
|
||||
FULL = "full"
|
||||
QUERY = "query"
|
||||
RESULTS = "results"
|
||||
SAMPLES = "samples"
|
||||
TIMEGRAINS = "timegrains"
|
||||
|
||||
|
||||
class DatasourceDict(TypedDict):
|
||||
type: str
|
||||
id: int
|
||||
|
||||
|
||||
class ExtraFiltersTimeColumnType(str, Enum):
|
||||
@@ -1490,6 +1498,15 @@ def extract_dataframe_dtypes(df: pd.DataFrame) -> List[GenericDataType]:
|
||||
return generic_types
|
||||
|
||||
|
||||
def extract_column_dtype(col: "BaseColumn") -> GenericDataType:
|
||||
if col.is_temporal:
|
||||
return GenericDataType.TEMPORAL
|
||||
if col.is_numeric:
|
||||
return GenericDataType.NUMERIC
|
||||
# TODO: add check for boolean data type when proper support is added
|
||||
return GenericDataType.STRING
|
||||
|
||||
|
||||
def indexed(
|
||||
items: List[Any], key: Union[str, Callable[[Any], Any]]
|
||||
) -> Dict[Any, List[Any]]:
|
||||
|
||||
Reference in New Issue
Block a user