-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[Refactor] Replace TableName with TableRef in AST #66662
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
base: main
Are you sure you want to change the base?
Conversation
🧪 CI InsightsHere's what we observed from your CI run for 0b360ee. 🟢 All jobs passed!But CI Insights is watching 👀 |
|
@cursor review |
fe/fe-core/src/main/java/com/starrocks/service/FrontendServiceImpl.java
Outdated
Show resolved
Hide resolved
fe10348 to
0b360ee
Compare
|
@cursor review |
fe/fe-core/src/main/java/com/starrocks/sql/analyzer/AuthorizerStmtVisitor.java
Show resolved
Hide resolved
97527f7 to
aa8f1fe
Compare
|
@cursor review |
fe/fe-core/src/main/java/com/starrocks/server/LocalMetastore.java
Outdated
Show resolved
Hide resolved
fe/fe-core/src/main/java/com/starrocks/sql/analyzer/AuthorizerStmtVisitor.java
Show resolved
Hide resolved
aa8f1fe to
b1a9b37
Compare
|
@cursor review |
fe/fe-core/src/main/java/com/starrocks/connector/iceberg/IcebergMetadata.java
Outdated
Show resolved
Hide resolved
…nStmt and related classes
… related classes # Conflicts: # fe/fe-core/src/test/java/com/starrocks/analysis/ShowCreateTableStmtTest.java
…d related classes
# Conflicts: # fe/fe-core/src/main/java/com/starrocks/sql/DeletePlanner.java # fe/fe-core/src/main/java/com/starrocks/sql/analyzer/DeleteAnalyzer.java
b1a9b37 to
0e9b629
Compare
…utor, IcebergMetadata, LocalMetastore, and related classes
0e9b629 to
34960e0
Compare
|
[Java-Extensions Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
[FE Incremental Coverage Report]✅ pass : 1006 / 1205 (83.49%) file detail
|
[BE Incremental Coverage Report]✅ pass : 0 / 0 (0%) |
|
@cursor review |
| String tableName = stmt.getTableName().toSql(); | ||
| TableRef tableRef = stmt.getTableRef(); | ||
| TableName tableNameObj = TableName.fromTableRef(tableRef); | ||
| String tableName = tableNameObj.toSql(); |
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.
Missing null check causes NPE in partition pruning
The partitionPruneForDelete method calls TableName.fromTableRef(tableRef) without checking if tableRef is null first. Since fromTableRef returns null when given null input, the subsequent call to tableNameObj.toSql() will throw a NullPointerException. While the process method has a null check for tableRef, the public method extractPartitionNamesByCondition directly calls partitionPruneForDelete without this protection, allowing callers to trigger the NPE.


Why I'm doing:
What I'm doing:
This pull request refactors how table names are handled throughout the codebase, moving from direct usage of
TableNameobjects to consistently constructing them fromTableRefinstances. This change standardizes table identification, making the code more robust and easier to maintain, especially when working with parsed SQL statements. Several visitor methods and job classes are updated to use the new utility methodTableName.fromTableRef, and parser logic is adjusted to propagateTableRefinstead ofTableNamewhere appropriate.Core Table Name Handling Refactor:
fromTableRefto theTableNameclass, allowing construction of aTableNamefrom aTableRefobject. This is now the preferred way to obtain aTableNamefrom AST nodes.AlterJobExecutor,ConnectorAlterTableExecutor,ColumnPrivilege) to useTableName.fromTableRefinstead of directly accessing or storingTableNamefrom statements. [1] [2] [3] [4] [5] [6] [7]Parser and Statement Construction Updates:
AstBuilder) to propagateTableRefinstead ofTableNameinInsertStmt,CreateTableStmt, andDropTableStmtconstruction, aligning with the new table name handling approach. [1] [2] [3]Job and Manager Class Adjustments:
DeleteMgr,ExportJob,InsertOverwriteJobRunner,Pipe) to extract database and table names fromTableRefrather thanTableName, ensuring consistency and leveraging the new utility method. [1] [2] [3] [4] [5] [6]Iceberg and Stream Load Integration:
TableRefand constructTableNamevia the new method, improving error reporting and logging. [1] [2]TableNamereferences in stream load and related classes. [1] [2]These changes collectively improve the maintainability and correctness of table name handling across the codebase by ensuring a single, reliable pathway from SQL AST to persistent table identification.
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:
Note
Unifies table identification across the stack by switching from direct
TableNameusage toTableRefin AST, analyzers, planners, and executors, with on-demand conversion viaTableName.fromTableRef.TableName.fromTableRefandAnalyzerUtils.normalizedTableRef; updates DML/DDL analyzers, authorizer, planners, and executors to store/useTableRefand constructTableNameonly when neededAstBuilder) now buildsInsertStmt/CreateTableStmt/DropTableStmtwithTableRefDeleteMgr,ExportJob,InsertOverwriteJobRunner,Pipe, Iceberg metadata/rewrite) to pull db/table fromTableRef; improves error messages/loggingShowExecutorhelpers and multiple SHOW paths to accept/useTableRef; replaces calls inShowExecutor/authorizerTableRef(e.g.,CreateTableAnalyzer,CreateTableLikeAnalyzer,CancelAlterTableStmt,AlterJobExecutor,ConnectorAlterTableExecutor)TableRefand adjusts privilege checks accordinglyNo functional changes intended; primarily API/refactor for consistency and maintainability.
Written by Cursor Bugbot for commit 34960e0. This will update automatically on new commits. Configure here.