Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Fix incorrect execution plan when generated column rewrite in join relation if left table and right table has the same column name #52584

Merged

Commits on Nov 4, 2024

  1. [BugFix] Fix incorrect execution plan when generated rewrite in join …

    …relation if left table and right table has the same column name
    
    Why I'm doing:
    This problem is introduced by pr StarRocks#50398. In this pr, we introduce some new rule for generated column rewriting.
    The basic idea is following:
    1. Collect the rewriting relation in every SELECT scope in query. (Expr -> ColumnRef)
    2. Translate the expression relation into Operator mapping: ScalarOperator -> ColumnRefOperator
    3. Introduce new rule says ReplaceScalarOperatorRule, use this new rule to replace the ScalarOperator
       into ColumnRefOperator when generating the logical plan in optimizer.
    
    This problem is that, ReplaceScalarOperatorRule use ScalarOperator.isEquivalent to check if a ScalarOperator
    is hit the rule instead of using ScalarOperator.equals. ScalarOperator.isEquivalent does not check the operator
    id but this id will be used to indentify the column with the same column name but come from different table in JOIN
    relation. (e.g column xx in TABLE A and column xx in TABLE B has same name but different id, in this case, ScalarOperator.isEquivalent
    return true but ScalarOperator.equals return false). So in this case, we will get the wrong mapping and generated a
    incorrent plan for generated column rewrite.
    
    What I'm doing:
    1. Using ScalarOperator.equals instead
    2. Introduce session variables disable_generated_column_rewrite for disable the generated column rewrite if we want.
    
    Signed-off-by: srlch <[email protected]>
    srlch committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    0f95ef4 View commit details
    Browse the repository at this point in the history
  2. fix

    Signed-off-by: srlch <[email protected]>
    srlch committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    f924c3f View commit details
    Browse the repository at this point in the history
  3. fix

    Signed-off-by: srlch <[email protected]>
    srlch committed Nov 4, 2024
    Configuration menu
    Copy the full SHA
    d3d513b View commit details
    Browse the repository at this point in the history

Commits on Nov 5, 2024

  1. add more sql-test

    Signed-off-by: srlch <[email protected]>
    srlch committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    26b327b View commit details
    Browse the repository at this point in the history
  2. add sql-test function

    Signed-off-by: srlch <[email protected]>
    srlch committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    cccce5f View commit details
    Browse the repository at this point in the history
  3. format

    Signed-off-by: srlch <[email protected]>
    srlch committed Nov 5, 2024
    Configuration menu
    Copy the full SHA
    2245617 View commit details
    Browse the repository at this point in the history