This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
commit a028e81f49a25a196f0133baffa78b23b6e0d30e Author: starocean999 <40539150+starocean...@users.noreply.github.com> AuthorDate: Tue Dec 6 14:32:35 2022 +0800 [fix](fe)fix select from temporary partition bug (#14809) --- .../java/org/apache/doris/catalog/OlapTable.java | 3 ++ .../data/correctness_p0/test_temp_partition.out | 4 ++ .../correctness_p0/test_temp_partition.groovy | 56 ++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java index 91cd500ddf..71659b6cb3 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java @@ -388,6 +388,9 @@ public class OlapTable extends Table { public List<MaterializedIndex> getVisibleIndex() { Optional<Partition> partition = idToPartition.values().stream().findFirst(); + if (!partition.isPresent()) { + partition = tempPartitions.getAllPartitions().stream().findFirst(); + } return partition.isPresent() ? partition.get().getMaterializedIndices(IndexExtState.VISIBLE) : Collections.emptyList(); } diff --git a/regression-test/data/correctness_p0/test_temp_partition.out b/regression-test/data/correctness_p0/test_temp_partition.out new file mode 100644 index 0000000000..94b0002ac2 --- /dev/null +++ b/regression-test/data/correctness_p0/test_temp_partition.out @@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +0 a 10 asddfa 2022-11-11T00:00 + diff --git a/regression-test/suites/correctness_p0/test_temp_partition.groovy b/regression-test/suites/correctness_p0/test_temp_partition.groovy new file mode 100644 index 0000000000..4c6047b54b --- /dev/null +++ b/regression-test/suites/correctness_p0/test_temp_partition.groovy @@ -0,0 +1,56 @@ +// 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. + +suite("test_temp_partition") { + sql """ + drop table if exists t_temp_partition; + """ + + sql """ + create table t_temp_partition ( + id bigint(20) not null , + name varchar(64) not null , + age varchar(64) not null , + address varchar(300) not null, + create_time datetime not null + ) engine = olap + duplicate key (`id`) + partition by range (`create_time`) () + DISTRIBUTED BY HASH(`id`) BUCKETS 3 + properties ( + "replication_num" = "1", + "in_memory" = "false", + "storage_format" = "V2" + ); + """ + + sql """ + alter table t_temp_partition add temporary partition tp1 values[("2022-11-01 00:00:00"), ("2022-11-17 00:00:00")); + """ + + sql """ + insert into t_temp_partition temporary partition(tp1) values (0, "a", "10", "asddfa","2022-11-11 00:00:00"); + """ + + qt_select """ + select * from t_temp_partition temporary partition(tp1) + """ + + sql """ + drop table if exists t_temp_partition; + """ +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org