Skip to content

Commit e397408

Browse files
authored
[QPROF] Updating session params (#1283)
* [QPROF] Updating session params Should close: - https://jira.verticacorp.com/jira/browse/VER-96476?filter=-1 * Adding session_params_current session_params_current allows to get the current params.
1 parent de14804 commit e397408

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

verticapy/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
__url__: str = "https://github.com/vertica/verticapy/"
3838
__license__: str = "Apache License, Version 2.0"
3939
__version__: str = "1.0.5"
40-
__iteration__: int = 1
40+
__iteration__: int = 2
4141
__date__: str = "25092024"
42-
__last_commit__: str = "d15329cab9a2360454f4473e676068d2f793b965"
42+
__last_commit__: str = "845f1130772d54ecd184f71f57c92b76ed4b1628"
4343
__long_version__: str = f"{__version__}-{__iteration__}{__date__}-{__last_commit__}"
4444
__codecov__: float = 0.84
4545

verticapy/performance/vertica/qprof.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ class QueryProfiler:
225225
Current Transaction ID.
226226
statement_id: int
227227
Current Statement ID.
228+
session_params_current: dict
229+
Current Session Parameters.
228230
target_schema: dict
229231
Name of the schema used to store
230232
all the Vertica monitor and internal
@@ -239,6 +241,9 @@ class QueryProfiler:
239241
tables_dtypes: list
240242
Datatypes of all the loaded
241243
performance tables.
244+
session_params: list
245+
Non Default Session Parameters used
246+
to run the transactions.
242247
overwrite: bool
243248
If set to ``True`` overwrites the
244249
existing performance tables.
@@ -1146,6 +1151,7 @@ def __init__(
11461151
session_control_loop = session_control_loop[1:]
11471152

11481153
session_control_loop_all = []
1154+
session_params = []
11491155

11501156
for sc in session_control_loop:
11511157
if sc not in ({}, ""):
@@ -1203,8 +1209,10 @@ def __init__(
12031209
" will be skipped."
12041210
)
12051211
warnings.warn(warning_message, Warning)
1212+
session_params += [self._get_current_session_params()]
12061213

12071214
self.session_control_params = session_control_loop_all
1215+
self.session_params = session_params
12081216

12091217
if len(self.transactions) == 0 and isinstance(key_id, NoneType):
12101218
raise ValueError("No transactions found.")
@@ -1252,8 +1260,38 @@ def __init__(
12521260
iterchecks=iterchecks, ignore_operators_check=ignore_operators_check
12531261
)
12541262

1263+
# CORRECTING WRONG ATTRIBUTES
1264+
if not (hasattr(self, "session_params")) or not (self.session_params):
1265+
self.session_params = [{} for x in self.transactions]
1266+
try:
1267+
self.session_params_current = self.session_params[0]
1268+
except:
1269+
self.session_params_current = {}
1270+
12551271
# Tools
12561272

1273+
@staticmethod
1274+
def _get_current_session_params():
1275+
"""
1276+
Returns a ``dict`` of the current
1277+
session parameters.
1278+
"""
1279+
query = """
1280+
SELECT
1281+
parameter_name,
1282+
current_value
1283+
FROM v_monitor.configuration_parameters
1284+
WHERE current_level != 'DEFAULT';"""
1285+
res = _executeSQL(
1286+
query,
1287+
title="Getting transaction_id, statement_id.",
1288+
method="fetchall",
1289+
)
1290+
params = {}
1291+
for key, val in res:
1292+
params[key] = val
1293+
return params
1294+
12571295
def _check_kind(self, kind: str, kind_list: list) -> str:
12581296
"""
12591297
Checks if the parameter 'kind'
@@ -2024,6 +2062,10 @@ def set_position(self, idx: Union[int, tuple]) -> None:
20242062
self.request = self.requests[idx]
20252063
self.qduration = self.qdurations[idx]
20262064
self.query_success = self.query_successes[idx]
2065+
try:
2066+
self.session_params_current = self.session_params[idx]
2067+
except:
2068+
self.session_params_current = {}
20272069
else:
20282070
raise TypeError(
20292071
"Wrong type for parameter 'idx'. Expecting: int or tuple."
@@ -2047,6 +2089,10 @@ def next(self) -> None:
20472089
self.statement_id = self.transactions[idx][1]
20482090
self.request = self.requests[idx]
20492091
self.qduration = self.qdurations[idx]
2092+
try:
2093+
self.session_params_current = self.session_params[idx]
2094+
except:
2095+
self.session_params_current = {}
20502096

20512097
def previous(self) -> None:
20522098
"""
@@ -2065,6 +2111,10 @@ def previous(self) -> None:
20652111
self.statement_id = self.transactions[idx][1]
20662112
self.request = self.requests[idx]
20672113
self.qduration = self.qdurations[idx]
2114+
try:
2115+
self.session_params_current = self.session_params[idx]
2116+
except:
2117+
self.session_params_current = {}
20682118

20692119
# Main Method
20702120

verticapy/performance/vertica/tree.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,7 +2032,7 @@ def _gen_legend_annotations(self, rows: Optional[list] = None):
20322032
if "RESEGMENT" in row_tmp and "BROADCAST" not in row_tmp:
20332033
all_legend[
20342034
"---"
2035-
] = f'<tr><td BGCOLOR="{bgcolor}"><FONT COLOR="{fontcolor}">---</FONT></td><td BGCOLOR="{fillcolor}"><FONT COLOR="{fontcolor}">RESEGMENT | NO BROADCAST</FONT></td></tr>'
2035+
] = f'<tr><td BGCOLOR="{bgcolor}"><FONT COLOR="{fontcolor}">---</FONT></td><td BGCOLOR="{fillcolor}"><FONT COLOR="{fontcolor}">RESEGMENT</FONT></td></tr>'
20362036
if "HASH" in row_tmp:
20372037
all_legend[
20382038
"HASH"
@@ -2087,9 +2087,9 @@ def _gen_legend_annotations(self, rows: Optional[list] = None):
20872087
):
20882088
res_trans = ""
20892089
if idx == 0:
2090-
name_tmp = "Path transition"
2090+
name_tmp = "Path transitions"
20912091
elif idx == 1:
2092-
name_tmp = "Link"
2092+
name_tmp = "Links"
20932093
elif idx == 2:
20942094
name_tmp = "Information"
20952095
for op in trans_list:

0 commit comments

Comments
 (0)