Skip to content

Commit

Permalink
implement showTableStatsCommand in nereids
Browse files Browse the repository at this point in the history
  • Loading branch information
yx-keith committed Mar 7, 2025
1 parent ca850fa commit 3116bc1
Show file tree
Hide file tree
Showing 5 changed files with 390 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,9 @@ supportedStatsStatement
(WITH analyzeProperties)* propertyClause? #analyzeDatabase
| ANALYZE TABLE name=multipartIdentifier partitionSpec?
columns=identifierList? (WITH analyzeProperties)* propertyClause? #analyzeTable
| SHOW TABLE STATS tableName=multipartIdentifier
partitionSpec? columnList=identifierList? #showTableStats
| SHOW TABLE STATS tableId=INTEGER_VALUE #showTableStats
;

unsupportedStatsStatement
Expand All @@ -751,9 +754,6 @@ unsupportedStatsStatement
| DROP EXPIRED STATS #dropExpiredStats
| DROP ANALYZE JOB INTEGER_VALUE #dropAanalyzeJob
| KILL ANALYZE jobId=INTEGER_VALUE #killAnalyzeJob
| SHOW TABLE STATS tableName=multipartIdentifier
partitionSpec? columnList=identifierList? #showTableStats
| SHOW TABLE STATS tableId=INTEGER_VALUE #showTableStats
| SHOW INDEX STATS tableName=multipartIdentifier indexId=identifier #showIndexStats
| SHOW COLUMN CACHED? STATS tableName=multipartIdentifier
columnList=identifierList? partitionSpec? #showColumnStats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@
import org.apache.doris.nereids.trees.plans.commands.ShowTableCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowTableCreationCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowTableIdCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowTableStatsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowTabletStorageFormatCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowTabletsBelongCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowTrashCommand;
Expand Down Expand Up @@ -6092,5 +6093,26 @@ public LogicalPlan visitDescribeTableValuedFunction(DorisParser.DescribeTableVal
}
return new DescribeCommand(tableValuedFunctionRef);
}

@Override
public LogicalPlan visitShowTableStats(DorisParser.ShowTableStatsContext ctx) {
if (ctx.tableId != null) {
return new ShowTableStatsCommand(Long.parseLong(ctx.tableId.getText()));
} else {
TableNameInfo tableNameInfo = new TableNameInfo(visitMultipartIdentifier(ctx.tableName));

PartitionNamesInfo partitionNamesInfo = null;
if (ctx.partitionSpec() != null) {
Pair<Boolean, List<String>> partitionSpec = visitPartitionSpec(ctx.partitionSpec());
partitionNamesInfo = new PartitionNamesInfo(partitionSpec.first, partitionSpec.second);
}

List<String> columnNames = new ArrayList<>();
if (ctx.columnList != null) {
columnNames.addAll(visitIdentifierList(ctx.columnList));
}
return new ShowTableStatsCommand(tableNameInfo, columnNames, partitionNamesInfo);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -310,5 +310,6 @@ public enum PlanType {
ALTER_SYSTEM_SET_LOAD_ERRORS_HU,
ALTER_SYSTEM_MODIFY_BACKEND,
ALTER_SYSTEM_MODIFY_FRONTEND_OR_BACKEND_HOSTNAME,
ALTER_SYSTEM_RENAME_COMPUTE_GROUP
ALTER_SYSTEM_RENAME_COMPUTE_GROUP,
SHOW_TABLE_STATS_COMMAND
}
Loading

0 comments on commit 3116bc1

Please sign in to comment.