Skip to content

Commit

Permalink
Merge pull request #282 from vertica/nocode_ui_pages_update_12
Browse files Browse the repository at this point in the history
QueryProfiler Main Page - Multiple SQL queries directly from text
  • Loading branch information
oualib authored Aug 12, 2024
2 parents 6772ff2 + 81c5454 commit 2509045
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion project/ui/qprof_main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -574,16 +574,32 @@
"output_0 = widgets.Output()\n",
"query_val = None\n",
"\n",
"# Split the queries\n",
"def query_list(sql_queries: str):\n",
" # Split the input string by \";\"\n",
" queries = [query.strip() for query in sql_queries.split(';') if query.strip()]\n",
" return queries\n",
"\n",
"# Check if there is at least one space inside the query - to avoid the \";;\" typo mistake.\n",
"def query_check(queries: list):\n",
" for query in queries:\n",
" if ' ' not in query:\n",
" return 1\n",
" return 0\n",
" \n",
"\n",
"def on_button_clicked_0(b):\n",
" output_0.clear_output(wait=True)\n",
" global query_val, target_schema_val_2, key_val_2\n",
" with output_0:\n",
" target_schema_val_2 = target_schema_2.value\n",
" query_val = query_list(query.value)\n",
" if not target_schema_val_2 == \"\" and not schema_exists(target_schema_val_2):\n",
" print(\"\\033[91m\\033[1m Error! The schema does not exist. \\033[0m\\033[0m\")\n",
" elif query_check(query_val):\n",
" print(\"\\033[91m\\033[1m Error! Re-check your query. \\033[0m\\033[0m\")\n",
" else:\n",
" key_val_2 = key_2.value\n",
" query_val = query.value\n",
" logging.info(f\"\"\"[Query Profile Main Page] For create using query option, saved key value as :{key_val_2}, target schema as {target_schema_val_2}, query as \"{query_val}\".\"\"\")\n",
" reset_values(query_val = query_val, target_schema_val_2 = target_schema_val_2, key_val_2 = key_val_2)\n",
"\n",
Expand Down

0 comments on commit 2509045

Please sign in to comment.