Skip to content

Commit 3026bdb

Browse files
authored
Merge pull request #303 from vertica/update_ui_add_table_dc_file_reads
Update qprof-ui.ipynb - Added a new tab for dc_dile_reads
2 parents f9f596d + 06824e9 commit 3026bdb

File tree

1 file changed

+46
-21
lines changed

1 file changed

+46
-21
lines changed

project/ui/qprof-ui.ipynb

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -420,46 +420,71 @@
420420
"\n",
421421
"def on_button_clicked_other_info(b):\n",
422422
" button_other_info.disabled = True\n",
423-
" table_1.clear_output(wait=True)\n",
424-
" table_2.clear_output(wait=True)\n",
423+
" table_slow_events.clear_output(wait=True)\n",
424+
" table_optimizer_events.clear_output(wait=True)\n",
425+
" table_file_reads.clear_output(wait=True)\n",
426+
" \n",
425427
" try:\n",
426428
" transaction_statement_list = qprof.transactions\n",
427429
" logging.info(f'[Query Profile Tree Page] The list of transaction and statement ids are: {transaction_statement_list}')\n",
428-
" # Construct the WHERE clause dynamically\n",
429430
" where_clause = \" OR \".join([f\"(transaction_id = {elem[0]} AND statement_id = {elem[1]})\" for elem in transaction_statement_list])\n",
430-
" \n",
431-
" # Construct the query\n",
431+
" except Exception as e:\n",
432+
" with table_slow_events:\n",
433+
" display(widgets.HTML(f\"<p style='color:red'>The following error occurred while preparing the WHERE clause: </p> <p> {e}</p>\"))\n",
434+
" button_other_info.disabled = False\n",
435+
" return\n",
436+
"\n",
437+
" try:\n",
432438
" query = f\"\"\"\n",
433439
" SELECT transaction_id, statement_id, node_name, event_description, time, duration_us/1000000 AS duration_sec\n",
434440
" FROM dc_slow_events\n",
435441
" WHERE {where_clause}\n",
436442
" ORDER BY duration_sec DESC\n",
437443
" LIMIT 500;\n",
438444
" \"\"\"\n",
439-
" query_2 = f\"\"\"\n",
445+
" logging.info(f'[Query Profile Tree Page] Trying to get the DC SLOW EVENTS table')\n",
446+
" res_slow_events = vp.vDataFrame(f\"\"\"{query}\"\"\")\n",
447+
" with table_slow_events:\n",
448+
" res_slow_events.idisplay()\n",
449+
" except Exception as e:\n",
450+
" with table_slow_events:\n",
451+
" display(widgets.HTML(f\"<p style='color:red'>The following error occurred while loading DC SLOW EVENTS: </p> <p> {e}</p>\"))\n",
452+
"\n",
453+
" try:\n",
454+
" query = f\"\"\"\n",
440455
" SELECT *\n",
441456
" FROM dc_optimizer_events\n",
442457
" WHERE {where_clause};\n",
443458
" \"\"\"\n",
444-
" logging.info(f'[Query Profile Tree Page] Trying to get the DC SLOW EVENTS table')\n",
445-
" res_1 = vp.vDataFrame(f\"\"\"{query}\"\"\")\n",
446-
" res_2 = vp.vDataFrame(f\"\"\"{query_2}\"\"\")\n",
447-
" with table_1:\n",
448-
" res_1.idisplay()\n",
449-
" with table_2:\n",
450-
" res_2.idisplay()\n",
459+
" res_optimizer_events = vp.vDataFrame(f\"\"\"{query}\"\"\")\n",
460+
" with table_optimizer_events:\n",
461+
" res_optimizer_events.idisplay()\n",
462+
" except Exception as e:\n",
463+
" with table_optimizer_events:\n",
464+
" display(widgets.HTML(f\"<p style='color:red'>The following error occurred while loading DC OPTIMIZER EVENTS: </p> <p> {e}</p>\"))\n",
465+
"\n",
466+
" try:\n",
467+
" query = f\"\"\"\n",
468+
" SELECT *\n",
469+
" FROM dc_file_reads\n",
470+
" WHERE {where_clause};\n",
471+
" \"\"\"\n",
472+
" res_file_reads = vp.vDataFrame(f\"\"\"{query}\"\"\")\n",
473+
" with table_file_reads:\n",
474+
" res_file_reads.idisplay()\n",
451475
" except Exception as e:\n",
452-
" with table_1:\n",
453-
" display(widgets.HTML(f\"<p style='color:red'>The following error occured: </p> <p> {e}</p>\"))\n",
454-
" with table_2:\n",
455-
" display(widgets.HTML(f\"<p style='color:red'>The following error occured: </p> <p> {e}</p>\"))\n",
476+
" with table_file_reads:\n",
477+
" display(widgets.HTML(f\"<p style='color:red'>The following error occurred while loading DC FILE READS: </p> <p> {e}</p>\"))\n",
478+
"\n",
456479
" button_other_info.disabled = False\n",
480+
"\n",
457481
" \n",
458-
"table_1 = widgets.Output()\n",
459-
"table_2 = widgets.Output()\n",
482+
"table_slow_events = widgets.Output()\n",
483+
"table_optimizer_events = widgets.Output()\n",
484+
"table_file_reads = widgets.Output()\n",
460485
"tables = widgets.Tab()\n",
461-
"tables.children = [table_1, table_2]\n",
462-
"tables.titles = [\"Slow Events\", \"Optimizer Events\"]\n",
486+
"tables.children = [table_slow_events, table_optimizer_events, table_file_reads]\n",
487+
"tables.titles = [\"Slow Events\", \"Optimizer Events\", \"File Reads\"]\n",
463488
"other_info = widgets.VBox([button_other_info, tables])\n",
464489
"\n",
465490
"button_other_info.on_click(on_button_clicked_other_info)\n",

0 commit comments

Comments
 (0)