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

[Enhancement] (nereids) implement showTableStatsCommand in nereids #48827

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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