Skip to content

Commit 6cecb88

Browse files
author
ci bot
committed
Merge branch 'data-preview' into 'enterprise'
fix(data-preview): use top for sql server See merge request dkinternal/testgen/dataops-testgen!219
2 parents b64fd83 + 852ed17 commit 6cecb88

1 file changed

Lines changed: 24 additions & 18 deletions

File tree

testgen/ui/views/dialogs/data_preview_dialog.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,29 +63,35 @@ def get_preview_data(
6363
connection_df = db.retrieve_data(connection_query).iloc[0]
6464

6565
if not connection_df.empty:
66+
use_top = connection_df["sql_flavor"] == "mssql"
6667
query = f"""
6768
SELECT
69+
{"TOP 100" if use_top else ""}
6870
{column_name or "*"}
6971
FROM {schema_name}.{table_name}
70-
LIMIT 100
72+
{"LIMIT 100" if not use_top else ""}
7173
"""
7274

73-
df = db.retrieve_target_db_df(
74-
connection_df["sql_flavor"],
75-
connection_df["project_host"],
76-
connection_df["project_port"],
77-
connection_df["project_db"],
78-
connection_df["project_user"],
79-
connection_df["project_pw_encrypted"],
80-
query,
81-
connection_df["url"],
82-
connection_df["connect_by_url"],
83-
connection_df["connect_by_key"],
84-
connection_df["private_key"],
85-
connection_df["private_key_passphrase"],
86-
connection_df["http_path"],
87-
)
88-
df.index = df.index + 1
89-
return df
75+
try:
76+
df = db.retrieve_target_db_df(
77+
connection_df["sql_flavor"],
78+
connection_df["project_host"],
79+
connection_df["project_port"],
80+
connection_df["project_db"],
81+
connection_df["project_user"],
82+
connection_df["project_pw_encrypted"],
83+
query,
84+
connection_df["url"],
85+
connection_df["connect_by_url"],
86+
connection_df["connect_by_key"],
87+
connection_df["private_key"],
88+
connection_df["private_key_passphrase"],
89+
connection_df["http_path"],
90+
)
91+
except:
92+
return pd.DataFrame()
93+
else:
94+
df.index = df.index + 1
95+
return df
9096
else:
9197
return pd.DataFrame()

0 commit comments

Comments
 (0)