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](iot) Fix unexpected error when iot auto detect get no data #40657

Merged
merged 2 commits into from
Sep 11, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public static void replacePartition(TableIf olapTable, List<String> partitionNam
ReplacePartitionClause replacePartitionClause = new ReplacePartitionClause(
new PartitionNames(false, partitionNames),
new PartitionNames(true, tempPartitionNames), true, properties);
if (replacePartitionClause.getTempPartitionNames().isEmpty()) {
return;
}
Env.getCurrentEnv()
.replaceTempPartition((Database) olapTable.getDatabase(),
(OlapTable) olapTable, replacePartitionClause);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,18 @@ suite("test_iot_auto_detect") {
sql """ insert into dt values ("2005-01-01"), ("2013-02-02"), ("2022-03-03"); """
sql """ insert overwrite table dt partition(*) values ("2008-01-01"), ("2008-02-02"); """
qt_sql " select * from dt order by k0; "
try {
test {
sql """ insert overwrite table dt partition(*) values ("2023-02-02"), ("3000-12-12"); """
} catch (Exception e) {
log.info(e.getMessage())
assertTrue(e.getMessage().contains('Insert has filtered data in strict mode') ||
e.getMessage().contains('Cannot found origin partitions in auto detect overwriting'))
}

check { result, exception, startTime, endTime ->
assertTrue(exception.getMessage().contains('Insert has filtered data in strict mode') ||
exception.getMessage().contains('Cannot found origin partitions in auto detect overwriting'))
}
}
// test no rows(no partition hits) overwrite
sql " drop table if exists dt2"
sql " create table dt2 like dt"
zclllyybb marked this conversation as resolved.
Show resolved Hide resolved
sql " insert overwrite table dt2 partition(*) select * from dt2"
sql " insert overwrite table dt partition(*) select * from dt2"
sql " insert overwrite table dt partition(p10, pMAX) select * from dt2"
sql " insert overwrite table dt select * from dt2"
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ suite("test_auto_partition_behavior") {
result = sql "show partitions from unique_table"
assertEquals(result.size(), 10)
// add partition
try {
test {
sql """ alter table unique_table add partition padd values in ("Xxx") """
fail()
} catch (Exception e) {
assertTrue(e.getMessage().contains("is conflict with current partitionKeys"))
exception "is conflict with current partitionKeys"
}
// drop partition
def partitions = sql "show partitions from unique_table order by PartitionName"
Expand Down Expand Up @@ -94,11 +92,9 @@ suite("test_auto_partition_behavior") {
result = sql "show partitions from dup_table"
assertEquals(result.size(), 10)
// add partition
try {
test {
sql """ alter table dup_table add partition padd values in ("Xxx") """
fail()
} catch (Exception e) {
assertTrue(e.getMessage().contains("is conflict with current partitionKeys"))
exception "is conflict with current partitionKeys"
}
// drop partition
partitions = sql "show partitions from dup_table order by PartitionName"
Expand Down Expand Up @@ -168,11 +164,9 @@ suite("test_auto_partition_behavior") {
);
"""
sql """ insert into rewrite values ("Xxx"); """
try {
test {
sql """ insert overwrite table rewrite partition(p1) values ("") """
fail()
} catch (Exception e) {
assertTrue(e.getMessage().contains("Insert has filtered data in strict mode"))
exception "Insert has filtered data in strict mode"
}
sql """ insert overwrite table rewrite partition(p1) values ("Xxx") """
qt_sql_overwrite """ select * from rewrite """ // Xxx
Expand Down Expand Up @@ -297,6 +291,9 @@ suite("test_auto_partition_behavior") {
part_result = sql " show tablets from test_change "
assertEquals(part_result.size, 52 * replicaNum)



// test not auto partition have expr.
test {
sql """
CREATE TABLE not_auto_expr (
Expand All @@ -310,4 +307,11 @@ suite("test_auto_partition_behavior") {
"""
exception "Non-auto partition table not support partition expr!"
}


// test insert empty
sql "create table if not exists empty_range like test_change"
sql "insert into test_change select * from empty_range"
sql "create table if not exists empty_list like long_value"
sql "insert into long_value select * from empty_list"
}
Loading