Skip to content

Commit e8145cb

Browse files
author
ci bot
committed
Merge branch 'aarthy/qa-fixes' into 'enterprise'
fix: miscellaneous qa fixes See merge request dkinternal/testgen/dataops-testgen!331
2 parents 151598a + 1f540de commit e8145cb

File tree

6 files changed

+31
-37
lines changed

6 files changed

+31
-37
lines changed

testgen/commands/queries/profiling_query.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from testgen.commands.queries.refresh_data_chars_query import CRefreshDataCharsSQL
55
from testgen.commands.queries.rollup_scores_query import CRollupScoresSQL
66
from testgen.common import date_service, read_template_sql_file, read_template_yaml_file
7-
from testgen.common.database.database_service import replace_params
7+
from testgen.common.database.database_service import get_flavor_service, replace_params
88
from testgen.common.read_file import replace_templated_functions
99

1010

@@ -121,6 +121,7 @@ def _get_params(self) -> dict:
121121
"CONTINGENCY_MAX_VALUES": self.contingency_max_values,
122122
"PROCESS_ID": self.process_id,
123123
"SQL_FLAVOR": self.flavor,
124+
"QUOTE": get_flavor_service(self.flavor).quote_character
124125
}
125126

126127
def _get_query(

testgen/template/profiling/project_update_profile_results_to_estimates.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ set sample_ratio = :PROFILE_SAMPLE_RATIO,
2424
future_date_ct = ROUND(future_date_ct * :PROFILE_SAMPLE_RATIO, 0),
2525
boolean_true_ct = ROUND(boolean_true_ct * :PROFILE_SAMPLE_RATIO, 0)
2626
where profile_run_id = :PROFILE_RUN_ID
27-
and schema_name = split_part(:SAMPLING_TABLE, '.', 1)
28-
and table_name = split_part(:SAMPLING_TABLE, '.', 2)
27+
and schema_name = TRIM(SPLIT_PART(:SAMPLING_TABLE, '.', 1), :QUOTE)
28+
and table_name = TRIM(SPLIT_PART(:SAMPLING_TABLE, '.', 2), :QUOTE)
2929
and sample_ratio IS NULL;
3030

3131

testgen/ui/components/frontend/js/components/connection_form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ const BigqueryForm = (
11031103

11041104
div(
11051105
{ class: 'text-caption text-right' },
1106-
`Project ID: ${projectId.val}`,
1106+
() => `Project ID: ${projectId.val}`,
11071107
),
11081108
),
11091109
);

testgen/ui/services/form_service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ def on_page_change():
316316
"hide": column not in columns,
317317
"headerCheckboxSelection": selection_mode == "multiple" and column == columns[0],
318318
"headerCheckboxSelectionFilteredOnly": selection_mode == "multiple" and column == columns[0],
319+
"sortable": False,
320+
"filter": False,
319321
}
320322
highlight_kwargs = {
321323
"cellStyle": cellstyle_jscode,

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)