Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/.vuepress/sidebar/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ module.exports = [
"ADMIN SHOW CONFIG",
"ADMIN SHOW REPLICA DISTRIBUTION",
"ADMIN SHOW REPLICA STATUS",
"ADMIN-SHOW-DATA-SKEW",
"ALTER CLUSTER",
"ALTER SYSTEM",
"CANCEL DECOMMISSION",
Expand Down
1 change: 1 addition & 0 deletions docs/.vuepress/sidebar/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ module.exports = [
"ADMIN SHOW CONFIG",
"ADMIN SHOW REPLICA DISTRIBUTION",
"ADMIN SHOW REPLICA STATUS",
"ADMIN-SHOW-DATA-SKEW",
"ALTER CLUSTER",
"ALTER SYSTEM",
"CANCEL DECOMMISSION",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
{
"title": "ADMIN SHOW DATA SKEW",
"language": "en"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

# ADMIN SHOW DATA SKEW
## description

This statement is used to view the data skew of a table or a partition.

grammar:

ADMIN SHOW DATA SKEW FROM [db_name.]tbl_name [PARTITION (p1)];

Description:

1. Only one partition must be specified. For non-partitioned tables, the partition name is the same as the table name.
2. The result will show the data volume of each bucket under the specified partition, and the proportion of the data volume of each bucket in the total data volume.

## example

1. View the data skew of the table

ADMIN SHOW DATA SKEW FROM db1.test PARTITION(p1);

## keyword

ADMIN, SHOW, DATA, SKEW

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
{
"title": "ADMIN SHOW DATA SKEW",
"language": "zh-CN"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

# ADMIN SHOW DATA SKEW
## description

该语句用于查看表或某个分区的数据倾斜情况。

语法:

ADMIN SHOW DATA SKEW FROM [db_name.]tbl_name PARTITION (partition_name);

说明:

1. 必须指定且仅指定一个分区。对于非分区表,分区名称同表名。
2. 结果将展示指定分区下,各个分桶的数据量,以及每个分桶数据量在总数据量中的占比。

## example

1. 查看表的数据倾斜情况

ADMIN SHOW DATA SKEW FROM db1.test PARTITION(p1);

## keyword

ADMIN,SHOW,DATA,SKEW

7 changes: 7 additions & 0 deletions fe/fe-core/src/main/cup/sql_parser.cup
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ terminal String KW_ADD, KW_ADMIN, KW_AFTER, KW_AGGREGATE, KW_ALL, KW_ALTER, KW_A
KW_REPAIR, KW_REPEATABLE, KW_REPOSITORY, KW_REPOSITORIES, KW_REPLACE, KW_REPLACE_IF_NOT_NULL, KW_REPLICA, KW_RESOURCE, KW_RESOURCES, KW_RESTORE, KW_RETURNS, KW_RESUME, KW_REVOKE,
KW_RIGHT, KW_ROLE, KW_ROLES, KW_ROLLBACK, KW_ROLLUP, KW_ROUTINE, KW_ROW, KW_ROWS,
KW_S3, KW_SCHEMA, KW_SCHEMAS, KW_SECOND, KW_SELECT, KW_SEMI, KW_SERIALIZABLE, KW_SESSION, KW_SET, KW_SETS, KW_SET_VAR, KW_SHOW, KW_SIGNED,
KW_SKEW,
KW_SMALLINT, KW_SNAPSHOT, KW_SONAME, KW_SPLIT, KW_START, KW_STATUS, KW_STOP, KW_STORAGE, KW_STREAM, KW_STRING, KW_STRUCT,
KW_SUM, KW_SUPERUSER, KW_SYNC, KW_SYSTEM,
KW_TABLE, KW_TABLES, KW_TABLET, KW_TASK, KW_TEMPORARY, KW_TERMINATED, KW_THAN, KW_TIME, KW_THEN, KW_TIMESTAMP, KW_TINYINT,
Expand Down Expand Up @@ -4823,6 +4824,10 @@ admin_stmt ::=
{:
RESULT = new AdminCheckTabletsStmt(tabletIds, properties);
:}
| KW_ADMIN KW_SHOW KW_DATA KW_SKEW KW_FROM base_table_ref:table_ref
{:
RESULT = new AdminShowDataSkewStmt(table_ref);
:}
;

truncate_stmt ::=
Expand Down Expand Up @@ -5132,6 +5137,8 @@ keyword ::=
{: RESULT = id; :}
| KW_SESSION:id
{: RESULT = id; :}
| KW_SKEW:id
{: RESULT = id; :}
| KW_SNAPSHOT:id
{: RESULT = id; :}
| KW_SONAME:id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package org.apache.doris.analysis;

import org.apache.doris.catalog.Catalog;
import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.ScalarType;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.ErrorReport;
import org.apache.doris.common.UserException;
import org.apache.doris.mysql.privilege.PrivPredicate;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.ShowResultSetMetaData;

import com.google.common.collect.ImmutableList;

// admin show data skew from tbl [partition(p1, p2, ...)]
public class AdminShowDataSkewStmt extends ShowStmt {
public static final ImmutableList<String> TITLE_NAMES = new ImmutableList.Builder<String>()
.add("BucketIdx").add("AvgDataSize")
.add("Graph").add("Percent")
.build();

private TableRef tblRef;

public AdminShowDataSkewStmt(TableRef tblRef) {
this.tblRef = tblRef;
}

@Override
public void analyze(Analyzer analyzer) throws UserException {
super.analyze(analyzer);

// check auth
if (!Catalog.getCurrentCatalog().getAuth().checkGlobalPriv(ConnectContext.get(), PrivPredicate.ADMIN)) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "ADMIN");
}

tblRef.getName().analyze(analyzer);

PartitionNames partitionNames = tblRef.getPartitionNames();
if (partitionNames == null || partitionNames.getPartitionNames().size() != 1) {
throw new AnalysisException("Should specify one and only one partition");
}
}

public String getDbName() {
return tblRef.getName().getDb();
}

public String getTblName() {
return tblRef.getName().getTbl();
}

public PartitionNames getPartitionNames() {
return tblRef.getPartitionNames();
}

@Override
public ShowResultSetMetaData getMetaData() {
ShowResultSetMetaData.Builder builder = ShowResultSetMetaData.builder();
for (String title : TITLE_NAMES) {
builder.addColumn(new Column(title, ScalarType.createVarchar(30)));
}
return builder.build();
}

@Override
public RedirectStatus getRedirectStatus() {
return RedirectStatus.FORWARD_NO_SYNC;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
// admin show replica distribution from tbl [partition(p1, p2, ...)]
public class AdminShowReplicaDistributionStmt extends ShowStmt {
public static final ImmutableList<String> TITLE_NAMES = new ImmutableList.Builder<String>()
.add("BackendId").add("ReplicaNum").add("Graph").add("Percent").build();
.add("BackendId").add("ReplicaNum").add("ReplicaSize")
.add("NumGraph").add("NumPercent")
.add("SizeGraph").add("SizePercent")
.build();

private TableRef tblRef;

Expand Down Expand Up @@ -88,10 +91,6 @@ public ShowResultSetMetaData getMetaData() {

@Override
public RedirectStatus getRedirectStatus() {
if (ConnectContext.get().getSessionVariable().getForwardToMaster()) {
return RedirectStatus.FORWARD_NO_SYNC;
} else {
return RedirectStatus.NO_FORWARD;
}
return RedirectStatus.FORWARD_NO_SYNC;
}
}
Loading