Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Aug 9, 2021
1 parent d71f328 commit 7f11b86
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions superset/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,16 +1008,16 @@ def zlib_decompress(blob: bytes, decode: Optional[bool] = True) -> Union[bytes,


def simple_filter_to_adhoc(
filt: QueryObjectFilterClause, clause: str = "where",
filter_clause: QueryObjectFilterClause, clause: str = "where",
) -> AdhocFilterClause:
result: AdhocFilterClause = {
"clause": clause.upper(),
"expressionType": "SIMPLE",
"comparator": filt.get("val"),
"operator": filt["op"],
"subject": filt["col"],
"comparator": filter_clause.get("val"),
"operator": filter_clause["op"],
"subject": filter_clause["col"],
}
if filt.get("isExtra"):
if filter_clause.get("isExtra"):
result["isExtra"] = True
result["filterOptionName"] = md5_sha_from_dict(cast(Dict[Any, Any], result))

Expand Down
4 changes: 3 additions & 1 deletion tests/integration_tests/model_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
load_birth_names_dashboard_with_slices,
)

import pandas
import pytest
from sqlalchemy.engine.url import make_url

Expand Down Expand Up @@ -343,15 +342,18 @@ def test_get_timestamp_expression(self):
ds_col = tbl.get_column("ds")
sqla_literal = ds_col.get_timestamp_expression(None)
self.assertEqual(str(sqla_literal.compile()), "ds")
assert type(sqla_literal.type).__name__ == "TemporalWrapperType"

sqla_literal = ds_col.get_timestamp_expression("P1D")
assert type(sqla_literal.type).__name__ == "TemporalWrapperType"
compiled = "{}".format(sqla_literal.compile())
if tbl.database.backend == "mysql":
self.assertEqual(compiled, "DATE(ds)")

prev_ds_expr = ds_col.expression
ds_col.expression = "DATE_ADD(ds, 1)"
sqla_literal = ds_col.get_timestamp_expression("P1D")
assert type(sqla_literal.type).__name__ == "TemporalWrapperType"
compiled = "{}".format(sqla_literal.compile())
if tbl.database.backend == "mysql":
self.assertEqual(compiled, "DATE(DATE_ADD(ds, 1))")
Expand Down

0 comments on commit 7f11b86

Please sign in to comment.