diff --git a/project/ui/qprof-ui.ipynb b/project/ui/qprof-ui.ipynb index cc062d97..10d132ca 100644 --- a/project/ui/qprof-ui.ipynb +++ b/project/ui/qprof-ui.ipynb @@ -97,7 +97,7 @@ " %store -r target_schema_val_2\n", " %store -r key_val_2\n", " %store -r transaction_statement_list_val\n", - "\n", + " %store -r control_query_val\n", " if \"file_val\" in globals():\n", " if not \"key_val\" in globals():\n", " characters = string.ascii_letters + string.digits # includes 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'\n", @@ -128,6 +128,7 @@ " target_schema = target_schema_val_2 if \"target_schema_val_2\" in globals() else None,\n", " key_id = key_val_2 if \"key_val_2\" in globals() else None,\n", " check_tables = False,\n", + " session_control = control_query_val if \"control_query_val\" in globals() else None,\n", " )\n", " elif \"transaction_val\" in globals():\n", " logging.info(f'[Query Profile Tree Page] Creating qprof object using transactions as {eval(transaction_val), eval(statement_val)}, target_schema as {target_schema_val_2 if \"target_schema_val_2\" in globals() else None}, key_id as{key_val_2 if \"key_val_2\" in globals() else None}')\n", @@ -465,66 +466,37 @@ "\n", "engine_tab_summary_1 = widgets.Output()\n", "\n", - "# List of checkbox tags\n", - "tags = [\n", - " \"blocks_analyzed_sip\",\n", - " \"clock_time_us\",\n", - " \"container_rows_filtered_sip\",\n", - " \"container_rows_filtered_pred\",\n", - " \"container_rows_pruned_sip\",\n", - " \"container_rows_pruned_pred\",\n", - " \"container_rows_pruned_valindex\",\n", - " \"exec_time_us\",\n", - " \"hash_tables_spilled_sort\",\n", - " \"join_inner_clock_time_us\",\n", - " \"join_inner_exec_time_us\",\n", - " \"join_outer_clock_time_us\",\n", - " \"join_outer_exec_time_us\",\n", - " \"mem_res_b\",\n", - " \"mem_all_b\",\n", - " \"network_wait_us\",\n", - " \"proc_rows\",\n", - " \"producer_stall_us\",\n", - " \"producer_wait_us\",\n", - " \"prod_rows\",\n", - " \"request_wait_us\",\n", - " \"response_wait_us\",\n", - " \"recv_net_time_us\",\n", - " \"recv_wait_us\",\n", - " \"rle_prod_rows\",\n", - " \"rows_filtered_sip\",\n", - " \"rows_pruned_valindex\",\n", - " \"rows_processed_sip\",\n", - " \"total_rows_read_join_sort\",\n", - " \"total_rows_read_sort\"\n", - "]\n", + "tags = sorted(qprof.get_qexecution_report(return_useful_cols=True))\n", "\n", - "tags=sorted(tags)\n", "\n", + "selected_checkboxes = [\"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\"]\n", "# Create checkboxes\n", "checkboxes = [\n", - " widgets.Checkbox(value=(tag in [\"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]), description=tag) \n", + " widgets.Checkbox(value=(tag in selected_checkboxes), description=tag) \n", " for tag in tags\n", "]\n", - "selected_checkboxes = [cb.description for cb in checkboxes if cb.value]\n", + "\n", + "\n", "# Function to update based on selections\n", "def on_checkbox_change(change):\n", - " global selected_checkboxes, summary_vdf, summary_vdf_main, granularity_level, granularity_column_list\n", - " selected_checkboxes = [cb.description for cb in checkboxes if cb.value]\n", - " if len(selected_checkboxes) > 6:\n", - " # Deselect the latest selection if limit is exceeded\n", - " change['owner'].value = False\n", - " return\n", + " global selected_checkboxes, summary_vdf, granularity_level\n", + " \n", + " # If the checkbox is being checked\n", + " if change['new']:\n", + " # If we already have 6 checkboxes selected, prevent this one from being checked\n", + " if len(selected_checkboxes) >= 6:\n", + " change['owner'].value = False\n", + " return\n", + " selected_checkboxes.append(change['owner'].description)\n", + " else:\n", + " # If the checkbox is being unchecked, remove it from the list\n", + " selected_checkboxes.remove(change['owner'].description)\n", "\n", " # Update the dataframe based on selected checkboxes\n", - " column_list = granularity_column_list.copy()\n", - " column_list.extend(selected_checkboxes.copy())\n", - " summary_vdf = qprof._get_vdf_summary()[granularity_level][column_list]\n", - " summary_vdf_main = summary_vdf\n", - " \n", - " # Update the table display\n", - " display_vdf_across_paths(path_id=summary_path_id_dropdown.value)\n", - " display_vdf_across_nodes(path_id=summary_path_id_dropdown.value, localplan_id=summary_localplan_id_dropdown.value, operator_name=summary_operator_name_dropdown.value)\n", + " detailed_update_table(node_name=summary_node_name_dropdown.value, \n", + " path_id=summary_path_id_dropdown.value, \n", + " localplan_id=summary_localplan_id_dropdown.value, \n", + " operator_name=summary_operator_name_dropdown.value)\n", "\n", "# Attach the observer to each checkbox\n", "for cb in checkboxes:\n", @@ -552,9 +524,10 @@ " if change['new'] == 'Across nodes':\n", " granularity_level = 1\n", " summary_node_name_dropdown.disabled = True\n", - " summary_localplan_id_dropdown.disabled = False\n", + " summary_localplan_id_dropdown.disabled = True\n", " summary_operator_name_dropdown.disabled = False\n", - " display_vdf_across_nodes(path_id=summary_path_id_dropdown.value, localplan_id=summary_localplan_id_dropdown.value, operator_name=summary_operator_name_dropdown.value)\n", + " summary_baseplan_id_dropdown.disabled = False\n", + " display_vdf_across_nodes(path_id=summary_path_id_dropdown.value, baseplan_id=summary_baseplan_id_dropdown.value, operator_name=summary_operator_name_dropdown.value)\n", " elif change['new'] == 'Across paths':\n", " granularity_level = 2\n", " summary_node_name_dropdown.disabled = True\n", @@ -583,7 +556,7 @@ " # display(widgets.HTML(vdf._repr_html_()))\n", " display(vdf.idisplay())\n", "\n", - " def display_vdf_across_nodes(path_id=\"All\", localplan_id=\"All\", operator_name=\"All\"):\n", + " def display_vdf_across_nodes(path_id=\"All\", baseplan_id=\"All\", operator_name=\"All\"):\n", " if vdf_across_nodes is None:\n", " return\n", " vdf = vdf_across_nodes.copy()\n", @@ -591,8 +564,8 @@ " engine_tab_summary_1.clear_output(wait=True)\n", " if path_id != \"All\":\n", " vdf = vdf[vdf[\"path_id\"] == path_id]\n", - " if localplan_id != \"All\":\n", - " vdf = vdf[vdf[\"localplan_id\"] == localplan_id]\n", + " if baseplan_id != \"All\":\n", + " vdf = vdf[vdf[\"baseplan_id\"] == baseplan_id]\n", " if operator_name != \"All\":\n", " vdf = vdf[vdf[\"operator_name\"] == operator_name]\n", " # display(widgets.HTML(vdf._repr_html_()))\n", @@ -618,7 +591,8 @@ " options=['All'],\n", " description='Select Local Plan ID:',\n", " style={'description_width': 'initial'},\n", - " value='All'\n", + " value='All',\n", + " disabled=True\n", " )\n", " summary_operator_name_dropdown = widgets.Dropdown(\n", " options=['All'],\n", @@ -626,7 +600,13 @@ " style={'description_width': 'initial'},\n", " value='All'\n", " )\n", - " engine_table_summary_controls = widgets.VBox([summary_node_name_dropdown, summary_path_id_dropdown, summary_localplan_id_dropdown, summary_operator_name_dropdown])\n", + " summary_baseplan_id_dropdown = widgets.Dropdown(\n", + " options=['All'],\n", + " description='Select Base Plan ID:',\n", + " style={'description_width': 'initial'},\n", + " value='All',\n", + " )\n", + " engine_table_summary_controls = widgets.VBox([summary_node_name_dropdown, summary_path_id_dropdown, summary_localplan_id_dropdown, summary_baseplan_id_dropdown,summary_operator_name_dropdown])\n", " \n", " def summary_on_node_name_dropdown_change(change):\n", " if change['type'] == 'change' and change['name'] == 'value':\n", @@ -687,14 +667,36 @@ " vdf = vdf[vdf[\"localplan_id\"]==selected_key]\n", " summary_operator_name_dropdown.options = ['All'] + sorted(vdf[\"operator_name\"].distinct())\n", " summary_operator_name_dropdown.value = 'All'\n", - " if engine_table_granularity_switch.value == 'Across nodes':\n", - " display_vdf_across_nodes(path_id = summary_path_id_dropdown.value, localplan_id = selected_key)\n", - " else:\n", - " display_vdf_across_paths(path_id = summary_path_id_dropdown.value)\n", + " # if engine_table_granularity_switch.value == 'Across nodes':\n", + " # display_vdf_across_nodes(path_id = summary_path_id_dropdown.value, localplan_id = selected_key)\n", + " # else:\n", + " # display_vdf_across_paths(path_id = summary_path_id_dropdown.value)\n", " detailed_update_table(node_name = summary_node_name_dropdown.value,path_id = summary_path_id_dropdown.value,localplan_id = selected_key)\n", "\n", " summary_localplan_id_dropdown.observe(summary_on_localplan_id_dropdown_change, names='value') \n", " \n", + " def summary_on_baseplan_id_dropdown_change(change):\n", + " if not summary_node_name_dropdown.value == \"All\":\n", + " vdf=vdf_across_nodes[vdf_across_nodes[\"node_name\"]==summary_node_name_dropdown.value]\n", + " summary_operator_name_dropdown.options = ['All'] + sorted(vdf[\"operator_name\"].distinct())\n", + " else:\n", + " vdf = vdf_across_nodes\n", + " if change['type'] == 'change' and change['name'] == 'value':\n", + " selected_key = change['new']\n", + " if selected_key == 'All':\n", + " summary_operator_name_dropdown.options = ['All'] + sorted(vdf[\"operator_name\"].distinct())\n", + " else:\n", + " vdf = vdf[vdf[\"baseplan_id\"]==selected_key]\n", + " summary_operator_name_dropdown.options = ['All'] + sorted(vdf[\"operator_name\"].distinct())\n", + " summary_operator_name_dropdown.value = 'All'\n", + " if engine_table_granularity_switch.value == 'Across nodes':\n", + " display_vdf_across_nodes(path_id = summary_path_id_dropdown.value, baseplan_id = selected_key)\n", + " else:\n", + " display_vdf_across_paths(path_id = summary_path_id_dropdown.value)\n", + " detailed_update_table(node_name = summary_node_name_dropdown.value, path_id = summary_path_id_dropdown.value, baseplan_id = selected_key)\n", + " \n", + " summary_baseplan_id_dropdown.observe(summary_on_baseplan_id_dropdown_change, names='value') \n", + " \n", " def summary_on_operator_name_dropdown_change(change):\n", " if not summary_node_name_dropdown.value == \"All\":\n", " vdf=summary_vdf_main[summary_vdf_main[\"node_name\"]==summary_node_name_dropdown.value]\n", @@ -707,7 +709,7 @@ " if change['type'] == 'change' and change['name'] == 'value':\n", " selected_key = change['new']\n", " if engine_table_granularity_switch.value == 'Across nodes':\n", - " display_vdf_across_nodes(path_id=summary_path_id_dropdown.value, localplan_id=summary_localplan_id_dropdown.value, operator_name=selected_key)\n", + " display_vdf_across_nodes(path_id=summary_path_id_dropdown.value, baseplan_id=summary_baseplan_id_dropdown.value, operator_name=selected_key)\n", " else:\n", " display_vdf_across_paths(path_id=summary_path_id_dropdown.value)\n", " detailed_update_table(node_name=summary_node_name_dropdown.value, path_id=summary_path_id_dropdown.value, localplan_id=summary_localplan_id_dropdown.value, operator_name=selected_key)\n", @@ -755,7 +757,7 @@ " operator_name=summary_operator_name_dropdown.value\n", " )\n", "engine_table_detailed_selection_switch.observe(on_detailed_view_change, names='value')\n", - "engine_table_detailed_widget = widgets.Output()\n", + "engine_table_detailed_widget = widgets.Output(layout=widgets.Layout(width='1400px'))\n", "try:\n", " query = (f\"\"\" \n", " select node_name, path_id, localplan_id, operator_id, operator_name, counter_name, counter_value from v_monitor.execution_engine_profiles\n", @@ -765,14 +767,17 @@ " detailed_vdf = vp.vDataFrame(query)\n", " \n", " def detailed_update_table(node_name=\"All\", path_id=\"All\", localplan_id=\"All\", operator_name=\"All\"):\n", - " global detailed_vdf, summary_vdf\n", + " global detailed_vdf, summary_vdf_main, selected_checkboxes\n", " \n", " with engine_table_detailed_widget:\n", " engine_table_detailed_widget.clear_output(wait=True)\n", " if engine_table_detailed_selection_switch.value == \"Raw Table\":\n", " vdf = detailed_vdf.copy()\n", " elif engine_table_detailed_selection_switch.value == \"Pivot Table\":\n", - " vdf = summary_vdf.copy()\n", + " vdf = summary_vdf_main.copy()\n", + " cols = [\"node_name\", \"path_id\", \"localplan_id\", \"operator_name\"]\n", + " cols.extend(selected_checkboxes)\n", + " vdf = vdf[cols]\n", " if path_id != \"All\":\n", " vdf = vdf[vdf[\"path_id\"] == path_id]\n", " if node_name != \"All\":\n", @@ -789,9 +794,11 @@ " engine_table_detailed_widget = widgets.HTML(f\"

The following error occured:

{e}

\") \n", "\n", "engine_table_detailed_top = widgets.HBox([engine_table_summary_controls, engine_table_detailed_selection_title_switch])\n", - "engine_table_detailed = widgets.VBox([\n", - " engine_table_detailed_top,\n", - " engine_table_detailed_widget])\n", + "engine_table_detailed = widgets.VBox([\n", + " engine_table_detailed_top,\n", + " widgets.HBox([engine_table_detailed_widget ,widgets.VBox(checkboxes)]),\n", + " # checkboxes, engine_table_detailed_widget\n", + "])\n", "\n", "engine_table_tab = widgets.Tab()\n", "engine_table_tab.children = [engine_tab_summary_all, engine_table_detailed]\n", @@ -810,50 +817,65 @@ " summary_path_id_dropdown.disabled = False\n", " summary_localplan_id_dropdown.disabled = True\n", " summary_operator_name_dropdown.disabled = True\n", + " summary_baseplan_id_dropdown.disabled = True\n", " else: # 'Across nodes'\n", " summary_node_name_dropdown.disabled = True\n", " summary_path_id_dropdown.disabled = False\n", " summary_localplan_id_dropdown.disabled = False\n", " summary_operator_name_dropdown.disabled = False\n", - "\n", + " summary_baseplan_id_dropdown.disabled = False\n", "def enable_all_dropdowns():\n", " summary_node_name_dropdown.disabled = False\n", " summary_path_id_dropdown.disabled = False\n", " summary_localplan_id_dropdown.disabled = False\n", " summary_operator_name_dropdown.disabled = False\n", + " summary_baseplan_id_dropdown.disabled = True # It is not used in the Detailed tab.\n", "\n", "engine_table_tab.observe(on_tab_change, names='selected_index')\n", "# Button to calcualte Query Execution Engine data\n", "engine_table_button = widgets.Button(description = \"Fetch data\", layout=widgets.Layout(margin='10px 0 10px 0'))\n", "def on_engine_table_button_click(b):\n", " engine_table_button.disabled = True\n", - " global summary_vdf, summary_vdf_main, vdf_across_paths, vdf_across_nodes\n", + " global summary_vdf, summary_vdf_main, vdf_across_paths, vdf_across_nodes, checkboxes\n", " \n", " try:\n", " # Adjust the column list based on the current granularity level\n", " if granularity_level == 2:\n", " columns = [\"path_id\", \"thread_count\", \"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]\n", " elif granularity_level == 1:\n", - " columns = [\"path_id\", \"localplan_id\", \"operator_name\", \"thread_count\", \"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]\n", + " columns = [\"path_id\", \"baseplan_id\", \"operator_name\", \"thread_count\", \"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]\n", " else:\n", " columns = [\"node_name\", \"path_id\", \"localplan_id\", \"operator_name\", \"thread_count\", \"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]\n", - " \n", "\n", - " summary_vdf = qprof._get_vdf_summary()[0][\"node_name\", \"path_id\", \"localplan_id\", \"operator_name\", \"thread_count\", \"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]\n", + " vdf_across_paths = qprof._get_vdf_summary()[2][\"path_id\", \"thread_count\", \"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]\n", + " vdf_across_nodes = qprof._get_vdf_summary()[1][\"path_id\", \"baseplan_id\", \"operator_name\", \"thread_count\", \"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]\n", + " summary_vdf_main = qprof._get_vdf_summary()[0]\n", + " summary_vdf = summary_vdf_main[\"node_name\", \"path_id\", \"localplan_id\", \"operator_name\", \"thread_count\", \"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]\n", "\n", " # Update dropdowns\n", " summary_node_name_dropdown.options = ['All'] + sorted(summary_vdf[\"node_name\"].distinct())\n", " summary_path_id_dropdown.options = ['All'] + sorted(summary_vdf[\"path_id\"].distinct())\n", " summary_localplan_id_dropdown.options = ['All'] + sorted(summary_vdf[\"localplan_id\"].distinct())\n", " summary_operator_name_dropdown.options = ['All'] + sorted(summary_vdf[\"operator_name\"].distinct())\n", + " summary_baseplan_id_dropdown.options = ['All'] + sorted(vdf_across_nodes[\"baseplan_id\"].distinct())\n", "\n", - " vdf_across_paths = qprof._get_vdf_summary()[2][\"path_id\", \"thread_count\", \"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]\n", - " vdf_across_nodes = qprof._get_vdf_summary()[1][\"path_id\", \"localplan_id\", \"operator_name\", \"thread_count\", \"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]\n", - " summary_vdf_main = summary_vdf\n", "\n", " # Initial table updates\n", " display_vdf_across_paths()\n", " detailed_update_table()\n", + "\n", + " tags = sorted(qprof.get_qexecution_report(return_useful_cols=True))\n", + "\n", + " # Create checkboxes\n", + " checkboxes = [\n", + " widgets.Checkbox(value=(tag in [\"exec_time_us\", \"prod_rows\", \"proc_rows\", \"clock_time_us\", \"mem_all_b\"]), description=tag) \n", + " for tag in tags\n", + " ]\n", + "\n", + " # Attach the observer to each checkbox\n", + " for cb in checkboxes:\n", + " cb.observe(on_checkbox_change, names='value')\n", + "\n", " except Exception as e:\n", " with engine_tab_summary_1:\n", " engine_tab_summary_1.clear_output(wait=True)\n", diff --git a/project/ui/qprof_main.ipynb b/project/ui/qprof_main.ipynb index 047d0d20..22767626 100644 --- a/project/ui/qprof_main.ipynb +++ b/project/ui/qprof_main.ipynb @@ -85,7 +85,7 @@ "metadata": {}, "outputs": [], "source": [ - "def reset_values(query_val = None, key_val = None, target_schema_val = None, transaction_val = None, statement_val = None, file_val = None, key_val_2 = None, target_schema_val_2 = None, transaction_statement_list_val = None): \n", + "def reset_values(query_val = None, key_val = None, target_schema_val = None, transaction_val = None, statement_val = None, file_val = None, key_val_2 = None, target_schema_val_2 = None, transaction_statement_list_val = None, control_query_val = None): \n", " if query_val:\n", " %store query_val\n", " else:\n", @@ -122,7 +122,10 @@ " %store transaction_statement_list_val\n", " else:\n", " %store -d transaction_statement_list_val\n", - " \n", + " if control_query_val:\n", + " %store control_query_val\n", + " else:\n", + " %store -d control_query_val\n", " notebook_url = '/voila/render/ui/qprof-ui.ipynb'\n", " display(HTML(f\"\"))" ] @@ -459,35 +462,8 @@ " query_search_check])\n", "search_box_vbox = widgets.VBox([search_box_test, request_label_widget, query_search_widget, button_01, output_01])\n", "\n", - "query_session_control_input = widgets.Text(description=\"SQL:\", placeholder=\"Enter Session Control SQL\",\n", - " layout={'width': \"650px\"})\n", - "query_session_control_button = widgets.Button(description=\"Run SQL\")\n", - "query_session_control_output = widgets.Output()\n", - "\n", - "def on_query_session_control_button_clicked(b):\n", - " query_session_control_button.disabled = True\n", - " query_session_control_output.clear_output(wait=True)\n", - " with query_session_control_output:\n", - " sql_query = query_session_control_input.value\n", - " if sql_query:\n", - " logging.info(f'[Query Profile Main Page] Running the following query for session parameter changes: {sql_query}')\n", - " vp._utils._sql._sys._executeSQL(sql_query)\n", - " print(\"Successfully ran the query for session parameter changes.\")\n", - " logging.info('[Query Profile Main Page] Successfully fran query for session parameter chagnes')\n", - " else:\n", - " print(\"\\033[91m\\033[1m Error! Please enter a SQL statement. \\033[0m\\033[0m\")\n", - " query_session_control_button.disabled = False\n", - "\n", - "query_session_control_button.on_click(on_query_session_control_button_clicked)\n", - "\n", - "query_session_control_box = widgets.VBox([\n", - " query_session_control_input,\n", - " query_session_control_button,\n", - " query_session_control_output\n", - "])\n", - "\n", "# Update the accordion with the new child\n", - "search_box = widgets.Accordion(children=[search_box_vbox, query_session_control_box], titles=('Search for a query', 'Session Parameter Control'))\n", + "search_box = widgets.Accordion(children=[search_box_vbox], titles=('Search for a query', 'Session Parameter Control'))\n", "\n", "\n", "def on_button_clicked_01(b):\n", @@ -534,10 +510,10 @@ "metadata": {}, "outputs": [], "source": [ - "key_2 = widgets.Text(description = \"Key (Optional)\", placeholder = \"Enter a unique Key\", layout=widgets.Layout(width='300px'))\n", - "key_2.style.description_width = '100px'\n", + "key_2 = widgets.Text(description = \"Key (Optional)\", placeholder = \"Enter a unique Key\", layout=widgets.Layout(width='350px'))\n", + "key_2.style.description_width = '150px'\n", "key_2_combo = widgets.HBox([key_2, create_tooltip(\"Enter a unique key that will be used to save your profile tables. If your key is already in use then a random key will be generated to store the data. Note that you will need the combination of schema and the key to load your saved data. If you do not provide this, you may not be able to export your profile tables to a tar file.\")])\n", - "target_schema_2 = widgets.Text(description = \"Target Schema (Optional)\", placeholder = \"Enter Schema\",layout=widgets.Layout(width='300px'))\n", + "target_schema_2 = widgets.Text(description = \"Target Schema (Optional)\", placeholder = \"Enter Schema\",layout=widgets.Layout(width='350px'))\n", "target_schema_2.style.description_width = '150px'\n", "target_schema_2_combo = widgets.HBox([target_schema_2, create_tooltip(\"Enter the schema in which you would like to store the profile data. Note that you will need the combination of schema and the key to load your saved data. If you do not provide this, you may not be able to export your profile tables to a tar file.\")])" ] @@ -585,8 +561,17 @@ " placeholder='Enter a SQL Query',\n", " description='SQL Query:',\n", " disabled=False,\n", - " layout=widgets.Layout(width='700px', height = '300px')\n", - ")" + " layout=widgets.Layout(width='800px', height = '300px')\n", + ")\n", + "\n", + "session_control_sql_textarea = widgets.Textarea( \n", + " placeholder='SQL. E.g. ALTER SESSION SET statement_mem = 100000000;',\n", + " description='Session Control SQL:',\n", + " disabled=False,\n", + " layout=widgets.Layout(width='800px')\n", + ")\n", + "session_control_sql_textarea.style.description_width = '150px'\n", + "session_control_sql = widgets.HBox([session_control_sql_textarea, create_tooltip(\"Enter the session control SQL that you want to run before your query. This is useful if you want to control the session parameters for your query. For example, you can use this to set the statement memory for your query. You can even enter multiple statements by separating them with a semicolon.\"),])\n" ] }, { @@ -618,21 +603,24 @@ "\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", + " global query_val, target_schema_val_2, key_val_2, control_query_val\n", " with output_0:\n", " target_schema_val_2 = target_schema_2.value\n", " query_val = query_list(query.value)\n", + " control_query_val = query_list(session_control_sql_textarea.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", + " elif query_check(control_query_val):\n", + " print(\"\\033[91m\\033[1m Error! Re-check your session control query. \\033[0m\\033[0m\")\n", " else:\n", " key_val_2 = key_2.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", + " reset_values(query_val = query_val, target_schema_val_2 = target_schema_val_2, key_val_2 = key_val_2, control_query_val = control_query_val)\n", "\n", "button.on_click(on_button_clicked_0)\n", - "create_1 = widgets.VBox([target_schema_2_combo, key_2_combo, query, button, output_0])\n" + "create_1 = widgets.VBox([target_schema_2_combo, key_2_combo, session_control_sql, query, button, output_0])\n" ] }, {