Skip to content

Commit

Permalink
Reworked diff reporting, not first (red) code will be baseline and (g…
Browse files Browse the repository at this point in the history
…reen) code will be changed one.
  • Loading branch information
qvad committed May 19, 2023
1 parent 2c117d5 commit 00b05db
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/reports/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ def _end_collapsible(self):
self.report += """\n====\n\n"""

@staticmethod
def _get_plan_diff(original, changed):
def _get_plan_diff(baseline, changed):
return "\n".join(
text for text in difflib.unified_diff(original.split("\n"), changed.split("\n")) if
text for text in difflib.unified_diff(baseline.split("\n"), changed.split("\n")) if
text[:3] not in ('+++', '---', '@@ '))

def publish_report(self, report_name):
Expand Down
5 changes: 4 additions & 1 deletion src/reports/adoc/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ def __report_query(self, yb_query: Query, pg_query: Query):

self._start_source(["diff"])

diff = self._get_plan_diff(yb_query.execution_plan.full_str, pg_query.execution_plan.full_str)
diff = self._get_plan_diff(
pg_query.execution_plan.full_str,
yb_query.execution_plan.full_str,
)
if not diff:
diff = yb_query.execution_plan.full_str

Expand Down
10 changes: 6 additions & 4 deletions src/reports/adoc/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,17 +415,17 @@ def __report_query(self, yb_query: Type[Query], pg_query: Type[Query], show_best
self._start_source(["diff"])
# postgres plan should be red
self.report += self._get_plan_diff(
yb_query.execution_plan.full_str,
pg_query.execution_plan.full_str,
yb_query.execution_plan.full_str,
)
self._end_source()
self._end_collapsible()

self._start_collapsible(f"{best_yb_pg_equality}PG best vs YB best")
self._start_source(["diff"])
self.report += self._get_plan_diff(
yb_best.execution_plan.full_str,
pg_best.execution_plan.full_str,
yb_best.execution_plan.full_str,
)
self._end_source()
self._end_collapsible()
Expand All @@ -447,8 +447,10 @@ def __report_query(self, yb_query: Type[Query], pg_query: Type[Query], show_best

self.report += f"{default_yb_equality}YB default vs YB best\n"
self._start_source(["diff"])
diff = self._get_plan_diff(yb_query.execution_plan.full_str,
yb_best.execution_plan.full_str)
diff = self._get_plan_diff(
yb_query.execution_plan.full_str,
yb_best.execution_plan.full_str
)
if not diff:
diff = yb_query.execution_plan.full_str

Expand Down
6 changes: 4 additions & 2 deletions src/reports/adoc/selectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ def __report_query(self,

self._start_source(["diff"])

diff = self._get_plan_diff(default.execution_plan.full_str,
all_analyze.execution_plan.full_str)
diff = self._get_plan_diff(
default.execution_plan.full_str,
all_analyze.execution_plan.full_str
)
if not diff:
diff = default.execution_plan.full_str

Expand Down
22 changes: 14 additions & 8 deletions src/reports/adoc/taqo.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ def __report_query(self, query: Query, pg_query: Query, show_best: bool):
if self.config.compare_with_pg:
self.report += \
f"!! Result hash|{query.result_hash}|{best_optimization.result_hash} (yb) != {pg_query.result_hash} (pg)" \
if pg_query.result_hash != query.result_hash else \
f"Result hash|`{query.result_hash}|{best_optimization.result_hash} (yb) != {pg_query.result_hash} (pg)"
if pg_query.result_hash != query.result_hash else \
f"Result hash|`{query.result_hash}|{best_optimization.result_hash} (yb) != {pg_query.result_hash} (pg)"
elif best_optimization.result_hash != query.result_hash:
self.report += f"!! Result hash|{query.result_hash}|{best_optimization.result_hash}"
else:
Expand Down Expand Up @@ -244,15 +244,19 @@ def __report_query(self, query: Query, pg_query: Query, show_best: bool):

self._start_collapsible("Best Postgres plan diff with YB default")
self._start_source(["diff"])
self.report += self._get_plan_diff(best_pg.execution_plan.full_str,
query.execution_plan.full_str, )
self.report += self._get_plan_diff(
query.execution_plan.full_str,
best_pg.execution_plan.full_str,
)
self._end_source()
self._end_collapsible()

self._start_collapsible("Best Postgres plan diff with YB best")
self._start_source(["diff"])
self.report += self._get_plan_diff(best_pg.execution_plan.full_str,
best_optimization.execution_plan.full_str, )
self.report += self._get_plan_diff(
best_pg.execution_plan.full_str,
best_optimization.execution_plan.full_str,
)
self._end_source()
self._end_collapsible()

Expand All @@ -273,8 +277,10 @@ def __report_query(self, query: Query, pg_query: Query, show_best: bool):

self._start_source(["diff"])

diff = self._get_plan_diff(query.execution_plan.full_str,
best_optimization.execution_plan.full_str)
diff = self._get_plan_diff(
query.execution_plan.full_str,
best_optimization.execution_plan.full_str
)
if not diff:
diff = query.execution_plan.full_str

Expand Down

0 comments on commit 00b05db

Please sign in to comment.