Skip to content

Commit

Permalink
bugfix: Oracle timegrains fail to render when wrapped in outer query (a…
Browse files Browse the repository at this point in the history
…pache#7767)

* Add check if TimegrainExpression col is None

* Clean up TimestampExpression proxying logic

* Remove redundant optionality from init
  • Loading branch information
villebro authored Jun 26, 2019
1 parent 5c58fd1 commit ebb7fbc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions superset/db_engine_specs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ def __init__(self, expr: str, col: ColumnClause, **kwargs):
super().__init__(expr, **kwargs)
self.col = col

@property
def _constructor(self):
# Needed to ensure that the column label is rendered correctly when
# proxied to the outer query.
# See https://github.com/sqlalchemy/sqlalchemy/issues/4730
return ColumnClause


@compiles(TimestampExpression)
def compile_timegrain_expression(element: TimestampExpression, compiler, **kw):
Expand Down Expand Up @@ -123,9 +130,9 @@ def get_timestamp_expr(
cls, col: ColumnClause, pdf: Optional[str], time_grain: Optional[str]
) -> TimestampExpression:
"""
Construct a TimeExpression to be used in a SQLAlchemy query.
Construct a TimestampExpression to be used in a SQLAlchemy query.
:param col: Target column for the TimeExpression
:param col: Target column for the TimestampExpression
:param pdf: date format (seconds or milliseconds)
:param time_grain: time grain, e.g. P1Y for 1 year
:return: TimestampExpression object
Expand Down

0 comments on commit ebb7fbc

Please sign in to comment.