Skip to content

Commit 8fd8cc8

Browse files
committed
fix(profiling-results): make filters consistent with hygiene issues
1 parent 007a17a commit 8fd8cc8

2 files changed

Lines changed: 24 additions & 33 deletions

File tree

testgen/ui/views/hygiene_issues.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ def render(
121121
)
122122
column_name = testgen.select(
123123
options=column_options,
124-
value_column="column_name",
125124
default_value=column_name,
126125
bind_to_query="column_name",
127126
label="Column",

testgen/ui/views/profiling_results.py

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,39 @@ def render(self, run_id: str, table_name: str | None = None, column_name: str |
6767
filters_changed = True
6868
st.session_state["profiling_results:filters"] = current_filters
6969

70-
70+
run_columns_df = get_profiling_run_columns(run_id)
7171
with table_filter_column:
72-
# Table Name filter
73-
df = get_profiling_run_tables(run_id)
74-
df = df.sort_values("table_name", key=lambda x: x.str.lower())
7572
table_name = testgen.select(
76-
options=df,
77-
value_column="table_name",
73+
options=list(run_columns_df["table_name"].unique()),
7874
default_value=table_name,
7975
bind_to_query="table_name",
8076
label="Table",
8177
)
8278

8379
with column_filter_column:
84-
# Column Name filter
85-
df = get_profiling_run_columns(run_id, table_name)
86-
df = df.sort_values("column_name", key=lambda x: x.str.lower())
80+
if table_name:
81+
column_options = (
82+
run_columns_df
83+
.loc[run_columns_df["table_name"] == table_name]
84+
["column_name"]
85+
.dropna()
86+
.unique()
87+
.tolist()
88+
)
89+
else:
90+
column_options = (
91+
run_columns_df
92+
.groupby("column_name")
93+
.first()
94+
.reset_index()
95+
.sort_values("column_name", key=lambda x: x.str.lower())
96+
)
8797
column_name = testgen.select(
88-
options=df,
89-
value_column="column_name",
98+
options=column_options,
9099
default_value=column_name,
91100
bind_to_query="column_name",
92101
label="Column",
93-
disabled=not table_name,
94-
accept_new_options=bool(table_name),
102+
accept_new_options=True,
95103
)
96104

97105
with sort_column:
@@ -272,27 +280,11 @@ def get_excel_report_data(
272280

273281

274282
@st.cache_data(show_spinner=False)
275-
def get_profiling_run_tables(profiling_run_id: str) -> pd.DataFrame:
283+
def get_profiling_run_columns(profiling_run_id: str) -> pd.DataFrame:
276284
query = """
277-
SELECT DISTINCT table_name
285+
SELECT table_name, column_name
278286
FROM profile_results
279287
WHERE profile_run_id = :profiling_run_id
280-
ORDER BY table_name;
288+
ORDER BY LOWER(table_name), LOWER(column_name);
281289
"""
282290
return fetch_df_from_db(query, {"profiling_run_id": profiling_run_id})
283-
284-
285-
@st.cache_data(show_spinner=False)
286-
def get_profiling_run_columns(profiling_run_id: str, table_name: str) -> pd.DataFrame:
287-
query = """
288-
SELECT DISTINCT column_name
289-
FROM profile_results
290-
WHERE profile_run_id = :profiling_run_id
291-
AND table_name = :table_name
292-
ORDER BY column_name;
293-
"""
294-
params = {
295-
"profiling_run_id": profiling_run_id,
296-
"table_name": table_name or "",
297-
}
298-
return fetch_df_from_db(query, params)

0 commit comments

Comments
 (0)