Skip to content

Commit

Permalink
Merge pull request #257 from vertica/query_profile_upgrade_4
Browse files Browse the repository at this point in the history
QueryProfiler Main UI page - Added a warning to check if the provided key and schema already exist
  • Loading branch information
oualib authored May 14, 2024
2 parents e63262c + 2c75d48 commit cbdc018
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion project/ui/qprof_main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@
" file_val = uploader.value\n",
" logging.info(f\"[Query Profile Main Page] For load from file option, saved key value as :{key_val}, target schema as {target_schema_val}, file name as {file_val}.\")\n",
" if target_schema_val == \"\" or file_val == \"\":\n",
" print(\"Error! You must provide a value for Schema and File.\")\n",
" print(\"\\033[91m\\033[1m Error! You must provide a value for Schema and File. \\033[0m\\033[0m\")\n",
" return\n",
" elif check_if_schema_key_exist(target_schema_val, key_val):\n",
" print(\"\\033[91m\\033[1m Error! The combination of schema and key already exist. Please try again with another key that is unique. \\033[0m\\033[0m\")\n",
" # print(\"Error! The combination of schema and key already exist. Please try again with another key that is unique.\")\n",
" return\n",
" else:\n",
" reset_values(key_val = key_val, target_schema_val = target_schema_val, file_val = file_val)\n",
Expand Down Expand Up @@ -459,6 +463,28 @@
" )\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f06e3fad-3a2f-4b0d-9fcb-bf5c86b58cad",
"metadata": {},
"outputs": [],
"source": [
"# Utility function\n",
"def check_if_schema_key_exist(schema, key):\n",
" query = f\"\"\"\n",
" SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END AS table_exists\n",
" FROM v_catalog.tables \n",
" WHERE table_schema = '{schema}'\n",
" AND table_name LIKE 'qprof_%{key}';\n",
" \"\"\"\n",
" res = vp.vDataFrame(query)\n",
" if res[0][0] == 1:\n",
" return True\n",
" else:\n",
" return False"
]
}
],
"metadata": {
Expand Down

0 comments on commit cbdc018

Please sign in to comment.