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 showColumnStatsCommand in nereids #45439

Open
wants to merge 2 commits 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 @@ -63,6 +63,7 @@ statementBase
| supportedRecoverStatement #supportedRecoverStatementAlias
| supportedAdminStatement #supportedAdminStatementAlias
| supportedUseStatement #supportedUseStatementAlias
| supportedStatsStatement #supportedStatsStatementAlias
| supportedOtherStatement #supportedOtherStatementAlias
| unsupportedStatement #unsupported
;
Expand Down Expand Up @@ -707,6 +708,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 @@ -727,8 +733,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 @@ -271,6 +271,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 @@ -554,6 +555,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 @@ -4696,6 +4698,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 @@ -213,6 +213,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
Loading