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 df3a6e2412 [fix](fe)only set column info for slots in sortTupleDesc
(#16407)
df3a6e2412 is described below
commit df3a6e2412f28cf838b3069b7a72e9aee5ad946a
Author: starocean999 <[email protected]>
AuthorDate: Sat Feb 4 23:14:25 2023 +0800
[fix](fe)only set column info for slots in sortTupleDesc (#16407)
---
.../org/apache/doris/analysis/SlotDescriptor.java | 4 +++
.../java/org/apache/doris/analysis/SortInfo.java | 4 ++-
.../correctness_p0/test_topn_with_cast_to_date.out | 4 +++
.../test_topn_with_cast_to_date.groovy | 40 ++++++++++++++++++++++
4 files changed, 51 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotDescriptor.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotDescriptor.java
index 79026840b3..0713ff0009 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotDescriptor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SlotDescriptor.java
@@ -165,6 +165,10 @@ public class SlotDescriptor {
this.originType = column.getOriginType();
}
+ public void setSrcColumn(Column column) {
+ this.column = column;
+ }
+
public boolean isMaterialized() {
return isMaterialized;
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SortInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/SortInfo.java
index 7cdd2d0d0d..00b871c3b4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SortInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SortInfo.java
@@ -298,7 +298,9 @@ public class SortInfo {
SlotRef origSlotRef = origOrderingExpr.getSrcSlotRef();
LOG.debug("origOrderingExpr {}", origOrderingExpr);
if (origSlotRef != null) {
- materializedDesc.setColumn(origSlotRef.getColumn());
+ // need do this for two phase read of topn query optimization
+ // check https://github.com/apache/doris/pull/15642 for detail
+ materializedDesc.setSrcColumn(origSlotRef.getColumn());
}
SlotRef materializedRef = new SlotRef(materializedDesc);
substOrderBy.put(origOrderingExpr, materializedRef);
diff --git
a/regression-test/data/correctness_p0/test_topn_with_cast_to_date.out
b/regression-test/data/correctness_p0/test_topn_with_cast_to_date.out
new file mode 100644
index 0000000000..44a5340435
--- /dev/null
+++ b/regression-test/data/correctness_p0/test_topn_with_cast_to_date.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !sql --
+2016-11-04
+
diff --git
a/regression-test/suites/correctness_p0/test_topn_with_cast_to_date.groovy
b/regression-test/suites/correctness_p0/test_topn_with_cast_to_date.groovy
new file mode 100644
index 0000000000..f2ce807f12
--- /dev/null
+++ b/regression-test/suites/correctness_p0/test_topn_with_cast_to_date.groovy
@@ -0,0 +1,40 @@
+// 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_topn_with_cast_to_date") {
+
+ sql """
+ DROP TABLE IF EXISTS t_test_topn_with_cast_to_date
+ """
+
+ sql """
+ create table t_test_topn_with_cast_to_date(k1 datetimev2, k2 int)
distributed by hash(k1) buckets 1 properties("replication_num" = "1");
+ """
+
+ sql """
+ insert into t_test_topn_with_cast_to_date values("2016-11-04
00:00:01", 1);
+ """
+
+ qt_sql """
+ SELECT dt
+ FROM
+ (SELECT cast(k1 AS datev2) AS dt
+ FROM t_test_topn_with_cast_to_date ) r
+ GROUP BY dt
+ ORDER BY dt;
+ """
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]