Skip to content

Commit

Permalink
Fix interaction UI (#44)
Browse files Browse the repository at this point in the history
* fix table info column names

* remove result from delete

* remove display
  • Loading branch information
david-tempelmann authored Jun 27, 2023
1 parent c99fce4 commit e3134ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
1 change: 0 additions & 1 deletion discoverx/dx.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ def delete_by_class(
if delete_result is not None:
delete_result = delete_result.toPandas()
self.logger.friendlyHTML(f"<p>The affcted tables are</p>{delete_result.to_html()}")
return delete_result

def _msql(self, msql: str, what_if: bool = False, min_score: Optional[float] = None):
self.logger.debug(f"Executing sql template: {msql}")
Expand Down
12 changes: 8 additions & 4 deletions notebooks/interaction_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@
dx.select_by_classes(from_tables="discoverx*.*.*", by_classes=["ip_v4"])
.groupby(
[
"catalog",
"schema",
"table",
"classified_columns.ip_v4.column",
"table_catalog",
"table_schema",
"table_name",
"classified_columns.ip_v4.column_name",
"classified_columns.ip_v4.value",
]
)
Expand Down Expand Up @@ -185,3 +185,7 @@
# COMMAND ----------

help(DX)

# COMMAND ----------


8 changes: 4 additions & 4 deletions tests/unit/dx_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ def test_select_by_class(spark, dx_ip):
# @pytest.mark.skip(reason="Delete is only working with v2 tables. Needs investigation")
def test_delete_by_class(spark, dx_ip):
# search a specific term and auto-detect matching classes/rules
result = dx_ip.delete_by_class(from_tables="*.default.tb_*", by_class="ip_v4", values="9.9.9.9")
assert result is None # Nothing should be executed
dx_ip.delete_by_class(from_tables="*.default.tb_*", by_class="ip_v4", values="9.9.9.9")
assert {row.ip for row in spark.sql("select * from tb_1").collect()} == {'1.2.3.4', '3.4.5.60'}

result = dx_ip.delete_by_class(from_tables="*.default.tb_*", by_class="ip_v4", values="9.9.9.9", yes_i_am_sure=True)
assert result["table_name"][0] == "tb_1"
dx_ip.delete_by_class(from_tables="*.default.tb_*", by_class="ip_v4", values="1.2.3.4", yes_i_am_sure=True)
assert {row.ip for row in spark.sql("select * from tb_1").collect()} == {'3.4.5.60'}

with pytest.raises(ValueError):
dx_ip.delete_by_class(from_tables="*.default.tb_*", by_class="x")
Expand Down

0 comments on commit e3134ce

Please sign in to comment.