Skip to content

Commit

Permalink
Raise NotImplementedError
Browse files Browse the repository at this point in the history
  • Loading branch information
JCZuurmond committed Jun 14, 2024
1 parent f423dc0 commit 7faf11e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/databricks/labs/lsql/dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def _get_fields(query: str) -> list[Field]:
for named_select in projection.named_selects:
field = Field(name=named_select, expression=f"`{named_select}`")
if named_select == "*":
logger.warning(f"Select with `*` is ignored, please define column explicitly: {query}")
raise NotImplementedError(f"Select with `*` is ignored, please define column explicitly: {query}")
else:
fields.append(field)
return fields
Expand Down
14 changes: 0 additions & 14 deletions tests/integration/test_dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,3 @@ def test_dashboard_deploys_dashboard_with_table(ws, make_dashboard):
sdk_dashboard = dashboards.deploy_dashboard(lakeview_dashboard, dashboard_id=sdk_dashboard.dashboard_id)

assert ws.lakeview.get(sdk_dashboard.dashboard_id)


def test_dashboard_deploys_empty_dashboard_with_star_table(ws, make_dashboard, tmp_path):
sdk_dashboard = make_dashboard()

query = "SELECT * FROM VALUES ('Atlanta', 'USA'), ('WA', 'USA') AS tab(State, Country)"
(tmp_path / "star.sql").write_text(query)

dashboards = Dashboards(ws)
lakeview_dashboard = dashboards.create_dashboard(tmp_path)

sdk_dashboard = dashboards.deploy_dashboard(lakeview_dashboard, dashboard_id=sdk_dashboard.dashboard_id)

assert ws.lakeview.get(sdk_dashboard.dashboard_id)
8 changes: 3 additions & 5 deletions tests/unit/test_dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,12 +455,10 @@ def test_dashboard_handles_query_with_star(tmp_path, caplog):
with (tmp_path / "star.sql").open("w") as f:
f.write(query)

with caplog.at_level(logging.WARNING, logger="databricks.labs.lsql.dashboards"):
lakeview_dashboard = Dashboards(ws).create_dashboard(tmp_path)
with pytest.raises(NotImplementedError) as e:
Dashboards(ws).create_dashboard(tmp_path)

widget = lakeview_dashboard.pages[0].layout[0].widget
assert isinstance(widget.spec, TableV2Spec)
assert query in caplog.text
assert query in str(e)
ws.assert_not_called()


Expand Down

0 comments on commit 7faf11e

Please sign in to comment.