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

[fix](coldheat) fix missing partition's storage policy in create_table_like stmt #47145

Open
wants to merge 2 commits into
base: branch-2.0
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 @@ -222,6 +222,10 @@ public String toSql(OlapTable table, List<Long> partitionId) {
}
sb.append(")");

if (!"".equals(getStoragePolicy(entry.getKey()))) {
sb.append("(\"storage_policy\" = \"").append(getStoragePolicy(entry.getKey())).append("\")");
}

if (partitionId != null) {
partitionId.add(entry.getKey());
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ public String toSql(OlapTable table, List<Long> partitionId) {
sb.append("PARTITION ").append(partitionName).append(" VALUES [");
sb.append(range.lowerEndpoint().toSql());
sb.append(", ").append(range.upperEndpoint().toSql()).append(")");
if (!"".equals(getStoragePolicy(entry.getKey()))) {
sb.append("(\"storage_policy\" = \"").append(getStoragePolicy(entry.getKey())).append("\")");
}

if (partitionId != null) {
partitionId.add(entry.getKey());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,64 @@ suite("create_table_use_partition_policy") {
) PARTITION BY RANGE (k1) (
PARTITION p1 VALUES LESS THAN ("2022-01-01 00:00:00.111") ("storage_policy" = "test_create_table_partition_use_policy_1" ,"replication_num"="1"),
PARTITION p2 VALUES LESS THAN ("2022-02-01 00:00:00.111") ("storage_policy" = "test_create_table_partition_use_policy_2" ,"replication_num"="1")
) DISTRIBUTED BY HASH(k2) BUCKETS 1;
) DISTRIBUTED BY HASH(k2) BUCKETS 1
PROPERTIES (
"replication_num" = "1"
);
"""

assertEquals(create_table_partition_use_created_policy_2.size(), 1);

// test create table like
sql """
CREATE TABLE create_table_partition_use_created_policy_3 LIKE create_table_partition_use_created_policy_2;
"""
def policy_using_item_count_1 = try_sql """
SHOW STORAGE POLICY USING for test_create_table_partition_use_policy_1
"""
assertEquals(policy_using_item_count_1.size(), 2);

def policy_using_item_count_2 = try_sql """
SHOW STORAGE POLICY USING for test_create_table_partition_use_policy_2
"""
assertEquals(policy_using_item_count_2.size(), 2);

def create_table_partition_use_created_policy_4 = try_sql """
CREATE TABLE IF NOT EXISTS create_table_partition_use_created_policy_4
(
k1 DATE NOT NULL,
k2 INT,
V1 VARCHAR(2048) REPLACE
) PARTITION BY LIST (k1) (
PARTITION p1 VALUES IN ("2022-01-01") ("storage_policy" = "test_create_table_partition_use_policy_1" ,"replication_num"="1"),
PARTITION p2 VALUES IN ("2022-02-01") ("storage_policy" = "test_create_table_partition_use_policy_2" ,"replication_num"="1")
) DISTRIBUTED BY HASH(k2) BUCKETS 1
PROPERTIES (
"replication_num" = "1"
);
"""
sql """
CREATE TABLE create_table_partition_use_created_policy_5 LIKE create_table_partition_use_created_policy_4;
"""
def policy_using_item_count_3 = try_sql """
SHOW STORAGE POLICY USING for test_create_table_partition_use_policy_1
"""
assertEquals(policy_using_item_count_3.size(), 4);

def policy_using_item_count_4 = try_sql """
SHOW STORAGE POLICY USING for test_create_table_partition_use_policy_2
"""
assertEquals(policy_using_item_count_4.size(), 4);

sql """
DROP TABLE create_table_partition_use_created_policy_5;
"""
sql """
DROP TABLE create_table_partition_use_created_policy_4;
"""
sql """
DROP TABLE create_table_partition_use_created_policy_3;
"""
sql """
DROP TABLE create_table_partition_use_created_policy_2;
"""
Expand Down
Loading