Skip to content

Commit

Permalink
Merge pull request #266 from vertica/nocode_ui_pages_update_02
Browse files Browse the repository at this point in the history
QueryProfiler UI Page Update: Added search for query + trees to explain plan
  • Loading branch information
mail4umar authored Jun 5, 2024
2 parents 45b58f1 + aec1728 commit c236046
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 33 deletions.
8 changes: 2 additions & 6 deletions project/ui/qprof-ui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -630,11 +630,7 @@
"\n",
"def on_button_clicked_run_explain_plan(b):\n",
" with explain_output:\n",
" explain = qprof.get_qplan_explain(display_trees= False)\n",
" for i in range(len(explain)):\n",
" to_print = explain[i]\n",
" if type(to_print) is str:\n",
" print(to_print)\n",
" qprof.get_qplan_explain()\n",
"\n",
"\n",
"def on_button_clicked_run_query(b):\n",
Expand Down Expand Up @@ -691,7 +687,7 @@
"</head>\n",
"<body>\n",
" <div class=\"version\">\n",
" Page version update date: 5/30/2024\n",
" Page version update date: 6/3/2024\n",
" </div>\n",
"</body>\n",
"</html>"
Expand Down
176 changes: 149 additions & 27 deletions project/ui/qprof_main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "bdf3c956-2080-4d20-9263-def117c59119",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2d3fe546e9fd4c4a8a4a7f902ee1b334",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(HTML(value=\"<a href='/lab/' style='text-decoration: none; padding: 8px; background-color: #007b…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import ipywidgets as widgets\n",
"from IPython.display import display, HTML\n",
Expand Down Expand Up @@ -41,7 +56,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "bc6c88a7-a1f2-4dc6-a776-febd38ad2003",
"metadata": {},
"outputs": [],
Expand All @@ -57,7 +72,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "df021d4b-5dc7-4c43-b223-e5ba20728ab0",
"metadata": {},
"outputs": [],
Expand All @@ -80,7 +95,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "535b9b43-6aa3-4fa1-b6ef-1cff6048478d",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -129,21 +144,43 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "c5dbc921-631c-452e-bc3f-2dd91bdbef39",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<h2> Connection Info </h2>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%html\n",
"<h2> Connection Info </h2>"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "8d23fd76-3f33-494b-8fe4-49f45de9ec31",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1mDatabase\u001b[0m: demo\n",
"\u001b[1mUsername\u001b[0m: dbadmin\n"
]
}
],
"source": [
"logging.info('[Query Profile Main Page] Trying to print database connection details')\n",
"try:\n",
Expand Down Expand Up @@ -173,7 +210,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"id": "f2df8e39-73e2-463c-b450-eacccd1823b0",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -223,10 +260,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"id": "b0f623e0-05df-4752-ae85-6fdbe29be943",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3865d856d02d45789ecb2322fc4c05ea",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Tab(children=(VBox(children=(Text(value='', description='Target Schema', layout=Layout(width='300px'), placeho…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"key = widgets.Text(description = \"Key\", placeholder = \"Enter Key\", layout=widgets.Layout(width='300px'))\n",
"key.style.description_width = '100px'\n",
Expand Down Expand Up @@ -265,23 +317,70 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "3cff15cf-0b8d-4651-89dd-026b4e8c9121",
"execution_count": 9,
"id": "88e269a3-38f0-411a-8eac-968a00a6d9e3",
"metadata": {},
"outputs": [],
"source": [
"search_box_test = widgets.HTML(\"\"\"\n",
"You can query the ``query_requests`` table to search for the required query. You can use either:\n",
"<ul>\n",
"<li>Reqeuest label</li> \n",
"<li>Query part</li>\n",
"</ul>\n",
"\"\"\")"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "3cff15cf-0b8d-4651-89dd-026b4e8c9121",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f1af660228604845a264d2e64e02ae6a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Accordion(children=(VBox(children=(HTML(value='\\nYou can query the ``query_requests`` table to search for the …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"request_label_input = widgets.Text(description = \"Request label\", placeholder = \"Enter part of label\")\n",
"request_label_check = widgets.Checkbox(value=False,description='Exact')\n",
"query_search_input = widgets.Text(description = \"Query text\", placeholder = \"Enter part of query\")\n",
"query_search_check = widgets.Checkbox(value=False,description='Exact')\n",
"button_01 = widgets.Button(description=\"Query Request Table\", layout=widgets.Layout(width='auto'))\n",
"output_01 = widgets.Output()\n",
"display(button_01, output_01)\n",
"request_label_widget = widgets.HBox([request_label_input, request_label_check])\n",
"query_search_widget = widgets.HBox([query_search_input, query_search_check])\n",
"search_box_vbox = widgets.VBox([search_box_test, request_label_widget, query_search_widget, button_01, output_01])\n",
"search_box = widgets.Accordion(children=[search_box_vbox], titles=('Search for a query',))\n",
"display(search_box)\n",
"\n",
"def on_button_clicked_01(b):\n",
" output_01.clear_output(wait=True)\n",
" with output_01:\n",
" logging.info('[Query Profile Main Page] Trying to fetch the queries from query_request table')\n",
" sql_query = \"SELECT * from query_requests WHERE request_type = 'QUERY' AND request LIKE 'select%' ORDER BY request_duration_ms DESC LIMIT 6;\"\n",
" if not request_label_check.value:\n",
" request_label_wild_card = '%'\n",
" else:\n",
" request_label_wild_card = ''\n",
" if not query_search_check.value:\n",
" query_search_wild_card = '%'\n",
" else:\n",
" query_search_wild_card = ''\n",
" logging.info(f'[Query Profile Main Page] Trying to fetch the queries from query_request table using the label: {request_label_input.value}, and query text: {query_search_input.value}')\n",
" sql_query = f\"SELECT * from query_requests WHERE request_type = 'QUERY' AND request_label LIKE '{request_label_wild_card}{request_label_input.value}{request_label_wild_card}' AND request LIKE '{query_search_wild_card}{query_search_input.value}{query_search_wild_card}' ORDER BY request_duration_ms DESC LIMIT 6;\"\n",
" result = vp.vDataFrame(sql_query)\n",
" logging.info('[Query Profile Main Page] Successfully fetched the queries from query_request table')\n",
" result.idisplay()\n",
" result.idisplay(checkboxes=True)\n",
" \n",
"logging.info('Trying to display Query Request Table button [Query Profile Main Page]')\n",
"button_01.on_click(on_button_clicked_01)\n",
Expand All @@ -290,7 +389,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"id": "59c1d00b-0ecd-429f-8d39-af3b0ca8f215",
"metadata": {},
"outputs": [],
Expand All @@ -303,7 +402,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"id": "c18c43b6-9bae-4371-aec1-87d35a30160e",
"metadata": {},
"outputs": [],
Expand All @@ -316,7 +415,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"id": "69be4766-8633-4bd9-8588-42967d27a6fb",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -345,7 +444,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"id": "19e7defc-558f-455a-bc6e-4c6bc2cade65",
"metadata": {},
"outputs": [],
Expand All @@ -360,7 +459,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 16,
"id": "f82c652f-0dca-48ce-a2f7-3c5eda71f3fe",
"metadata": {},
"outputs": [],
Expand All @@ -385,7 +484,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 17,
"id": "947b5d38-5c30-4f77-87e9-7402e690ea06",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -421,12 +520,35 @@
"create_list_transaction_statement = widgets.VBox([target_schema_2, key_2,transaction_statement_list, button_4, output_4])"
]
},
{
"cell_type": "markdown",
"id": "f5064472-4cd8-437c-8a4b-a9a01e3537c2",
"metadata": {},
"source": [
"## Directly"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"id": "fbb6fb85-5802-4786-a656-c98f1b5645eb",
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0d31b67802a8410db052ef89b033e970",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Tab(children=(VBox(children=(Text(value='', description='Target Schema (Optional)', layout=Layout(width='300px…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"tab_2 = widgets.Tab()\n",
"tab_2.children = [create_0, create_1, create_list_transaction_statement]\n",
Expand Down Expand Up @@ -515,7 +637,7 @@
"</head>\n",
"<body>\n",
" <div class=\"version\">\n",
" Page version update date: 5/30/2024\n",
" Page version update date: 6/3/2024\n",
" </div>\n",
"</body>\n",
"</html>"
Expand Down

0 comments on commit c236046

Please sign in to comment.