You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/12/06 06:32:41 UTC

[doris] branch master updated: [fix](fe)fix select from temporary partition bug (#14809)

This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 3e911a05b1 [fix](fe)fix select from temporary partition bug (#14809)
3e911a05b1 is described below

commit 3e911a05b196c9d791a16896e1fe04ea5199f66b
Author: starocean999 <40...@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 c43aef26eb..94786d7682 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
@@ -391,6 +391,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-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org