Skip to content

[improve](table_properties) make replication_allocation property same as show create table #51561

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

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 @@ -24,6 +24,7 @@
import org.apache.doris.catalog.DatabaseIf;
import org.apache.doris.catalog.DistributionInfo;
import org.apache.doris.catalog.DistributionInfo.DistributionInfoType;
import org.apache.doris.catalog.DynamicPartitionProperty;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.HashDistributionInfo;
import org.apache.doris.catalog.MTMV;
Expand All @@ -47,6 +48,7 @@
import org.apache.doris.common.proc.PartitionsProcDir;
import org.apache.doris.common.util.DebugUtil;
import org.apache.doris.common.util.NetUtils;
import org.apache.doris.common.util.PropertyAnalyzer;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.common.util.Util;
import org.apache.doris.datasource.CatalogIf;
Expand Down Expand Up @@ -1306,6 +1308,17 @@ private static void tablePropertiesForInternalCatalog(UserIdentity currentUserId
}

Map<String, String> propertiesMap = property.getProperties();
// make [dynamic_partition.]replication_allocation properties same as SHOW CREATE TABLE stmt
if (!property.getReplicaAllocation().isNotSet()) {
propertiesMap.put(PropertyAnalyzer.PROPERTIES_REPLICATION_ALLOCATION,
property.getReplicaAllocation().toCreateStmt());
}
DynamicPartitionProperty dynamicProperty = property.getDynamicPartitionProperty();
if (dynamicProperty != null && dynamicProperty.isExist() && !dynamicProperty.getReplicaAllocation()
.isNotSet()) {
propertiesMap.put(DynamicPartitionProperty.REPLICATION_ALLOCATION,
dynamicProperty.getReplicaAllocation().toCreateStmt());
}
propertiesMap.forEach((key, value) -> {
TRow trow = new TRow();
trow.addToColumnValue(new TCell().setStringVal(catalog.getName())); // TABLE_CATALOG
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select_check_1 --
102
105

-- !select_check_2 --
internal test_table_properties_db duplicate_table _auto_bucket false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ suite("test_table_properties") {
"""

qt_select_check_1 """select count(*) from information_schema.table_properties where table_schema=\"${dbName}\"; """
qt_select_check_2 """select * from information_schema.table_properties where table_schema=\"${dbName}\" and PROPERTY_NAME != "default.replication_allocation" ORDER BY TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PROPERTY_NAME,PROPERTY_VALUE"""
qt_select_check_2 """select * from information_schema.table_properties where table_schema=\"${dbName}\" and PROPERTY_NAME != "default.replication_allocation" and PROPERTY_NAME != "replication_allocation" ORDER BY TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PROPERTY_NAME,PROPERTY_VALUE"""
sql """
drop table listtable;
"""
qt_select_check_3 """select * from information_schema.table_properties where table_schema=\"${dbName}\" and PROPERTY_NAME != "default.replication_allocation" ORDER BY TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PROPERTY_NAME,PROPERTY_VALUE"""
qt_select_check_3 """select * from information_schema.table_properties where table_schema=\"${dbName}\" and PROPERTY_NAME != "default.replication_allocation" and PROPERTY_NAME != "replication_allocation" ORDER BY TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PROPERTY_NAME,PROPERTY_VALUE"""

def user = "table_properties_user"
sql "DROP USER IF EXISTS ${user}"
Expand All @@ -106,17 +106,17 @@ suite("test_table_properties") {
def url=tokens[0] + "//" + tokens[2] + "/" + "information_schema" + "?"

connect(user, '123abc!@#', url) {
qt_select_check_4 """select * from information_schema.table_properties where PROPERTY_NAME != "default.replication_allocation" ORDER BY TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PROPERTY_NAME,PROPERTY_VALUE"""
qt_select_check_4 """select * from information_schema.table_properties where PROPERTY_NAME != "default.replication_allocation" and PROPERTY_NAME != "replication_allocation" ORDER BY TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PROPERTY_NAME,PROPERTY_VALUE"""
}

sql "GRANT SELECT_PRIV ON ${dbName}.duplicate_table TO ${user}"
connect(user, '123abc!@#', url) {
qt_select_check_5 """select * from information_schema.table_properties where PROPERTY_NAME != "default.replication_allocation" ORDER BY TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PROPERTY_NAME,PROPERTY_VALUE"""
qt_select_check_5 """select * from information_schema.table_properties where PROPERTY_NAME != "default.replication_allocation" and PROPERTY_NAME != "replication_allocation" ORDER BY TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PROPERTY_NAME,PROPERTY_VALUE"""
}

sql "REVOKE SELECT_PRIV ON ${dbName}.duplicate_table FROM ${user}"
connect(user, '123abc!@#', url) {
qt_select_check_6 """select * from information_schema.table_properties where PROPERTY_NAME != "default.replication_allocation" ORDER BY TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PROPERTY_NAME,PROPERTY_VALUE"""
qt_select_check_6 """select * from information_schema.table_properties where PROPERTY_NAME != "default.replication_allocation" and PROPERTY_NAME != "replication_allocation" ORDER BY TABLE_CATALOG,TABLE_SCHEMA,TABLE_NAME,PROPERTY_NAME,PROPERTY_VALUE"""
}


Expand Down