Skip to content

Commit

Permalink
[Enhancement] (nereids)implement showColumnStatsCommand in nereids
Browse files Browse the repository at this point in the history
  • Loading branch information
msridhar78 committed Dec 20, 2024
1 parent 62a6360 commit c3e07ca
Show file tree
Hide file tree
Showing 6 changed files with 498 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ statementBase
| supportedRecoverStatement #supportedRecoverStatementAlias
| supportedAdminStatement #supportedAdminStatementAlias
| supportedUseStatement #supportedUseStatementAlias
| supportedStatsStatement #supportedStatsStatementAlias
| unsupportedStatement #unsupported
;

Expand Down Expand Up @@ -703,6 +704,11 @@ unsupportedDropStatement
| DROP STAGE (IF EXISTS)? name=identifier #dropStage
;

supportedStatsStatement
: SHOW COLUMN CACHED? STATS tableName=multipartIdentifier
columnList=identifierList? partitionSpec? #showColumnStats
;

unsupportedStatsStatement
: ANALYZE TABLE name=multipartIdentifier partitionSpec?
columns=identifierList? (WITH analyzeProperties)* propertyClause? #analyzeTable
Expand All @@ -723,8 +729,6 @@ unsupportedStatsStatement
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
| SHOW COLUMN HISTOGRAM tableName=multipartIdentifier
columnList=identifierList #showColumnHistogramStats
| SHOW AUTO? ANALYZE tableName=multipartIdentifier? wildWhere? #showAnalyze
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@
import org.apache.doris.nereids.DorisParser.ShowBrokerContext;
import org.apache.doris.nereids.DorisParser.ShowCharsetContext;
import org.apache.doris.nereids.DorisParser.ShowCollationContext;
import org.apache.doris.nereids.DorisParser.ShowColumnStatsContext;
import org.apache.doris.nereids.DorisParser.ShowConfigContext;
import org.apache.doris.nereids.DorisParser.ShowConstraintContext;
import org.apache.doris.nereids.DorisParser.ShowCreateCatalogContext;
Expand Down Expand Up @@ -566,6 +567,7 @@
import org.apache.doris.nereids.trees.plans.commands.ShowBrokerCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowCharsetCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowCollationCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowColumnStatsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowConfigCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowConstraintsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowCreateCatalogCommand;
Expand Down Expand Up @@ -4571,6 +4573,22 @@ private Expression getWildWhere(DorisParser.WildWhereContext ctx) {
}
}

@Override
public LogicalPlan visitShowColumnStats(ShowColumnStatsContext ctx) {
List<String> tableNameParts = visitMultipartIdentifier(ctx.tableName);
List<String> colNames = ctx.columnList == null ? ImmutableList.of() : visitIdentifierList(ctx.columnList);
Pair<Boolean, List<String>> partitionSpec = visitPartitionSpec(ctx.partitionSpec());
PartitionNamesInfo partitionNames;
if (partitionSpec.second == null) {
partitionNames = new PartitionNamesInfo(true); //isStar = true
} else {
partitionNames = new PartitionNamesInfo(partitionSpec.first, partitionSpec.second);
}
boolean isCached = ctx.CACHED() != null;

return new ShowColumnStatsCommand(new TableNameInfo(tableNameParts), colNames, partitionNames, isCached);
}

@Override
public ShowViewCommand visitShowView(ShowViewContext ctx) {
List<String> tableNameParts = visitMultipartIdentifier(ctx.tableName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public enum PlanType {
SHOW_BROKER_COMMAND,
SHOW_CHARSET_COMMAND,
SHOW_COLLATION_COMMAND,
SHOW_COLUMN_STATS_COMMAND,
SHOW_CONFIG_COMMAND,
SHOW_CREATE_CATALOG_COMMAND,
SHOW_CREATE_DATABASE_COMMAND,
Expand Down
Loading

0 comments on commit c3e07ca

Please sign in to comment.