From 317e4a06bace3e9598a3b910a8d2889cc5fc60a2 Mon Sep 17 00:00:00 2001 From: pavel-zotov Date: Mon, 31 Jul 2023 14:02:20 +0300 Subject: [PATCH] Added/Updated tests\bugs\core_4809_test.py: Adjusted expected execution plans for FB 5.x. Explained by dimitr, letter 31-JUL-2023 11:00, see notes. --- tests/bugs/core_4809_test.py | 82 ++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 45 deletions(-) diff --git a/tests/bugs/core_4809_test.py b/tests/bugs/core_4809_test.py index 59f58b27..425e6c5e 100644 --- a/tests/bugs/core_4809_test.py +++ b/tests/bugs/core_4809_test.py @@ -3,8 +3,7 @@ """ ID: issue-5107 ISSUE: 5107 -TITLE: HASH/MERGE JOIN is not used for more than two streams if they are joined via - USING/NATURAL clauses and join is based on DBKEY concatenations +TITLE: HASH/MERGE JOIN is not used for more than two streams if they are joined via USING/NATURAL clauses and join is based on DBKEY concatenations DESCRIPTION: JIRA: CORE-4809 FBTEST: bugs.core_4809 @@ -13,6 +12,12 @@ NOTES: FB 5.0.0.455 and later: data sources with equal cardinality now present in the HASH plan in order they are specified in the query. Reversed order was used before this build. Because of this, two cases of expected stdout must be taken in account, see variables 'fb3x_checked_stdout' and 'fb5x_checked_stdout'. + [31.07.2023] pzotov + Adjusted expected execution plans for FB 5.x after commit: 8ef5b9838129ff1ae90a3672ddc6f0e924b42166 + ("Fixed cardinality for hash joins"). Explained by dimitr, letter 31-JUL-2023 11:00: + result of HASH(A, B) is considered now as having greater cardinality than HASH(C). + This causes optimizer to put HASH(A,B) as first source. + Checked on 5.0.0.1149. """ import pytest @@ -160,84 +165,71 @@ act = isql_act('db', test_script) fb3x_checked_stdout = """ PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL) - PLAN HASH (HASH (DATASOURCE_C TK NATURAL, DATASOURCE_B TK NATURAL), DATASOURCE_A TK NATURAL) - PLAN HASH (HASH (HASH (DATASOURCE_D TK NATURAL, DATASOURCE_C TK NATURAL), DATASOURCE_B TK NATURAL), DATASOURCE_A TK NATURAL) - PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL) - PLAN HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)) - PLAN HASH (DATASOURCE_D TK NATURAL, HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL))) - PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL) - PLAN HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)) - PLAN HASH (DATASOURCE_D TK NATURAL, HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL))) - PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL) - PLAN HASH (HASH (DATASOURCE_C TF NATURAL, DATASOURCE_B TF NATURAL), DATASOURCE_A TF NATURAL) - PLAN HASH (HASH (HASH (DATASOURCE_D TF NATURAL, DATASOURCE_C TF NATURAL), DATASOURCE_B TF NATURAL), DATASOURCE_A TF NATURAL) - PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL) - PLAN HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)) - PLAN HASH (DATASOURCE_D TF NATURAL, HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL))) - PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL) - PLAN HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)) - PLAN HASH (DATASOURCE_D TF NATURAL, HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL))) """ +fb4x_checked_stdout = """ + PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL) + PLAN HASH (HASH (DATASOURCE_C TK NATURAL, DATASOURCE_B TK NATURAL), DATASOURCE_A TK NATURAL) + PLAN HASH (HASH (HASH (DATASOURCE_D TK NATURAL, DATASOURCE_C TK NATURAL), DATASOURCE_B TK NATURAL), DATASOURCE_A TK NATURAL) + PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL) + PLAN HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)) + PLAN HASH (DATASOURCE_D TK NATURAL, HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL))) + PLAN HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL) + PLAN HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL)) + PLAN HASH (DATASOURCE_D TK NATURAL, HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_B TK NATURAL, DATASOURCE_A TK NATURAL))) + PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL) + PLAN HASH (HASH (DATASOURCE_C TF NATURAL, DATASOURCE_B TF NATURAL), DATASOURCE_A TF NATURAL) + PLAN HASH (HASH (HASH (DATASOURCE_D TF NATURAL, DATASOURCE_C TF NATURAL), DATASOURCE_B TF NATURAL), DATASOURCE_A TF NATURAL) + PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL) + PLAN HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)) + PLAN HASH (DATASOURCE_D TF NATURAL, HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL))) + PLAN HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL) + PLAN HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL)) + PLAN HASH (DATASOURCE_D TF NATURAL, HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_B TF NATURAL, DATASOURCE_A TF NATURAL))) +""" + fb5x_checked_stdout = """ PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL) - PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL, DATASOURCE_C TK NATURAL) - PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL, DATASOURCE_C TK NATURAL, DATASOURCE_D TK NATURAL) - PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL) - - PLAN HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL)) - - PLAN HASH (DATASOURCE_D TK NATURAL, HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL))) - + PLAN HASH (HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL), DATASOURCE_C TK NATURAL) + PLAN HASH (HASH (HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL), DATASOURCE_C TK NATURAL), DATASOURCE_D TK NATURAL) PLAN HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL) - - PLAN HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL)) - - PLAN HASH (DATASOURCE_D TK NATURAL, HASH (DATASOURCE_C TK NATURAL, HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL))) - + PLAN HASH (HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL), DATASOURCE_C TK NATURAL) + PLAN HASH (HASH (HASH (DATASOURCE_A TK NATURAL, DATASOURCE_B TK NATURAL), DATASOURCE_C TK NATURAL), DATASOURCE_D TK NATURAL) PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL) - PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL, DATASOURCE_C TF NATURAL) - PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL, DATASOURCE_C TF NATURAL, DATASOURCE_D TF NATURAL) - PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL) - - PLAN HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL)) - - PLAN HASH (DATASOURCE_D TF NATURAL, HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL))) - + PLAN HASH (HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL), DATASOURCE_C TF NATURAL) + PLAN HASH (HASH (HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL), DATASOURCE_C TF NATURAL), DATASOURCE_D TF NATURAL) PLAN HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL) - - PLAN HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL)) - - PLAN HASH (DATASOURCE_D TF NATURAL, HASH (DATASOURCE_C TF NATURAL, HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL))) + PLAN HASH (HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL), DATASOURCE_C TF NATURAL) + PLAN HASH (HASH (HASH (DATASOURCE_A TF NATURAL, DATASOURCE_B TF NATURAL), DATASOURCE_C TF NATURAL), DATASOURCE_D TF NATURAL) """ @pytest.mark.version('>=3.0') def test_1(act: Action): - act.expected_stdout = fb3x_checked_stdout if act.is_version('<5') else fb5x_checked_stdout + act.expected_stdout = fb3x_checked_stdout if act.is_version('<4') else fb4x_checked_stdout if act.is_version('<5') else fb5x_checked_stdout act.execute(combine_output = True) assert act.clean_stdout == act.clean_expected_stdout