Skip to content

Commit

Permalink
fix: allow adhoc columns in non-aggregate query (#21729)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurnewase authored and AAfghahi committed Nov 18, 2022
1 parent cdf03df commit 11a40a4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions superset/superset_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class AdhocColumn(TypedDict, total=False):
hasCustomLabel: Optional[bool]
label: str
sqlExpression: str
columnType: Optional[Literal["BASE_AXIS", "SERIES"]]
timeGrain: Optional[str]


class ResultSetColumnType(TypedDict):
Expand Down
9 changes: 9 additions & 0 deletions superset/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,15 @@ def is_adhoc_column(column: Column) -> TypeGuard[AdhocColumn]:
)


def get_base_axis_labels(columns: Optional[List[Column]]) -> Tuple[str, ...]:
axis_cols = [
col
for col in columns or []
if is_adhoc_column(col) and col.get("columnType") == "BASE_AXIS"
]
return tuple(get_column_name(col) for col in axis_cols)


def get_column_name(
column: Column, verbose_map: Optional[Dict[str, Any]] = None
) -> str:
Expand Down

0 comments on commit 11a40a4

Please sign in to comment.