-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Enhancement] Support Generated Column rewrite in complex Query #50398
Conversation
|
||
GeneratedColumnVisitor visitor = new GeneratedColumnVisitor(); | ||
visitor.process(node, viewScope); | ||
|
||
return viewScope; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I help you today?
public Map<Expr, SlotRef> getGeneratedExprToColumnRef() { | ||
return generatedExprToColumnRef; | ||
} | ||
|
||
@Override | ||
public <R, C> R accept(AstVisitor<R, C> visitor, C context) { | ||
return visitor.visitRelation(this, context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most risky bug in this code is:
Potential thread-safety issues with generatedExprToColumnRef
.
You can modify the code like this:
import java.util.Collections;
import java.util.concurrent.ConcurrentHashMap;
//...
private Map<Expr, SlotRef> generatedExprToColumnRef = new ConcurrentHashMap<>();
public void setGeneratedExprToColumnRef(Map<Expr, SlotRef> generatedExprToColumnRef) {
this.generatedExprToColumnRef = Collections.synchronizedMap(generatedExprToColumnRef);
}
784e377
to
7583580
Compare
f8b5ab8
to
05deed6
Compare
In this pr: 1. Refactor Generated Column rewrite code: a. Collect generated column expr mapping From QueryAnalyzer. b. Introduce ReplaceScalarOperatorRule to replace the ScalarOperator match the generated column expression. 2. Supprot View, JOIN with Subquery and CTE for Generated Column rewriting. 3. Support simple equivalent expression rewrite for generated column. Note: All query structure support Generated Column rewriting obey a simple rule: the Generated Column and its ref columns output directly into the outer scope. Signed-off-by: srlch <[email protected]>
f145e83
to
3068c59
Compare
Quality Gate passedIssues Measures |
[Java-Extensions Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[FE Incremental Coverage Report]✅ pass : 127 / 132 (96.21%) file detail
|
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
@Mergifyio backport branch-3.3 |
✅ Backports have been created
|
Signed-off-by: srlch <[email protected]> (cherry picked from commit 96b97a7) # Conflicts: # fe/fe-core/src/main/java/com/starrocks/sql/analyzer/QueryAnalyzer.java
…Rocks#50398) Signed-off-by: srlch <[email protected]>
…Rocks#50398) Signed-off-by: srlch <[email protected]>
…Rocks#50398) Signed-off-by: srlch <[email protected]>
…port StarRocks#50398) Signed-off-by: srlch <[email protected]>
…port #50398) (#50830) Signed-off-by: srlch <[email protected]>
…port #50398) (#50831) Signed-off-by: srlch <[email protected]>
…Rocks#50398) Signed-off-by: srlch <[email protected]>
In this pr:
a. Collect generated column expr mapping From QueryAnalyzer.
b. Introduce ReplaceScalarOperatorRule to replace the ScalarOperator match the generated column expression.
Note: All query structure support Generated Column rewriting obey a simple rule: the Generated Column and its ref columns output directly into the outer scope.
Fixes #issue
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check: