(doris) branch master updated: [enhancement](nereids)optimized aggregate node's error msg (#38122)

2024-07-22 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 33c878f313c [enhancement](nereids)optimized aggregate node's error msg 
(#38122)
33c878f313c is described below

commit 33c878f313cec6633dc3dbd1e86753584f0a42ba
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Tue Jul 23 11:37:19 2024 +0800

[enhancement](nereids)optimized aggregate node's error msg (#38122)

## Proposed changes

```
create table t1
(
c1 bigint,
c2 bigint
)
DISTRIBUTED BY HASH(c1) BUCKETS 3
PROPERTIES ("replication_num" = "1");
```

sql
`select * from t1 group by 1;`

the error msg before:
ERROR 1105 (HY000): errCode = 2, detailMessage = Invalid call to toSlot
on unbound object
after:
ERROR 1105 (HY000): errCode = 2, detailMessage = c2 not in aggregate's
output



Issue Number: close #xxx


---
 .../doris/nereids/rules/analysis/BindExpression.java | 16 +---
 .../suites/nereids_p0/aggregate/agg_error_msg.groovy | 15 +++
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
index 8a74d71917c..15f8dabc8f7 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
@@ -110,6 +110,7 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.jetbrains.annotations.NotNull;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
@@ -622,10 +623,19 @@ public class BindExpression implements 
AnalysisRuleFactory {
 SimpleExprAnalyzer aggOutputAnalyzer = buildSimpleExprAnalyzer(
 agg, cascadesContext, agg.children(), true, true);
 List boundAggOutput = 
aggOutputAnalyzer.analyzeToList(agg.getOutputExpressions());
-Supplier aggOutputScopeWithoutAggFun = 
buildAggOutputScopeWithoutAggFun(boundAggOutput, cascadesContext);
+List boundProjections = new 
ArrayList<>(boundAggOutput.size());
+for (NamedExpression output : boundAggOutput) {
+if (output instanceof BoundStar) {
+boundProjections.addAll(((BoundStar) output).getSlots());
+} else {
+boundProjections.add(output);
+}
+}
+Supplier aggOutputScopeWithoutAggFun =
+buildAggOutputScopeWithoutAggFun(boundProjections, 
cascadesContext);
 List boundGroupBy = bindGroupBy(
- agg, agg.getGroupByExpressions(), boundAggOutput, 
aggOutputScopeWithoutAggFun, cascadesContext);
-return agg.withGroupByAndOutput(boundGroupBy, boundAggOutput);
+agg, agg.getGroupByExpressions(), boundProjections, 
aggOutputScopeWithoutAggFun, cascadesContext);
+return agg.withGroupByAndOutput(boundGroupBy, boundProjections);
 }
 
 private Plan bindRepeat(MatchingContext> ctx) {
diff --git a/regression-test/suites/nereids_p0/aggregate/agg_error_msg.groovy 
b/regression-test/suites/nereids_p0/aggregate/agg_error_msg.groovy
index 0b807be9d3a..a644a26ade7 100644
--- a/regression-test/suites/nereids_p0/aggregate/agg_error_msg.groovy
+++ b/regression-test/suites/nereids_p0/aggregate/agg_error_msg.groovy
@@ -47,4 +47,19 @@ suite("agg_error_msg") {
 sql """SELECT col_int_undef_signed2   col_alias1, col_int_undef_signed 
 *  (SELECT  MAX (col_int_undef_signed) FROM 
table_20_undef_partitions2_keys3_properties4_distributed_by58 where 
table_20_undef_partitions2_keys3_properties4_distributed_by53.pk = pk)  AS 
col_alias2 FROM table_20_undef_partitions2_keys3_properties4_distributed_by53  
GROUP BY  GROUPING SETS ((col_int_undef_signed2),())  ;"""
 exception "pk, col_int_undef_signed not in aggregate's output";
 }
+
+test {
+sql """SELECT * from 
table_20_undef_partitions2_keys3_properties4_distributed_by58 group by 1;"""
+exception "col_int_undef_signed, col_int_undef_signed2 not in 
aggregate's output";
+}
+
+test {
+sql """SELECT *, pk from 
table_20_undef_partitions2_keys3_properties4_distributed_by58 group by 1;"""
+exception "col_int_undef_signed, col_int_undef_signed2 not in 
aggregate's output";
+}
+
+test {
+sql """SELEC

(doris) branch master updated: [fix](nereids)the keys of agg table with random distribute are not unique (#37881)

2024-07-18 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 664164fdff5 [fix](nereids)the keys of agg table with random distribute 
are not unique (#37881)
664164fdff5 is described below

commit 664164fdff5681b31f2b0831c0795988f2d869dd
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Thu Jul 18 15:37:29 2024 +0800

[fix](nereids)the keys of agg table with random distribute are not unique 
(#37881)
---
 .../org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
index 785ebe90363..ef3d4c43d82 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalOlapScan.java
@@ -507,7 +507,7 @@ public class LogicalOlapScan extends LogicalCatalogRelation 
implements OlapScan
 Plan originalPlan = cache.getOriginalPlan();
 
builder.addUniqueSlot(originalPlan.getLogicalProperties().getTrait());
 builder.replaceUniqueBy(constructReplaceMap(mtmv));
-} else if (getTable().getKeysType().isAggregationFamily()) {
+} else if (getTable().getKeysType().isAggregationFamily() && 
!getTable().isRandomDistribution()) {
 ImmutableSet.Builder uniqSlots = 
ImmutableSet.builderWithExpectedSize(outputSet.size());
 for (Slot slot : outputSet) {
 if (!(slot instanceof SlotReference)) {


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (7f5b2759968 -> 5670e1ae764)

2024-07-17 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 7f5b2759968 [opt](Nereids) support no-key hint parameter (#37720)
 add 5670e1ae764 [fix](nereids)subquery unnesting get wrong result if 
correlated conjuncts is not slot_a = slot_b (#37644)

No new revisions were added by this update.

Summary of changes:
 .../doris/nereids/jobs/executor/Rewriter.java  |  6 +-
 .../nereids/rules/analysis/SubExprAnalyzer.java| 10 
 .../rewrite/UnCorrelatedApplyAggregateFilter.java  | 18 +-
 .../trees/plans/logical/LogicalProject.java|  4 ++
 .../java/org/apache/doris/nereids/util/Utils.java  | 56 +
 .../nereids_syntax_p0/test_subquery_conjunct.out   | 54 +
 .../sub_query_diff_old_optimize.groovy |  2 +-
 .../test_subquery_conjunct.groovy  | 70 ++
 8 files changed, 205 insertions(+), 15 deletions(-)
 create mode 100644 
regression-test/data/nereids_syntax_p0/test_subquery_conjunct.out
 create mode 100644 
regression-test/suites/nereids_syntax_p0/test_subquery_conjunct.groovy


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (256e16ed180 -> a23cf3a6417)

2024-07-15 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 256e16ed180 [Fix](nereids) add backquote and qualifier to udf, column, 
column alias and table alias when create view (#37237)
 add a23cf3a6417 [Fix](regression) fix create table like regression (#37846)

No new revisions were added by this update.

Summary of changes:
 .../ddl_p0/test_create_table_like_nereids.groovy   | 25 +-
 1 file changed, 20 insertions(+), 5 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](test)fix regression test case failure (#37797)

2024-07-15 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 88e3bad1249 [fix](test)fix regression test case failure (#37797)
88e3bad1249 is described below

commit 88e3bad12492110c9a49497c25f8b4a3d115fbfb
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Tue Jul 16 11:03:33 2024 +0800

[fix](test)fix regression test case failure (#37797)
---
 regression-test/suites/nereids_p0/aggregate/agg_nullable.groovy   | 6 +++---
 regression-test/suites/nereids_p0/aggregate/agg_nullable_2.groovy | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/regression-test/suites/nereids_p0/aggregate/agg_nullable.groovy 
b/regression-test/suites/nereids_p0/aggregate/agg_nullable.groovy
index 2b0b51cd64f..417cd7aa99d 100644
--- a/regression-test/suites/nereids_p0/aggregate/agg_nullable.groovy
+++ b/regression-test/suites/nereids_p0/aggregate/agg_nullable.groovy
@@ -863,19 +863,19 @@ suite("agg_nullable") {
 qt_select_topn_weighted """select topn_weighted(kvchrs1, ktint, 3) from 
agg_nullable_test;"""
 explain {
 sql("verbose select topn_weighted(kvchrs1, ktint, 3) from 
agg_nullable_test;")
-contains "colUniqueId=null, type=ARRAY, nullable=true"
+contains ">, nullable=true"
 }
 
 qt_select_topn_weighted2 """select topn_weighted(kvchrs1, ktint, 3) from 
agg_nullable_test group by id;"""
 explain {
 sql("verbose select topn_weighted(kvchrs1, ktint, 3) from 
agg_nullable_test group by id;")
-contains "colUniqueId=null, type=ARRAY, nullable=false"
+contains ">, nullable=false"
 }
 
 qt_select_topn_weighted_n """select topn_weighted(knvchrs1, kntint, 3) 
from agg_nullable_test;"""
 explain {
 sql("verbose select topn_weighted(knvchrs1, kntint, 3) from 
agg_nullable_test;")
-contains "colUniqueId=null, type=ARRAY, nullable=true"
+contains ">, nullable=true"
 }
 
 qt_select_variance """select variance(kint) from agg_nullable_test;"""
diff --git a/regression-test/suites/nereids_p0/aggregate/agg_nullable_2.groovy 
b/regression-test/suites/nereids_p0/aggregate/agg_nullable_2.groovy
index 7bf859b5552..ba2ea9ea5f6 100644
--- a/regression-test/suites/nereids_p0/aggregate/agg_nullable_2.groovy
+++ b/regression-test/suites/nereids_p0/aggregate/agg_nullable_2.groovy
@@ -875,19 +875,19 @@ suite("agg_nullable_2") {
 qt_select_topn_weighted """select topn_weighted(kvchrs1, ktint, 3) from 
agg_nullable_test_2;"""
 explain {
 sql("verbose select topn_weighted(kvchrs1, ktint, 3) from 
agg_nullable_test_2;")
-contains "colUniqueId=null, type=ARRAY, nullable=true"
+contains ">, nullable=true"
 }
 
 qt_select_topn_weighted2 """select topn_weighted(kvchrs1, ktint, 3) from 
agg_nullable_test_2 group by id;"""
 explain {
 sql("verbose select topn_weighted(kvchrs1, ktint, 3) from 
agg_nullable_test_2 group by id;")
-contains "colUniqueId=null, type=ARRAY, nullable=false"
+contains ">, nullable=false"
 }
 
 qt_select_topn_weighted_n """select topn_weighted(knvchrs1, kntint, 3) 
from agg_nullable_test_2;"""
 explain {
 sql("verbose select topn_weighted(knvchrs1, kntint, 3) from 
agg_nullable_test_2;")
-contains "colUniqueId=null, type=ARRAY, nullable=true"
+contains ">, nullable=true"
 }
 
 qt_select_variance """select variance(kint) from agg_nullable_test_2;"""


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](mtmv) Fix rewrite wrongly when sync and async materialized view name is same (#37311)

2024-07-07 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 5c038905110 [fix](mtmv) Fix rewrite wrongly when sync and async 
materialized view name is same (#37311)
5c038905110 is described below

commit 5c0389051108ff49d3141d41b831dc546e602945
Author: seawinde <149132972+seawi...@users.noreply.github.com>
AuthorDate: Mon Jul 8 10:51:08 2024 +0800

[fix](mtmv) Fix rewrite wrongly when sync and async materialized view name 
is same (#37311)

## Proposed changes

This is brought by https://github.com/apache/doris/pull/33699

`AbstractMaterializedViewRule#isMaterializationValid` check would fail
when sync and async materialized view name is same, because the
Materialization valid check result is cached by name。this will cause the
async materialized view check fail wrongly. This fix this by make sync
materialized view name unique in every place.
---
 .../mv/AsyncMaterializationContext.java|   7 +-
 .../exploration/mv/SyncMaterializationContext.java |   3 +-
 .../mv/same_name/sync_async_same_name.out  |  17 ++
 .../mv/same_name/sync_async_same_name.groovy   | 178 +
 4 files changed, 203 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AsyncMaterializationContext.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AsyncMaterializationContext.java
index eef0a36d301..f9c0261e0c9 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AsyncMaterializationContext.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AsyncMaterializationContext.java
@@ -120,7 +120,12 @@ public class AsyncMaterializationContext extends 
MaterializationContext {
 if (!(relation instanceof PhysicalCatalogRelation)) {
 return false;
 }
-return ((PhysicalCatalogRelation) relation).getTable() instanceof MTMV;
+if (!(((PhysicalCatalogRelation) relation).getTable() instanceof 
MTMV)) {
+return false;
+}
+return ((PhysicalCatalogRelation) 
relation).getTable().getFullQualifiers().equals(
+this.getMaterializationQualifier()
+);
 }
 
 public Plan getScanPlan() {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/SyncMaterializationContext.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/SyncMaterializationContext.java
index 1159952f7a2..781b7171407 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/SyncMaterializationContext.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/SyncMaterializationContext.java
@@ -72,7 +72,8 @@ public class SyncMaterializationContext extends 
MaterializationContext {
 @Override
 List getMaterializationQualifier() {
 return ImmutableList.of(olapTable.getDatabase().getCatalog().getName(),
-
ClusterNamespace.getNameFromFullName(olapTable.getDatabase().getFullName()), 
indexName);
+
ClusterNamespace.getNameFromFullName(olapTable.getDatabase().getFullName()),
+olapTable.getName(), indexName);
 }
 
 @Override
diff --git 
a/regression-test/data/nereids_rules_p0/mv/same_name/sync_async_same_name.out 
b/regression-test/data/nereids_rules_p0/mv/same_name/sync_async_same_name.out
new file mode 100644
index 000..dde90507fdf
--- /dev/null
+++ 
b/regression-test/data/nereids_rules_p0/mv/same_name/sync_async_same_name.out
@@ -0,0 +1,17 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !query_mv_before --
+1  yy  77.50   33.50   9.505
+2  mi  57.40   56.20   1.202
+2  mm  43.20   43.20   43.20   1
+
+-- !query_mtmv_before --
+1  yy  0   0   11.50   11.50   11.50   1
+
+-- !query_mv_after --
+1  yy  77.50   33.50   9.505
+2  mi  57.40   56.20   1.202
+2  mm  43.20   43.20   43.20   1
+
+-- !query_mtmv_after --
+1  yy  0   0   11.50   11.50   11.50   1
+
diff --git 
a/regression-test/suites/nereids_rules_p0/mv/same_name/sync_async_same_name.groovy
 
b/regression-test/suites/nereids_rules_p0/mv/same_name/sync_async_same_name.groovy
new file mode 100644
index 000..e8350d487a8
--- /dev/null
+++ 
b/regression-test/suites/nereids_rules_p0/mv/same_name/sync_async_same_name.groovy
@@ -0,0 +1,178 @@
+package mv.same_name
+// 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.  T

(doris) branch master updated (7118d7c512e -> 841e39a22db)

2024-07-03 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 7118d7c512e [enhancement](regression-test) dup modify case (#37111)
 add 841e39a22db [fix](nereids)mv selection should rule out shadow index 
from schema change (#37154)

No new revisions were added by this update.

Summary of changes:
 fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java | 9 +
 .../rules/exploration/mv/InitMaterializationContextHook.java | 5 -
 2 files changed, 13 insertions(+), 1 deletion(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (6f432784833 -> 707cb40d008)

2024-07-01 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 6f432784833 [fix](map)fix upgrade behavior from 1.2 version (#36937)
 add 707cb40d008 [feature](nereids)use mtmv to match legacy mv (#33699)

No new revisions were added by this update.

Summary of changes:
 .../main/java/org/apache/doris/analysis/Expr.java  |2 +-
 .../apache/doris/catalog/AggregateFunction.java|3 +-
 .../java/org/apache/doris/catalog/FunctionSet.java |4 +
 .../doris/nereids/analyzer/UnboundFunction.java|   48 +-
 .../parser/LogicalPlanBuilderForSyncMv.java|  194 +++
 .../apache/doris/nereids/parser/NereidsParser.java |7 +
 .../org/apache/doris/nereids/rules/RuleSet.java|2 +
 .../org/apache/doris/nereids/rules/RuleType.java   |1 +
 .../mv/AbstractMaterializedViewAggregateRule.java  |3 +-
 .../mv/AbstractMaterializedViewRule.java   |   22 +
 .../mv/InitMaterializationContextHook.java |  160 +++
 .../mv/MaterializedViewOnlyScanRule.java   |   34 +-
 .../exploration/mv/MaterializedViewUtils.java  |   67 +
 .../exploration/mv/SyncMaterializationContext.java |  117 ++
 .../exploration/mv/rollup/DirectRollupHandler.java |8 +-
 .../mv/SelectMaterializedIndexWithAggregate.java   |   30 +
 .../SelectMaterializedIndexWithoutAggregate.java   |   15 +
 .../functions/agg/MultiDistinctCount.java  |   10 +-
 .../functions/agg/NullableAggregateFunction.java   |   14 +
 .../trees/plans/commands/info/AlterViewInfo.java   |5 +-
 .../trees/plans/commands/info/BaseViewInfo.java|   40 -
 .../trees/plans/commands/info/CreateViewInfo.java  |5 +-
 .../apache/doris/nereids/types/AggStateType.java   |   23 +-
 .../org/apache/doris/nereids/util/PlanUtils.java   |   40 +
 .../java/org/apache/doris/qe/SessionVariable.java  |   16 +
 .../rules/rewrite/mv/SelectMvIndexTest.java|1 +
 .../rules/rewrite/mv/SelectRollupIndexTest.java|1 +
 .../planner/MaterializedViewFunctionTest.java  |1 +
 .../mv_p0/agg_have_dup_base/agg_have_dup_base.out  |7 +-
 regression-test/data/mv_p0/k1s2m3/k1s2m3.out   |   12 +-
 .../multi_slot_k1p2ap3ps/multi_slot_k1p2ap3ps.out  |3 +-
 .../multi_slot_multi_mv/multi_slot_multi_mv.out|4 +-
 .../mv_ignore_predicate/mv_ignore_predicate.out|5 +-
 .../mv_p0/test_upper_alias/test_upper_alias.out|1 +
 .../single_table_without_aggregate.out |  116 ++
 .../data/nereids_syntax_p0/mv/agg_mv_test.dat  |   26 +
 .../nereids_syntax_p0/mv/aggregate/agg_sync_mv.out | 1501 
 .../nereids_syntax_p0/mv/newMv/aggHaveDupBase.out  |7 +-
 .../nereids_syntax_p0/mv/newMv/multi_slot4.out |1 +
 .../data/nereids_syntax_p0/mv/ut/aggOnAggMV3.out   |3 +-
 .../data/nereids_syntax_p0/rollup/agg.out  |2 +-
 regression-test/data/rollup_p0/test_rollup_agg.out |2 +-
 .../agg_have_dup_base/agg_have_dup_base.groovy |   22 +
 .../mv_p0/agg_state/test_agg_state_max_by.groovy   |   26 +
 .../suites/mv_p0/case_ignore/case_ignore.groovy|   13 +
 .../suites/mv_p0/count_star/count_star.groovy  |   27 +-
 .../suites/mv_p0/k1ap2spa/k1ap2spa.groovy  |   10 +
 regression-test/suites/mv_p0/k1s2m3/k1s2m3.groovy  |   37 +
 .../mv_p0/k1s2m3_auto_inc/k1s2m3_auto_inc.groovy   |9 +
 .../multi_agg_with_same_slot.groovy|   25 +
 .../mv_p0/multi_slot_k123p/multi_slot_k123p.groovy |   13 +-
 .../multi_slot_k1a2p2ap3p.groovy   |9 +
 .../multi_slot_k1a2p2ap3ps.groovy  |   14 +
 .../multi_slot_k1p2ap3p/multi_slot_k1p2ap3p.groovy |9 +
 .../multi_slot_k1p2ap3ps.groovy|   10 +
 .../multi_slot_multi_mv/multi_slot_multi_mv.groovy |   39 +
 .../mv_ignore_predicate/mv_ignore_predicate.groovy |   37 +-
 .../mv_p0/mv_percentile/mv_percentile.groovy   |   50 +-
 .../suites/mv_p0/mv_with_view/mv_with_view.groovy  |   45 +-
 .../suites/mv_p0/null_insert/null_insert.groovy|   11 +
 .../mv_p0/routine_load_hll/routine_load_hll.groovy |9 +
 .../ssb/multiple_no_where/multiple_no_where.groovy |   62 +
 .../mv_p0/ssb/multiple_ssb/multiple_ssb.groovy |   66 +
 .../multiple_ssb_between.groovy|   56 +
 .../suites/mv_p0/ssb/q_1_1/q_1_1.groovy|   16 +
 .../suites/mv_p0/ssb/q_2_1/q_2_1.groovy|   15 +
 .../suites/mv_p0/ssb/q_3_1/q_3_1.groovy|   19 +
 .../suites/mv_p0/ssb/q_4_1/q_4_1.groovy|   18 +-
 .../suites/mv_p0/ssb/q_4_1_r1/q_4_1_r1.groovy  |   17 +
 .../suites/mv_p0/sum_count/sum_count.groovy|   34 +-
 .../mv_p0/sum_divede_count/sum_devide_count.groovy |   24 +
 .../suites/mv_p0/test_28741/test_28741.groovy  |9 +
 .../test_approx_count_distinct.groovy  |   19 +
 .../suites/mv_p0/test_base/test_base.groovy|   18 +-
 .../mv_p0/test_casewhen

(doris) branch master updated (d7b5411aeb5 -> e613b54b5ab)

2024-06-27 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from d7b5411aeb5 [Fix](Prepared Statment) use fixed charset to init 
StringLiteral (#36860)
 add e613b54b5ab [mv](nereids) add expression cost to filter (#36789)

No new revisions were added by this update.

Summary of changes:
 .../src/main/java/org/apache/doris/nereids/cost/CostModelV1.java  | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](test)fix regression test case failure (#36391)

2024-06-26 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 1def10f3f58 [fix](test)fix regression test case failure (#36391)
1def10f3f58 is described below

commit 1def10f3f58fa10c0d79965589aa8560d8475089
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Wed Jun 26 21:30:19 2024 +0800

[fix](test)fix regression test case failure (#36391)

## Proposed changes

Issue Number: close #xxx


---
 .../suites/correctness_p0/test_ctas_mv/test_ctas_mv.groovy  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/regression-test/suites/correctness_p0/test_ctas_mv/test_ctas_mv.groovy 
b/regression-test/suites/correctness_p0/test_ctas_mv/test_ctas_mv.groovy
index 81c71221756..932ffdbdfb4 100644
--- a/regression-test/suites/correctness_p0/test_ctas_mv/test_ctas_mv.groovy
+++ b/regression-test/suites/correctness_p0/test_ctas_mv/test_ctas_mv.groovy
@@ -66,9 +66,9 @@ suite("test_ctas_mv") {
 sql """ insert into test_table_t1 values(); """
 sql """ insert into test_table_t2 values(); """
 
-sql """ CREATE MATERIALIZED VIEW test_table_view As
+createMV(""" CREATE MATERIALIZED VIEW test_table_view As
 select a1,a3,a4,DATE_FORMAT(a5, 'MMdd') 
QUERY_TIME,DATE_FORMAT(a6 ,'MMdd') CREATE_TIME
-from test_table_t1 where DATE_FORMAT(a5, 'MMdd') =20230131; """
+from test_table_t1 where DATE_FORMAT(a5, 'MMdd') =20230131; 
""")
 
 sql """ create table szjdf_zjb PROPERTIES("replication_num"="1") as
 select disf.a2, disf.a1, disf.a3, disf.a4,
@@ -90,7 +90,7 @@ suite("test_ctas_mv") {
 """
 
 sql """
-drop table if exists test_table_t1 FORCE;
+drop table if exists test_table_t1;
 """
 
 sql """


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (1579f67a708 -> 4d6172d2652)

2024-06-25 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 1579f67a708 [fix](Nereids) processCharacterLiteral even if both side 
are literal (#36729)
 add 4d6172d2652 [fix](show) show create table show index comment error 
(#36306)

No new revisions were added by this update.

Summary of changes:
 .../main/java/org/apache/doris/catalog/Index.java  | 23 +++---
 .../doris/nereids/parser/LogicalPlanBuilder.java   |  4 +++-
 .../show_p0/test_show_create_table_and_views.out   |  8 
 .../test_show_create_table_and_views_nereids.out   |  8 
 .../suites/index_p0/test_index_meta.groovy | 12 +--
 .../test_show_create_table_and_views.groovy|  4 +++-
 ...test_show_create_table_and_views_nereids.groovy |  4 +++-
 7 files changed, 39 insertions(+), 24 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (9205b8d9f3c -> 89a6f12f367)

2024-06-24 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 9205b8d9f3c [regression](statistics)Add test case for partition stats. 
(#36664)
 add 89a6f12f367 [feat](mtmv) compute agg expressions tree cost (#36368)

No new revisions were added by this update.

Summary of changes:
 .../org/apache/doris/nereids/cost/CostModelV1.java | 25 +---
 .../shape/tpcds_sf1t_stats.groovy  | 74 --
 2 files changed, 16 insertions(+), 83 deletions(-)
 delete mode 100644 
regression-test/suites/nereids_tpcds_shape_sf1000_p0/shape/tpcds_sf1t_stats.groovy


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](nereids)NullSafeEqualToEqual rule should keep <=> unchanged if it has none-literal child (#36521)

2024-06-20 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 9c7ec37fde7 [fix](nereids)NullSafeEqualToEqual rule should keep <=> 
unchanged if it has none-literal child (#36521)
9c7ec37fde7 is described below

commit 9c7ec37fde7e7a9631846ee1cd712ee7db3a7a9a
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Thu Jun 20 18:05:19 2024 +0800

[fix](nereids)NullSafeEqualToEqual rule should keep <=> unchanged if it has 
none-literal child (#36521)

convert:
 expr <=> null to expr is null
 null <=> null to true
 null <=> 1 to false
 literal <=> literal to literal = literal ( 1 <=> 2 to 1 = 2 )
others are unchanged.
---
 .../rules/expression/ExpressionOptimization.java   |  2 ++
 .../expression/rules/NullSafeEqualToEqual.java | 24 +-
 .../expression/rules/NullSafeEqualToEqualTest.java | 38 +-
 3 files changed, 41 insertions(+), 23 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/ExpressionOptimization.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/ExpressionOptimization.java
index 828592bbba3..abf57057601 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/ExpressionOptimization.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/ExpressionOptimization.java
@@ -23,6 +23,7 @@ import 
org.apache.doris.nereids.rules.expression.rules.DateFunctionRewrite;
 import org.apache.doris.nereids.rules.expression.rules.DistinctPredicatesRule;
 import org.apache.doris.nereids.rules.expression.rules.ExtractCommonFactorRule;
 import org.apache.doris.nereids.rules.expression.rules.LikeToEqualRewrite;
+import org.apache.doris.nereids.rules.expression.rules.NullSafeEqualToEqual;
 import org.apache.doris.nereids.rules.expression.rules.OrToIn;
 import 
org.apache.doris.nereids.rules.expression.rules.SimplifyComparisonPredicate;
 import 
org.apache.doris.nereids.rules.expression.rules.SimplifyDecimalV3Comparison;
@@ -51,6 +52,7 @@ public class ExpressionOptimization extends ExpressionRewrite 
{
 ArrayContainToArrayOverlap.INSTANCE,
 CaseWhenToIf.INSTANCE,
 TopnToMax.INSTANCE,
+NullSafeEqualToEqual.INSTANCE,
 LikeToEqualRewrite.INSTANCE
 )
 );
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/NullSafeEqualToEqual.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/NullSafeEqualToEqual.java
index dda109a42e0..16c4663a1ed 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/NullSafeEqualToEqual.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/NullSafeEqualToEqual.java
@@ -24,17 +24,16 @@ import 
org.apache.doris.nereids.trees.expressions.Expression;
 import org.apache.doris.nereids.trees.expressions.IsNull;
 import org.apache.doris.nereids.trees.expressions.NullSafeEqual;
 import org.apache.doris.nereids.trees.expressions.literal.BooleanLiteral;
-import org.apache.doris.nereids.trees.expressions.literal.NullLiteral;
 
 import com.google.common.collect.ImmutableList;
 
 import java.util.List;
 
 /**
- * convert "<=>" to "=", if both sides are not nullable
  * convert "A <=> null" to "A is null"
  * null <=> null : true
  * null <=> 1 : false
+ * 1 <=> 2 : 1 = 2
  */
 public class NullSafeEqualToEqual implements ExpressionPatternRuleFactory {
 public static final NullSafeEqualToEqual INSTANCE = new 
NullSafeEqualToEqual();
@@ -47,19 +46,14 @@ public class NullSafeEqualToEqual implements 
ExpressionPatternRuleFactory {
 }
 
 private static Expression rewrite(NullSafeEqual nullSafeEqual) {
-if (nullSafeEqual.left() instanceof NullLiteral) {
-if (nullSafeEqual.right().nullable()) {
-return new IsNull(nullSafeEqual.right());
-} else {
-return BooleanLiteral.FALSE;
-}
-} else if (nullSafeEqual.right() instanceof NullLiteral) {
-if (nullSafeEqual.left().nullable()) {
-return new IsNull(nullSafeEqual.left());
-} else {
-return BooleanLiteral.FALSE;
-}
-} else if (!nullSafeEqual.left().nullable() && 
!nullSafeEqual.right().nullable()) {
+// because the nullable info hasn't been finalized yet, the 
optimization is limited
+if (nullSafeEqual.left().isNullLiteral() && 
nullSafeEqual.right().isNullLiteral()) {
+return BooleanLiteral.TRUE;
+} else if (nullSafeEqual.le

(doris) branch master updated (09e5d3530eb -> cdcb02a6e8d)

2024-06-20 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 09e5d3530eb [revert](memory) Revert fix jdk17 and jemalloc hook not 
compatible on some env (#35694)
 add cdcb02a6e8d [fix](Nereids) should check it is Slot before check it is 
DELETE_SIGN (#36564)

No new revisions were added by this update.

Summary of changes:
 .../rules/analysis/LogicalResultSinkToShortCircuitPointQuery.java  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (48e3f2061d6 -> c265b359839)

2024-06-18 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 48e3f2061d6 [exec](agg) group by limit valid limit change (#36419)
 add c265b359839 [fix](nereids)disable unique key compute for mv (#35898)

No new revisions were added by this update.

Summary of changes:
 .../plans/logical/LogicalCatalogRelation.java  | 18 
 .../trees/plans/logical/LogicalOlapScan.java   | 49 ++
 2 files changed, 49 insertions(+), 18 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](nereids)disable NullSafeEqualToEqual rule (#36365)

2024-06-18 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 417bbc92054 [fix](nereids)disable NullSafeEqualToEqual rule (#36365)
417bbc92054 is described below

commit 417bbc920545553b7884461639b818d2ec2c7305
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Tue Jun 18 16:11:18 2024 +0800

[fix](nereids)disable NullSafeEqualToEqual rule (#36365)

## Proposed changes

NullSafeEqualToEqual depends on join conjunct's nullable info. But the
nullable value may change after this rule. So convert from <=> to = may
be wrong. We disable this rule for now and fix it later
---
 .../apache/doris/nereids/rules/expression/ExpressionOptimization.java   | 2 --
 1 file changed, 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/ExpressionOptimization.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/ExpressionOptimization.java
index abf57057601..828592bbba3 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/ExpressionOptimization.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/ExpressionOptimization.java
@@ -23,7 +23,6 @@ import 
org.apache.doris.nereids.rules.expression.rules.DateFunctionRewrite;
 import org.apache.doris.nereids.rules.expression.rules.DistinctPredicatesRule;
 import org.apache.doris.nereids.rules.expression.rules.ExtractCommonFactorRule;
 import org.apache.doris.nereids.rules.expression.rules.LikeToEqualRewrite;
-import org.apache.doris.nereids.rules.expression.rules.NullSafeEqualToEqual;
 import org.apache.doris.nereids.rules.expression.rules.OrToIn;
 import 
org.apache.doris.nereids.rules.expression.rules.SimplifyComparisonPredicate;
 import 
org.apache.doris.nereids.rules.expression.rules.SimplifyDecimalV3Comparison;
@@ -52,7 +51,6 @@ public class ExpressionOptimization extends ExpressionRewrite 
{
 ArrayContainToArrayOverlap.INSTANCE,
 CaseWhenToIf.INSTANCE,
 TopnToMax.INSTANCE,
-NullSafeEqualToEqual.INSTANCE,
 LikeToEqualRewrite.INSTANCE
 )
 );


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [feature](mtmv) Support to use mv group dimension when query aggregate function is distinct (#36318)

2024-06-17 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 c1999479954 [feature](mtmv) Support to use mv group dimension when 
query aggregate  function is distinct (#36318)
c1999479954 is described below

commit c19994799543149e2967d297602a8e8f19578d6b
Author: seawinde <149132972+seawi...@users.noreply.github.com>
AuthorDate: Mon Jun 17 15:26:00 2024 +0800

[feature](mtmv) Support to use mv group dimension when query aggregate  
function is distinct (#36318)

## Proposed changes

This extend the query rewrite by materialized view ability
For example mv def is
>CREATE MATERIALIZED VIEW mv1
> BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
> DISTRIBUTED BY RANDOM BUCKETS 2
> PROPERTIES ('replication_num' = '1')
> AS
>  select
>  count(o_totalprice),
>  o_shippriority,
>  o_orderstatus,
>  bin(o_orderkey)
>  from orders
>  group by
>  o_orderstatus,
>  o_shippriority,
>  bin(o_orderkey);

the query as following can be rewritten by materialized view
successfully
though `sum(distinct o_shippriority)` in query is not appear in mv
output, but query aggregate function is distinct and it use
the group by dimension in mv, in this scene, the `sum(distinct
o_shippriority)` can use mv group dimension `o_shippriority`
directly and the result is true.

Suppport the following distinct aggregate function currently, others are
supported in the furture on demand

- max(distinct arg)
- min(distinct arg)
- sum(distinct arg)
- avg(distinct arg)
- count(distinct arg)

> select
> count(o_totalprice),
>  max(distinct o_shippriority),
>  min(distinct o_shippriority),
>  avg(distinct o_shippriority),
> sum(distinct o_shippriority) / count(distinct o_shippriority)
>  o_orderstatus,
>  bin(o_orderkey)
>  from orders
 > group by
 > o_orderstatus,
 > bin(o_orderkey);
---
 .../mv/AbstractMaterializedViewAggregateRule.java  |  21 +-
 .../mv/rollup/AggFunctionRollUpHandler.java|   7 +-
 .../mv/rollup/BothCombinatorRollupHandler.java |   9 +-
 .../ContainDistinctFunctionRollupHandler.java  | 133 ++
 .../exploration/mv/rollup/DirectRollupHandler.java |  10 +-
 .../mv/rollup/MappingRollupHandler.java|   8 +-
 .../mv/rollup/SingleCombinatorRollupHandler.java   |   9 +-
 .../mv/agg_variety/agg_variety.out | 141 ++
 .../mv/agg_variety/agg_variety.groovy  | 508 +
 9 files changed, 825 insertions(+), 21 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewAggregateRule.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewAggregateRule.java
index 53b0c29bde1..0418f735ccd 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewAggregateRule.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/mv/AbstractMaterializedViewAggregateRule.java
@@ -26,6 +26,7 @@ import 
org.apache.doris.nereids.rules.exploration.mv.StructInfo.PlanSplitContext
 import org.apache.doris.nereids.rules.exploration.mv.mapping.SlotMapping;
 import 
org.apache.doris.nereids.rules.exploration.mv.rollup.AggFunctionRollUpHandler;
 import 
org.apache.doris.nereids.rules.exploration.mv.rollup.BothCombinatorRollupHandler;
+import 
org.apache.doris.nereids.rules.exploration.mv.rollup.ContainDistinctFunctionRollupHandler;
 import 
org.apache.doris.nereids.rules.exploration.mv.rollup.DirectRollupHandler;
 import 
org.apache.doris.nereids.rules.exploration.mv.rollup.MappingRollupHandler;
 import 
org.apache.doris.nereids.rules.exploration.mv.rollup.SingleCombinatorRollupHandler;
@@ -71,7 +72,8 @@ public abstract class AbstractMaterializedViewAggregateRule 
extends AbstractMate
 ImmutableList.of(DirectRollupHandler.INSTANCE,
 MappingRollupHandler.INSTANCE,
 SingleCombinatorRollupHandler.INSTANCE,
-BothCombinatorRollupHandler.INSTANCE);
+BothCombinatorRollupHandler.INSTANCE,
+ContainDistinctFunctionRollupHandler.INSTANCE);
 
 protected static final AggregateExpressionRewriter 
AGGREGATE_EXPRESSION_REWRITER =

(doris) branch branch-2.0 updated: [fix](nereids)change the decimal's precision and scale for cast(xx as decimal) (#36315)

2024-06-16 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 4c85fab1701 [fix](nereids)change the decimal's precision and scale for 
cast(xx as decimal) (#36315)
4c85fab1701 is described below

commit 4c85fab1701c0dc417b959f8ee63a423d8a49e56
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Mon Jun 17 10:52:00 2024 +0800

[fix](nereids)change the decimal's precision and scale for cast(xx as 
decimal) (#36315)

pick from master https://github.com/apache/doris/pull/36316
---
 .../expressions/functions/executable/ExecutableFunctions.java | 2 +-
 .../trees/expressions/functions/executable/NumericArithmetic.java | 8 
 .../src/main/java/org/apache/doris/nereids/types/DataType.java| 2 +-
 .../nereids/rules/expression/rules/SimplifyCastRuleTest.java  | 8 
 regression-test/data/nereids_p0/datatype/test_cast.out| 2 +-
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/ExecutableFunctions.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/ExecutableFunctions.java
index abed55a1ff4..91a7e5ab353 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/ExecutableFunctions.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/ExecutableFunctions.java
@@ -76,7 +76,7 @@ public class ExecutableFunctions {
 return new DoubleLiteral(Math.abs(literal.getValue()));
 }
 
-@ExecFunction(name = "abs", argTypes = {"DECIMAL"}, returnType = "DECIMAL")
+@ExecFunction(name = "abs", argTypes = {"DECIMALV2"}, returnType = 
"DECIMALV2")
 public static Expression abs(DecimalLiteral literal) {
 return new DecimalLiteral(literal.getValue().abs());
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java
index f0fb57c76d5..7016c456ebc 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java
@@ -197,7 +197,7 @@ public class NumericArithmetic {
 return new DoubleLiteral(result);
 }
 
-@ExecFunction(name = "add", argTypes = {"DECIMAL", "DECIMAL"}, returnType 
= "DECIMAL")
+@ExecFunction(name = "add", argTypes = {"DECIMALV2", "DECIMALV2"}, 
returnType = "DECIMALV2")
 public static Expression addDecimalDecimal(DecimalLiteral first, 
DecimalLiteral second) {
 BigDecimal result = first.getValue().add(second.getValue());
 return new DecimalLiteral(result);
@@ -368,7 +368,7 @@ public class NumericArithmetic {
 return new DoubleLiteral(result);
 }
 
-@ExecFunction(name = "subtract", argTypes = {"DECIMAL", "DECIMAL"}, 
returnType = "DECIMAL")
+@ExecFunction(name = "subtract", argTypes = {"DECIMALV2", "DECIMALV2"}, 
returnType = "DECIMALV2")
 public static Expression subtractDecimalDecimal(DecimalLiteral first, 
DecimalLiteral second) {
 BigDecimal result = first.getValue().subtract(second.getValue());
 return new DecimalLiteral(result);
@@ -539,7 +539,7 @@ public class NumericArithmetic {
 return new DoubleLiteral(result);
 }
 
-@ExecFunction(name = "multiply", argTypes = {"DECIMAL", "DECIMAL"}, 
returnType = "DECIMAL")
+@ExecFunction(name = "multiply", argTypes = {"DECIMALV2", "DECIMALV2"}, 
returnType = "DECIMALV2")
 public static Expression multiplyDecimalDecimal(DecimalLiteral first, 
DecimalLiteral second) {
 BigDecimal result = first.getValue().multiply(second.getValue());
 return new DecimalLiteral(result);
@@ -570,7 +570,7 @@ public class NumericArithmetic {
 return new DoubleLiteral(result);
 }
 
-@ExecFunction(name = "divide", argTypes = {"DECIMAL", "DECIMAL"}, 
returnType = "DECIMAL")
+@ExecFunction(name = "divide", argTypes = {"DECIMALV2", "DECIMALV2"}, 
returnType = "DECIMALV2")
 public static Expression divideDecimal(DecimalLiteral first, 
DecimalLiteral second) {
 if (first.getValue(

(doris) branch master updated: [feature](mtmv) Support query rewrite by materialized view when query is aggregate and materialized view has no aggregate (#36278)

2024-06-13 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 649f9bc6837  [feature](mtmv) Support query rewrite by materialized 
view when query is aggregate and materialized view has no aggregate (#36278)
649f9bc6837 is described below

commit 649f9bc6837b57618ea17341ca716ceaffa3a1e0
Author: seawinde <149132972+seawi...@users.noreply.github.com>
AuthorDate: Fri Jun 14 11:15:53 2024 +0800

 [feature](mtmv) Support query rewrite by materialized view when query is 
aggregate and materialized view has no aggregate (#36278)

## Proposed changes

Support query rewrite by materialized view when query is aggregate and
materialized view has no aggregate
this maybe improve query spped, because it can save expression
evaluation by use the expression result in materialized view.

this also support single table rewrite.

For example as follwoing:
mv def is:

>CREATE MATERIALIZED VIEW mv1
> BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
> DISTRIBUTED BY RANDOM BUCKETS 2
> PROPERTIES ('replication_num' = '1')
> AS
> select case when o_shippriority > 1 and o_orderkey IN (4, 5) then
o_custkey else o_shippriority end,
>  o_orderstatus,
>  bin(o_orderkey),
>  l_suppkey,
>  l_linenumber
>  from orders
>  left join lineitem on o_orderkey =  l_orderkey;


the query as following can be rewritten by mv successfully

> select
> count(case when o_shippriority > 1 and o_orderkey IN (4, 5) then
o_custkey else o_shippriority end) as count_case,
> o_orderstatus,
> bin(o_orderkey)
> from orders
> left join lineitem on o_orderkey =  l_orderkey
> where l_linenumber = 4
>group by
> o_orderstatus,
> bin(o_orderkey);
---
 .../org/apache/doris/nereids/rules/RuleSet.java|   2 +
 .../org/apache/doris/nereids/rules/RuleType.java   |   6 +
 .../mv/AbstractMaterializedViewAggregateRule.java  | 116 -
 .../mv/AbstractMaterializedViewJoinRule.java   |   2 +-
 .../mv/AbstractMaterializedViewRule.java   |  18 +-
 ...terializedViewAggregateOnNoneAggregateRule.java | 134 ++
 ...MaterializedViewFilterProjectAggregateRule.java |   2 +-
 ...MaterializedViewProjectFilterAggregateRule.java |   2 +-
 .../exploration/mv/MaterializedViewScanRule.java   |   2 +-
 .../mv/agg_on_none_agg/agg_on_none_agg.out | 155 +++
 .../mv/agg_on_none_agg/agg_on_none_agg.groovy  | 488 +
 .../aggregate_without_roll_up.groovy   |   2 +-
 12 files changed, 890 insertions(+), 39 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleSet.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleSet.java
index ada72f04680..a5fb0b8736a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleSet.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleSet.java
@@ -31,6 +31,7 @@ import 
org.apache.doris.nereids.rules.exploration.join.OuterJoinLAsscomProject;
 import 
org.apache.doris.nereids.rules.exploration.join.PushDownProjectThroughInnerOuterJoin;
 import 
org.apache.doris.nereids.rules.exploration.join.PushDownProjectThroughSemiJoin;
 import 
org.apache.doris.nereids.rules.exploration.join.SemiJoinSemiJoinTransposeProject;
+import 
org.apache.doris.nereids.rules.exploration.mv.MaterializedViewAggregateOnNoneAggregateRule;
 import 
org.apache.doris.nereids.rules.exploration.mv.MaterializedViewAggregateRule;
 import 
org.apache.doris.nereids.rules.exploration.mv.MaterializedViewFilterAggregateRule;
 import 
org.apache.doris.nereids.rules.exploration.mv.MaterializedViewFilterJoinRule;
@@ -236,6 +237,7 @@ public class RuleSet {
 .add(MaterializedViewFilterProjectScanRule.INSTANCE)
 .add(MaterializedViewProjectScanRule.INSTANCE)
 .add(MaterializedViewProjectFilterScanRule.INSTANCE)
+.add(MaterializedViewAggregateOnNoneAggregateRule.INSTANCE)
 .build();
 
 public static final List DPHYP_REORDER_RULES = 
ImmutableList.builder()
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
index 62dc7840da9..bde86b61c29 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
@@ -396,6 +396,12 @@ public enum RuleTy

(doris) branch master updated: [Fix](nereids)make agg output unchanged after normalized repeat (#36207)

2024-06-13 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 9a125d35666 [Fix](nereids)make agg output unchanged after normalized 
repeat (#36207)
9a125d35666 is described below

commit 9a125d35666a109dd245cab166f9d5bcba66993f
Author: feiniaofeiafei <53502832+feiniaofeia...@users.noreply.github.com>
AuthorDate: Thu Jun 13 18:20:30 2024 +0800

[Fix](nereids)make agg output unchanged after normalized repeat (#36207)

The NormalizeRepeat rule can change the output of agg.
For example:
```sql
 SELECT
 col_int_undef_signed2 AS C1 ,
 col_int_undef_signed2
 FROM
 normalize_repeat_name_unchanged
 GROUP BY
 GROUPING SETS (
 (col_int_undef_signed2),
 (col_int_undef_signed2))
```
Before fixing the bug, the plan is:
```sql
LogicalResultSink[97] ( outputExprs=[C1#7, col_int_undef_signed2#1] )
  +--LogicalProject[94] ( distinct=false, projects=[C1#7, C1#7], 
excepts=[] )
 +--LogicalAggregate[93] ( groupByExpr=[C1#7, GROUPING_ID#8], 
outputExpr=[C1#7, GROUPING_ID#8], hasRepeat=true )
+--LogicalRepeat ( groupingSets=[[C1#7], [C1#7]], 
outputExpressions=[C1#7, GROUPING_ID#8] )
   +--LogicalProject[91] ( distinct=false, 
projects=[col_int_undef_signed2#1 AS `C1`#7], excepts=[] )
  +--LogicalOlapScan (  )
```
This can lead to column not found in LogicalResultSink, report error:
Input slot(s) not in childs output: col_int_undef_signed2#1 in plan:
LogicalResultSink[97] ( outputExprs=[C1#7, col_int_undef_signed2#1] )
child output is: [C1#7]

This pr makes agg output unchanged after normalized repeat. After
fixing, the plan is:
```sql
LogicalResultSink[97] ( outputExprs=[C1#7, col_int_undef_signed2#1] )
  +--LogicalProject[94] ( distinct=false, projects=[C1#7, C1#7 as 
`col_int_undef_signed2`#1], excepts=[] )
 +--LogicalAggregate[93] ( groupByExpr=[C1#7, GROUPING_ID#8], 
outputExpr=[C1#7, GROUPING_ID#8], hasRepeat=true )
+--LogicalRepeat ( groupingSets=[[C1#7], [C1#7]], 
outputExpressions=[C1#7, GROUPING_ID#8] )
   +--LogicalProject[91] ( distinct=false, 
projects=[col_int_undef_signed2#1 AS `C1`#7], excepts=[] )
  +--LogicalOlapScan (  )
```

-

Co-authored-by: feiniaofeiafei 
---
 .../nereids/rules/analysis/NormalizeRepeat.java| 24 +++
 .../grouping_sets/grouping_normalize_test.out  | 28 +
 .../grouping_sets/grouping_normalize_test.groovy   | 35 ++
 3 files changed, 87 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeRepeat.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeRepeat.java
index 0ff15ac7ecf..6465b81da30 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeRepeat.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeRepeat.java
@@ -42,6 +42,7 @@ import org.apache.doris.nereids.util.ExpressionUtils;
 import org.apache.doris.nereids.util.PlanUtils.CollectNonWindowedAggFuncs;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
@@ -198,6 +199,8 @@ public class NormalizeRepeat extends OneAnalysisRuleFactory 
{
 .addAll(groupingSetsUsedSlot)
 .addAll(allVirtualSlots)
 .build();
+
+normalizedAggOutput = 
getExprIdUnchangedNormalizedAggOutput(normalizedAggOutput, 
repeat.getOutputExpressions());
 return new LogicalAggregate<>(normalizedAggGroupBy, (List) 
normalizedAggOutput,
 Optional.of(normalizedRepeat), normalizedRepeat);
 }
@@ -460,4 +463,25 @@ public class NormalizeRepeat extends 
OneAnalysisRuleFactory {
 return hasNewChildren ? windowExpression.withChildren(newChildren) 
: windowExpression;
 }
 }
+
+private static List getExprIdUnchangedNormalizedAggOutput(
+List normalizedAggOutput, List 
originalAggOutput) {
+Builder builder = new ImmutableList.Builder<>();
+for (int i = 0; i < originalAggOutput.size(); i++) {
+NamedExpression e = normalizedAggOutput.get(i);
+// process Expression like Alias(SlotReference#0)#0
+if (e instanceof Alias && e.child(0) instanceof SlotReference) {
+SlotReference slotReference = (SlotReference) e.child(0);
+if (slo

(doris) branch master updated: [fix](planner)remove constant expr in window function's partition and order exprs (#36184)

2024-06-12 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 b052621150d [fix](planner)remove constant expr in window function's 
partition and order exprs (#36184)
b052621150d is described below

commit b052621150df2f3f955d0f87cbb695586cdc5708
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Thu Jun 13 09:51:08 2024 +0800

[fix](planner)remove constant expr in window function's partition and order 
exprs (#36184)

the legacy planner reports error if there is constant expr in window
function's partition or order by keys. This pr just remove these
unnecessary constant exprs and make planner happy.
now:
`SELECT row_number() OVER (partition by 1 order by 2) from t`
will be changed to
`SELECT row_number() OVER () from t  `
---
 .../java/org/apache/doris/analysis/AnalyticExpr.java   | 18 ++
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
index 7028370dc45..87681a636e2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
@@ -475,22 +475,8 @@ public class AnalyticExpr extends Expr {
 public void analyzeImpl(Analyzer analyzer) throws AnalysisException {
 fnCall.analyze(analyzer);
 type = getFnCall().getType();
-
-for (Expr e : partitionExprs) {
-if (e.isLiteral()) {
-throw new AnalysisException(
-"Expressions in the PARTITION BY clause must not be 
constant: "
-+ e.toSql() + " (in " + toSql() + ")");
-}
-}
-
-for (OrderByElement e : orderByElements) {
-if (e.getExpr().isLiteral()) {
-throw new AnalysisException(
-"Expressions in the ORDER BY clause must not be constant: "
-+ e.getExpr().toSql() + " (in " + toSql() + ")");
-}
-}
+partitionExprs.removeIf(expr -> expr.isConstant());
+orderByElements.removeIf(expr -> expr.getExpr().isConstant());
 
 if (getFnCall().getParams().isDistinct()) {
 throw new AnalysisException(


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated: [fix](planner)remove constant expr in window function's partition and order exprs (#36186)

2024-06-12 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 3163127510b [fix](planner)remove constant expr in window function's 
partition and order exprs (#36186)
3163127510b is described below

commit 3163127510b35dff921638c41d52d28a50f274a8
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Thu Jun 13 09:34:07 2024 +0800

[fix](planner)remove constant expr in window function's partition and order 
exprs (#36186)

pick from master https://github.com/apache/doris/pull/36184
---
 .../java/org/apache/doris/analysis/AnalyticExpr.java   | 18 ++
 .../window_functions/test_window_function.out  | 18 ++
 .../window_functions/test_window_function.groovy   |  3 +++
 3 files changed, 23 insertions(+), 16 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
index 2a9e9a9c88d..e24ff74e9d2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticExpr.java
@@ -463,22 +463,8 @@ public class AnalyticExpr extends Expr {
 public void analyzeImpl(Analyzer analyzer) throws AnalysisException {
 fnCall.analyze(analyzer);
 type = getFnCall().getType();
-
-for (Expr e : partitionExprs) {
-if (e.isLiteral()) {
-throw new AnalysisException(
-"Expressions in the PARTITION BY clause must not be 
constant: "
-+ e.toSql() + " (in " + toSql() + ")");
-}
-}
-
-for (OrderByElement e : orderByElements) {
-if (e.getExpr().isLiteral()) {
-throw new AnalysisException(
-"Expressions in the ORDER BY clause must not be constant: "
-+ e.getExpr().toSql() + " (in " + toSql() + ")");
-}
-}
+partitionExprs.removeIf(expr -> expr.isConstant());
+orderByElements.removeIf(expr -> expr.getExpr().isConstant());
 
 if (getFnCall().getParams().isDistinct()) {
 throw new AnalysisException(
diff --git 
a/regression-test/data/query_p0/sql_functions/window_functions/test_window_function.out
 
b/regression-test/data/query_p0/sql_functions/window_functions/test_window_function.out
index 8a753341bbd..5d5231297a6 100644
--- 
a/regression-test/data/query_p0/sql_functions/window_functions/test_window_function.out
+++ 
b/regression-test/data/query_p0/sql_functions/window_functions/test_window_function.out
@@ -574,3 +574,21 @@ USAPeteHello
 32767  6   12  32767
 32767  6   6   32767
 
+-- !sql --
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+
diff --git 
a/regression-test/suites/query_p0/sql_functions/window_functions/test_window_function.groovy
 
b/regression-test/suites/query_p0/sql_functions/window_functions/test_window_function.groovy
index eb5d557469b..76bffcbb7b1 100644
--- 
a/regression-test/suites/query_p0/sql_functions/window_functions/test_window_function.groovy
+++ 
b/regression-test/suites/query_p0/sql_functions/window_functions/test_window_function.groovy
@@ -492,5 +492,8 @@ suite("test_window_function") {
( SELECT k2, k1, row_number () over (PARTITION BY k2 ORDER BY k3) 
AS wj  
FROM baseall ) AS A JOIN ( SELECT k2, k1, row_number () over  
(PARTITION BY k2 ORDER BY k3) AS wj FROM baseall ) AS B WHERE 
A.k2=B.k2"""
+
+sql """set enable_nereids_planner=false"""
+qt_sql """SELECT row_number() OVER (partition by 1 order by 2) from 
baseall order by 1; """
 }
 


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](Nereids): add be test number in some tests (#35500)

2024-06-06 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 98b101c2336 [fix](Nereids): add be test number in some tests (#35500)
98b101c2336 is described below

commit 98b101c2336394478adcf5367250c39f5549f2d1
Author: 谢健 
AuthorDate: Thu Jun 6 20:19:26 2024 +0800

[fix](Nereids): add be test number in some tests (#35500)
---
 .../push_down_count_through_join_one_side.out  | 11 +-
 .../eliminate_outer_join/eliminate_outer_join.out  | 25 --
 .../push_down_top_n_distinct_through_join.out  | 15 ++---
 .../suites/nereids_p0/hint/test_distribute.groovy  |  3 ++-
 .../push_down_count_through_join_one_side.groovy   |  1 +
 .../eliminate_gby_key/eliminate_gby_key.groovy | 12 +--
 .../eliminate_outer_join.groovy|  2 +-
 .../push_down_alias_through_join.groovy|  1 +
 .../push_down_top_n_distinct_through_join.groovy   |  1 +
 .../performance_p0/redundant_conjuncts.groovy  |  1 +
 .../suites/query_p0/join/test_join.groovy  |  2 +-
 11 files changed, 40 insertions(+), 34 deletions(-)

diff --git 
a/regression-test/data/nereids_rules_p0/eager_aggregate/push_down_count_through_join_one_side.out
 
b/regression-test/data/nereids_rules_p0/eager_aggregate/push_down_count_through_join_one_side.out
index eb7e77a7544..c3132e18112 100644
--- 
a/regression-test/data/nereids_rules_p0/eager_aggregate/push_down_count_through_join_one_side.out
+++ 
b/regression-test/data/nereids_rules_p0/eager_aggregate/push_down_count_through_join_one_side.out
@@ -338,13 +338,12 @@ PhysicalResultSink
 
 -- !groupby_pushdown_multi_table_join --
 PhysicalResultSink
---hashAgg[GLOBAL]
-hashAgg[LOCAL]
---hashJoin[INNER_JOIN] hashCondition=((t1.name = t3.name)) 
otherCondition=()
-hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=()
---PhysicalOlapScan[count_t_one_side]
---PhysicalOlapScan[count_t_one_side]
+--hashAgg[LOCAL]
+hashJoin[INNER_JOIN] hashCondition=((t1.name = t3.name)) otherCondition=()
+--hashJoin[INNER_JOIN] hashCondition=((t1.id = t2.id)) otherCondition=()
 PhysicalOlapScan[count_t_one_side]
+PhysicalOlapScan[count_t_one_side]
+--PhysicalOlapScan[count_t_one_side]
 
 -- !groupby_pushdown_with_order_by --
 PhysicalResultSink
diff --git 
a/regression-test/data/nereids_rules_p0/eliminate_outer_join/eliminate_outer_join.out
 
b/regression-test/data/nereids_rules_p0/eliminate_outer_join/eliminate_outer_join.out
index a0119589c46..c08e68d3c72 100644
--- 
a/regression-test/data/nereids_rules_p0/eliminate_outer_join/eliminate_outer_join.out
+++ 
b/regression-test/data/nereids_rules_p0/eliminate_outer_join/eliminate_outer_join.out
@@ -103,11 +103,12 @@ PhysicalResultSink
 PhysicalResultSink
 --PhysicalDistribute[DistributionSpecGather]
 hashJoin[LEFT_OUTER_JOIN] hashCondition=((t1.id = t3.id)) otherCondition=()
---hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) 
otherCondition=()
-PhysicalOlapScan[t]
-filter((t2.score > 10))
+--PhysicalDistribute[DistributionSpecHash]
+hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) 
otherCondition=()
 --PhysicalOlapScan[t]
---PhysicalDistribute[DistributionSpecReplicated]
+--filter((t2.score > 10))
+PhysicalOlapScan[t]
+--PhysicalDistribute[DistributionSpecHash]
 PhysicalOlapScan[t]
 
 -- !left_outer_join_non_null_assertion --
@@ -150,10 +151,11 @@ PhysicalResultSink
 --PhysicalDistribute[DistributionSpecGather]
 PhysicalProject
 --hashJoin[LEFT_OUTER_JOIN] hashCondition=((expr_cast(score as BIGINT) = 
expr_(score + 10))) otherCondition=()
-PhysicalProject
---filter(( not id IS NULL))
-PhysicalOlapScan[t]
-PhysicalDistribute[DistributionSpecReplicated]
+PhysicalDistribute[DistributionSpecHash]
+--PhysicalProject
+filter(( not id IS NULL))
+--PhysicalOlapScan[t]
+PhysicalDistribute[DistributionSpecHash]
 --PhysicalProject
 PhysicalOlapScan[t]
 
@@ -251,9 +253,10 @@ PhysicalResultSink
 --PhysicalDistribute[DistributionSpecGather]
 PhysicalProject
 --hashJoin[INNER_JOIN] hashCondition=((expr_cast(score as BIGINT) = 
expr_(score * 2))) otherCondition=((t1.id < t2.id))
-PhysicalProject
---PhysicalOlapScan[t]
-PhysicalDistribute[DistributionSpecReplicated]
+PhysicalDistribute[DistributionSpecHash]
+--PhysicalProject
+PhysicalOlapScan[t]
+PhysicalDistribute[DistributionSpecHash]
 --PhysicalProject
 PhysicalOlapScan[t]
 
diff --git 
a/regression-test/data/nereids_rules_p0/push_down_top_n/push_down_top_n_distinct_through_join.out
 
b/regression-

(doris) branch master updated: [opt](Nereids) use date signature for date arithmetic as far as possible (#35863)

2024-06-05 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 a103163fd3e [opt](Nereids) use date signature for date arithmetic as 
far as possible (#35863)
a103163fd3e is described below

commit a103163fd3e353501ace2d2ba0f982c4ec9004f7
Author: morrySnow <101034200+morrys...@users.noreply.github.com>
AuthorDate: Wed Jun 5 22:11:06 2024 +0800

[opt](Nereids) use date signature for date arithmetic as far as possible 
(#35863)

if date arithmetic (date_add / date_sub)'s first argument is
StringLikeLiteral. We use date signature as far as possible.

for example:

SQL: `select date_sub('2024-05-28', INTERVAL 1 week);`

before this PR:
```
++
| weeks_sub(cast('2024-05-28' as DATETIMEV2), 1) |
++
| 2024-05-21 00:00:00|
++
```

after this PR:
```
++
| weeks_sub(cast('2024-05-28' as DATEV2), 1) |
++
| 2024-05-21 |
++
```
---
 .../ComputeSignatureForDateArithmetic.java |  59 ++
 .../expressions/functions/scalar/DaysAdd.java  |   4 +-
 .../expressions/functions/scalar/DaysSub.java  |   4 +-
 .../expressions/functions/scalar/MonthsAdd.java|  15 +-
 .../expressions/functions/scalar/MonthsSub.java|  15 +-
 .../expressions/functions/scalar/WeeksAdd.java |   4 +-
 .../expressions/functions/scalar/WeeksSub.java |   4 +-
 .../expressions/functions/scalar/YearsAdd.java |  15 +-
 .../expressions/functions/scalar/YearsSub.java |  15 +-
 .../apache/doris/planner/ConstantExpressTest.java  |   4 +-
 .../fold_constant/fold_constant_by_fe.out  | 200 ++---
 .../data/nereids_syntax_p0/test_date_add.out   |  28 +--
 .../data/nereids_syntax_p0/test_date_sub.out   |  24 +--
 13 files changed, 251 insertions(+), 140 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignatureForDateArithmetic.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignatureForDateArithmetic.java
new file mode 100644
index 000..c5aa4caae54
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignatureForDateArithmetic.java
@@ -0,0 +1,59 @@
+// 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.
+
+package org.apache.doris.nereids.trees.expressions.functions;
+
+import org.apache.doris.catalog.FunctionSignature;
+import org.apache.doris.common.Config;
+import org.apache.doris.nereids.annotation.Developing;
+import org.apache.doris.nereids.trees.expressions.literal.DateV2Literal;
+import org.apache.doris.nereids.trees.expressions.literal.StringLikeLiteral;
+import org.apache.doris.nereids.types.DateType;
+import org.apache.doris.nereids.types.DateV2Type;
+import org.apache.doris.nereids.types.IntegerType;
+
+/**
+ * use for date arithmetic, such as date_sub('2024-05-28', INTERVAL 1 day).
+ * if the first argument is string like literal and could cast to legal date 
literal,
+ * then use date/dateV2 signature
+ */
+@Developing
+public interface ComputeSignatureForDateArithmetic extends ComputeSignature {
+
+@Override
+default FunctionSignature computeSignature(FunctionSignature signature) {
+FunctionSignature ret = 
ComputeSignature.super.computeSignature(signature);
+if (child(0) instanceof StringLikeLiteral) {
+try {
+String s = ((StringLikeLiteral) 
child(0)).getStringValue().trim();
+// avoid use date/dateV2 signature for '2020-02-02 00:00:00'
+if (s.length() <= 10) {
+new DateV2Literal(s);
+if (

(doris) branch branch-2.1 updated: [enhancement](nereids)eliminate repeat node if there is only 1 grouping set and no grouping scalar function (#35872)

2024-06-05 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
 new bcde9c65249 [enhancement](nereids)eliminate repeat node if there is 
only 1 grouping set and no grouping scalar function (#35872)
bcde9c65249 is described below

commit bcde9c65249ba1e5469a29bd6453acbbf003f0ab
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Wed Jun 5 18:03:20 2024 +0800

[enhancement](nereids)eliminate repeat node if there is only 1 grouping set 
and no grouping scalar function (#35872)
---
 .../nereids/rules/analysis/NormalizeRepeat.java|  6 
 .../rules/analysis/NormalizeRepeatTest.java| 39 +-
 .../grouping_sets/grouping_normalize_test.groovy   | 15 +
 3 files changed, 59 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeRepeat.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeRepeat.java
index 169d5a901a7..2d39852dd18 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeRepeat.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeRepeat.java
@@ -82,6 +82,12 @@ public class NormalizeRepeat extends OneAnalysisRuleFactory {
 public Rule build() {
 return RuleType.NORMALIZE_REPEAT.build(
 
logicalRepeat(any()).when(LogicalRepeat::canBindVirtualSlot).then(repeat -> {
+if (repeat.getGroupingSets().size() == 1
+&& 
ExpressionUtils.collect(repeat.getOutputExpressions(),
+GroupingScalarFunction.class::isInstance).isEmpty()) {
+return new 
LogicalAggregate<>(repeat.getGroupByExpressions(),
+repeat.getOutputExpressions(), repeat.child());
+}
 checkRepeatLegality(repeat);
 repeat = removeDuplicateColumns(repeat);
 // add virtual slot, LogicalAggregate and LogicalProject for 
normalize
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/NormalizeRepeatTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/NormalizeRepeatTest.java
index 3fc2fec9a65..556f5279412 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/NormalizeRepeatTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/NormalizeRepeatTest.java
@@ -20,6 +20,7 @@ package org.apache.doris.nereids.rules.analysis;
 import org.apache.doris.nereids.trees.expressions.Alias;
 import org.apache.doris.nereids.trees.expressions.Slot;
 import org.apache.doris.nereids.trees.expressions.functions.agg.Sum;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.GroupingId;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalOlapScan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalRepeat;
@@ -41,7 +42,7 @@ public class NormalizeRepeatTest implements 
MemoPatternMatchSupported {
 Slot name = scan1.getOutput().get(1);
 Alias alias = new Alias(new Sum(name), "sum(name)");
 Plan plan = new LogicalRepeat<>(
-ImmutableList.of(ImmutableList.of(id)),
+ImmutableList.of(ImmutableList.of(id), ImmutableList.of(name)),
 ImmutableList.of(idNotNull, alias),
 scan1
 );
@@ -51,4 +52,40 @@ public class NormalizeRepeatTest implements 
MemoPatternMatchSupported {
 logicalRepeat().when(repeat -> 
repeat.getOutputExpressions().get(0).nullable())
 );
 }
+
+@Test
+public void testEliminateRepeat() {
+Slot id = scan1.getOutput().get(0);
+Slot idNotNull = id.withNullable(true);
+Slot name = scan1.getOutput().get(1);
+Alias alias = new Alias(new Sum(name), "sum(name)");
+Plan plan = new LogicalRepeat<>(
+ImmutableList.of(ImmutableList.of(id)),
+ImmutableList.of(idNotNull, alias),
+scan1
+);
+PlanChecker.from(MemoTestUtils.createCascadesContext(plan))
+.applyTopDown(new NormalizeRepeat())
+.matchesFromRoot(
+logicalAggregate(logicalOlapScan())
+);
+}
+
+@Test
+public void testNoEliminateRepeat() {
+Slot id = scan1.getOutput().get(0);
+Slot idNotNull = id.withNullable(true);
+Slot name = scan1.getOutput().get(1);
+Alias alias = new Alias(new GroupingId(name), "grouping_id(name)");
+Plan plan = new LogicalRepeat<>(
+ImmutableList.of

(doris) branch master updated (f4d029dba03 -> 71c5b852cd9)

2024-06-03 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from f4d029dba03 [fix](Nereids) unix_timestamp compute signature and fold 
const is wrong (#35727)
 add 71c5b852cd9 [opt](nereids)calculate expression cost (#35701)

No new revisions were added by this update.

Summary of changes:
 .../org/apache/doris/nereids/cost/CostModelV1.java | 12 ++-
 .../nereids/cost/ExpressionCostEvaluator.java  | 86 +
 .../nereids/cost/ExpressionCostEvaluatorTest.java  | 87 ++
 3 files changed, 181 insertions(+), 4 deletions(-)
 create mode 100644 
fe/fe-core/src/main/java/org/apache/doris/nereids/cost/ExpressionCostEvaluator.java
 create mode 100644 
fe/fe-core/src/test/java/org/apache/doris/nereids/cost/ExpressionCostEvaluatorTest.java


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated: [fix](nereids)days_diff should match datetimev2 function sigature in higher priority (#35327)

2024-05-26 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 30119ebbd7f [fix](nereids)days_diff should match datetimev2 function 
sigature in higher priority (#35327)
30119ebbd7f is described below

commit 30119ebbd7f79b2cffa4091d44e6a9b2155b5fab
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Mon May 27 10:06:39 2024 +0800

[fix](nereids)days_diff should match datetimev2 function sigature in higher 
priority (#35327)
---
 .../doris/nereids/trees/expressions/functions/scalar/DateDiff.java| 4 ++--
 .../doris/nereids/trees/expressions/functions/scalar/DaysDiff.java| 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateDiff.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateDiff.java
index 0595f70ea03..e581b7c3598 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateDiff.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DateDiff.java
@@ -40,11 +40,11 @@ public class DateDiff extends ScalarFunction
 implements BinaryExpression, ExplicitlyCastableSignature, 
PropagateNullableOnDateLikeV2Args {
 
 public static final List SIGNATURES = ImmutableList.of(
+FunctionSignature.ret(IntegerType.INSTANCE)
+.args(DateTimeV2Type.SYSTEM_DEFAULT, 
DateTimeV2Type.SYSTEM_DEFAULT),
 
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, 
DateV2Type.INSTANCE),
 
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE, 
DateTimeV2Type.SYSTEM_DEFAULT),
 
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, 
DateV2Type.INSTANCE),
-FunctionSignature.ret(IntegerType.INSTANCE)
-.args(DateTimeV2Type.SYSTEM_DEFAULT, 
DateTimeV2Type.SYSTEM_DEFAULT),
 
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeType.INSTANCE, 
DateTimeType.INSTANCE)
 );
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysDiff.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysDiff.java
index 3f12ba2d74f..e0343f1148f 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysDiff.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DaysDiff.java
@@ -40,11 +40,11 @@ public class DaysDiff extends ScalarFunction
 implements BinaryExpression, ExplicitlyCastableSignature, 
PropagateNullableOnDateLikeV2Args {
 
 private static final List SIGNATURES = ImmutableList.of(
+FunctionSignature.ret(BigIntType.INSTANCE)
+.args(DateTimeV2Type.SYSTEM_DEFAULT, 
DateTimeV2Type.SYSTEM_DEFAULT),
 
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, 
DateV2Type.INSTANCE),
 
FunctionSignature.ret(BigIntType.INSTANCE).args(DateV2Type.INSTANCE, 
DateTimeV2Type.SYSTEM_DEFAULT),
 
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT, 
DateV2Type.INSTANCE),
-FunctionSignature.ret(BigIntType.INSTANCE)
-.args(DateTimeV2Type.SYSTEM_DEFAULT, 
DateTimeV2Type.SYSTEM_DEFAULT),
 
FunctionSignature.ret(BigIntType.INSTANCE).args(DateTimeType.INSTANCE, 
DateTimeType.INSTANCE)
 );
 


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.1 updated: [fix](nereids)AdjustNullable rule should handle union node with no children (#35323)

2024-05-26 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
 new a9bd98d65b0 [fix](nereids)AdjustNullable rule should handle union node 
with no children (#35323)
a9bd98d65b0 is described below

commit a9bd98d65b05e73a3c359ec283444f32a52b72ae
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Mon May 27 10:06:20 2024 +0800

[fix](nereids)AdjustNullable rule should handle union node with no children 
(#35323)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (260166d09b2 -> 32ceaaca7f0)

2024-05-23 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 260166d09b2 [test](case) Remove sensitive information in k8s deploy 
test (#35185)
 add 32ceaaca7f0 days_diff should match datetimev2 function sigature in 
higher priority (#35191)

No new revisions were added by this update.

Summary of changes:
 .../doris/nereids/trees/expressions/functions/scalar/DateDiff.java| 4 ++--
 .../doris/nereids/trees/expressions/functions/scalar/DaysDiff.java| 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (90426618c70 -> 971c2ad3106)

2024-05-22 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 90426618c70 [fix](noexcept) Remove incorrect noexcept #35230
 add 971c2ad3106 [fix](nereids)should use nereids expr's nullable info when 
call Expr's toThrift method (#35071)

No new revisions were added by this update.

Summary of changes:
 .../main/java/org/apache/doris/analysis/Expr.java  |   8 +-
 .../glue/translator/ExpressionTranslator.java  | 137 +++--
 2 files changed, 106 insertions(+), 39 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (6e2e95ddf51 -> 27c75b31938)

2024-05-20 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 6e2e95ddf51 [chore](femetaversion) add a check in fe code to avoid fe 
meta version changed during pick PR (#35039)
 add 27c75b31938 [opt](nereids)new way to set pre-agg status (#34738)

No new revisions were added by this update.

Summary of changes:
 .../doris/nereids/jobs/executor/Rewriter.java  |   4 +
 .../org/apache/doris/nereids/rules/RuleType.java   |  15 +
 .../doris/nereids/rules/analysis/BindRelation.java |   2 +-
 .../nereids/rules/rewrite/AdjustPreAggStatus.java  | 748 +
 .../mv/AbstractSelectMaterializedIndexRule.java|  12 +-
 .../mv/SelectMaterializedIndexWithAggregate.java   |  18 +-
 .../SelectMaterializedIndexWithoutAggregate.java   |  20 +-
 .../doris/nereids/trees/plans/PreAggStatus.java|  15 +-
 .../trees/plans/logical/LogicalOlapScan.java   |  14 +-
 .../rules/rewrite/mv/SelectRollupIndexTest.java|  30 +-
 .../nereids/trees/plans/PlanToStringTest.java  |   2 +-
 11 files changed, 823 insertions(+), 57 deletions(-)
 create mode 100644 
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/AdjustPreAggStatus.java


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (de96162ab37 -> 0d3423b472e)

2024-05-16 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from de96162ab37 [Chore](hash) catch error when hash method variant meet 
valueless_by_exception #34956
 add 0d3423b472e [fix](mtmv)Fix slot desc wrong in query rewrite by 
materialized view when query is complex (#34904)

No new revisions were added by this update.

Summary of changes:
 .../main/java/org/apache/doris/catalog/MTMV.java   |   8 +-
 .../mv/AbstractMaterializedViewRule.java   |   2 +-
 .../mv/InitMaterializationContextHook.java |   5 +-
 .../exploration/mv/MaterializationContext.java |  13 +-
 .../exploration/mv/MaterializedViewUtils.java  |   7 +-
 .../trees/plans/visitor/TableCollector.java|  14 +-
 .../mv/nested}/ddl/customer_create.sql |   0
 .../mv/nested}/ddl/customer_delete.sql |   0
 .../mv/nested}/ddl/date_create.sql |   0
 .../mv/nested}/ddl/date_delete.sql |   0
 .../mv/nested}/ddl/lineorder_create.sql|   0
 .../mv/nested}/ddl/lineorder_delete.sql|   0
 .../mv/nested}/ddl/lineorder_flat_create.sql   |   0
 .../mv/nested}/ddl/lineorder_flat_delete.sql   |   0
 .../mv/nested}/ddl/part_create.sql |   0
 .../mv/nested}/ddl/part_delete.sql |   0
 .../mv/nested}/ddl/supplier_create.sql |   0
 .../mv/nested}/ddl/supplier_delete.sql |   0
 .../mv/nested/nested_materialized_view.groovy  | 750 -
 19 files changed, 776 insertions(+), 23 deletions(-)
 copy regression-test/suites/{hdfs_vault/default_vault_p2 => 
nereids_rules_p0/mv/nested}/ddl/customer_create.sql (100%)
 copy regression-test/suites/{hdfs_vault/default_vault_p2 => 
nereids_rules_p0/mv/nested}/ddl/customer_delete.sql (100%)
 copy regression-test/suites/{hdfs_vault/default_vault_p2 => 
nereids_rules_p0/mv/nested}/ddl/date_create.sql (100%)
 copy regression-test/suites/{hdfs_vault/default_vault_p2 => 
nereids_rules_p0/mv/nested}/ddl/date_delete.sql (100%)
 copy regression-test/suites/{hdfs_vault/default_vault_p2 => 
nereids_rules_p0/mv/nested}/ddl/lineorder_create.sql (100%)
 copy regression-test/suites/{hdfs_vault/default_vault_p2 => 
nereids_rules_p0/mv/nested}/ddl/lineorder_delete.sql (100%)
 copy regression-test/suites/{hdfs_vault/default_vault_p2 => 
nereids_rules_p0/mv/nested}/ddl/lineorder_flat_create.sql (100%)
 copy regression-test/suites/{hdfs_vault/default_vault_p2 => 
nereids_rules_p0/mv/nested}/ddl/lineorder_flat_delete.sql (100%)
 copy regression-test/suites/{hdfs_vault/default_vault_p2 => 
nereids_rules_p0/mv/nested}/ddl/part_create.sql (100%)
 copy regression-test/suites/{hdfs_vault/default_vault_p2 => 
nereids_rules_p0/mv/nested}/ddl/part_delete.sql (100%)
 copy regression-test/suites/{hdfs_vault/default_vault_p2 => 
nereids_rules_p0/mv/nested}/ddl/supplier_create.sql (100%)
 copy regression-test/suites/{hdfs_vault/default_vault_p2 => 
nereids_rules_p0/mv/nested}/ddl/supplier_delete.sql (100%)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (f7ffac07d95 -> 41c0e85978d)

2024-05-15 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from f7ffac07d95 [Fix](Nereids) fix leading with cte and same subqueryalias 
name (#34838)
 add 41c0e85978d [fix](nereids)LogicalPlanDeepCopier will lost some info 
when coping logical relation (#34894)

No new revisions were added by this update.

Summary of changes:
 .../nereids/analyzer/UnboundOneRowRelation.java|   5 +
 .../doris/nereids/analyzer/UnboundRelation.java|   5 +
 .../doris/nereids/analyzer/UnboundTVFRelation.java |   5 +
 .../trees/copier/LogicalPlanDeepCopier.java| 112 +
 .../trees/plans/logical/LogicalCTEConsumer.java|   5 +
 .../logical/LogicalDeferMaterializeOlapScan.java   |   6 ++
 .../trees/plans/logical/LogicalEmptyRelation.java  |   5 +
 .../nereids/trees/plans/logical/LogicalEsScan.java |   8 +-
 .../trees/plans/logical/LogicalFileScan.java   |  10 +-
 .../trees/plans/logical/LogicalJdbcScan.java   |   7 +-
 .../trees/plans/logical/LogicalOdbcScan.java   |   7 +-
 .../trees/plans/logical/LogicalOlapScan.java   |  10 ++
 .../trees/plans/logical/LogicalOneRowRelation.java |   5 +
 .../trees/plans/logical/LogicalRelation.java   |   2 +
 .../trees/plans/logical/LogicalSchemaScan.java |   5 +
 .../trees/plans/logical/LogicalTVFRelation.java|   5 +
 .../trees/plans/logical/LogicalTestScan.java   |   5 +
 .../doris/nereids/jobs/RewriteTopDownJobTest.java  |   6 ++
 18 files changed, 146 insertions(+), 67 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](planner)correlated predicate should include isnull predicate (#34833)

2024-05-15 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 27e61b7626c [fix](planner)correlated predicate should include isnull 
predicate (#34833)
27e61b7626c is described below

commit 27e61b7626c571aadad544a69a0529205520950a
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Wed May 15 18:02:18 2024 +0800

[fix](planner)correlated predicate should include isnull predicate (#34833)
---
 .../org/apache/doris/analysis/StmtRewriter.java|  3 +-
 .../correctness_p0/test_subquery_with_agg.groovy   | 41 ++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java
index 62737131b62..93823cf398c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java
@@ -957,7 +957,8 @@ public class StmtRewriter {
  * query block (i.e. is not bound by the given 'tupleIds').
  */
 private static boolean isCorrelatedPredicate(Expr expr, List 
tupleIds) {
-return (expr instanceof BinaryPredicate || expr instanceof SlotRef) && 
!expr.isBoundByTupleIds(tupleIds);
+return (expr instanceof BinaryPredicate || expr instanceof SlotRef
+|| expr instanceof IsNullPredicate) && 
!expr.isBoundByTupleIds(tupleIds);
 }
 
 /**
diff --git 
a/regression-test/suites/correctness_p0/test_subquery_with_agg.groovy 
b/regression-test/suites/correctness_p0/test_subquery_with_agg.groovy
index e0592830ffe..a962d64dcbc 100644
--- a/regression-test/suites/correctness_p0/test_subquery_with_agg.groovy
+++ b/regression-test/suites/correctness_p0/test_subquery_with_agg.groovy
@@ -82,4 +82,45 @@ suite("test_subquery_with_agg") {
 drop table if exists agg_subquery_table;
 """
 
+sql """drop table if exists subquery_table_xyz;"""
+sql """CREATE TABLE `subquery_table_xyz` (
+`phone`bigint(20) NULL
+) ENGINE=OLAP
+DUPLICATE KEY(`phone`)
+COMMENT 'OLAP'
+DISTRIBUTED BY HASH(`phone`) BUCKETS 3
+PROPERTIES (
+"replication_allocation" = "tag.location.default: 1"
+);"""
+sql """WITH tmp1 AS 
+(SELECT DISTINCT phone
+FROM subquery_table_xyz oua
+WHERE (NOT EXISTS 
+(SELECT 1
+FROM subquery_table_xyz o1
+WHERE oua.phone = o1.phone
+AND phone IS NOT NULL))), 
+tmp2 AS 
+(SELECT DISTINCT phone
+FROM subquery_table_xyz oua
+WHERE (NOT EXISTS 
+(SELECT 1
+FROM subquery_table_xyz o1
+WHERE oua.phone = o1.phone
+and phone IS NOT NULL))), 
+tmp3 AS 
+(SELECT DISTINCT phone
+FROM subquery_table_xyz oua
+WHERE (NOT EXISTS 
+(SELECT 1
+FROM subquery_table_xyz o1
+WHERE oua.phone = o1.phone and 
+phone IS NOT NULL)))
+SELECT COUNT(DISTINCT tmp1.phone)
+FROM tmp1
+JOIN tmp2
+ON tmp1.phone = tmp2.phone
+JOIN tmp3
+ON tmp2.phone = tmp3.phone;"""
+
 }


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](nereids)4 phase agg may lost parameter in some case (#34816)

2024-05-15 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 6b39275cea0 [fix](nereids)4 phase agg may lost parameter in some case 
(#34816)
6b39275cea0 is described below

commit 6b39275cea048f65044873a134092b6a33c2e33c
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Wed May 15 17:54:30 2024 +0800

[fix](nereids)4 phase agg may lost parameter in some case (#34816)
---
 .../apache/doris/nereids/rules/implementation/AggregateStrategies.java  | 2 +-
 regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
index edbd28677b4..e1095df7bab 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
@@ -1766,7 +1766,7 @@ public class AggregateStrategies implements 
ImplementationRuleFactory {
 AggregateFunction nonDistinct = 
aggregateFunction
 .withDistinctAndChildren(false, 
ImmutableList.copyOf(aggChild));
 AggregateExpression nonDistinctAggExpr = new 
AggregateExpression(nonDistinct,
-distinctLocalParam, 
aggregateFunction.child(0));
+distinctLocalParam, aggregateFunction);
 return nonDistinctAggExpr;
 } else {
 needUpdateSlot.add(aggregateFunction);
diff --git a/regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy 
b/regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy
index 4a3e60afb73..19cac99c153 100644
--- a/regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy
+++ b/regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy
@@ -56,4 +56,6 @@ suite("agg_4_phase") {
 contains ":VAGGREGATE (update serialize)"
 }
 qt_4phase (test_sql)
+
+sql """select GROUP_CONCAT(distinct name, " ") from agg_4_phase_tbl;"""
 }
\ No newline at end of file


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated: [fix](planner)correlated predicate should include isnull predicate (#34834)

2024-05-15 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 5d719b8e564 [fix](planner)correlated predicate should include isnull 
predicate (#34834)
5d719b8e564 is described below

commit 5d719b8e564e7d9eeef22209480e5d6c4f071984
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Wed May 15 17:48:39 2024 +0800

[fix](planner)correlated predicate should include isnull predicate (#34834)
---
 .../org/apache/doris/analysis/StmtRewriter.java|  3 +-
 .../correctness_p0/test_subquery_with_agg.groovy   | 41 ++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java
index 1ac31c8fc63..032ce708617 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java
@@ -947,7 +947,8 @@ public class StmtRewriter {
  * query block (i.e. is not bound by the given 'tupleIds').
  */
 private static boolean isCorrelatedPredicate(Expr expr, List 
tupleIds) {
-return (expr instanceof BinaryPredicate || expr instanceof SlotRef) && 
!expr.isBoundByTupleIds(tupleIds);
+return (expr instanceof BinaryPredicate || expr instanceof SlotRef
+|| expr instanceof IsNullPredicate) && 
!expr.isBoundByTupleIds(tupleIds);
 }
 
 /**
diff --git 
a/regression-test/suites/correctness_p0/test_subquery_with_agg.groovy 
b/regression-test/suites/correctness_p0/test_subquery_with_agg.groovy
index e0592830ffe..a962d64dcbc 100644
--- a/regression-test/suites/correctness_p0/test_subquery_with_agg.groovy
+++ b/regression-test/suites/correctness_p0/test_subquery_with_agg.groovy
@@ -82,4 +82,45 @@ suite("test_subquery_with_agg") {
 drop table if exists agg_subquery_table;
 """
 
+sql """drop table if exists subquery_table_xyz;"""
+sql """CREATE TABLE `subquery_table_xyz` (
+`phone`bigint(20) NULL
+) ENGINE=OLAP
+DUPLICATE KEY(`phone`)
+COMMENT 'OLAP'
+DISTRIBUTED BY HASH(`phone`) BUCKETS 3
+PROPERTIES (
+"replication_allocation" = "tag.location.default: 1"
+);"""
+sql """WITH tmp1 AS 
+(SELECT DISTINCT phone
+FROM subquery_table_xyz oua
+WHERE (NOT EXISTS 
+(SELECT 1
+FROM subquery_table_xyz o1
+WHERE oua.phone = o1.phone
+AND phone IS NOT NULL))), 
+tmp2 AS 
+(SELECT DISTINCT phone
+FROM subquery_table_xyz oua
+WHERE (NOT EXISTS 
+(SELECT 1
+FROM subquery_table_xyz o1
+WHERE oua.phone = o1.phone
+and phone IS NOT NULL))), 
+tmp3 AS 
+(SELECT DISTINCT phone
+FROM subquery_table_xyz oua
+WHERE (NOT EXISTS 
+(SELECT 1
+FROM subquery_table_xyz o1
+WHERE oua.phone = o1.phone and 
+phone IS NOT NULL)))
+SELECT COUNT(DISTINCT tmp1.phone)
+FROM tmp1
+JOIN tmp2
+ON tmp1.phone = tmp2.phone
+JOIN tmp3
+ON tmp2.phone = tmp3.phone;"""
+
 }


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated: [fix](nereids)4 phase agg may lost parameter in some case (#34826)

2024-05-15 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new f3622800cb2 [fix](nereids)4 phase agg may lost parameter in some case 
(#34826)
f3622800cb2 is described below

commit f3622800cb2dcdf54011d7ae17d69f5fb730c0d2
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Wed May 15 17:48:20 2024 +0800

[fix](nereids)4 phase agg may lost parameter in some case (#34826)
---
 .../apache/doris/nereids/rules/implementation/AggregateStrategies.java  | 2 +-
 regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
index 10b21d0b979..7f31585fd66 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/implementation/AggregateStrategies.java
@@ -1734,7 +1734,7 @@ public class AggregateStrategies implements 
ImplementationRuleFactory {
 AggregateFunction nonDistinct = 
aggregateFunction
 .withDistinctAndChildren(false, 
ImmutableList.copyOf(aggChild));
 AggregateExpression nonDistinctAggExpr = new 
AggregateExpression(nonDistinct,
-distinctLocalParam, 
aggregateFunction.child(0));
+distinctLocalParam, aggregateFunction);
 return nonDistinctAggExpr;
 } else {
 needUpdateSlot.add(aggregateFunction);
diff --git a/regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy 
b/regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy
index 4a3e60afb73..a9a10e66992 100644
--- a/regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy
+++ b/regression-test/suites/nereids_syntax_p0/agg_4_phase.groovy
@@ -56,4 +56,5 @@ suite("agg_4_phase") {
 contains ":VAGGREGATE (update serialize)"
 }
 qt_4phase (test_sql)
+sql """select GROUP_CONCAT(distinct name, " ") from agg_4_phase_tbl;"""
 }
\ No newline at end of file


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (976cb35dcb7 -> adcbc8cce57)

2024-05-14 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 976cb35dcb7 [Chore](rollup) check duplicate column name when create 
table with rollup (#34827)
 add adcbc8cce57 [feature](Nereids) support select distinct with aggregate

No new revisions were added by this update.

Summary of changes:
 .../java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java | 4 
 regression-test/suites/nereids_syntax_p0/window_function.groovy  | 9 +
 2 files changed, 9 insertions(+), 4 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated: [opt](Nereids) support where, group by, having, order by clause without from clause in query statement (#34475)

2024-05-08 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 68c8bce8300 [opt](Nereids) support where, group by, having, order by 
clause without from clause in query statement (#34475)
68c8bce8300 is described below

commit 68c8bce8300a4f0ed6c457fa235923fc9ca8d9d6
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Thu May 9 10:18:42 2024 +0800

[opt](Nereids) support where, group by, having, order by clause without 
from clause in query statement (#34475)
---
 .../java/org/apache/doris/catalog/ScalarType.java  |  8 +++-
 .../doris/nereids/parser/LogicalPlanBuilder.java   | 19 +
 .../nereids/rules/analysis/BindExpression.java |  7 +++
 .../rules/analysis/FunctionRegistryTest.java   | 18 
 .../doris/nereids/trees/expressions/UdfTest.java   | 24 +++---
 .../select_no_from/sql/withWhereFalse.out  |  3 +++
 .../select_no_from/sql/withWhereFalse.sql  |  2 ++
 .../suites/nereids_syntax_p0/bind_priority.groovy  |  2 +-
 .../nereids_syntax_p0/one_row_relation.groovy  |  7 ---
 9 files changed, 51 insertions(+), 39 deletions(-)

diff --git 
a/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java 
b/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java
index cd635649fd1..3db3739d08a 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java
@@ -1095,7 +1095,13 @@ public class ScalarType extends Type {
 if (t1.type == PrimitiveType.STRING || t2.type == 
PrimitiveType.STRING) {
 return createStringType();
 }
-return createVarcharType(Math.max(t1.len, t2.len));
+int minLength = Math.min(t1.len, t2.len);
+if (minLength < 0) {
+// If < 0 which means max length, use firstly
+return createVarcharType(minLength);
+}
+int length = Math.max(t1.len, t2.len);
+return createVarcharType(length == 0 ? MAX_VARCHAR_LENGTH : 
length);
 }
 
 if (((t1.isDecimalV3() || t1.isDecimalV2()) && (t2.isDateV2() || 
t2.isDate()))
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index 873d7f28c19..289097ca2ef 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -585,22 +585,23 @@ public class LogicalPlanBuilder extends 
DorisParserBaseVisitor {
 return ParserUtils.withOrigin(ctx, () -> {
 SelectClauseContext selectCtx = ctx.selectClause();
 LogicalPlan selectPlan;
+LogicalPlan relation;
 if (ctx.fromClause() == null) {
 SelectColumnClauseContext columnCtx = 
selectCtx.selectColumnClause();
 if (columnCtx.EXCEPT() != null) {
 throw new ParseException("select-except cannot be used in 
one row relation", selectCtx);
 }
-selectPlan = withOneRowRelation(columnCtx);
+relation = new 
UnboundOneRowRelation(StatementScopeIdGenerator.newRelationId(),
+ImmutableList.of(new UnboundAlias(Literal.of(0;
 } else {
-LogicalPlan relation = visitFromClause(ctx.fromClause());
-selectPlan = withSelectQuerySpecification(
-ctx, relation,
-selectCtx,
-Optional.ofNullable(ctx.whereClause()),
-Optional.ofNullable(ctx.aggClause()),
-Optional.ofNullable(ctx.havingClause())
-);
+relation = visitFromClause(ctx.fromClause());
 }
+selectPlan = withSelectQuerySpecification(
+ctx, relation,
+selectCtx,
+Optional.ofNullable(ctx.whereClause()),
+Optional.ofNullable(ctx.aggClause()),
+Optional.ofNullable(ctx.havingClause()));
 selectPlan = withQueryOrganization(selectPlan, 
ctx.queryOrganization());
 return withSelectHint(selectPlan, selectCtx.selectHint());
 });
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
index e0f0d1baa78..72af439f452 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpr

(doris) branch master updated (14b6bb38a3d -> 6e94ac902fa)

2024-04-27 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 14b6bb38a3d [fix](test) fix some external test cases (#34210)
 add 6e94ac902fa [Feat](nereids)nereids support create table like (#34025)

No new revisions were added by this update.

Summary of changes:
 .../antlr4/org/apache/doris/nereids/DorisParser.g4 |  3 +
 .../doris/nereids/parser/LogicalPlanBuilder.java   | 20 ++
 .../apache/doris/nereids/trees/plans/PlanType.java |  4 +-
 ...iewCommand.java => CreateTableLikeCommand.java} | 26 
 .../plans/commands/info/CreateTableLikeInfo.java   | 77 ++
 .../trees/plans/visitor/CommandVisitor.java|  5 ++
 .../data/ddl_p0/test_create_table_like_nereids.out | 20 ++
 .../ddl_p0/test_create_table_like_nereids.groovy   | 75 +
 8 files changed, 215 insertions(+), 15 deletions(-)
 copy 
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/{CreateViewCommand.java
 => CreateTableLikeCommand.java} (68%)
 create mode 100644 
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableLikeInfo.java
 create mode 100644 
regression-test/data/ddl_p0/test_create_table_like_nereids.out
 create mode 100644 
regression-test/suites/ddl_p0/test_create_table_like_nereids.groovy


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (d4cdd289d37 -> f34114d35fe)

2024-04-25 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from d4cdd289d37 Support high priority column stats auto collection. 
(#33703)
 add f34114d35fe [Fix](nereids) fix rule merge_aggregate when has project 
(#33892)

No new revisions were added by this update.

Summary of changes:
 .../doris/nereids/jobs/executor/Rewriter.java  |  4 +-
 .../nereids/rules/rewrite/MergeAggregate.java  | 23 ---
 .../merge_aggregate/merge_aggregate.out| 51 ++
 .../merge_aggregate/merge_aggregate.groovy | 80 ++
 4 files changed, 148 insertions(+), 10 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](planner)date_add function should accept date type as its param (#34035)

2024-04-25 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 e6801105349 [fix](planner)date_add function should accept date type as 
its param (#34035)
e6801105349 is described below

commit e6801105349b262f4ca5eef7812d764a124dd57c
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Fri Apr 26 09:38:10 2024 +0800

[fix](planner)date_add function should accept date type as its param 
(#34035)
---
 .../java/org/apache/doris/analysis/FunctionCallExpr.java | 16 
 gensrc/script/doris_builtins_functions.py|  2 ++
 .../suites/correctness/test_date_function_const.groovy   |  5 -
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
index 9cfce9e67de..3978c3802bc 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
@@ -1658,6 +1658,22 @@ public class FunctionCallExpr extends Expr {
 }
 fn = getBuiltinFunction(fnName.getFunction(), argTypes,
 Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
+} else if (fnName.getFunction().equalsIgnoreCase("date_add")
+|| fnName.getFunction().equalsIgnoreCase("days_add")
+|| fnName.getFunction().equalsIgnoreCase("adddate")
+|| fnName.getFunction().equalsIgnoreCase("date_sub")
+|| fnName.getFunction().equalsIgnoreCase("days_sub")
+|| fnName.getFunction().equalsIgnoreCase("subdate")) {
+Type[] childTypes = collectChildReturnTypes();
+argTypes[0] = childTypes[0];
+argTypes[1] = childTypes[1];
+if (childTypes[1] == Type.TINYINT || childTypes[1] == 
Type.SMALLINT) {
+// be only support second param as int type
+uncheckedCastChild(Type.INT, 1);
+argTypes[1] = Type.INT;
+}
+fn = getBuiltinFunction(fnName.getFunction(), argTypes,
+Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
 } else {
 // now first find table function in table function sets
 if (isTableFnCall) {
diff --git a/gensrc/script/doris_builtins_functions.py 
b/gensrc/script/doris_builtins_functions.py
index 841799f0a13..b7912d08904 100644
--- a/gensrc/script/doris_builtins_functions.py
+++ b/gensrc/script/doris_builtins_functions.py
@@ -1080,6 +1080,8 @@ visible_functions = {
 [['weeks_sub'], 'DATEV2', ['DATEV2', 'INT'], ''],
 [['days_add', 'date_add', 'adddate'], 'DATEV2', ['DATEV2', 'INT'], ''],
 [['days_sub', 'date_sub', 'subdate'], 'DATEV2', ['DATEV2', 'INT'], ''],
+[['days_add', 'date_add', 'adddate'], 'DATE', ['DATE', 'INT'], ''],
+[['days_sub', 'date_sub', 'subdate'], 'DATE', ['DATE', 'INT'], ''],
 [['hours_add'], 'DATETIMEV2', ['DATEV2', 'INT'], ''],
 [['hours_sub'], 'DATETIMEV2', ['DATEV2', 'INT'], ''],
 [['minutes_add'], 'DATETIMEV2', ['DATEV2', 'INT'], ''],
diff --git a/regression-test/suites/correctness/test_date_function_const.groovy 
b/regression-test/suites/correctness/test_date_function_const.groovy
index 85d8e5ba711..df05738b1bf 100644
--- a/regression-test/suites/correctness/test_date_function_const.groovy
+++ b/regression-test/suites/correctness/test_date_function_const.groovy
@@ -57,5 +57,8 @@ suite("test_date_function_const") {
 qt_select10 """
 select hours_add(cast('2023-03-30 22:23:45.23452' as datetimev2(6)),8)
 """ 
-
+explain {
+sql("""select date_add(CURRENT_DATE(),-2);""")
+notContains("00:00:00")
+}
 }
\ No newline at end of file


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](nereids)move ReplaceVariableByLiteral rule to analyze phase (#33997)

2024-04-25 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 05e734a8e6b [fix](nereids)move ReplaceVariableByLiteral rule to 
analyze phase (#33997)
05e734a8e6b is described below

commit 05e734a8e6b033d11caf9d4f03e624554e23ec7c
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Fri Apr 26 09:36:05 2024 +0800

[fix](nereids)move ReplaceVariableByLiteral rule to analyze phase (#33997)
---
 .../doris/nereids/jobs/executor/Analyzer.java  | 12 +++
 .../nereids/rules/analysis/VariableToLiteral.java  | 37 --
 .../rules/expression/ExpressionNormalization.java  |  2 --
 .../suites/nereids_p0/test_user_var.groovy | 35 
 4 files changed, 68 insertions(+), 18 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java
index a0431e066be..ac0a4421071 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java
@@ -44,6 +44,7 @@ import 
org.apache.doris.nereids.rules.analysis.ProjectToGlobalAggregate;
 import org.apache.doris.nereids.rules.analysis.ProjectWithDistinctToAggregate;
 import org.apache.doris.nereids.rules.analysis.ReplaceExpressionByChildOutput;
 import org.apache.doris.nereids.rules.analysis.SubqueryToApply;
+import org.apache.doris.nereids.rules.analysis.VariableToLiteral;
 import org.apache.doris.nereids.rules.rewrite.MergeProjects;
 import org.apache.doris.nereids.rules.rewrite.SemiJoinCommute;
 import org.apache.doris.nereids.rules.rewrite.SimplifyAggGroupBy;
@@ -157,6 +158,17 @@ public class Analyzer extends AbstractBatchJobExecutor {
 new NormalizeRepeat()
 ),
 bottomUp(new AdjustAggregateNullableForEmptySet()),
+// consider sql with user defined var @t_zone
+// set @t_zone='GMT';
+// SELECT
+// DATE_FORMAT(convert_tz(dt, time_zone, @t_zone),'%Y-%m-%d') 
day
+// FROM
+// t
+// GROUP BY
+// 1;
+// @t_zone must be replaced as 'GMT' before 
EliminateGroupByConstant and NormalizeAggregate rule.
+// So need run VariableToLiteral rule before the two rules.
+topDown(new VariableToLiteral()),
 // run CheckAnalysis before EliminateGroupByConstant in order to 
report error message correctly like bellow
 // select SUM(lo_tax) FROM lineorder group by 1;
 // errCode = 2, detailMessage = GROUP BY expression must not 
contain aggregate functions: sum(lo_tax)
diff --git a/regression-test/suites/nereids_p0/test_user_var.groovy 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/VariableToLiteral.java
similarity index 50%
copy from regression-test/suites/nereids_p0/test_user_var.groovy
copy to 
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/VariableToLiteral.java
index d5eb164e3f9..c7ba1bfe6a7 100644
--- a/regression-test/suites/nereids_p0/test_user_var.groovy
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/VariableToLiteral.java
@@ -15,20 +15,25 @@
 // specific language governing permissions and limitations
 // under the License.
 
-suite("test_user_var") {
-sql "SET enable_nereids_planner=true"
-sql "SET enable_fallback_to_original_planner=false"
-sql "SET @a1=1, @a2=0, @a3=-1"
-sql "SET @b1=1.1, @b2=0.0, @b3=-1.1"
-sql "SET @c1='H', @c2=''"
-sql "SET @d1=true, @d2=false"
-sql "SET @f1=null"
-sql "set @func_1=(abs(1) + 1) * 2"
+package org.apache.doris.nereids.rules.analysis;
 
-qt_integer 'select @a1, @a2, @a3;'
-qt_decimal 'select @b1, @b2, @b3;'
-qt_string 'select @c1, @c2;'
-qt_boolean 'select @d1, @d2;'
-qt_null_literal 'select @f1, @f2;'
-qt_function 'select @func_1'
-}
\ No newline at end of file
+import org.apache.doris.nereids.rules.expression.ExpressionRewrite;
+import org.apache.doris.nereids.rules.expression.ExpressionRewriteRule;
+import org.apache.doris.nereids.rules.expression.ExpressionRuleExecutor;
+import 
org.apache.doris.nereids.rules.expression.rules.ReplaceVariableByLiteral;
+
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/**
+ * replace Variable To Literal
+ */
+public class VariableToLiteral extends ExpressionRewrite {
+public static final List NORMALIZE_REWRITE_RULES =
+ImmutableList.of(bottomUp(ReplaceVariableByLiteral.INSTANCE));
+
+public VariableToLiteral() {
+super(new ExpressionRul

(doris) branch branch-2.0 updated: [fix](planner)cast expr should do nothing in compactForLiteral method (#34051)

2024-04-25 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new a8120e97537 [fix](planner)cast expr should do nothing in 
compactForLiteral method (#34051)
a8120e97537 is described below

commit a8120e97537234d948545fbed5834125d097b8dd
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Fri Apr 26 09:35:54 2024 +0800

[fix](planner)cast expr should do nothing in compactForLiteral method 
(#34051)
---
 .../src/main/java/org/apache/doris/analysis/CastExpr.java |  5 +
 .../suites/correctness_p0/test_cast_decimal.groovy| 11 +++
 2 files changed, 16 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
index d592f50f352..fe464bf25bd 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
@@ -586,5 +586,10 @@ public class CastExpr extends Expr {
 public boolean isNotFold() {
 return this.notFold;
 }
+
+@Override
+protected void compactForLiteral(Type type) {
+// do nothing
+}
 }
 
diff --git a/regression-test/suites/correctness_p0/test_cast_decimal.groovy 
b/regression-test/suites/correctness_p0/test_cast_decimal.groovy
index 88859ea1d52..21a1ab6d0c3 100644
--- a/regression-test/suites/correctness_p0/test_cast_decimal.groovy
+++ b/regression-test/suites/correctness_p0/test_cast_decimal.groovy
@@ -34,4 +34,15 @@ suite("test_cast_decimal") {
 sql """select cast(32123.34212456734 as decimal(3,2));"""
 contains "CAST(32123.34212456734 AS DECIMALV3(3, 2))"
 }
+
+sql """drop table if exists test_ttt"""
+sql """create table test_ttt(big_key bigint)DISTRIBUTED BY HASH(big_key) 
BUCKETS 1 PROPERTIES ("replication_num" = "1");"""
+sql """set enable_nereids_planner=false;"""
+sql """set enable_fold_constant_by_be = false; """
+sql """SELECT 1
+FROM test_ttt e1
+HAVING truncate(100, 2) < -2308.57
+AND cast(round(round(465.56, min(-5.987)), 2) AS DECIMAL) in
+(SELECT cast(truncate(round(8990.65 - 4556.2354, 2.4652), 2)AS 
DECIMAL)
+FROM test_ttt r2);"""
 }


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](planner)cast expr should do nothing in compactForLiteral method (#34047)

2024-04-25 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 837b5e83d0b [fix](planner)cast expr should do nothing in 
compactForLiteral method (#34047)
837b5e83d0b is described below

commit 837b5e83d0b30391c1847e58dfd84c40dcca6e7b
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Fri Apr 26 09:35:47 2024 +0800

[fix](planner)cast expr should do nothing in compactForLiteral method 
(#34047)
---
 .../src/main/java/org/apache/doris/analysis/CastExpr.java |  5 +
 .../suites/correctness_p0/test_cast_decimal.groovy| 11 +++
 2 files changed, 16 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
index 739901b7929..c73afac14c8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
@@ -592,4 +592,9 @@ public class CastExpr extends Expr {
 public boolean isNotFold() {
 return this.notFold;
 }
+
+@Override
+protected void compactForLiteral(Type type) {
+// do nothing
+}
 }
diff --git a/regression-test/suites/correctness_p0/test_cast_decimal.groovy 
b/regression-test/suites/correctness_p0/test_cast_decimal.groovy
index 88859ea1d52..21a1ab6d0c3 100644
--- a/regression-test/suites/correctness_p0/test_cast_decimal.groovy
+++ b/regression-test/suites/correctness_p0/test_cast_decimal.groovy
@@ -34,4 +34,15 @@ suite("test_cast_decimal") {
 sql """select cast(32123.34212456734 as decimal(3,2));"""
 contains "CAST(32123.34212456734 AS DECIMALV3(3, 2))"
 }
+
+sql """drop table if exists test_ttt"""
+sql """create table test_ttt(big_key bigint)DISTRIBUTED BY HASH(big_key) 
BUCKETS 1 PROPERTIES ("replication_num" = "1");"""
+sql """set enable_nereids_planner=false;"""
+sql """set enable_fold_constant_by_be = false; """
+sql """SELECT 1
+FROM test_ttt e1
+HAVING truncate(100, 2) < -2308.57
+AND cast(round(round(465.56, min(-5.987)), 2) AS DECIMAL) in
+(SELECT cast(truncate(round(8990.65 - 4556.2354, 2.4652), 2)AS 
DECIMAL)
+FROM test_ttt r2);"""
 }


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated: [fix](nereids)prevent null pointer access if translate expression fails (#34055)

2024-04-25 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new a793ca825b9 [fix](nereids)prevent null pointer access if translate 
expression fails (#34055)
a793ca825b9 is described below

commit a793ca825b946db31606d55a14fc60a656dc98fa
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Fri Apr 26 09:26:55 2024 +0800

[fix](nereids)prevent null pointer access if translate expression fails 
(#34055)
---
 .../doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java   | 5 +
 1 file changed, 5 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
index e334eb8425e..89955dc4950 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
@@ -136,6 +136,11 @@ public class FoldConstantRuleOnBE extends 
AbstractExpressionRewriteRule {
 LOG.warn("expression {} translate to legacy expr failed. ", 
expr, e);
 return;
 }
+if (staleExpr == null) {
+// just return, it's a fail-safe
+LOG.warn("expression {} translate to legacy expr failed. ", 
expr);
+return;
+}
 tExprMap.put(id, staleExpr.treeToThrift());
 } else {
 for (int i = 0; i < expr.children().size(); i++) {


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](nereids)prevent null pointer access if translate expression fails (#33990)

2024-04-25 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 0038423c026 [fix](nereids)prevent null pointer access if translate 
expression fails (#33990)
0038423c026 is described below

commit 0038423c026cbe057237a25d5654fedad5cd3fd3
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Fri Apr 26 09:26:36 2024 +0800

[fix](nereids)prevent null pointer access if translate expression fails 
(#33990)
---
 .../doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java   | 5 +
 1 file changed, 5 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
index 3c2f0d546dd..e0e19bd19e2 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java
@@ -215,6 +215,11 @@ public class FoldConstantRuleOnBE implements 
ExpressionPatternRuleFactory {
 LOG.warn("expression {} translate to legacy expr failed. ", 
expr, e);
 return;
 }
+if (staleExpr == null) {
+// just return, it's a fail-safe
+LOG.warn("expression {} translate to legacy expr failed. ", 
expr);
+return;
+}
 tExprMap.put(id, staleExpr.treeToThrift());
 } else {
 for (int i = 0; i < expr.children().size(); i++) {


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated: [fix](nereids)move ReplaceVariableByLiteral rule to analyze phase (#34023)

2024-04-25 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new fa7c1f77803 [fix](nereids)move ReplaceVariableByLiteral rule to 
analyze phase (#34023)
fa7c1f77803 is described below

commit fa7c1f778032adb1fb3fff6d439872862a0fe1c7
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Thu Apr 25 18:51:14 2024 +0800

[fix](nereids)move ReplaceVariableByLiteral rule to analyze phase (#34023)
---
 .../doris/nereids/jobs/executor/Analyzer.java  | 12 
 .../nereids/rules/analysis/VariableToLiteral.java  | 35 +-
 .../rules/expression/ExpressionNormalization.java  |  2 --
 .../suites/nereids_p0/test_user_var.groovy | 28 +
 4 files changed, 61 insertions(+), 16 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java
index 78fdd17a7a6..2432661a568 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java
@@ -41,6 +41,7 @@ import 
org.apache.doris.nereids.rules.analysis.ProjectWithDistinctToAggregate;
 import org.apache.doris.nereids.rules.analysis.ReplaceExpressionByChildOutput;
 import 
org.apache.doris.nereids.rules.analysis.ResolveOrdinalInOrderByAndGroupBy;
 import org.apache.doris.nereids.rules.analysis.SubqueryToApply;
+import org.apache.doris.nereids.rules.analysis.VariableToLiteral;
 import org.apache.doris.nereids.rules.rewrite.JoinCommute;
 import org.apache.doris.nereids.rules.rewrite.MergeProjects;
 
@@ -150,6 +151,17 @@ public class Analyzer extends AbstractBatchJobExecutor {
 new NormalizeRepeat()
 ),
 bottomUp(new AdjustAggregateNullableForEmptySet()),
+// consider sql with user defined var @t_zone
+// set @t_zone='GMT';
+// SELECT
+// DATE_FORMAT(convert_tz(dt, time_zone, @t_zone),'%Y-%m-%d') 
day
+// FROM
+// t
+// GROUP BY
+// 1;
+// @t_zone must be replaced as 'GMT' before 
EliminateGroupByConstant and NormalizeAggregate rule.
+// So need run VariableToLiteral rule before the two rules.
+topDown(new VariableToLiteral()),
 // run CheckAnalysis before EliminateGroupByConstant in order to 
report error message correctly like bellow
 // select SUM(lo_tax) FROM lineorder group by 1;
 // errCode = 2, detailMessage = GROUP BY expression must not 
contain aggregate functions: sum(lo_tax)
diff --git a/regression-test/suites/nereids_p0/test_user_var.groovy 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/VariableToLiteral.java
similarity index 51%
copy from regression-test/suites/nereids_p0/test_user_var.groovy
copy to 
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/VariableToLiteral.java
index f54e139632d..912310ea32b 100644
--- a/regression-test/suites/nereids_p0/test_user_var.groovy
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/VariableToLiteral.java
@@ -15,18 +15,25 @@
 // specific language governing permissions and limitations
 // under the License.
 
-suite("test_user_var") {
-sql "SET enable_nereids_planner=true"
-sql "SET enable_fallback_to_original_planner=false"
-sql "SET @a1=1, @a2=0, @a3=-1"
-sql "SET @b1=1.1, @b2=0.0, @b3=-1.1"
-sql "SET @c1='H', @c2=''"
-sql "SET @d1=true, @d2=false"
-sql "SET @f1=null"
+package org.apache.doris.nereids.rules.analysis;
 
-qt_select1 'select @a1, @a2, @a3;'
-qt_select2 'select @b1, @b2, @b3;'
-qt_select3 'select @c1, @c2;'
-qt_select4 'select @d1, @d2;'
-qt_select5 'select @f1, @f2;'
-}
\ No newline at end of file
+import org.apache.doris.nereids.rules.expression.ExpressionRewrite;
+import org.apache.doris.nereids.rules.expression.ExpressionRewriteRule;
+import org.apache.doris.nereids.rules.expression.ExpressionRuleExecutor;
+import 
org.apache.doris.nereids.rules.expression.rules.ReplaceVariableByLiteral;
+
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+/**
+ * replace Variable To Literal
+ */
+public class VariableToLiteral extends ExpressionRewrite {
+public static final List NORMALIZE_REWRITE_RULES =
+ImmutableList.of(ReplaceVariableByLiteral.INSTANCE);
+
+public VariableToLiteral() {
+super(new ExpressionRuleExecutor(NORMALIZE_REWRITE_RULES));
+}
+}
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/ExpressionNor

(doris) branch branch-2.0 updated: [fix](planner)date_add function should accept date type as its param (#34036)

2024-04-25 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 93471ca93e0 [fix](planner)date_add function should accept date type as 
its param (#34036)
93471ca93e0 is described below

commit 93471ca93e0515cc62a5595dd5dec8e8ec5b8380
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Thu Apr 25 18:50:49 2024 +0800

[fix](planner)date_add function should accept date type as its param 
(#34036)
---
 .../java/org/apache/doris/analysis/FunctionCallExpr.java | 16 
 gensrc/script/doris_builtins_functions.py|  2 ++
 .../suites/correctness/test_date_function_const.groovy   |  5 -
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
index b7bc0cea969..1a52c965818 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
@@ -1602,6 +1602,22 @@ public class FunctionCallExpr extends Expr {
 }
 fn = getBuiltinFunction(fnName.getFunction(), argTypes,
 Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
+} else if (fnName.getFunction().equalsIgnoreCase("date_add")
+|| fnName.getFunction().equalsIgnoreCase("days_add")
+|| fnName.getFunction().equalsIgnoreCase("adddate")
+|| fnName.getFunction().equalsIgnoreCase("date_sub")
+|| fnName.getFunction().equalsIgnoreCase("days_sub")
+|| fnName.getFunction().equalsIgnoreCase("subdate")) {
+Type[] childTypes = collectChildReturnTypes();
+argTypes[0] = childTypes[0];
+argTypes[1] = childTypes[1];
+if (childTypes[1] == Type.TINYINT || childTypes[1] == 
Type.SMALLINT) {
+// be only support second param as int type
+uncheckedCastChild(Type.INT, 1);
+argTypes[1] = Type.INT;
+}
+fn = getBuiltinFunction(fnName.getFunction(), argTypes,
+Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
 } else {
 // now first find table function in table function sets
 if (isTableFnCall) {
diff --git a/gensrc/script/doris_builtins_functions.py 
b/gensrc/script/doris_builtins_functions.py
index e7a0f1ec278..9fa38174be1 100644
--- a/gensrc/script/doris_builtins_functions.py
+++ b/gensrc/script/doris_builtins_functions.py
@@ -1028,6 +1028,8 @@ visible_functions = {
 [['weeks_sub'], 'DATEV2', ['DATEV2', 'INT'], ''],
 [['days_add', 'date_add', 'adddate'], 'DATEV2', ['DATEV2', 'INT'], ''],
 [['days_sub', 'date_sub', 'subdate'], 'DATEV2', ['DATEV2', 'INT'], ''],
+[['days_add', 'date_add', 'adddate'], 'DATE', ['DATE', 'INT'], ''],
+[['days_sub', 'date_sub', 'subdate'], 'DATE', ['DATE', 'INT'], ''],
 [['hours_add'], 'DATETIMEV2', ['DATEV2', 'INT'], ''],
 [['hours_sub'], 'DATETIMEV2', ['DATEV2', 'INT'], ''],
 [['minutes_add'], 'DATETIMEV2', ['DATEV2', 'INT'], ''],
diff --git a/regression-test/suites/correctness/test_date_function_const.groovy 
b/regression-test/suites/correctness/test_date_function_const.groovy
index fd5607d519e..2b423e4e933 100644
--- a/regression-test/suites/correctness/test_date_function_const.groovy
+++ b/regression-test/suites/correctness/test_date_function_const.groovy
@@ -55,5 +55,8 @@ suite("test_date_function_const") {
 qt_select10 """
 select hours_add(cast('2023-03-30 22:23:45.23452' as datetimev2(6)),8)
 """ 
-
+explain {
+sql("""select date_add(CURRENT_DATE(),-2);""")
+notContains("00:00:00")
+}
 }
\ No newline at end of file


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated: [fix](nereids) do not transpose semi join agg when mark join (#33949)

2024-04-23 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 325e18d743f [fix](nereids) do not transpose semi join agg when mark 
join (#33949)
325e18d743f is described below

commit 325e18d743fbf6d7867c126f513c4383eafa8d38
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Wed Apr 24 09:40:19 2024 +0800

[fix](nereids) do not transpose semi join agg when mark join (#33949)
---
 .../rules/rewrite/TransposeSemiJoinAgg.java|   1 +
 .../rules/rewrite/TransposeSemiJoinAggProject.java |   1 +
 .../transposeJoin/transposeSemiJoinAgg.out |  89 
 .../transposeJoin/transposeSemiJoinAgg.groovy  | 151 +
 4 files changed, 242 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinAgg.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinAgg.java
index 1a86e933a51..b0d47f9e64f 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinAgg.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinAgg.java
@@ -36,6 +36,7 @@ public class TransposeSemiJoinAgg extends 
OneRewriteRuleFactory {
 return logicalJoin(logicalAggregate(), any())
 .whenNot(join -> 
ConnectContext.get().getSessionVariable().isDisableJoinReorder())
 .when(join -> join.getJoinType().isLeftSemiOrAntiJoin())
+.whenNot(join -> join.isMarkJoin())
 .then(join -> {
 LogicalAggregate aggregate = join.left();
 if (!canTranspose(aggregate, join)) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinAggProject.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinAggProject.java
index 24ca535eed8..0bbc65a1f2a 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinAggProject.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/TransposeSemiJoinAggProject.java
@@ -34,6 +34,7 @@ public class TransposeSemiJoinAggProject extends 
OneRewriteRuleFactory {
 return logicalJoin(logicalProject(logicalAggregate()), any())
 .whenNot(join -> 
ConnectContext.get().getSessionVariable().isDisableJoinReorder())
 .when(join -> join.getJoinType().isLeftSemiOrAntiJoin())
+.whenNot(join -> join.isMarkJoin())
 .when(join -> join.left().isAllSlots())
 .when(join -> join.left().getProjects().stream().allMatch(n -> 
n instanceof Slot))
 .then(join -> {
diff --git 
a/regression-test/data/nereids_rules_p0/transposeJoin/transposeSemiJoinAgg.out 
b/regression-test/data/nereids_rules_p0/transposeJoin/transposeSemiJoinAgg.out
new file mode 100644
index 000..79378dff1bf
--- /dev/null
+++ 
b/regression-test/data/nereids_rules_p0/transposeJoin/transposeSemiJoinAgg.out
@@ -0,0 +1,89 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !groupby_positive_case --
+PhysicalResultSink
+--hashAgg[LOCAL]
+hashJoin[LEFT_SEMI_JOIN](T3.a = T2.a)
+--filter((T1.__DORIS_DELETE_SIGN__ = 0))
+PhysicalOlapScan[T1]
+--filter((T2.__DORIS_DELETE_SIGN__ = 0))
+PhysicalOlapScan[T2]
+
+-- !groupby_negative_case --
+PhysicalResultSink
+--hashJoin[LEFT_SEMI_JOIN](T3.D = expr_cast(a as BIGINT))
+hashAgg[LOCAL]
+--filter((T1.__DORIS_DELETE_SIGN__ = 0))
+PhysicalOlapScan[T1]
+filter((T2.__DORIS_DELETE_SIGN__ = 0))
+--PhysicalOlapScan[T2]
+
+-- !grouping_positive_case --
+PhysicalResultSink
+--hashJoin[LEFT_SEMI_JOIN](T3.a = T2.a)
+hashAgg[GLOBAL]
+--hashAgg[LOCAL]
+PhysicalRepeat
+--filter((T1.__DORIS_DELETE_SIGN__ = 0))
+PhysicalOlapScan[T1]
+filter((T2.__DORIS_DELETE_SIGN__ = 0))
+--PhysicalOlapScan[T2]
+
+-- !grouping_negative_case --
+PhysicalResultSink
+--hashJoin[LEFT_SEMI_JOIN](T3.D = expr_cast(a as BIGINT))
+hashAgg[GLOBAL]
+--hashAgg[LOCAL]
+PhysicalRepeat
+--filter((T1.__DORIS_DELETE_SIGN__ = 0))
+PhysicalOlapScan[T1]
+filter((T2.__DORIS_DELETE_SIGN__ = 0))
+--PhysicalOlapScan[T2]
+
+-- !groupby_positive_case2 --
+PhysicalResultSink
+--hashAgg[LOCAL]
+hashJoin[LEFT_SEMI_JOIN](T3.a = T2.a)
+--filter((T1.__DORIS_DELETE_SIGN__ = 0))
+PhysicalOlapScan[T1]
+--filter((T2.__DORIS_DELETE_SIGN__ = 0))
+PhysicalOlapScan[T2]
+
+-- !groupby_negative_case2 --
+PhysicalResultSink
+--hashJoin[LEFT_SEMI_JOIN](T3.D = expr_cast(a as BIGINT))
+hashAgg[LOCAL]
+---

(doris) branch master updated: [Fix](planner) fix create view star except and modify cast to sql (#33726)

2024-04-18 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 c6b766722be [Fix](planner) fix create view star except and modify cast 
to sql (#33726)
c6b766722be is described below

commit c6b766722beb669462f74b70f13745f53ed195e1
Author: feiniaofeiafei <53502832+feiniaofeia...@users.noreply.github.com>
AuthorDate: Fri Apr 19 10:43:54 2024 +0800

[Fix](planner) fix create view star except and modify cast to sql (#33726)
---
 .../java/org/apache/doris/catalog/ScalarType.java  |  2 +-
 .../java/org/apache/doris/analysis/CastExpr.java   |  2 +-
 .../java/org/apache/doris/analysis/SelectStmt.java |  7 ++--
 .../analysis/CreateTableAsSelectStmtTest.java  |  4 +-
 .../doris/planner/TableFunctionPlanTest.java   |  2 +-
 .../create_view_star_except_and_cast_to_sql.out| 11 ++
 .../create_view_star_except_and_cast_to_sql.groovy | 45 ++
 7 files changed, 64 insertions(+), 9 deletions(-)

diff --git 
a/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java 
b/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java
index adf064c..8e8a66849e2 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java
@@ -626,7 +626,7 @@ public class ScalarType extends Type {
 break;
 case VARCHAR:
 if (isWildcardVarchar()) {
-stringBuilder.append("VARCHAR(*)");
+return "VARCHAR(" + MAX_VARCHAR_LENGTH + ")";
 } else if (Strings.isNullOrEmpty(lenStr)) {
 
stringBuilder.append("VARCHAR").append("(").append(len).append(")");
 } else {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
index d2437fbd95c..739901b7929 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
@@ -213,7 +213,7 @@ public class CastExpr extends Expr {
 return getChild(0).toSql();
 }
 if (isAnalyzed) {
-return "CAST(" + getChild(0).toSql() + " AS " + type.toString() + 
")";
+return "CAST(" + getChild(0).toSql() + " AS " + type.toSql() + ")";
 } else {
 return "CAST(" + getChild(0).toSql() + " AS "
 + (isImplicit ? type.toString() : targetTypeDef.toSql()) + 
")";
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index 0b8e6070524..efe275c50d1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -541,6 +541,9 @@ public class SelectStmt extends QueryStmt {
 }
 // populate selectListExprs, aliasSMap, groupingSmap and colNames
 if (selectList.isExcept()) {
+if (needToSql) {
+originalExpr = new ArrayList<>();
+}
 List items = selectList.getItems();
 TableName tblName = items.get(0).getTblName();
 if (tblName == null) {
@@ -561,10 +564,6 @@ public class SelectStmt extends QueryStmt {
 // remove excepted columns
 resultExprs.removeIf(expr -> 
exceptCols.contains(expr.toColumnLabel()));
 colLabels.removeIf(exceptCols::contains);
-if (needToSql) {
-originalExpr = Expr.cloneList(resultExprs);
-}
-
 } else {
 if (needToSql) {
 originalExpr = new ArrayList<>();
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java
index ca4233e17cf..be1ddf7bc4a 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableAsSelectStmtTest.java
@@ -688,8 +688,8 @@ public class CreateTableAsSelectStmtTest extends 
TestWithFeService {
 String showStr = showResultSet.getResultRows().get(0).get(1);
 Assertions.assertEquals(
 "CREATE TABLE `varchar_len1` (\n"
-+ "  `__literal_0` VARCHAR(*) NULL,\n"
-+ "  `__concat_1` VARCHAR(*) NULL,\n"
++ "  `__literal_0` VARCHAR(65533) NULL,\n"
+ 

(doris) branch master updated (049729a3612 -> c04416b2f8d)

2024-04-18 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 049729a3612 [fix](move-memtable) fix commit may fail due to duplicated 
reports (#32403)
 add c04416b2f8d [Fix](nereids) fix bind order by expression logic (#33843)

No new revisions were added by this update.

Summary of changes:
 .../nereids/rules/analysis/BindExpression.java |  4 +--
 .../nereids_syntax_p0/order_by_bind_priority.out   | 22 +
 .../order_by_bind_priority.groovy  | 36 ++
 3 files changed, 60 insertions(+), 2 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](Nereids)fix unstable plan shape in limit_push_down case

2024-04-18 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 31b3feb5eae [fix](Nereids)fix unstable plan shape in limit_push_down 
case
31b3feb5eae is described below

commit 31b3feb5eae1285be7fb541551a9b44ff4517050
Author: 谢健 
AuthorDate: Thu Apr 18 15:47:29 2024 +0800

[fix](Nereids)fix unstable plan shape in limit_push_down case
---
 .../org/apache/doris/nereids/cost/CostModelV1.java |  2 +-
 .../limit_push_down/limit_push_down.out| 89 +-
 .../limit_push_down/order_push_down.out| 86 +++--
 .../limit_push_down/limit_push_down.groovy |  8 +-
 .../limit_push_down/order_push_down.groovy | 48 ++--
 5 files changed, 111 insertions(+), 122 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModelV1.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModelV1.java
index d56a9d8be2a..d469dd3b40b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModelV1.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/cost/CostModelV1.java
@@ -176,7 +176,7 @@ class CostModelV1 extends PlanVisitor {
 double rowCount = statistics.getRowCount();
 if (topN.getSortPhase().isGather()) {
 // Now we do more like two-phase sort, so penalise one-phase sort
-rowCount *= 100;
+rowCount = rowCount * 100 + 100;
 }
 return CostV1.of(context.getSessionVariable(), childRowCount, 
rowCount, childRowCount);
 }
diff --git 
a/regression-test/data/nereids_rules_p0/limit_push_down/limit_push_down.out 
b/regression-test/data/nereids_rules_p0/limit_push_down/limit_push_down.out
index cbf8a09c7e6..54b8a7a6b6c 100644
--- a/regression-test/data/nereids_rules_p0/limit_push_down/limit_push_down.out
+++ b/regression-test/data/nereids_rules_p0/limit_push_down/limit_push_down.out
@@ -274,60 +274,47 @@ PhysicalResultSink
 PhysicalResultSink
 --PhysicalLimit[GLOBAL]
 PhysicalLimit[LOCAL]
---hashAgg[GLOBAL]
-hashAgg[LOCAL]
---PhysicalUnion
-PhysicalLimit[LOCAL]
---hashAgg[LOCAL]
-filter((t1.id > 100))
---PhysicalOlapScan[t1]
-PhysicalLimit[LOCAL]
---hashAgg[LOCAL]
-filter((t2.id > 100))
---PhysicalOlapScan[t2]
+--PhysicalUnion
+PhysicalLimit[LOCAL]
+--filter((cast(msg as DOUBLE) > 100.0))
+PhysicalOlapScan[t1]
+PhysicalLimit[LOCAL]
+--filter((t2.id > 100))
+PhysicalOlapScan[t2]
 
 -- !limit_union_join --
 PhysicalResultSink
 --PhysicalLimit[GLOBAL]
 PhysicalLimit[LOCAL]
---hashAgg[GLOBAL]
-hashAgg[LOCAL]
---PhysicalUnion
+--PhysicalUnion
+PhysicalLimit[LOCAL]
+--hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) 
otherCondition=()
+PhysicalOlapScan[t1]
 PhysicalLimit[LOCAL]
---hashAgg[GLOBAL]
-hashAgg[LOCAL]
---hashJoin[RIGHT_OUTER_JOIN] hashCondition=((t1.id = t2.id)) 
otherCondition=()
-PhysicalOlapScan[t1]
-PhysicalOlapScan[t2]
+--PhysicalOlapScan[t2]
+PhysicalLimit[LOCAL]
+--hashJoin[LEFT_OUTER_JOIN] hashCondition=((t3.id = t4.id)) 
otherCondition=()
 PhysicalLimit[LOCAL]
---hashAgg[LOCAL]
-hashJoin[LEFT_OUTER_JOIN] hashCondition=((t3.id = t4.id)) 
otherCondition=()
---PhysicalLimit[LOCAL]
-hashAgg[LOCAL]
---PhysicalOlapScan[t3]
---PhysicalOlapScan[t4]
+--PhysicalOlapScan[t3]
+PhysicalOlapScan[t4]
 
 -- !limit_union_window --
 PhysicalResultSink
 --PhysicalLimit[GLOBAL]
 PhysicalLimit[LOCAL]
---hashAgg[GLOBAL]
-hashAgg[LOCAL]
---PhysicalUnion
-PhysicalLimit[LOCAL]
---hashAgg[GLOBAL]
-hashAgg[LOCAL]
---PhysicalWindow
-PhysicalQuickSort[MERGE_SORT]
---PhysicalQuickSort[LOCAL_SORT]
-PhysicalOlapScan[t1]
-PhysicalLimit[LOCAL]
---hashAgg[GLOBAL]
-hashAgg[LOCAL]
---PhysicalWindow
-PhysicalQuickSort[MERGE_SORT]
---PhysicalQuickSort[LOCAL_SORT]
-PhysicalOlapScan[t2]
+--PhysicalUnion
+PhysicalLimit[LOCAL]
+--PhysicalWindow
+PhysicalQuickSort[MERGE_SORT]
+--PhysicalQuickSort[LOCAL_SORT]
+PhysicalPartitionTopN
+--PhysicalOlapScan[t1]
+PhysicalLimit[LOCAL]
+--Ph

(doris) branch branch-2.0 updated (b15854a19f3 -> 4954b1cea8c)

2024-04-17 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a change to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


from b15854a19f3 routine load date where expression rewrite should change 
over time (#33763)
 add 4954b1cea8c [fix](planner)create view statement should forbid mv 
rewrite (#33785)

No new revisions were added by this update.

Summary of changes:
 .../apache/doris/analysis/SetOperationStmt.java|  7 +
 .../suites/mv_p0/test_base/test_base.groovy| 32 ++
 2 files changed, 39 insertions(+)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (e421bfee8fe -> e82a56a1c39)

2024-04-15 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from e421bfee8fe [testcases](auto-partition) fix data sync (#33635)
 add e82a56a1c39 [fix](nereids)EliminateGroupBy should keep the output's 
datatype same as old ones (#33585)

No new revisions were added by this update.

Summary of changes:
 .../java/org/apache/doris/nereids/rules/rewrite/EliminateGroupBy.java | 4 +++-
 .../org/apache/doris/nereids/rules/rewrite/EliminateGroupByTest.java  | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (47bb99f1394 -> f06765fd68c)

2024-04-11 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 47bb99f1394 [fix](mtmv)add logs for mv_infos() (#33485)
 add f06765fd68c [fix](nereids) do not transpose semi join agg when mark 
join (#32475)

No new revisions were added by this update.

Summary of changes:
 .../nereids/rules/rewrite/TransposeSemiJoinAgg.java  |  1 +
 .../rules/rewrite/TransposeSemiJoinAggProject.java   |  1 +
 .../transposeJoin/transposeSemiJoinAgg.out   |  8 
 .../transposeJoin/transposeSemiJoinAgg.groovy| 16 
 4 files changed, 26 insertions(+)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [chore](test) let some case suitable for legacy planner and nereids (#33352)

2024-04-08 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 d816945973c [chore](test) let some case suitable for legacy planner 
and nereids (#33352)
d816945973c is described below

commit d816945973c5b2e228306db74c70e77150f85a7a
Author: morrySnow <101034200+morrys...@users.noreply.github.com>
AuthorDate: Tue Apr 9 08:51:33 2024 +0800

[chore](test) let some case suitable for legacy planner and nereids (#33352)
---
 .../doris/nereids/rules/analysis/BindExpression.java   |  3 ++-
 .../suites/account_p0/test_nereids_authentication.groovy   | 14 --
 .../suites/correctness_p0/test_group_having_alias.groovy   |  3 +++
 .../suites/inverted_index_p0/test_null_index.groovy|  5 -
 .../window_functions/test_ntile_function.groovy|  4 ++--
 .../schema_change_p0/test_alter_table_replace.groovy   |  2 +-
 6 files changed, 12 insertions(+), 19 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
index 8c8a447e830..1d0fd3ed632 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
@@ -478,7 +478,8 @@ public class BindExpression implements AnalysisRuleFactory {
 conjunct = TypeCoercionUtils.castIfNotSameType(conjunct, 
BooleanType.INSTANCE);
 boundConjuncts.add(conjunct);
 }
-checkIfOutputAliasNameDuplicatedForGroupBy(boundConjuncts.build(), 
child.getOutput());
+checkIfOutputAliasNameDuplicatedForGroupBy(boundConjuncts.build(),
+child instanceof LogicalProject ? ((LogicalProject) 
child).getOutputs() : child.getOutput());
 return new LogicalHaving<>(boundConjuncts.build(), having.child());
 }
 
diff --git 
a/regression-test/suites/account_p0/test_nereids_authentication.groovy 
b/regression-test/suites/account_p0/test_nereids_authentication.groovy
index 8bc2d18cb3e..2d30835f69a 100644
--- a/regression-test/suites/account_p0/test_nereids_authentication.groovy
+++ b/regression-test/suites/account_p0/test_nereids_authentication.groovy
@@ -60,22 +60,16 @@ suite("test_nereids_authentication", "query") {
 assertEquals(result.size(), 0)
 
 connect(user=user, password='Doris_123456', url=url) {
-try {
+test {
 sql "SELECT * FROM ${tableName2}"
-fail()
-} catch (Exception e) {
-log.info(e.getMessage())
-assertTrue(e.getMessage().contains('denied to user'))
+exception "denied"
 }
 }
 
 connect(user=user, password='Doris_123456', url=url) {
-try {
+test {
 sql "SELECT * FROM ${tableName1}, ${tableName2} WHERE 
${tableName1}.`key` = ${tableName2}.`key`"
-fail()
-} catch (Exception e) {
-log.info(e.getMessage())
-assertTrue(e.getMessage().contains('denied to user'))
+exception "denied"
 }
 }
 
diff --git 
a/regression-test/suites/correctness_p0/test_group_having_alias.groovy 
b/regression-test/suites/correctness_p0/test_group_having_alias.groovy
index fc5e112d1d7..43f5abf4fcb 100644
--- a/regression-test/suites/correctness_p0/test_group_having_alias.groovy
+++ b/regression-test/suites/correctness_p0/test_group_having_alias.groovy
@@ -72,6 +72,7 @@
 """
 
 sql """set group_by_and_having_use_alias_first=true"""
+sql "set enable_nereids_planner=false" // nereids not support it
 
 qt_sql """
 SELECT
@@ -84,6 +85,8 @@
 ORDER BY date;
 """
 
+sql "set enable_nereids_planner=default" // nereids not support bellow sql
+
 qt_sql """
 SELECT
 date_format(date, '%x%v') AS `date2`,
diff --git a/regression-test/suites/inverted_index_p0/test_null_index.groovy 
b/regression-test/suites/inverted_index_p0/test_null_index.groovy
index 6bbab71e940..797200ab010 100644
--- a/regression-test/suites/inverted_index_p0/test_null_index.groovy
+++ b/regression-test/suites/inverted_index_p0/test_null_index.groovy
@@ -48,9 +48,4 @@ suite("test_null_index", "p0"){
 sql "INSERT INTO $indexTblName VALUES (1, 'a', null, [null], [1]), (2, 
'b', 'b', ['b'], [2]), (3, 'c', 'c', ['c'], [3]);"
 qt_sql "SELECT * FROM $indexTblName WHERE str match null order by id;"
 qt_sql "SELECT * FROM $indexTblName WHERE str_null match null order by id;"
-try {
-qt_sql "SELE

(doris) branch master updated (84f5fa63129 -> 2674e222544)

2024-04-03 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 84f5fa63129 [fix](tvf) Support fs.defaultFS with postfix '/' (#33202)
 add 2674e222544 [fix](nereids)SimplifyRange didn't process NULL value 
correctly (#32854)

No new revisions were added by this update.

Summary of changes:
 .../rules/expression/rules/SimplifyRange.java  | 10 +
 .../rules/expression/SimplifyRangeTest.java| 25 ++
 2 files changed, 31 insertions(+), 4 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](Nereids) fix bind group by int literal (#33117)

2024-04-01 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 3fab4496c3f [fix](Nereids) fix bind group by int literal (#33117)
3fab4496c3f is described below

commit 3fab4496c3fefe95b4db01f300bf747080bfc3d8
Author: 924060929 <924060...@qq.com>
AuthorDate: Mon Apr 1 21:28:53 2024 +0800

[fix](Nereids) fix bind group by int literal (#33117)

This sql will failed because

2 in the group by will bind to 1 as col2 in BindExpression
ResolveOrdinalInOrderByAndGroupBy will replace 1 to MIN (LENGTH 
(cast(age as varchar)))
CheckAnalysis will throw an exception because group by can not contains 
aggregate function

select MIN (LENGTH (cast(age as varchar))), 1 AS col2
from test_bind_groupby_slots
group by 2

we should move ResolveOrdinalInOrderByAndGroupBy into BindExpression
---
 .../doris/nereids/jobs/executor/Analyzer.java  |   2 -
 .../nereids/rules/analysis/BindExpression.java |  33 ++-
 .../ResolveOrdinalInOrderByAndGroupBy.java | 102 -
 .../data/nereids_syntax_p0/bind_priority.out   |   6 ++
 .../suites/nereids_syntax_p0/bind_priority.groovy  |  28 ++
 5 files changed, 63 insertions(+), 108 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java
index 9ad10a30aa2..a0431e066be 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java
@@ -43,7 +43,6 @@ import 
org.apache.doris.nereids.rules.analysis.OneRowRelationExtractAggregate;
 import org.apache.doris.nereids.rules.analysis.ProjectToGlobalAggregate;
 import org.apache.doris.nereids.rules.analysis.ProjectWithDistinctToAggregate;
 import org.apache.doris.nereids.rules.analysis.ReplaceExpressionByChildOutput;
-import 
org.apache.doris.nereids.rules.analysis.ResolveOrdinalInOrderByAndGroupBy;
 import org.apache.doris.nereids.rules.analysis.SubqueryToApply;
 import org.apache.doris.nereids.rules.rewrite.MergeProjects;
 import org.apache.doris.nereids.rules.rewrite.SemiJoinCommute;
@@ -147,7 +146,6 @@ public class Analyzer extends AbstractBatchJobExecutor {
 // please see rule BindSlotReference or BindFunction for 
example
 new EliminateDistinctConstant(),
 new ProjectWithDistinctToAggregate(),
-new ResolveOrdinalInOrderByAndGroupBy(),
 new ReplaceExpressionByChildOutput(),
 new OneRowRelationExtractAggregate()
 ),
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
index 6211f493eaf..43f89d5b010 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java
@@ -56,6 +56,7 @@ import 
org.apache.doris.nereids.trees.expressions.functions.scalar.GroupingScala
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Lambda;
 import 
org.apache.doris.nereids.trees.expressions.functions.scalar.StructElement;
 import 
org.apache.doris.nereids.trees.expressions.functions.table.TableValuedFunction;
+import org.apache.doris.nereids.trees.expressions.literal.IntegerLikeLiteral;
 import org.apache.doris.nereids.trees.expressions.literal.StringLiteral;
 import org.apache.doris.nereids.trees.plans.AbstractPlan;
 import org.apache.doris.nereids.trees.plans.JoinType;
@@ -486,11 +487,12 @@ public class BindExpression implements 
AnalysisRuleFactory {
 LogicalSort sort = ctx.root;
 CascadesContext cascadesContext = ctx.cascadesContext;
 
+List childOutput = sort.child().getOutput();
 SimpleExprAnalyzer analyzer = buildSimpleExprAnalyzer(
 sort, cascadesContext, sort.children(), true, true);
 Builder boundKeys = 
ImmutableList.builderWithExpectedSize(sort.getOrderKeys().size());
 for (OrderKey orderKey : sort.getOrderKeys()) {
-Expression boundKey = analyzer.analyze(orderKey.getExpr());
+Expression boundKey = bindWithOrdinal(orderKey.getExpr(), 
analyzer, childOutput);
 boundKeys.add(orderKey.withExpression(boundKey));
 }
 return new LogicalSort<>(boundKeys.build(), sort.child());
@@ -699,7 +701,11 @@ public class BindExpression implements AnalysisRuleFactory 
{
 return useOutputExpr.build();
 });
 
-List boundGroupBy = analyzer.analyzeToList(groupBy);
+ImmutableList.Builder boundGr

(doris) branch master updated (f9f1d805185 -> e7d6697cbcd)

2024-04-01 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from f9f1d805185 [fix](cloud-auth) Fix cloud cluster auth due to #32825 and 
#32918 (#33106)
 add e7d6697cbcd [fix](Nereids) fix group concat (#33091)

No new revisions were added by this update.

Summary of changes:
 be/src/pipeline/pipeline_fragment_context.cpp  |  9 --
 .../pipeline_x/pipeline_x_fragment_context.cpp | 11 ++--
 be/src/runtime/descriptors.h   |  5 
 be/src/vec/exec/vaggregation_node.h|  1 +
 .../java/org/apache/doris/nereids/memo/Group.java  | 22 +--
 .../apache/doris/nereids/memo/GroupExpression.java |  5 
 .../properties/ChildrenPropertiesRegulator.java|  4 ++-
 .../nereids/properties/PhysicalProperties.java |  6 ++--
 .../nereids/rules/analysis/NormalizeAggregate.java |  9 +-
 .../rules/implementation/AggregateStrategies.java  | 32 ++
 10 files changed, 93 insertions(+), 11 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (fb703f91acd -> cfc8954d6c6)

2024-04-01 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from fb703f91acd [Fix](nereids) fix qualifier problem that affects delete 
stmt in another catalog (#32853)
 add cfc8954d6c6 [Fix](test) add sync to ensure data synchronization in 
test_set_operater (#32993)

No new revisions were added by this update.

Summary of changes:
 regression-test/suites/query_p0/operator/test_set_operator.groovy | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (d1095a2d92c -> 8f449585c0b)

2024-03-29 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from d1095a2d92c [fix](nereids)partition prune should consider <=> operator 
(#32965)
 add 8f449585c0b [enhancement](nereids)add some date functions for constant 
fold (#32772)

No new revisions were added by this update.

Summary of changes:
 .../executable/DateTimeExtractAndTransform.java|   457 +-
 .../trees/expressions/literal/DateTimeLiteral.java | 2 +-
 .../datetime_functions/test_time_lut.out   | 25200 +++
 .../datetime_functions/test_time_diff.out  | 4 +-
 .../datetime_functions/test_time_lut.groovy|84 +
 5 files changed, 25741 insertions(+), 6 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](nereids)partition prune should consider <=> operator (#32965)

2024-03-29 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 d1095a2d92c [fix](nereids)partition prune should consider <=> operator 
(#32965)
d1095a2d92c is described below

commit d1095a2d92c0da336be2656813bd530d86473625
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Fri Mar 29 15:24:49 2024 +0800

[fix](nereids)partition prune should consider <=> operator (#32965)
---
 .../rules/OneRangePartitionEvaluator.java  | 23 +
 .../partition_prune/test_nullsafe_eq_prune.out |  4 ++
 .../partition_prune/test_nullsafe_eq_prune.groovy  | 56 ++
 3 files changed, 83 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/OneRangePartitionEvaluator.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/OneRangePartitionEvaluator.java
index deccd6cc1a3..06fea0fb44e 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/OneRangePartitionEvaluator.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/OneRangePartitionEvaluator.java
@@ -39,6 +39,7 @@ import org.apache.doris.nereids.trees.expressions.IsNull;
 import org.apache.doris.nereids.trees.expressions.LessThan;
 import org.apache.doris.nereids.trees.expressions.LessThanEqual;
 import org.apache.doris.nereids.trees.expressions.Not;
+import org.apache.doris.nereids.trees.expressions.NullSafeEqual;
 import org.apache.doris.nereids.trees.expressions.Or;
 import org.apache.doris.nereids.trees.expressions.Slot;
 import org.apache.doris.nereids.trees.expressions.functions.scalar.Date;
@@ -48,6 +49,7 @@ import 
org.apache.doris.nereids.trees.expressions.literal.NullLiteral;
 import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
 import org.apache.doris.nereids.types.BooleanType;
 import org.apache.doris.nereids.types.DataType;
+import org.apache.doris.nereids.util.ExpressionUtils;
 import org.apache.doris.nereids.util.Utils;
 
 import com.google.common.collect.BoundType;
@@ -341,6 +343,27 @@ public class OneRangePartitionEvaluator
 return result;
 }
 
+@Override
+public EvaluateRangeResult visitNullSafeEqual(NullSafeEqual nullSafeEqual, 
EvaluateRangeInput context) {
+EvaluateRangeResult result = evaluateChildrenThenThis(nullSafeEqual, 
context);
+if (!(result.result instanceof NullSafeEqual)) {
+return result;
+}
+// "A <=> null" has been convert to "A is null" or false by 
NullSafeEqualToEqual rule
+// so we don't consider "A <=> null" here
+if (nullSafeEqual.left() instanceof Slot && nullSafeEqual.right() 
instanceof Literal) {
+// A <=> literal -> A = literal and A is not null
+return visit(ExpressionUtils.and(new EqualTo(nullSafeEqual.left(), 
nullSafeEqual.right()),
+new Not(new IsNull(nullSafeEqual.left(, context);
+} else if (nullSafeEqual.left() instanceof Literal && 
nullSafeEqual.right() instanceof Slot) {
+// literal <=> A -> literal = A and A is not null
+return visit(ExpressionUtils.and(new EqualTo(nullSafeEqual.left(), 
nullSafeEqual.right()),
+new Not(new IsNull(nullSafeEqual.right(, context);
+} else {
+return result.withRejectNot(false);
+}
+}
+
 @Override
 public EvaluateRangeResult visitInPredicate(InPredicate inPredicate, 
EvaluateRangeInput context) {
 EvaluateRangeResult result = evaluateChildrenThenThis(inPredicate, 
context);
diff --git 
a/regression-test/data/nereids_rules_p0/partition_prune/test_nullsafe_eq_prune.out
 
b/regression-test/data/nereids_rules_p0/partition_prune/test_nullsafe_eq_prune.out
new file mode 100644
index 000..20f6445a2b8
--- /dev/null
+++ 
b/regression-test/data/nereids_rules_p0/partition_prune/test_nullsafe_eq_prune.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+481
+
diff --git 
a/regression-test/suites/nereids_rules_p0/partition_prune/test_nullsafe_eq_prune.groovy
 
b/regression-test/suites/nereids_rules_p0/partition_prune/test_nullsafe_eq_prune.groovy
new file mode 100644
index 000..20b70c86051
--- /dev/null
+++ 
b/regression-test/suites/nereids_rules_p0/partition_prune/test_nullsafe_eq_prune.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 y

(doris) branch master updated (86e99f9cf7d -> 367836ab999)

2024-03-29 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 86e99f9cf7d [chore](session_variable) change 
parallel_scan_min_rows_per_scanner' default value to 16384 (#32939)
 add 367836ab999 [fix](nereids)column name should be case insensitive when 
selecting mv (#33002)

No new revisions were added by this update.

Summary of changes:
 .../mv/AbstractSelectMaterializedIndexRule.java| 10 +++--
 .../suites/nereids_p0/test_mv_select.groovy| 50 ++
 2 files changed, 56 insertions(+), 4 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated: [fix](nereids)NullSafeEqualToEqual rule only change to equal if both children are not nullable (#32374) (#32771)

2024-03-25 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 0cf27ad29bd [fix](nereids)NullSafeEqualToEqual rule only change to 
equal if both children are not nullable (#32374) (#32771)
0cf27ad29bd is described below

commit 0cf27ad29bdcd9461559c592fd75e36f87c127b7
Author: Jerry Hu 
AuthorDate: Mon Mar 25 17:50:22 2024 +0800

[fix](nereids)NullSafeEqualToEqual rule only change to equal if both 
children are not nullable (#32374) (#32771)

Co-authored-by: starocean999 
<40539150+starocean...@users.noreply.github.com>
---
 be/src/vec/exec/join/vhash_join_node.cpp   | 42 +-
 be/src/vec/exec/join/vhash_join_node.h |  4 ++-
 .../org/apache/doris/planner/HashJoinNode.java |  2 +-
 3 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/be/src/vec/exec/join/vhash_join_node.cpp 
b/be/src/vec/exec/join/vhash_join_node.cpp
index 7990f5bd274..8b52608433c 100644
--- a/be/src/vec/exec/join/vhash_join_node.cpp
+++ b/be/src/vec/exec/join/vhash_join_node.cpp
@@ -362,13 +362,23 @@ Status HashJoinNode::init(const TPlanNode& tnode, 
RuntimeState* state) {
   eq_join_conjunct.opcode == TExprOpcode::EQ_FOR_NULL;
 _is_null_safe_eq_join.push_back(null_aware);
 
+const bool build_side_nullable = 
_build_expr_ctxs.back()->root()->is_nullable();
+const bool probe_side_nullable = 
_probe_expr_ctxs.back()->root()->is_nullable();
 // if is null aware, build join column and probe join column both need 
dispose null value
-_store_null_in_hash_table.emplace_back(
-null_aware ||
-(_build_expr_ctxs.back()->root()->is_nullable() && 
build_stores_null));
+_store_null_in_hash_table.emplace_back(null_aware ||
+   (build_side_nullable && 
build_stores_null));
 probe_not_ignore_null[conjuncts_index] =
-null_aware ||
-(_probe_expr_ctxs.back()->root()->is_nullable() && 
probe_dispose_null);
+null_aware || (probe_side_nullable && probe_dispose_null);
+
+const bool should_convert_build_side_to_nullable =
+null_aware && !build_side_nullable && probe_side_nullable;
+const bool should_convert_probe_side_to_nullable =
+(null_aware || _join_op == TJoinOp::RIGHT_ANTI_JOIN) && 
build_side_nullable &&
+!probe_side_nullable;
+
+
_should_convert_build_side_to_nullable.emplace_back(should_convert_build_side_to_nullable);
+
_should_convert_probe_side_to_nullable.emplace_back(should_convert_probe_side_to_nullable);
+
 conjuncts_index++;
 }
 for (size_t i = 0; i < _probe_expr_ctxs.size(); ++i) {
@@ -838,7 +848,7 @@ void HashJoinNode::_prepare_probe_block() {
 column_type.column = remove_nullable(column_type.column);
 column_type.type = remove_nullable(column_type.type);
 }
-_temp_probe_nullable_columns.clear();
+_key_columns_holder.clear();
 release_block_memory(_probe_block);
 }
 
@@ -1060,8 +1070,17 @@ Status HashJoinNode::_extract_join_column(Block& block, 
ColumnUInt8::MutablePtr&
   ColumnRawPtrs& raw_ptrs,
   const std::vector& res_col_ids) 
{
 DCHECK_EQ(_build_expr_ctxs.size(), _probe_expr_ctxs.size());
-_temp_probe_nullable_columns.clear();
+_key_columns_holder.clear();
+auto& should_convert_to_nullable = BuildSide ? 
_should_convert_build_side_to_nullable
+ : 
_should_convert_probe_side_to_nullable;
 for (size_t i = 0; i < _build_expr_ctxs.size(); ++i) {
+if (should_convert_to_nullable[i]) {
+_key_columns_holder.emplace_back(
+
make_nullable(block.get_by_position(res_col_ids[i]).column));
+raw_ptrs[i] = _key_columns_holder.back().get();
+continue;
+}
+
 if (_is_null_safe_eq_join[i]) {
 raw_ptrs[i] = block.get_by_position(res_col_ids[i]).column.get();
 } else {
@@ -1084,15 +1103,6 @@ Status HashJoinNode::_extract_join_column(Block& block, 
ColumnUInt8::MutablePtr&
 raw_ptrs[i] = _nested;
 }
 } else {
-if constexpr (!BuildSide) {
-if (_join_op == TJoinOp::RIGHT_ANTI_JOIN &&
-_build_expr_ctxs[i]->root()->is_nullable()) {
-
_temp_probe_nullable_columns.emplace_back(make_nullable(
-
block.get_by_position(res_col_ids[i]

(doris) branch master updated: [fix](nereids)str_to_date function's signature for folding constant is wrong (#32474)

2024-03-21 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 a1fa7f5fafd [fix](nereids)str_to_date function's signature for folding 
constant is wrong (#32474)
a1fa7f5fafd is described below

commit a1fa7f5fafd106871145a4d6c2387bef7e1b5ea1
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Fri Mar 22 10:19:44 2024 +0800

[fix](nereids)str_to_date function's signature for folding constant is 
wrong (#32474)
---
 .../src/main/java/org/apache/doris/mtmv/MTMVUtil.java | 15 +++
 .../functions/executable/DateTimeExtractAndTransform.java | 11 ---
 .../partition_prune/test_date_function_prune.groovy   |  5 +
 3 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVUtil.java 
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVUtil.java
index 16459fa1303..01033a9615a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVUtil.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVUtil.java
@@ -33,6 +33,8 @@ import 
org.apache.doris.nereids.trees.expressions.functions.executable.DateTimeA
 import 
org.apache.doris.nereids.trees.expressions.functions.executable.DateTimeArithmetic;
 import 
org.apache.doris.nereids.trees.expressions.functions.executable.DateTimeExtractAndTransform;
 import org.apache.doris.nereids.trees.expressions.literal.DateTimeLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.DateTimeV2Literal;
+import org.apache.doris.nereids.trees.expressions.literal.DateV2Literal;
 import org.apache.doris.nereids.trees.expressions.literal.IntegerLiteral;
 import org.apache.doris.nereids.trees.expressions.literal.VarcharLiteral;
 
@@ -163,12 +165,17 @@ public class MTMVUtil {
 String dateFormat = dateFormatOptional.get();
 Expression strToDate = DateTimeExtractAndTransform
 .strToDate(new VarcharLiteral(expr.getStringValue()), new 
VarcharLiteral(dateFormat));
-if (!(strToDate instanceof DateTimeLiteral)) {
+if (strToDate instanceof DateTimeV2Literal) {
+return ((IntegerLiteral) DateTimeExtractAndTransform
+.unixTimestamp((DateTimeV2Literal) strToDate)).getValue();
+} else if (strToDate instanceof DateV2Literal) {
+return ((IntegerLiteral) DateTimeExtractAndTransform
+.unixTimestamp((DateV2Literal) strToDate)).getValue();
+} else {
 throw new AnalysisException(
-String.format("strToDate failed, stringValue: %s, 
dateFormat: %s", expr.getStringValue(),
-dateFormat));
+String.format("strToDate failed, stringValue: %s, 
dateFormat: %s",
+expr.getStringValue(), dateFormat));
 }
-return ((IntegerLiteral) 
DateTimeExtractAndTransform.unixTimestamp((DateTimeLiteral) 
strToDate)).getValue();
 }
 
 /**
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
index fa1e1ee2a7d..2e53f454752 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java
@@ -593,10 +593,15 @@ public class DateTimeExtractAndTransform {
 /**
  * date transformation function: str_to_date
  */
-@ExecFunction(name = "str_to_date", argTypes = {"VARCHAR, VARCHAR"}, 
returnType = "DATETIME")
+@ExecFunction(name = "str_to_date", argTypes = {"VARCHAR", "VARCHAR"}, 
returnType = "DATETIMEV2")
 public static Expression strToDate(VarcharLiteral str, VarcharLiteral 
format) {
-return 
DateTimeLiteral.fromJavaDateType(DateUtils.getTime(DateUtils.formatBuilder(format.getValue())
-.toFormatter(), str.getValue()));
+if 
(org.apache.doris.analysis.DateLiteral.hasTimePart(format.getStringValue())) {
+return 
DateTimeV2Literal.fromJavaDateType(DateUtils.getTime(DateUtils.formatBuilder(format.getValue())
+.toFormatter(), str.getValue()));
+} else {
+return 
DateV2Literal.fromJavaDateType(DateUtils.getTime(DateUtils.formatBuilder(format.getValue())
+.toFormatter(), str.getValue()));
+}
 }
 
 @ExecFunction(name = "timestamp", argTypes = {"DATETIME"}, returnType = 
"DATETIME")
di

(doris) branch branch-2.0 updated: [fix](planner)decimalv3 literal's precision and scale is not correctly set (#32432)

2024-03-19 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new dbe86ca0b1c [fix](planner)decimalv3 literal's precision and scale is 
not correctly set (#32432)
dbe86ca0b1c is described below

commit dbe86ca0b1c09be92431fbe074c3ce7df43a5165
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Tue Mar 19 14:37:02 2024 +0800

[fix](planner)decimalv3 literal's precision and scale is not correctly set 
(#32432)
---
 .../java/org/apache/doris/analysis/DecimalLiteral.java |  3 +++
 .../rewrite/ExtractCommonFactorsRuleFunctionTest.java  |  4 ++--
 .../datatype_p0/decimalv3/test_decimalv3_where.out |  6 ++
 .../datatype_p0/decimalv3/test_decimalv3_where.groovy  | 18 ++
 4 files changed, 29 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/DecimalLiteral.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/DecimalLiteral.java
index ae0a31c2f43..3a3a8f8f66a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DecimalLiteral.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DecimalLiteral.java
@@ -306,6 +306,9 @@ public class DecimalLiteral extends LiteralExpr {
 int integerPart = Math.max(this.value.precision() - 
this.value.scale(),
 type.getPrecision() - ((ScalarType) type).decimalScale());
 this.type = ScalarType.createDecimalV3Type(integerPart + scale, 
scale);
+BigDecimal adjustedValue = value.scale() < 0 ? value
+: value.setScale(scale, RoundingMode.HALF_UP);
+this.value = Objects.requireNonNull(adjustedValue);
 }
 }
 
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/rewrite/ExtractCommonFactorsRuleFunctionTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/rewrite/ExtractCommonFactorsRuleFunctionTest.java
index 1fcffc4fa5c..3c55d248544 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/rewrite/ExtractCommonFactorsRuleFunctionTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/rewrite/ExtractCommonFactorsRuleFunctionTest.java
@@ -259,8 +259,8 @@ public class ExtractCommonFactorsRuleFunctionTest {
 Assert.assertTrue(planString.contains("`l_partkey` = `p_partkey`"));
 Assert.assertTrue(planString.contains("`l_shipmode` IN ('AIR', 'AIR 
REG')"));
 Assert.assertTrue(planString.contains("`l_shipinstruct` = 'DELIVER IN 
PERSON'"));
-Assert.assertTrue(planString.contains("`l_quantity` >= 9 AND 
`l_quantity` <= 19 "
-+ "OR `l_quantity` >= 20 AND `l_quantity` <= 36"));
+Assert.assertTrue(planString.contains("`l_quantity` >= 9.00 AND 
`l_quantity` <= 19.00 "
++ "OR `l_quantity` >= 20.00 AND `l_quantity` <= 36.00"));
 Assert.assertTrue(planString.contains("`p_size` >= 1"));
 Assert.assertTrue(planString.contains("`p_brand` IN ('Brand#11', 
'Brand#21', 'Brand#32')"));
 Assert.assertTrue(planString.contains("`p_size` <= 15"));
diff --git 
a/regression-test/data/datatype_p0/decimalv3/test_decimalv3_where.out 
b/regression-test/data/datatype_p0/decimalv3/test_decimalv3_where.out
index 36084d4d211..bd3a5c0a98a 100644
--- a/regression-test/data/datatype_p0/decimalv3/test_decimalv3_where.out
+++ b/regression-test/data/datatype_p0/decimalv3/test_decimalv3_where.out
@@ -4,3 +4,9 @@
 2  spark   10  96
 1  doris   20  324
 
+-- !select --
+1.001002.00200
+
+-- !select_after_update --
+1.001000.00010
+
diff --git 
a/regression-test/suites/datatype_p0/decimalv3/test_decimalv3_where.groovy 
b/regression-test/suites/datatype_p0/decimalv3/test_decimalv3_where.groovy
index 287a77cbd10..2f83e07729d 100644
--- a/regression-test/suites/datatype_p0/decimalv3/test_decimalv3_where.groovy
+++ b/regression-test/suites/datatype_p0/decimalv3/test_decimalv3_where.groovy
@@ -23,4 +23,22 @@ suite("test_decimalv3_where") {
sql """CREATE TABLE ${tableName} ( `id` varchar(11) NULL COMMENT 
'唯一标识', `name` varchar(10) NULL COMMENT '采集时间', `age` int(11) NULL, `dr` 
decimalv3(10, 0) ) ENGINE=OLAP UNIQUE KEY(`id`) COMMENT 'test' DISTRIBUTED BY 
HASH(`id`) BUCKETS 10 PROPERTIES ( "replication_allocation" = 
"tag.location.default: 1", "in_memory" = "false", "storage_format" = "V2", 
"light_schema_change" = "true", "disable_auto_compaction" = "false" );"""
sql """insert into ${tableName} values 
(1,'doris',20,324.10),(2,'spark',10,95.5),(3,'flink',9,20)"""
qt_

(doris) branch master updated (2d186565679 -> af4b4227cdf)

2024-03-18 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 2d186565679 [chore](ci) fix script (#32420)
 add af4b4227cdf [fix](planner)decimalv3 literal's precision and scale is 
not correctly set (#32288)

No new revisions were added by this update.

Summary of changes:
 .../org/apache/doris/analysis/DecimalLiteral.java |  3 +++
 .../rewrite/ExtractCommonFactorsRuleFunctionTest.java |  4 ++--
 .../datatype_p0/decimalv3/test_decimalv3_where.out|  6 ++
 .../datatype_p0/decimalv3/test_decimalv3_where.groovy | 19 +++
 4 files changed, 30 insertions(+), 2 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](nereids)AssertNumRow node's output should be nullable (#32136)

2024-03-15 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 140eb7f49c6 [fix](nereids)AssertNumRow node's output should be 
nullable (#32136)
140eb7f49c6 is described below

commit 140eb7f49c60631411784b399544df7852eb15f0
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Fri Mar 15 17:07:27 2024 +0800

[fix](nereids)AssertNumRow node's output should be nullable (#32136)

Co-authored-by: Co-Author Jerry Hu 
---
 be/src/pipeline/exec/assert_num_rows_operator.cpp  | 47 --
 be/src/pipeline/exec/assert_num_rows_operator.h|  1 +
 be/src/vec/exec/vassert_num_rows_node.cpp  | 47 --
 be/src/vec/exec/vassert_num_rows_node.h|  1 +
 .../glue/translator/PhysicalPlanTranslator.java| 29 -
 .../rules/rewrite/EliminateAssertNumRows.java  | 13 ++--
 .../nereids/rules/rewrite/ScalarApplyToJoin.java   |  7 +--
 .../trees/plans/logical/LogicalAssertNumRows.java  |  5 +-
 .../plans/physical/PhysicalAssertNumRows.java  |  5 +-
 .../apache/doris/planner/AssertNumRowsNode.java| 22 ++-
 .../apache/doris/planner/StatisticDeriveTest.java  |  1 -
 gensrc/thrift/PlanNodes.thrift |  1 +
 .../data/nereids_p0/subquery/test_subquery.out |  7 +++
 .../nereids_tpcds_shape_sf1000_p0/shape/query9.out | 73 +-
 .../noStatsRfPrune/query9.out  | 73 +-
 .../no_stats_shape/query9.out  | 73 +-
 .../rf_prune/query44.out   | 71 ++---
 .../rf_prune/query9.out| 73 +-
 .../nereids_tpcds_shape_sf100_p0/shape/query44.out | 71 ++---
 .../nereids_tpcds_shape_sf100_p0/shape/query9.out  | 73 +-
 .../nereids_p0/subquery/test_subquery.groovy   | 23 ++-
 21 files changed, 392 insertions(+), 324 deletions(-)

diff --git a/be/src/pipeline/exec/assert_num_rows_operator.cpp 
b/be/src/pipeline/exec/assert_num_rows_operator.cpp
index c1db78e59b0..ef0efd3f86b 100644
--- a/be/src/pipeline/exec/assert_num_rows_operator.cpp
+++ b/be/src/pipeline/exec/assert_num_rows_operator.cpp
@@ -18,6 +18,7 @@
 #include "assert_num_rows_operator.h"
 
 #include "vec/exprs/vexpr_context.h"
+#include "vec/utils/util.hpp"
 
 namespace doris::pipeline {
 
@@ -35,6 +36,10 @@ AssertNumRowsOperatorX::AssertNumRowsOperatorX(ObjectPool* 
pool, const TPlanNode
 } else {
 _assertion = TAssertion::LE; // just compatible for the previous code
 }
+
+_should_convert_output_to_nullable =
+
tnode.assert_num_rows_node.__isset.should_convert_output_to_nullable &&
+tnode.assert_num_rows_node.should_convert_output_to_nullable;
 }
 
 Status AssertNumRowsOperatorX::pull(doris::RuntimeState* state, 
vectorized::Block* block,
@@ -44,12 +49,14 @@ Status AssertNumRowsOperatorX::pull(doris::RuntimeState* 
state, vectorized::Bloc
 local_state.add_num_rows_returned(block->rows());
 int64_t num_rows_returned = local_state.num_rows_returned();
 bool assert_res = false;
+const auto has_more_rows = !(*eos);
 switch (_assertion) {
 case TAssertion::EQ:
-assert_res = num_rows_returned == _desired_num_rows;
+assert_res = num_rows_returned == _desired_num_rows ||
+ (has_more_rows && num_rows_returned < _desired_num_rows);
 break;
 case TAssertion::NE:
-assert_res = num_rows_returned != _desired_num_rows;
+assert_res = num_rows_returned != _desired_num_rows || (has_more_rows);
 break;
 case TAssertion::LT:
 assert_res = num_rows_returned < _desired_num_rows;
@@ -58,19 +65,47 @@ Status AssertNumRowsOperatorX::pull(doris::RuntimeState* 
state, vectorized::Bloc
 assert_res = num_rows_returned <= _desired_num_rows;
 break;
 case TAssertion::GT:
-assert_res = num_rows_returned > _desired_num_rows;
+assert_res = num_rows_returned > _desired_num_rows || has_more_rows;
 break;
 case TAssertion::GE:
-assert_res = num_rows_returned >= _desired_num_rows;
+assert_res = num_rows_returned >= _desired_num_rows || has_more_rows;
 break;
 default:
 break;
 }
 
+/**
+ * For nereids planner:
+ * The output of `AssertNumRowsOperatorX` should be nullable.
+ * If the `num_rows_returned` is 0 and `_desired_num_rows` is 1,
+ * here need to insert one row of null.
+ */
+if (_should_convert_output_to_nullable) {
+if (block->rows() > 0) {
+for (size_t i = 0; i != block->columns(); ++i) {
+auto& data = bl

(doris) branch master updated: [Feat](nereids) support column default value current_date (#32268)

2024-03-15 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 f3591247745 [Feat](nereids) support column default value current_date 
(#32268)
f3591247745 is described below

commit f35912477451b82f3e8e5adfb33b5cf8aebc9368
Author: feiniaofeiafei <53502832+feiniaofeia...@users.noreply.github.com>
AuthorDate: Fri Mar 15 14:11:29 2024 +0800

[Feat](nereids) support column default value current_date (#32268)
---
 .../antlr4/org/apache/doris/nereids/DorisParser.g4 |  4 +-
 .../java/org/apache/doris/analysis/ColumnDef.java  | 21 +-
 .../doris/nereids/parser/LogicalPlanBuilder.java   |  4 +-
 .../trees/plans/commands/info/DefaultValue.java|  2 +
 .../data/correctness_p0/test_current_date.out  | 13 
 .../suites/correctness_p0/test_current_date.groovy | 75 ++
 6 files changed, 115 insertions(+), 4 deletions(-)

diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 
b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
index ebb5984e862..921059637a5 100644
--- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
@@ -538,8 +538,8 @@ columnDef
 (aggType=aggTypeDef)?
 ((NOT)? NULL)?
 (AUTO_INCREMENT (LEFT_PAREN autoIncInitValue=number RIGHT_PAREN)?)?
-(DEFAULT (nullValue=NULL | INTEGER_VALUE | stringValue=STRING_LITERAL
-| CURRENT_TIMESTAMP (LEFT_PAREN defaultValuePrecision=number 
RIGHT_PAREN)?))?
+(DEFAULT (nullValue=NULL | INTEGER_VALUE | stringValue=STRING_LITERAL| 
CURRENT_DATE
+| defaultTimestamp=CURRENT_TIMESTAMP (LEFT_PAREN 
defaultValuePrecision=number RIGHT_PAREN)?))?
 (ON UPDATE CURRENT_TIMESTAMP (LEFT_PAREN onUpdateValuePrecision=number 
RIGHT_PAREN)?)?
 (COMMENT comment=STRING_LITERAL)?
 ;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
index d202467dfb3..990035bbecf 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
@@ -93,6 +93,7 @@ public class ColumnDef {
 this.defaultValueExprDef = new DefaultValueExprDef(exprName, 
precision);
 }
 
+public static String CURRENT_DATE = "CURRENT_DATE";
 // default "CURRENT_TIMESTAMP", only for DATETIME type
 public static String CURRENT_TIMESTAMP = "CURRENT_TIMESTAMP";
 public static String NOW = "now";
@@ -466,7 +467,15 @@ public class ColumnDef {
 break;
 case DATE:
 case DATEV2:
-new DateLiteral(defaultValue, scalarType);
+if (defaultValueExprDef == null) {
+new DateLiteral(defaultValue, scalarType);
+} else {
+if 
(defaultValueExprDef.getExprName().equalsIgnoreCase(DefaultValue.CURRENT_DATE)) 
{
+break;
+} else {
+throw new AnalysisException("date literal [" + 
defaultValue + "] is invalid");
+}
+}
 break;
 case DATETIME:
 case DATETIMEV2:
@@ -520,6 +529,16 @@ public class ColumnDef {
 throw new AnalysisException("Types other than DATETIME and 
DATETIMEV2 "
 + "cannot use current_timestamp as the default 
value");
 }
+} else if (null != defaultValueExprDef
+&& 
defaultValueExprDef.getExprName().equals(DefaultValue.CURRENT_DATE.toLowerCase()))
 {
+switch (primitiveType) {
+case DATE:
+case DATEV2:
+break;
+default:
+throw new AnalysisException("Types other than DATE and 
DATEV2 "
++ "cannot use current_date as the default value");
+}
 }
 }
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index 019e95cbed5..d89172f12d0 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -2550,7 +2550,7 @@ public class LogicalPlanBuilder extends 
DorisParserBaseVisitor {
 defaultValue = Optional.of(new 
DefaultValue(toStringValue(ctx.stringValue.getText(;
 } else if (ctx.null

(doris) branch master updated (7d5a64e6be2 -> e368c36589b)

2024-03-13 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 7d5a64e6be2 [fix](nereids)EliminateSemiJoin should consider empty 
table (#32107)
 add e368c36589b [enhancement](Nereids) Optimize expression (#32067)

No new revisions were added by this update.

Summary of changes:
 .../nereids/rules/analysis/FillUpMissingSlots.java |  8 +--
 .../nereids/rules/analysis/NormalizeAggregate.java |  6 +-
 .../nereids/rules/analysis/NormalizeRepeat.java| 12 ++--
 .../nereids/rules/rewrite/NormalizeToSlot.java | 28 +
 .../org/apache/doris/nereids/trees/TreeNode.java   |  4 +-
 .../doris/nereids/trees/expressions/Alias.java | 50 +---
 .../doris/nereids/trees/expressions/Any.java   |  4 ++
 .../trees/expressions/ArrayItemReference.java  |  4 +-
 .../nereids/trees/expressions/BinaryOperator.java  | 12 
 .../nereids/trees/expressions/Expression.java  | 69 --
 .../trees/expressions/MarkJoinSlotReference.java   |  2 +-
 .../nereids/trees/expressions/SlotReference.java   | 54 +++--
 .../trees/expressions/VirtualSlotReference.java|  6 +-
 .../nereids/trees/expressions/WhenClause.java  | 15 -
 .../trees/expressions/WindowExpression.java|  2 +-
 .../trees/expressions/functions/BoundFunction.java | 26 
 .../doris/nereids/trees/plans/AbstractPlan.java| 14 +++--
 .../org/apache/doris/nereids/trees/plans/Plan.java |  8 ++-
 .../apache/doris/nereids/util/ExpressionUtils.java | 16 +++--
 .../org/apache/doris/nereids/util/PlanUtils.java   | 59 +++---
 .../rules/analysis/FillUpMissingSlotsTest.java |  2 +-
 21 files changed, 233 insertions(+), 168 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [feat](nereids) add merge aggregate rule (#31811)

2024-03-12 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 f3fdb306e4f [feat](nereids) add merge aggregate rule (#31811)
f3fdb306e4f is described below

commit f3fdb306e4fd7d405250d478463276cdc55b4e25
Author: feiniaofeiafei <53502832+feiniaofeia...@users.noreply.github.com>
AuthorDate: Wed Mar 13 12:05:47 2024 +0800

[feat](nereids) add merge aggregate rule (#31811)
---
 .../doris/nereids/jobs/executor/Rewriter.java  |   4 +-
 .../org/apache/doris/nereids/rules/RuleType.java   |   1 +
 .../doris/nereids/rules/rewrite/ColumnPruning.java |  46 +++-
 .../nereids/rules/rewrite/MergeAggregate.java  | 211 ++
 .../nereids/trees/plans/logical/LogicalUnion.java  |   6 +
 .../org/apache/doris/nereids/util/PlanUtils.java   |   6 +
 .../merge_aggregate/merge_aggregate.out| 248 +
 .../merge_aggregate/merge_aggregate.groovy | 177 +++
 8 files changed, 695 insertions(+), 4 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java
index db463354120..c4fa3abd0b9 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Rewriter.java
@@ -81,6 +81,7 @@ import org.apache.doris.nereids.rules.rewrite.InferPredicates;
 import org.apache.doris.nereids.rules.rewrite.InferSetOperatorDistinct;
 import org.apache.doris.nereids.rules.rewrite.InlineLogicalView;
 import org.apache.doris.nereids.rules.rewrite.LimitSortToTopN;
+import org.apache.doris.nereids.rules.rewrite.MergeAggregate;
 import org.apache.doris.nereids.rules.rewrite.MergeFilters;
 import org.apache.doris.nereids.rules.rewrite.MergeOneRowRelationIntoUnion;
 import org.apache.doris.nereids.rules.rewrite.MergeProjects;
@@ -341,7 +342,8 @@ public class Rewriter extends AbstractBatchJobExecutor {
 ),
 
 topic("Eliminate GroupBy",
-topDown(new EliminateGroupBy())
+topDown(new EliminateGroupBy(),
+new MergeAggregate())
 ),
 
 topic("Eager aggregation",
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
index 90f2c222091..f7ca87a844b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
@@ -197,6 +197,7 @@ public enum RuleType {
 MERGE_LIMITS(RuleTypeClass.REWRITE),
 MERGE_GENERATES(RuleTypeClass.REWRITE),
 // Eliminate plan
+MERGE_AGGREGATE(RuleTypeClass.REWRITE),
 ELIMINATE_AGGREGATE(RuleTypeClass.REWRITE),
 ELIMINATE_LIMIT(RuleTypeClass.REWRITE),
 ELIMINATE_LIMIT_ON_ONE_ROW_RELATION(RuleTypeClass.REWRITE),
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ColumnPruning.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ColumnPruning.java
index cf94caa25c8..4d0c9be368d 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ColumnPruning.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/ColumnPruning.java
@@ -151,9 +151,7 @@ public class ColumnPruning extends 
DefaultPlanRewriter implements
 if (union.getQualifier() == Qualifier.DISTINCT) {
 return skipPruneThisAndFirstLevelChildren(union);
 }
-
-LogicalUnion prunedOutputUnion = pruneOutput(union, 
union.getOutputs(), union::pruneOutputs, context);
-
+LogicalUnion prunedOutputUnion = pruneUnionOutput(union, context);
 // start prune children of union
 List originOutput = union.getOutput();
 Set prunedOutput = prunedOutputUnion.getOutputSet();
@@ -303,6 +301,48 @@ public class ColumnPruning extends 
DefaultPlanRewriter implements
 }
 }
 
+private LogicalUnion pruneUnionOutput(LogicalUnion union, PruneContext 
context) {
+List originOutput = union.getOutputs();
+if (originOutput.isEmpty()) {
+return union;
+}
+List prunedOutputs = Lists.newArrayList();
+List> constantExprsList = 
union.getConstantExprsList();
+List> prunedConstantExprsList = 
Lists.newArrayList();
+List extractColumnIndex = Lists.newArrayList();
+for (int i = 0; i < originOutput.size(); i++) {
+NamedExpression output = originOutput.get(i);
+if (context.requiredSlots.contains(output.toSlot())) {
+prunedOutputs.add(output);
+extractColumnIndex.add(i);
+  

(doris) branch master updated: [Fix](nereids) fix date function rewrite (#32060)

2024-03-12 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 cd59bdcc1ac [Fix](nereids) fix date function rewrite (#32060)
cd59bdcc1ac is described below

commit cd59bdcc1ac019d3cc44080aa11815669fdc45fd
Author: feiniaofeiafei <53502832+feiniaofeia...@users.noreply.github.com>
AuthorDate: Tue Mar 12 17:49:49 2024 +0800

[Fix](nereids) fix date function rewrite (#32060)
---
 .../expression/rules/DateFunctionRewrite.java  |  4 +--
 .../date_function_rewrite.out  |  4 +++
 .../date_function_rewrite.groovy   | 30 ++
 3 files changed, 36 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/DateFunctionRewrite.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/DateFunctionRewrite.java
index e80022b0ba9..e78eeecff0d 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/DateFunctionRewrite.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/DateFunctionRewrite.java
@@ -77,14 +77,14 @@ public class DateFunctionRewrite extends 
AbstractExpressionRewriteRule {
 if (greaterThan.left().child(0).getDataType() instanceof 
DateTimeType
 && greaterThan.right() instanceof DateLiteral) {
 DateTimeLiteral newLiteral = ((DateLiteral) 
greaterThan.right()).toBeginOfTomorrow();
-return new GreaterThan(greaterThan.left().child(0), 
newLiteral);
+return new GreaterThanEqual(greaterThan.left().child(0), 
newLiteral);
 }
 
 // V2
 if (greaterThan.left().child(0).getDataType() instanceof 
DateTimeV2Type
 && greaterThan.right() instanceof DateV2Literal) {
 DateTimeV2Literal newLiteral = ((DateV2Literal) 
greaterThan.right()).toBeginOfTomorrow();
-return new GreaterThan(greaterThan.left().child(0), 
newLiteral);
+return new GreaterThanEqual(greaterThan.left().child(0), 
newLiteral);
 }
 }
 
diff --git 
a/regression-test/data/nereids_rules_p0/date_function_rewrite/date_function_rewrite.out
 
b/regression-test/data/nereids_rules_p0/date_function_rewrite/date_function_rewrite.out
new file mode 100644
index 000..2ef8304a2a0
--- /dev/null
+++ 
b/regression-test/data/nereids_rules_p0/date_function_rewrite/date_function_rewrite.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !test --
+1
+
diff --git 
a/regression-test/suites/nereids_rules_p0/date_function_rewrite/date_function_rewrite.groovy
 
b/regression-test/suites/nereids_rules_p0/date_function_rewrite/date_function_rewrite.groovy
new file mode 100644
index 000..01afc01431a
--- /dev/null
+++ 
b/regression-test/suites/nereids_rules_p0/date_function_rewrite/date_function_rewrite.groovy
@@ -0,0 +1,30 @@
+// 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("date_function_rewrite") {
+sql "SET enable_nereids_planner=true"
+sql "SET enable_fallback_to_original_planner=false"
+sql "drop table if exists test_date_func"
+sql """
+create table test_date_func(a int, test_time int(11)) distributed by 
hash (a) buckets 5
+properties("replication_num"="1");
+"""
+sql "insert into test_date_func values(1,1690128000);\n"
+qt_test """
+select if (date(date_add(FROM_UNIXTIME(t1.test_time, '%Y-%m-%d'),2)) > 
'2023-07-25',1,0) from test_date_func t1;
+"""
+}
\ No newline at end of file


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [fix](nereids)forbid some join reorder rules for mark join (#31966)

2024-03-07 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 8e7b51470a8 [fix](nereids)forbid some join reorder rules for mark join 
(#31966)
8e7b51470a8 is described below

commit 8e7b51470a8b34e5f8c4c7a4a8d88993c4c670d1
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Fri Mar 8 10:15:05 2024 +0800

[fix](nereids)forbid some join reorder rules for mark join (#31966)
---
 .../doris/nereids/rules/exploration/join/JoinCommute.java|  5 +++--
 .../rules/exploration/join/LogicalJoinSemiJoinTranspose.java |  7 +++
 .../join/LogicalJoinSemiJoinTransposeProject.java|  7 +++
 .../main/java/org/apache/doris/nereids/util/JoinUtils.java   | 12 
 4 files changed, 29 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinCommute.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinCommute.java
index ef8868998e0..49c91b92942 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinCommute.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/JoinCommute.java
@@ -63,8 +63,9 @@ public class JoinCommute extends OneExplorationRuleFactory {
 // null aware mark join will be translated to null aware left 
semi/anti join
 // we don't support null aware right semi/anti join, so should 
not commute
 .whenNot(join -> JoinUtils.isNullAwareMarkJoin(join))
-// commuting nest loop mark join is not supported by be
-.whenNot(join -> join.isMarkJoin() && 
join.getHashJoinConjuncts().isEmpty())
+// commuting nest loop mark join or left anti mark join is not 
supported by be
+.whenNot(join -> join.isMarkJoin() && 
(join.getHashJoinConjuncts().isEmpty()
+|| join.getJoinType().isLeftAntiJoin()))
 .then(join -> {
 LogicalJoin newJoin = 
join.withTypeChildren(join.getJoinType().swap(),
 join.right(), join.left(), null);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/LogicalJoinSemiJoinTranspose.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/LogicalJoinSemiJoinTranspose.java
index 7f0409e45e6..9482d719451 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/LogicalJoinSemiJoinTranspose.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/LogicalJoinSemiJoinTranspose.java
@@ -23,6 +23,7 @@ import 
org.apache.doris.nereids.rules.exploration.ExplorationRuleFactory;
 import org.apache.doris.nereids.trees.plans.GroupPlan;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+import org.apache.doris.nereids.util.JoinUtils;
 
 import com.google.common.collect.ImmutableList;
 
@@ -46,6 +47,9 @@ public class LogicalJoinSemiJoinTranspose implements 
ExplorationRuleFactory {
 .whenNot(topJoin -> topJoin.hasDistributeHint() || 
topJoin.left().hasDistributeHint())
 .then(topJoin -> {
 LogicalJoin bottomJoin = 
topJoin.left();
+if (!JoinUtils.checkReorderPrecondition(topJoin, 
bottomJoin)) {
+return null;
+}
 GroupPlan a = bottomJoin.left();
 GroupPlan b = bottomJoin.right();
 GroupPlan c = topJoin.right();
@@ -61,6 +65,9 @@ public class LogicalJoinSemiJoinTranspose implements 
ExplorationRuleFactory {
 .whenNot(topJoin -> topJoin.hasDistributeHint() || 
topJoin.right().hasDistributeHint())
 .then(topJoin -> {
 LogicalJoin bottomJoin = 
topJoin.right();
+if (!JoinUtils.checkReorderPrecondition(topJoin, 
bottomJoin)) {
+return null;
+}
 GroupPlan a = topJoin.left();
 GroupPlan b = bottomJoin.left();
 GroupPlan c = bottomJoin.right();
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/LogicalJoinSemiJoinTransposeProject.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/LogicalJoinSemiJoinTransposeProject.java
index 3b2c6e0dbc7..0240fc99586 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/LogicalJoinS

(doris) branch master updated (7ed02637dd8 -> dbb757382ad)

2024-03-06 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 7ed02637dd8 [fix](Nereids) fix group_concat(distinct) failed (#31873)
 add dbb757382ad [enhancement](Nereids): support more condition 
Date/DateTime Literal (#31858)

No new revisions were added by this update.

Summary of changes:
 .../trees/expressions/literal/DateLiteral.java | 46 ++
 .../expressions/literal/DateTimeLiteralTest.java   |  7 
 2 files changed, 28 insertions(+), 25 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated (c5fcdabb26f -> 7ed02637dd8)

2024-03-06 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from c5fcdabb26f [bugfix](coordinator) should use fragment id not profile 
fragment id to cancel fragment (#31852)
 add 7ed02637dd8 [fix](Nereids) fix group_concat(distinct) failed (#31873)

No new revisions were added by this update.

Summary of changes:
 .../rules/implementation/AggregateStrategies.java  | 33 
 .../functions/agg/AggregateFunction.java   |  3 ++
 .../expressions/functions/agg/GroupConcat.java |  9 +
 .../nereids/trees/plans/algebra/Aggregate.java |  2 +-
 .../group_concat.out}  |  9 +++--
 .../suites/nereids_syntax_p0/group_concat.groovy   | 45 +-
 6 files changed, 78 insertions(+), 23 deletions(-)
 copy regression-test/data/{delete_p0/test_array_column_delete.out => 
nereids_syntax_p0/group_concat.out} (70%)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [test](Nereids) add grouping sets test (#31675)

2024-03-05 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 0c2514377ae [test](Nereids) add grouping sets test (#31675)
0c2514377ae is described below

commit 0c2514377ae27073a700ec0d45bed987dba6d6ea
Author: feiniaofeiafei <53502832+feiniaofeia...@users.noreply.github.com>
AuthorDate: Tue Mar 5 22:01:39 2024 +0800

[test](Nereids) add grouping sets test (#31675)

Co-authored-by: feiniaofeiafei 
---
 .../test_grouping_sets_combination.out | 184 
 .../test_grouping_sets_combination.groovy  | 191 +
 2 files changed, 375 insertions(+)

diff --git 
a/regression-test/data/nereids_rules_p0/grouping_sets/test_grouping_sets_combination.out
 
b/regression-test/data/nereids_rules_p0/grouping_sets/test_grouping_sets_combination.out
new file mode 100644
index 000..71e6d66283f
--- /dev/null
+++ 
b/regression-test/data/nereids_rules_p0/grouping_sets/test_grouping_sets_combination.out
@@ -0,0 +1,184 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sum_distinct --
+\N
+1
+1
+1
+1
+5
+5
+5
+6
+
+-- !count_distinct --
+0
+1
+1
+1
+1
+1
+1
+1
+2
+
+-- !count_distinct_multi --
+0  1
+1  1
+1  1
+1  1
+1  1
+1  1
+1  1
+1  1
+2  3
+
+-- !group_concat_distinct --
+\N 1
+\N 1
+\N 1,5
+\N 5
+1  1
+2  1
+3  5
+4  5
+6  \N
+
+-- !agg_subquery_expression --
+\N
+13
+13
+13
+13
+17
+17
+34
+60
+
+-- !agg_subquery_expression_distinct --
+\N
+13
+13
+13
+13
+17
+17
+17
+30
+
+-- !expression_after_agg_func1 --
+\N 7
+1  6
+5  13
+
+-- !expression_before_agg_func1 --
+\N 7
+1  7
+5  14
+
+-- !expression_before_agg_func2 --
+\N 6
+1  5
+5  12
+
+-- !expression_after_agg_func2 --
+\N 6
+1  5
+5  12
+
+-- !agg_func_window_func_rank --
+1
+3
+3
+
+-- !agg_func_window_func_sum --
+\N
+3
+15
+
+-- !window_func_expression_subquery --
+6
+
+-- !window_func_subquery --
+3
+
+-- !agg_func_distinct_case_when --
+1
+
+-- !expression_after_agg_func_multi_grouping_sets1 --
+\N 3
+\N 4
+\N 7
+\N 7
+\N 19
+1  3
+1  4
+1  6
+5  13
+5  13
+
+-- !expression_before_agg_func_multi_grouping_sets1 --
+\N 3
+\N 4
+\N 7
+\N 21
+\N 28
+1  7
+5  14
+
+-- !expression_before_agg_func_multi_grouping_sets2 --
+\N 2
+\N 3
+\N 6
+\N 6
+\N 18
+\N 23
+1  2
+1  3
+1  5
+5  12
+5  12
+
+-- !expression_after_agg_func_multi_grouping_sets2 --
+\N 2
+\N 3
+\N 6
+\N 6
+\N 18
+\N 23
+1  2
+1  3
+1  5
+5  12
+5  12
+
+-- !agg_func_window_func_rank_multi_grouping_sets --
+1
+1
+1
+1
+2
+2
+3
+3
+3
+4
+
+-- !agg_func_window_func_sum_multi_grouping_sets --
+\N
+1
+2
+3
+15
+15
+18
+
+-- !window_func_expression_subquery_multi_grouping_sets --
+6
+6
+6
+
+-- !window_func_subquery_multi_grouping_sets --
+9
+9
+9
+
diff --git 
a/regression-test/suites/nereids_rules_p0/grouping_sets/test_grouping_sets_combination.groovy
 
b/regression-test/suites/nereids_rules_p0/grouping_sets/test_grouping_sets_combination.groovy
new file mode 100644
index 000..219a5ccbcda
--- /dev/null
+++ 
b/regression-test/suites/nereids_rules_p0/grouping_sets/test_grouping_sets_combination.groovy
@@ -0,0 +1,191 @@
+// 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_grouping_sets_combination") {
+sql "SET enable_nereids_planner=true"
+sql "SET enable_fallback_to_original_planner=false"
+sql """
+ DROP TABLE IF EXISTS mal_test1
+"""
+
+sql """
+create table mal_test1(pk int, a int, b int) distributed by hash(pk) 
buckets 10
+properties('replication_num' = '1'); 
+"""
+
+sql """
+insert into mal_test1 values(2,1,3),(1,1,2),(3,5,6),(6,null

(doris) branch master updated: [enhancement](nereids)support null partition for list partition (#31613)

2024-03-04 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 be418110cb4 [enhancement](nereids)support null partition for list 
partition (#31613)
be418110cb4 is described below

commit be418110cb45a313281617dc8870c06792399f81
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Mon Mar 4 16:31:34 2024 +0800

[enhancement](nereids)support null partition for list partition (#31613)
---
 be/src/exec/tablet_info.cpp|   5 +
 .../antlr4/org/apache/doris/nereids/DorisParser.g4 |   2 +-
 .../org/apache/doris/analysis/PartitionDesc.java   |   3 -
 .../org/apache/doris/analysis/PartitionValue.java  |  15 ++-
 .../org/apache/doris/catalog/PartitionKey.java | 119 +
 .../doris/nereids/parser/LogicalPlanBuilder.java   |   2 +
 .../nereids/trees/expressions/literal/Literal.java |   2 +
 .../trees/plans/commands/info/CreateTableInfo.java |   3 -
 .../plans/commands/info/PartitionDefinition.java   |   2 +-
 .../org/apache/doris/planner/OlapTableSink.java|   9 +-
 .../nereids_syntax_p0/list_partition_with_null.out |  15 +++
 .../list_partition_with_null.groovy|  71 
 .../test_list_partition_datatype.groovy|  19 
 13 files changed, 191 insertions(+), 76 deletions(-)

diff --git a/be/src/exec/tablet_info.cpp b/be/src/exec/tablet_info.cpp
index facb43ea403..582a97bd681 100644
--- a/be/src/exec/tablet_info.cpp
+++ b/be/src/exec/tablet_info.cpp
@@ -521,6 +521,11 @@ Status 
VOlapTablePartitionParam::_create_partition_key(const TExprNode& t_expr,
 column->insert_data(reinterpret_cast(_expr.bool_literal.value), 0);
 break;
 }
+case TExprNodeType::NULL_LITERAL: {
+// insert a null literal
+column->insert_data(nullptr, 0);
+break;
+}
 default: {
 return Status::InternalError("unsupported partition column node type, 
type={}",
  t_expr.node_type);
diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 
b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
index a56134f00f8..a70df9eec92 100644
--- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
@@ -561,7 +561,7 @@ constantSeq
 ;
 
 partitionValueDef
-: INTEGER_VALUE | STRING_LITERAL | MAXVALUE
+: INTEGER_VALUE | STRING_LITERAL | MAXVALUE | NULL
 ;
 
 rollupDefs
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionDesc.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionDesc.java
index 1f68bc2c6b3..39569d0b3e5 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionDesc.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionDesc.java
@@ -208,9 +208,6 @@ public class PartitionDesc {
 throw new AnalysisException(
 "The partition column must be NOT NULL with 
allow_partition_column_nullable OFF");
 }
-if (this instanceof ListPartitionDesc && 
columnDef.isAllowNull()) {
-throw new AnalysisException("The list partition column 
must be NOT NULL");
-}
 if (this instanceof RangePartitionDesc && partitionExprs 
!= null) {
 if (partitionExprs.get(0) instanceof FunctionCallExpr) 
{
 if (!columnDef.getType().isDateType()) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionValue.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionValue.java
index 5dea5c767b7..75e6f54bca2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionValue.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionValue.java
@@ -27,6 +27,7 @@ public class PartitionValue {
 
 private String value;
 private boolean isHiveDefaultPartition;
+private boolean isNullPartition;
 
 private PartitionValue() {
 
@@ -45,6 +46,12 @@ public class PartitionValue {
 this.isHiveDefaultPartition = isHiveDefaultPartition;
 }
 
+public PartitionValue(String value, boolean isNullPartition, boolean 
isHiveDefaultPartition) {
+this.value = value;
+this.isNullPartition = isNullPartition;
+this.isHiveDefaultPartition = isHiveDefaultPartition;
+}
+
 public LiteralExpr getValue(Type type) throws AnalysisException {
 if (isHiveDefaultPartition) {
 return new StringLiteral(value);
@@ -81,12 +88,16 @@ public class PartitionValue {
 return false;
 }

(doris) branch branch-2.0 updated: [fix](nereids)need add mark join slot to upper project in PullUpProjectUnderApply rule (#31421)

2024-03-03 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 48625f73cde [fix](nereids)need add mark join slot to upper project in 
PullUpProjectUnderApply rule (#31421)
48625f73cde is described below

commit 48625f73cde533b1d98705f28b99965cd5320e6a
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Mon Mar 4 11:50:09 2024 +0800

[fix](nereids)need add mark join slot to upper project in 
PullUpProjectUnderApply rule (#31421)
---
 .../nereids/rules/rewrite/PullUpProjectUnderApply.java |  3 +++
 .../trees/expressions/MarkJoinSlotReference.java   |  2 +-
 .../rules/rewrite/PushdownAliasThroughJoinTest.java| 18 +++---
 3 files changed, 7 insertions(+), 16 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PullUpProjectUnderApply.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PullUpProjectUnderApply.java
index 25c17b8f189..79750d55f6f 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PullUpProjectUnderApply.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/PullUpProjectUnderApply.java
@@ -65,6 +65,9 @@ public class PullUpProjectUnderApply extends 
OneRewriteRuleFactory {
 "ScalarSubquery should only have one output 
column");
 newProjects.add(project.getProjects().get(0));
 }
+if (apply.isMarkJoin()) {
+
newProjects.add(apply.getMarkJoinSlotReference().get());
+}
 return project.withProjectsAndChild(newProjects, 
newCorrelate);
 }).toRule(RuleType.PULL_UP_PROJECT_UNDER_APPLY);
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/MarkJoinSlotReference.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/MarkJoinSlotReference.java
index 35b217b8a9e..b9711ed52a1 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/MarkJoinSlotReference.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/MarkJoinSlotReference.java
@@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableList;
 /**
  * A special type of column that will be generated to replace the subquery 
when unnesting the subquery of MarkJoin.
  */
-public class MarkJoinSlotReference extends SlotReference implements 
SlotNotFromChildren {
+public class MarkJoinSlotReference extends SlotReference {
 final boolean existsHasAgg;
 
 public MarkJoinSlotReference(String name) {
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/PushdownAliasThroughJoinTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/PushdownAliasThroughJoinTest.java
index 543ff0933b5..ab7c3a2332d 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/PushdownAliasThroughJoinTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/PushdownAliasThroughJoinTest.java
@@ -18,10 +18,6 @@
 package org.apache.doris.nereids.rules.rewrite;
 
 import org.apache.doris.common.Pair;
-import org.apache.doris.nereids.trees.expressions.Alias;
-import org.apache.doris.nereids.trees.expressions.ExprId;
-import org.apache.doris.nereids.trees.expressions.MarkJoinSlotReference;
-import org.apache.doris.nereids.trees.expressions.NamedExpression;
 import org.apache.doris.nereids.trees.plans.JoinType;
 import org.apache.doris.nereids.trees.plans.logical.LogicalOlapScan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
@@ -34,8 +30,6 @@ import org.apache.doris.nereids.util.PlanConstructor;
 import com.google.common.collect.ImmutableList;
 import org.junit.jupiter.api.Test;
 
-import java.util.List;
-
 class PushdownAliasThroughJoinTest implements MemoPatternMatchSupported {
 private static final LogicalOlapScan scan1 = 
PlanConstructor.newLogicalOlapScan(0, "t1", 0);
 private static final LogicalOlapScan scan2 = 
PlanConstructor.newLogicalOlapScan(1, "t2", 0);
@@ -108,18 +102,12 @@ class PushdownAliasThroughJoinTest implements 
MemoPatternMatchSupported {
 
 @Test
 void testNoPushdownMarkJoin() {
-List projects =
-ImmutableList.of(new MarkJoinSlotReference(new ExprId(101), 
"markSlot1", false),
-new Alias(new MarkJoinSlotReference(new ExprId(102), 
"markSlot2", false),
-"markSlot2"));
 LogicalPlan plan = new LogicalPlanBuilder(scan1)
-.join(scan2, JoinType.INNER_JOIN, Pair.of(0, 
0)).projectExprs(projects).build();
+.markJoin(scan

(doris) branch master updated (90ab97b4817 -> 8dddd92146a)

2024-02-28 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from 90ab97b4817 [fix](test) fix error messages in fault injection tests 
(#31515)
 add 892146a [fix](Nereids): other cond should be kept for each anti 
join when expanding anti join such as (#31521)

No new revisions were added by this update.

Summary of changes:
 .../doris/nereids/rules/rewrite/OrExpansion.java   |  24 +-
 .../data/nereids_p0/union/or_expansion.out | 301 +
 .../suites/nereids_p0/union/or_expansion.groovy| 152 ---
 3 files changed, 425 insertions(+), 52 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated: [fix](nereids)use CATALOG_DEFAULT as default decimal precision and scale in cast xx as decimal expr (#31471)

2024-02-27 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new df4da754476 [fix](nereids)use CATALOG_DEFAULT as default decimal 
precision and scale in cast xx as decimal expr (#31471)
df4da754476 is described below

commit df4da75447670ceffe23a4c138c65fdb89062c36
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Wed Feb 28 10:04:08 2024 +0800

[fix](nereids)use CATALOG_DEFAULT as default decimal precision and scale in 
cast xx as decimal expr (#31471)
---
 .../src/main/java/org/apache/doris/nereids/types/DataType.java| 8 
 .../main/java/org/apache/doris/nereids/types/DecimalV3Type.java   | 2 ++
 .../nereids/rules/expression/rules/SimplifyCastRuleTest.java  | 8 
 regression-test/data/nereids_p0/datatype/test_cast.out| 4 
 regression-test/suites/nereids_p0/datatype/test_cast.groovy   | 2 ++
 5 files changed, 16 insertions(+), 8 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java
index ffe3c738a2d..9a1e58502b1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java
@@ -135,7 +135,7 @@ public abstract class DataType implements AbstractDataType {
 if (Config.enable_decimal_conversion && tryConvert) {
 switch (types.size()) {
 case 1:
-return DecimalV3Type.SYSTEM_DEFAULT;
+return DecimalV3Type.CATALOG_DEFAULT;
 case 2:
 return DecimalV3Type
 
.createDecimalV3Type(Integer.parseInt(types.get(1)));
@@ -148,7 +148,7 @@ public abstract class DataType implements AbstractDataType {
 } else {
 switch (types.size()) {
 case 1:
-return DecimalV2Type.SYSTEM_DEFAULT;
+return DecimalV2Type.CATALOG_DEFAULT;
 case 2:
 return 
DecimalV2Type.createDecimalV2Type(Integer.parseInt(types.get(1)),
 0);
@@ -162,7 +162,7 @@ public abstract class DataType implements AbstractDataType {
 case "decimalv2":
 switch (types.size()) {
 case 1:
-return DecimalV2Type.SYSTEM_DEFAULT;
+return DecimalV2Type.CATALOG_DEFAULT;
 case 2:
 return 
DecimalV2Type.createDecimalV2Type(Integer.parseInt(types.get(1)), 0);
 case 3:
@@ -174,7 +174,7 @@ public abstract class DataType implements AbstractDataType {
 case "decimalv3":
 switch (types.size()) {
 case 1:
-return DecimalV3Type.SYSTEM_DEFAULT;
+return DecimalV3Type.CATALOG_DEFAULT;
 case 2:
 return 
DecimalV3Type.createDecimalV3Type(Integer.parseInt(types.get(1)));
 case 3:
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV3Type.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV3Type.java
index b0fdd205800..80e9adbb906 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV3Type.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV3Type.java
@@ -42,6 +42,8 @@ public class DecimalV3Type extends FractionalType {
 public static final DecimalV3Type WILDCARD = new DecimalV3Type(-1, -1);
 public static final DecimalV3Type SYSTEM_DEFAULT = new 
DecimalV3Type(MAX_DECIMAL128_PRECISION, DEFAULT_SCALE);
 
+public static final DecimalV3Type CATALOG_DEFAULT = new 
DecimalV3Type(MAX_DECIMAL32_PRECISION, DEFAULT_SCALE);
+
 private static final DecimalV3Type BOOLEAN_DECIMAL = new DecimalV3Type(1, 
0);
 private static final DecimalV3Type TINYINT_DECIMAL = new DecimalV3Type(3, 
0);
 private static final DecimalV3Type SMALLINT_DECIMAL = new DecimalV3Type(5, 
0);
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rules/SimplifyCastRuleTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rules/SimplifyCastRuleTest.java
index f691a5cfdc2..8c07b3e972c 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rules/SimplifyCastRuleTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rules/SimplifyCastRuleTest.java
@@ -39,13 +39,13 @@ 

(doris) branch branch-2.0 updated: [fix](legacy-planner) fixed loss of BetweenPredicate rewrite on reanalyze in legacy planner (#31454)

2024-02-27 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 3a65e98003d [fix](legacy-planner) fixed loss of BetweenPredicate 
rewrite on reanalyze in legacy planner (#31454)
3a65e98003d is described below

commit 3a65e98003d97f711ad9c43bb3b9f7f96e07cce9
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Tue Feb 27 16:10:37 2024 +0800

[fix](legacy-planner) fixed loss of BetweenPredicate rewrite on reanalyze 
in legacy planner (#31454)
---
 .../java/org/apache/doris/analysis/SelectStmt.java |  1 +
 .../data/query_p0/having/having_between.out| 31 ++
 .../suites/query_p0/having/having_between.groovy   | 72 ++
 3 files changed, 104 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index 967ceb4b272..344fa3df6db 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -1862,6 +1862,7 @@ public class SelectStmt extends QueryStmt {
 if (havingClauseAfterAnalyzed != null) {
 havingClauseAfterAnalyzed = 
rewriter.rewrite(havingClauseAfterAnalyzed, analyzer);
 havingClauseAfterAnalyzed.collect(Subquery.class, subqueryExprs);
+havingClause = havingClauseAfterAnalyzed.clone();
 }
 
 for (Subquery subquery : subqueryExprs) {
diff --git a/regression-test/data/query_p0/having/having_between.out 
b/regression-test/data/query_p0/having/having_between.out
new file mode 100644
index 000..d8adf194fd7
--- /dev/null
+++ b/regression-test/data/query_p0/having/having_between.out
@@ -0,0 +1,31 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql01 --
+aa ba  22  cc  11  \N
+b  b   242 c   121 \N
+bb b   22  c   11  \N
+
+-- !sql02 --
+aa 1
+b  1
+bb 1
+
+-- !sql03 --
+aa 1
+b  1
+bb 1
+
+-- !sql01 --
+aa ba  22  cc  11  \N
+b  b   242 c   121 \N
+bb b   22  c   11  \N
+
+-- !sql02 --
+aa 1
+b  1
+bb 1
+
+-- !sql03 --
+aa 1
+b  1
+bb 1
+
diff --git a/regression-test/suites/query_p0/having/having_between.groovy 
b/regression-test/suites/query_p0/having/having_between.groovy
new file mode 100644
index 000..7f3091795b6
--- /dev/null
+++ b/regression-test/suites/query_p0/having/having_between.groovy
@@ -0,0 +1,72 @@
+// 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_having_between", "query,p0") {
+def DBname = "test_having_between"
+def tableName = "tbl_having_between"
+sql "DROP DATABASE IF EXISTS ${DBname}"
+sql "CREATE DATABASE IF NOT EXISTS ${DBname}"
+sql "use ${DBname}"
+
+sql "DROP TABLE IF EXISTS ${tableName};"
+
+sql """
+CREATE TABLE ${tableName}(a DATE, b VARCHAR(100), c VARCHAR(100), d 
VARCHAR(100), e INT, f INT)  
+ENGINE=OLAP
+DUPLICATE KEY( a )
+COMMENT "OLAP"
+DISTRIBUTED BY HASH( e ) BUCKETS  auto
+PROPERTIES (
+"replication_num" = "1"
+);
+"""
+
+def test_query = {
+qt_sql01 """
+select t1.b,t1.c,t1.f,t1.d,t1.e,stddev_pop(t1.d+t1.e) std from 
${tableName} t1 
+group by t1.f,t1.d,t1.e,t1.a,t1.b,t1.c
+having t1.b between 'aa' and 'bb' order by 1;
+"""
+
+qt_sql02 """
+SELECT b, count(*) FROM ${tableName} GROUP BY 1 HAVING b BETWEEN 
'aa' AND 'bb' order by 1;
+"""
+
+qt_sql03 """
+SELECT b, count(*) FROM ${tableName} GROUP BY 1 HAVING b 

(doris) branch branch-2.0 updated: [fix](nereids)collect all correlated slots from subquery in correct way (#31340)

2024-02-25 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 4cb192dc61a [fix](nereids)collect all correlated slots from subquery 
in correct way (#31340)
4cb192dc61a is described below

commit 4cb192dc61a3668f9ff8df7f316751f190ebda7b
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Mon Feb 26 09:47:47 2024 +0800

[fix](nereids)collect all correlated slots from subquery in correct way 
(#31340)
---
 .../java/org/apache/doris/nereids/util/Utils.java | 19 ++-
 .../data/nereids_p0/subquery/test_subquery.out| 12 
 .../suites/nereids_p0/subquery/test_subquery.groovy   | 13 +
 3 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/Utils.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/Utils.java
index 6ac9ffd9513..d259e348042 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/Utils.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/Utils.java
@@ -17,10 +17,8 @@
 
 package org.apache.doris.nereids.util;
 
-import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.trees.expressions.Cast;
 import org.apache.doris.nereids.trees.expressions.Expression;
-import org.apache.doris.nereids.trees.expressions.Not;
 import org.apache.doris.nereids.trees.expressions.SlotReference;
 import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
 
@@ -159,21 +157,8 @@ public class Utils {
  */
 public static List getCorrelatedSlots(List 
correlatedPredicates,
 List correlatedSlots) {
-List slots = new ArrayList<>();
-correlatedPredicates.forEach(predicate -> {
-if (!(predicate instanceof BinaryExpression) && !(predicate 
instanceof Not)) {
-throw new AnalysisException("UnSupported expr type: " + 
correlatedPredicates);
-}
-
-BinaryExpression binaryExpression;
-if (predicate instanceof Not) {
-binaryExpression = (BinaryExpression) ((Not) 
predicate).child();
-} else {
-binaryExpression = (BinaryExpression) predicate;
-}
-slots.addAll(collectCorrelatedSlotsFromChildren(binaryExpression, 
correlatedSlots));
-});
-return slots;
+return ExpressionUtils.getInputSlotSet(correlatedPredicates).stream()
+.filter(slot -> 
!correlatedSlots.contains(slot)).collect(Collectors.toList());
 }
 
 private static List collectCorrelatedSlotsFromChildren(
diff --git a/regression-test/data/nereids_p0/subquery/test_subquery.out 
b/regression-test/data/nereids_p0/subquery/test_subquery.out
index 7e44c264f5b..ca61be79456 100644
--- a/regression-test/data/nereids_p0/subquery/test_subquery.out
+++ b/regression-test/data/nereids_p0/subquery/test_subquery.out
@@ -30,6 +30,18 @@ true 15  19923021110119200.000   true
-12-12  2015-04-02T00:003.141592653 2
 1  9
 2  \N
 
+-- !select60 --
+\N 1
+\N 2
+1  2
+1  3
+2  4
+3  3
+3  4
+20 2
+22 3
+24 4
+
 -- !select61 --
 
 -- !select62 --
diff --git a/regression-test/suites/nereids_p0/subquery/test_subquery.groovy 
b/regression-test/suites/nereids_p0/subquery/test_subquery.groovy
index 1c8078ebc6f..21dd257a274 100644
--- a/regression-test/suites/nereids_p0/subquery/test_subquery.groovy
+++ b/regression-test/suites/nereids_p0/subquery/test_subquery.groovy
@@ -244,6 +244,7 @@ suite("test_subquery") {
 sql """drop table if exists table_9_undef_undef"""
 
 sql "drop table if exists t1"
+sql "drop table if exists t2"
 sql """create table t1
 (k1 bigint, k2 bigint)
 ENGINE=OLAP
@@ -253,8 +254,20 @@ suite("test_subquery") {
 PROPERTIES (
 "replication_num" = "1"
 );"""
+sql """create table t2
+(k1 int, k2 varchar(128), k3 bigint, v1 bigint, v2 bigint)
+ENGINE=OLAP
+DUPLICATE KEY(k1, k2)
+COMMENT 'OLAP'
+DISTRIBUTED BY HASH(k2) BUCKETS 1
+PROPERTIES (
+"replication_num" = "1"
+);"""
 sql """insert into t1 values (1,null),(null,1),(1,2), (null,2),(1,3), 
(2,4), (2,5), (3,3), (3,4), (20,2), (22,3), (24,4),(null,null);"""
+sql """insert into t2 values (1,'abc',2,3,4), (1,'abcd',3,3,4), 
(2,'xyz',2,4,2), (2,'uvw',3,

(doris) branch branch-2.0 updated: [fix](Nereids) fix '' and in string literal (#31288)

2024-02-22 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new d0163b8f8a4 [fix](Nereids) fix '' and  in string literal (#31288)
d0163b8f8a4 is described below

commit d0163b8f8a40591592662dcbdcc0f26b4902
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Fri Feb 23 09:51:12 2024 +0800

[fix](Nereids) fix '' and  in string literal (#31288)
---
 fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4 
b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4
index 820f40f909b..ddffbad133d 100644
--- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4
@@ -573,8 +573,8 @@ ATSIGN: '@';
 DOUBLEATSIGN: '@@';
 
 STRING_LITERAL
-: '\'' ( ~('\''|'\\') | ('\\' .) )* '\''
-| '"' ( ~('"'|'\\') | ('\\' .) )* '"'
+: '\'' ('\\'. | '\'\'' | ~('\'' | '\\'))* '\''
+| '"' ( '\\'. | '""' | ~('"'| '\\') )* '"'
 | 'R\'' (~'\'')* '\''
 | 'R"'(~'"')* '"'
 ;


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [feat-wip](join) support mark join for right semi join(without mark join conjunct) (#30767)

2024-02-03 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 89e53521a48 [feat-wip](join) support mark join for right semi 
join(without mark join conjunct) (#30767)
89e53521a48 is described below

commit 89e53521a48563d367b0c1c60f38049bf8138368
Author: Jerry Hu 
AuthorDate: Sun Feb 4 10:11:06 2024 +0800

[feat-wip](join) support mark join for right semi join(without mark join 
conjunct) (#30767)
---
 be/src/pipeline/exec/hashjoin_probe_operator.cpp   |  2 +-
 be/src/pipeline/exec/join_build_sink_operator.cpp  |  6 ++--
 be/src/vec/common/hash_table/join_hash_table.h | 34 +-
 be/src/vec/exec/join/process_hash_table_probe.h|  2 +-
 .../vec/exec/join/process_hash_table_probe_impl.h  | 22 ++
 be/src/vec/exec/join/vhash_join_node.cpp   |  2 +-
 be/src/vec/exec/join/vjoin_node_base.cpp   |  6 ++--
 7 files changed, 48 insertions(+), 26 deletions(-)

diff --git a/be/src/pipeline/exec/hashjoin_probe_operator.cpp 
b/be/src/pipeline/exec/hashjoin_probe_operator.cpp
index a2fb0012ffa..1cf3e54572e 100644
--- a/be/src/pipeline/exec/hashjoin_probe_operator.cpp
+++ b/be/src/pipeline/exec/hashjoin_probe_operator.cpp
@@ -343,7 +343,7 @@ Status HashJoinProbeOperatorX::pull(doris::RuntimeState* 
state, vectorized::Bloc
 if constexpr (!std::is_same_v) {
 bool eos = false;
 st = 
process_hashtable_ctx.process_data_in_hashtable(
-arg, mutable_join_block, _block, 
);
+arg, mutable_join_block, _block, 
, _is_mark_join);
 source_state = eos ? SourceState::FINISHED : 
source_state;
 } else {
 st = Status::InternalError("uninited hash 
table");
diff --git a/be/src/pipeline/exec/join_build_sink_operator.cpp 
b/be/src/pipeline/exec/join_build_sink_operator.cpp
index 73ebfb947a3..6b930ff8a5e 100644
--- a/be/src/pipeline/exec/join_build_sink_operator.cpp
+++ b/be/src/pipeline/exec/join_build_sink_operator.cpp
@@ -83,8 +83,10 @@ 
JoinBuildSinkOperatorX::JoinBuildSinkOperatorX(ObjectPool* pool,
 if (_is_mark_join) {
 DCHECK(_join_op == TJoinOp::LEFT_ANTI_JOIN || _join_op == 
TJoinOp::LEFT_SEMI_JOIN ||
_join_op == TJoinOp::CROSS_JOIN || _join_op == 
TJoinOp::NULL_AWARE_LEFT_ANTI_JOIN ||
-   _join_op == TJoinOp::NULL_AWARE_LEFT_SEMI_JOIN)
-<< "Mark join is only supported for null aware left semi/anti 
join and cross join "
+   _join_op == TJoinOp::NULL_AWARE_LEFT_SEMI_JOIN ||
+   _join_op == TJoinOp::RIGHT_SEMI_JOIN)
+<< "Mark join is only supported for null aware left semi/anti 
join and right semi "
+   "join and cross join "
"but this is "
 << _join_op;
 }
diff --git a/be/src/vec/common/hash_table/join_hash_table.h 
b/be/src/vec/common/hash_table/join_hash_table.h
index 85665e76853..5ae0a13acef 100644
--- a/be/src/vec/common/hash_table/join_hash_table.h
+++ b/be/src/vec/common/hash_table/join_hash_table.h
@@ -98,7 +98,8 @@ public:
 }
 }
 
-if constexpr (with_other_conjuncts || is_mark_join) {
+if constexpr (with_other_conjuncts ||
+  (is_mark_join && JoinOpType != 
TJoinOp::RIGHT_SEMI_JOIN)) {
 return _find_batch_conjunct(
 keys, build_idx_map, probe_idx, build_idx, probe_rows, 
probe_idxs, build_idxs);
 }
@@ -203,8 +204,9 @@ public:
 return std::tuple {probe_idx, build_idx, matched_cnt, 
picking_null_keys};
 }
 
-template 
-bool iterate_map(std::vector& build_idxs) const {
+template 
+bool iterate_map(std::vector& build_idxs,
+ vectorized::ColumnFilterHelper* mark_column_helper) const 
{
 const auto batch_size = max_batch_size;
 const auto elem_num = visited.size();
 int count = 0;
@@ -213,10 +215,15 @@ public:
 while (count < batch_size && iter_idx < elem_num) {
 const auto matched = visited[iter_idx];
 build_idxs[count] = iter_idx;
-if constexpr (JoinOpType != TJoinOp::RIGHT_SEMI_JOIN) {
-count += !matched;
+if constexpr (JoinOpType == TJoinOp::RIGHT_SEMI_JOIN) {
+if constexpr (is_mark_join) {
+mark_column_helper->insert_value(matched);
+++count;
+} else {
+count += matched;
+}
 } else {
-count += match

(doris) branch branch-2.0 updated: [fix](nereids)need substitute agg function using agg node's output if it's in order by key (#30758)

2024-02-02 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new c8a5c2628b0 [fix](nereids)need substitute agg function using agg 
node's output if it's in order by key (#30758)
c8a5c2628b0 is described below

commit c8a5c2628b0d3942834bc2d2c78fff70dd013fbc
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Fri Feb 2 17:20:48 2024 +0800

[fix](nereids)need substitute agg function using agg node's output if it's 
in order by key (#30758)
---
 .../nereids/rules/analysis/FillUpMissingSlots.java |  7 ++-
 .../rules/analysis/FillUpMissingSlotsTest.java | 24 ++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/FillUpMissingSlots.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/FillUpMissingSlots.java
index f7c04777457..1a59ba00adf 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/FillUpMissingSlots.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/FillUpMissingSlots.java
@@ -182,10 +182,14 @@ public class FillUpMissingSlots implements 
AnalysisRuleFactory {
 private final List groupByExpressions;
 private final Map substitution = Maps.newHashMap();
 private final List newOutputSlots = 
Lists.newArrayList();
+private final Map outputSubstitutionMap;
 
 Resolver(Aggregate aggregate) {
 outputExpressions = aggregate.getOutputExpressions();
 groupByExpressions = aggregate.getGroupByExpressions();
+outputSubstitutionMap = 
outputExpressions.stream().filter(Alias.class::isInstance)
+.collect(Collectors.toMap(alias -> alias.toSlot(), alias 
-> alias.child(0),
+(k1, k2) -> k1));
 }
 
 public void resolve(Expression expression) {
@@ -272,7 +276,8 @@ public class FillUpMissingSlots implements 
AnalysisRuleFactory {
 }
 
 private void generateAliasForNewOutputSlots(Expression expression) {
-Alias alias = new Alias(expression);
+Expression replacedExpr = ExpressionUtils.replace(expression, 
outputSubstitutionMap);
+Alias alias = new Alias(replacedExpr);
 newOutputSlots.add(alias);
 substitution.put(expression, alias.toSlot());
 }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/FillUpMissingSlotsTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/FillUpMissingSlotsTest.java
index 7b0c8095ba6..d6c71ee7759 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/FillUpMissingSlotsTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/analysis/FillUpMissingSlotsTest.java
@@ -32,6 +32,7 @@ import 
org.apache.doris.nereids.trees.expressions.SlotReference;
 import org.apache.doris.nereids.trees.expressions.functions.agg.Count;
 import org.apache.doris.nereids.trees.expressions.functions.agg.Min;
 import org.apache.doris.nereids.trees.expressions.functions.agg.Sum;
+import org.apache.doris.nereids.trees.expressions.functions.scalar.Abs;
 import org.apache.doris.nereids.trees.expressions.literal.Literal;
 import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral;
 import org.apache.doris.nereids.types.BigIntType;
@@ -513,6 +514,29 @@ public class FillUpMissingSlotsTest extends 
AnalyzeCheckTestBase implements Memo
 
).when(FieldChecker.check("outputExpressions", Lists.newArrayList(a1, 
countStar
 ).when(FieldChecker.check("orderKeys", 
ImmutableList.of(new OrderKey(countStar.toSlot(), true, true
 ).when(FieldChecker.check("projects", 
Lists.newArrayList(a1.toSlot();
+
+sql = "SELECT abs(a1) xx, sum(a2) FROM t1 GROUP BY xx ORDER BY 
MIN(xx)";
+a1 = new SlotReference(
+new ExprId(1), "a1", TinyIntType.INSTANCE, true,
+ImmutableList.of("test_resolve_aggregate_functions", "t1")
+);
+Alias xx = new Alias(new ExprId(3), new Abs(a1), "xx");
+a2 = new SlotReference(
+new ExprId(2), "a2", TinyIntType.INSTANCE, true,
+ImmutableList.of("test_resolve_aggregate_functions", "t1")
+);
+sumA2 = new Alias(new ExprId(4), new Sum(a2), "sum(a2)");
+
+Alias minXX = new Alias(new ExprId(5), new Min(xx.toSlot()), 
"min(xx)");
+
PlanChecker.from(connectContext).analyze(sql).printlnTree().matches(logicalProject(
+ 

(doris) branch branch-2.0 updated (34c36e72a90 -> ae71b8b1813)

2024-02-02 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a change to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


from 34c36e72a90 [pick](nereids)do not check invisible column stats (#30676)
 add ae71b8b1813 [fix](Nereids) add logical project to prevent extra wrong 
column (#30757)

No new revisions were added by this update.

Summary of changes:
 .../apache/doris/nereids/jobs/executor/Analyzer.java |  4 +++-
 .../nereids/rules/analysis/SubqueryToApply.java  |  9 ++---
 .../sub_query_diff_old_optimize.out  |  3 +++
 .../sub_query_diff_old_optimize.groovy   | 20 
 4 files changed, 28 insertions(+), 8 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated (0b7bc39bcb4 -> c7db8332b03)

2024-01-31 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a change to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


from 0b7bc39bcb4 [fix](Nereids) result nullable of sum distinct in scalar 
agg is wrong (#30221) (#30618)
 add c7db8332b03 [fix](nereids)keep cast operator if cast a varchar to 
another longer varchar in LogicalSetOperator (#30623)

No new revisions were added by this update.

Summary of changes:
 .../trees/plans/logical/LogicalSetOperation.java   |  4 ++--
 .../doris/nereids/util/TypeCoercionUtils.java  | 14 +
 .../suites/nereids_p0/union/test_union.groovy  | 23 ++
 3 files changed, 39 insertions(+), 2 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated (9dd012cb849 -> d6e4900f976)

2024-01-31 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a change to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


from 9dd012cb849 [fix](Nereids) div priority is not right (#30604)
 add d6e4900f976 [fix](planner)LateralViewRef's toSql method is not 
correctly implemented (#30606)

No new revisions were added by this update.

Summary of changes:
 fe/fe-core/src/main/java/org/apache/doris/analysis/LateralViewRef.java | 2 +-
 regression-test/suites/query_p0/lateral_view/test_with_view.groovy | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated (33b017c331f -> aaba094172b)

2024-01-30 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a change to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


from 33b017c331f [fix](nereids)window expression's window frame may lost in 
NormalizeToSlot (#30482)
 add aaba094172b [fix](nereids)should normalize mv column's name before 
matching prefix keys (#30481)

No new revisions were added by this update.

Summary of changes:
 .../mv/AbstractSelectMaterializedIndexRule.java|  4 +-
 .../nereids_syntax_p0/mv/newMv/unique_mv.groovy| 48 ++
 2 files changed, 50 insertions(+), 2 deletions(-)
 create mode 100644 
regression-test/suites/nereids_syntax_p0/mv/newMv/unique_mv.groovy


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated: [fix](planner)should return outputTupleDesc's id instead of tupleIds if outputTupleDesc is set in Plan Node (#30518)

2024-01-30 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 8e9a80fd2f9 [fix](planner)should return outputTupleDesc's id instead 
of tupleIds if outputTupleDesc is set in Plan Node (#30518)
8e9a80fd2f9 is described below

commit 8e9a80fd2f9c6abb5ad4693fc847dd5eeda2edfa
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Tue Jan 30 17:30:10 2024 +0800

[fix](planner)should return outputTupleDesc's id instead of tupleIds if 
outputTupleDesc is set in Plan Node (#30518)
---
 fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java 
b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
index 8dcc8043b44..830421d0712 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
@@ -383,6 +383,9 @@ public abstract class PlanNode extends TreeNode 
implements PlanStats {
 }
 
 public List getOutputTupleIds() {
+if (outputTupleDesc != null) {
+return Lists.newArrayList(outputTupleDesc.getId());
+}
 return tupleIds;
 }
 


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated: [fix](nereids)window expression's window frame may lost in NormalizeToSlot (#30482)

2024-01-30 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 33b017c331f [fix](nereids)window expression's window frame may lost in 
NormalizeToSlot (#30482)
33b017c331f is described below

commit 33b017c331f477985b5ced35a7b0255e08d0efc2
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Tue Jan 30 17:33:28 2024 +0800

[fix](nereids)window expression's window frame may lost in NormalizeToSlot 
(#30482)

* [fix](nereids)window expression's window frame may lost in NormalizeToSlot

* [fix](planner)avg function may use wrong decimal precision and scale
---
 .../main/java/org/apache/doris/analysis/FunctionCallExpr.java  | 10 --
 .../apache/doris/nereids/rules/rewrite/NormalizeToSlot.java|  3 +++
 regression-test/data/correctness_p0/test_avg.out   |  3 +++
 regression-test/suites/correctness_p0/test_avg.groovy  |  3 +++
 .../suites/nereids_p0/aggregate/agg_window_project.groovy  |  5 +
 5 files changed, 22 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
index 68de4c7d6d6..b547fb5e308 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
@@ -960,8 +960,14 @@ public class FunctionCallExpr extends Expr {
 // DecimalV3 scale lower than DEFAULT_MIN_AVG_DECIMAL128_SCALE should 
do cast
 if (fnName.getFunction().equalsIgnoreCase("avg") && 
arg.type.isDecimalV3()
 && arg.type.getDecimalDigits() < 
ScalarType.DEFAULT_MIN_AVG_DECIMAL128_SCALE) {
-Type t = ScalarType.createDecimalType(arg.type.getPrimitiveType(), 
arg.type.getPrecision(),
-ScalarType.DEFAULT_MIN_AVG_DECIMAL128_SCALE);
+int precision = arg.type.getPrecision();
+int scale = arg.type.getDecimalDigits();
+precision = precision - scale + 
ScalarType.DEFAULT_MIN_AVG_DECIMAL128_SCALE;
+scale = ScalarType.DEFAULT_MIN_AVG_DECIMAL128_SCALE;
+if (precision > ScalarType.MAX_DECIMAL128_PRECISION) {
+precision = ScalarType.MAX_DECIMAL128_PRECISION;
+}
+Type t = ScalarType.createDecimalType(arg.type.getPrimitiveType(), 
precision, scale);
 Expr e = getChild(0).castTo(t);
 setChild(0, e);
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NormalizeToSlot.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NormalizeToSlot.java
index 41f384ac776..9b32ff42cea 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NormalizeToSlot.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/NormalizeToSlot.java
@@ -182,6 +182,9 @@ public interface NormalizeToSlot {
 }
 newChildren.add(newChild);
 }
+if (windowExpression.getWindowFrame().isPresent()) {
+newChildren.add(windowExpression.getWindowFrame().get());
+}
 return hasNewChildren ? windowExpression.withChildren(newChildren) 
: windowExpression;
 }
 }
diff --git a/regression-test/data/correctness_p0/test_avg.out 
b/regression-test/data/correctness_p0/test_avg.out
index 4cfab69a28b..225ed688e85 100644
--- a/regression-test/data/correctness_p0/test_avg.out
+++ b/regression-test/data/correctness_p0/test_avg.out
@@ -14,3 +14,6 @@
 -- !select3 --
 \N \N
 
+-- !select4 --
+0.0100
+
diff --git a/regression-test/suites/correctness_p0/test_avg.groovy 
b/regression-test/suites/correctness_p0/test_avg.groovy
index 20e53486340..8772ed591e0 100644
--- a/regression-test/suites/correctness_p0/test_avg.groovy
+++ b/regression-test/suites/correctness_p0/test_avg.groovy
@@ -73,4 +73,7 @@ suite("test_avg") {
 qt_select3 """select avg(distinct k2), avg(distinct cast(k4 as largeint)) 
from avg_test;"""
 
 sql """ drop table if exists avg_test; """
+
+sql """set enable_nereids_planner=false;"""
+qt_select4 """SELECT avg(col) from ( SELECT 0.01 col  union all  select 
0.01 col ) t;"""
 }
diff --git 
a/regression-test/suites/nereids_p0/aggregate/agg_window_project.groovy 
b/regression-test/suites/nereids_p0/aggregate/agg_window_project.groovy
index e9e0659e220..b75f46b1a06 100644
--- a/regression-test/suites/nereids_p0/aggregate/agg_window_project.groovy
+++ b/regression-test/suites/nereids_p0/aggregate/agg_window_project.groo

(doris) branch branch-2.0 updated: [fix](fe)add from_unixtime to null_result_with_one_null_param_functions set (#30516)

2024-01-30 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 3df036a8363 [fix](fe)add from_unixtime to 
null_result_with_one_null_param_functions set (#30516)
3df036a8363 is described below

commit 3df036a83638c6b23405e8c2031b73a7ee2696fd
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Tue Jan 30 17:31:20 2024 +0800

[fix](fe)add from_unixtime to null_result_with_one_null_param_functions set 
(#30516)
---
 gensrc/script/doris_builtins_functions.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gensrc/script/doris_builtins_functions.py 
b/gensrc/script/doris_builtins_functions.py
index 9b812852431..12a8f243ed9 100644
--- a/gensrc/script/doris_builtins_functions.py
+++ b/gensrc/script/doris_builtins_functions.py
@@ -2157,7 +2157,8 @@ null_result_with_one_null_param_functions = [
 'ST_GeometryFromText',
 'ST_LineFromText',
 'ST_Polygon',
-'ST_Contains'
+'ST_Contains',
+'from_unixtime'
 ]
 
 invisible_functions = [


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch branch-2.0 updated: [fix](nereids)group by expr may be lost in EliminateGroupByConstant rule (#30517)

2024-01-30 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
 new 73a7634ec9a [fix](nereids)group by expr may be lost in 
EliminateGroupByConstant rule (#30517)
73a7634ec9a is described below

commit 73a7634ec9aed4956f324eca9525513743e5e970
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Tue Jan 30 17:30:44 2024 +0800

[fix](nereids)group by expr may be lost in EliminateGroupByConstant rule 
(#30517)
---
 .../apache/doris/nereids/rules/analysis/EliminateGroupByConstant.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/EliminateGroupByConstant.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/EliminateGroupByConstant.java
index e7fa14e5cb2..e683153e9a2 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/EliminateGroupByConstant.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/EliminateGroupByConstant.java
@@ -67,7 +67,7 @@ public class EliminateGroupByConstant extends 
OneRewriteRuleFactory {
 lit = expression;
 }
 }
-if (slotGroupByExprs.isEmpty() && lit != null && 
aggregate.getAggregateFunctions().isEmpty()) {
+if (slotGroupByExprs.isEmpty() && lit != null) {
 slotGroupByExprs.add(lit);
 }
 return 
aggregate.withGroupByAndOutput(ImmutableList.copyOf(slotGroupByExprs), 
outputExprs);


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [test](nereids)add fe ut for SimplifyArithmeticComparisonRule (#27644)

2024-01-28 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 289bdd44083 [test](nereids)add fe ut for 
SimplifyArithmeticComparisonRule (#27644)
289bdd44083 is described below

commit 289bdd44083a21177961c3a604f2086f4e984116
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Mon Jan 29 15:26:37 2024 +0800

[test](nereids)add fe ut for SimplifyArithmeticComparisonRule (#27644)
---
 .../rules/SimplifyArithmeticComparisonRule.java| 20 -
 .../SimplifyArithmeticComparisonRuleTest.java  | 34 ++
 2 files changed, 46 insertions(+), 8 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyArithmeticComparisonRule.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyArithmeticComparisonRule.java
index eda95ba32b1..7606d082479 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyArithmeticComparisonRule.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/SimplifyArithmeticComparisonRule.java
@@ -82,20 +82,23 @@ public class SimplifyArithmeticComparisonRule extends 
AbstractExpressionRewriteR
 
 @Override
 public Expression visitComparisonPredicate(ComparisonPredicate comparison, 
ExpressionRewriteContext context) {
-ComparisonPredicate newComparison = comparison;
 if (couldRearrange(comparison)) {
-newComparison = normalize(comparison);
+ComparisonPredicate newComparison = normalize(comparison);
 if (newComparison == null) {
 return comparison;
 }
 try {
-List children = 
tryRearrangeChildren(newComparison.left(), newComparison.right());
-newComparison = (ComparisonPredicate) 
newComparison.withChildren(children);
+List children =
+tryRearrangeChildren(newComparison.left(), 
newComparison.right(), context);
+newComparison = (ComparisonPredicate) visitComparisonPredicate(
+(ComparisonPredicate) 
newComparison.withChildren(children), context);
 } catch (Exception e) {
 return comparison;
 }
+return TypeCoercionUtils.processComparisonPredicate(newComparison);
+} else {
+return comparison;
 }
-return TypeCoercionUtils.processComparisonPredicate(newComparison);
 }
 
 private boolean couldRearrange(ComparisonPredicate cmp) {
@@ -104,11 +107,12 @@ public class SimplifyArithmeticComparisonRule extends 
AbstractExpressionRewriteR
 && 
cmp.left().children().stream().anyMatch(Expression::isConstant);
 }
 
-private List tryRearrangeChildren(Expression left, Expression 
right) throws Exception {
-if (!left.child(1).isLiteral()) {
+private List tryRearrangeChildren(Expression left, Expression 
right,
+ExpressionRewriteContext context) throws Exception {
+if (!left.child(1).isConstant()) {
 throw new RuntimeException(String.format("Expected literal when 
arranging children for Expr %s", left));
 }
-Literal leftLiteral = (Literal) left.child(1);
+Literal leftLiteral = (Literal) 
FoldConstantRule.INSTANCE.rewrite(left.child(1), context);
 Expression leftExpr = left.child(0);
 
 Class oppositeOperator = 
rearrangementMap.get(left.getClass());
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rules/SimplifyArithmeticComparisonRuleTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rules/SimplifyArithmeticComparisonRuleTest.java
index 5a438ded653..fc31daaa941 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rules/SimplifyArithmeticComparisonRuleTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rules/SimplifyArithmeticComparisonRuleTest.java
@@ -41,6 +41,40 @@ class SimplifyArithmeticComparisonRuleTest extends 
ExpressionRewriteTestHelper {
 assertRewriteAfterSimplify("a + 1 > 1", "a > cast((1 - 1) as INT)", 
nameToSlot);
 assertRewriteAfterSimplify("a - 1 > 1", "a > cast((1 + 1) as INT)", 
nameToSlot);
 assertRewriteAfterSimplify("a / -2 > 1", "cast((1 * -2) as INT) > a", 
nameToSlot);
+
+// test integer type
+assertRewriteAfterSimplify("1 + a > 2", "a > cast((2 - 1) as INT)", 
nameToSlot);
+assertRewriteAfterSimplify("-1 + a > 2", "a > cast((2 - (-1)) as 
INT)", nameToSlot);
+

(doris) branch master updated (ced86e8bdb8 -> 9529c57f295)

2024-01-28 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

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


from ced86e8bdb8 [fix](query state) Print correct DML state (#30489)
 add 9529c57f295 [fix](planner)avg function may use wrong decimal precision 
and scale (#30364)

No new revisions were added by this update.

Summary of changes:
 .../java/org/apache/doris/analysis/FunctionCallExpr.java | 16 ++--
 regression-test/data/correctness_p0/test_avg.out |  3 +++
 regression-test/suites/correctness_p0/test_avg.groovy|  3 +++
 3 files changed, 20 insertions(+), 2 deletions(-)


-
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org



(doris) branch master updated: [improvement](statistics nereids)Nereids support select mv. (#30267)

2024-01-24 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 6bfb85b665e [improvement](statistics nereids)Nereids support select 
mv. (#30267)
6bfb85b665e is described below

commit 6bfb85b665efc6b32f8319f1045db7423115b1f8
Author: Jibing-Li <64681310+jibing...@users.noreply.github.com>
AuthorDate: Wed Jan 24 19:27:15 2024 +0800

[improvement](statistics nereids)Nereids support select mv. (#30267)
---
 .../antlr4/org/apache/doris/nereids/DorisParser.g4 |  6 +-
 .../main/java/org/apache/doris/load/ExportJob.java |  2 +-
 .../doris/nereids/analyzer/UnboundRelation.java| 20 +++--
 .../doris/nereids/parser/LogicalPlanBuilder.java   |  7 +-
 .../doris/nereids/rules/analysis/BindRelation.java | 19 -
 .../rules/implementation/AggregateStrategies.java  |  6 +-
 .../trees/plans/logical/LogicalOlapScan.java   | 35 +---
 regression-test/data/statistics/test_select_mv.out | 47 +++
 .../suites/statistics/test_select_mv.groovy| 97 ++
 9 files changed, 215 insertions(+), 24 deletions(-)

diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 
b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
index 4ec4065ce73..2afcc4d524f 100644
--- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
@@ -439,7 +439,7 @@ identifierSeq
 ;
 
 relationPrimary
-: multipartIdentifier specifiedPartition?
+: multipartIdentifier materializedViewName? specifiedPartition?
tabletList? tableAlias sample? relationHint? lateralView*   
#tableName
 | LEFT_PAREN query RIGHT_PAREN tableAlias lateralView* 
#aliasedQuery
 | tvfName=identifier LEFT_PAREN
@@ -447,6 +447,10 @@ relationPrimary
   RIGHT_PAREN tableAlias   
#tableValuedFunction
 ;
 
+materializedViewName
+: INDEX indexName=identifier
+;
+
 propertyClause
 : PROPERTIES LEFT_PAREN fileProperties=propertyItemList RIGHT_PAREN
 ;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java 
b/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java
index fc2f6fca9c5..0ae513d1db6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/ExportJob.java
@@ -353,7 +353,7 @@ public class ExportJob implements Writable {
 List partitions, List selectLists) {
 // UnboundRelation
 LogicalPlan plan = new 
UnboundRelation(StatementScopeIdGenerator.newRelationId(), qualifiedTableName,
-partitions, false, tabletIds, ImmutableList.of(), 
Optional.empty());
+partitions, false, tabletIds, ImmutableList.of(), 
Optional.empty(), Optional.empty());
 // LogicalCheckPolicy
 plan = new LogicalCheckPolicy<>(plan);
 // LogicalFilter
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundRelation.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundRelation.java
index 080e749c05b..74f85e31651 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundRelation.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/analyzer/UnboundRelation.java
@@ -52,21 +52,22 @@ public class UnboundRelation extends LogicalRelation 
implements Unbound, BlockFu
 private final boolean isTempPart;
 private final List hints;
 private final Optional tableSample;
+private final Optional indexName;
 
 public UnboundRelation(RelationId id, List nameParts) {
 this(id, nameParts, Optional.empty(), Optional.empty(), 
ImmutableList.of(), false, ImmutableList.of(),
-ImmutableList.of(), Optional.empty());
+ImmutableList.of(), Optional.empty(), Optional.empty());
 }
 
 public UnboundRelation(RelationId id, List nameParts, List 
partNames, boolean isTempPart) {
 this(id, nameParts, Optional.empty(), Optional.empty(), partNames, 
isTempPart, ImmutableList.of(),
-ImmutableList.of(), Optional.empty());
+ImmutableList.of(), Optional.empty(), Optional.empty());
 }
 
 public UnboundRelation(RelationId id, List nameParts, List 
partNames, boolean isTempPart,
-List tabletIds, List hints, Optional 
tableSample) {
+List tabletIds, List hints, Optional 
tableSample, Optional indexName) {
 this(id, nameParts, Optional.empty(), Optional.empty(),
-partNames, isTempPart, tabletIds, hints, tableSample);
+partNames, isTempPart, tabletIds, hints, tableSample, 
indexName);
 }
 
 /**
@@ -74,7 +75,7 @@ public class UnboundRelation extends Log

(doris) branch master updated: [fix](datatype) fixed decimal type implicit cast handling in BinaryPredicate (#30181)

2024-01-23 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 54aad27a4ee [fix](datatype) fixed decimal type implicit cast handling 
in BinaryPredicate (#30181)
54aad27a4ee is described below

commit 54aad27a4ee9d14e6dc62ec6f3373bdb91582bed
Author: Nitin-Kashyap <66766227+nitin-kash...@users.noreply.github.com>
AuthorDate: Wed Jan 24 07:27:23 2024 +0530

[fix](datatype) fixed decimal type implicit cast handling in 
BinaryPredicate (#30181)
---
 .../main/java/org/apache/doris/analysis/Expr.java  | 13 +++-
 .../test_predicate_with_implicit_cast.out  | 19 ++
 .../test_predicate_with_implicit_cast.groovy   | 71 ++
 3 files changed, 101 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
index 465c2c947c8..c2341b8eead 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
@@ -1674,10 +1674,19 @@ public abstract class Expr extends TreeNode 
implements ParseNode, Cloneabl
 Type t2 = getChild(1).getType();
 // add operand casts
 Preconditions.checkState(compatibleType.isValid());
-if (t1.getPrimitiveType() != compatibleType.getPrimitiveType()) {
+if (t1.isDecimalV3() || t1.isDecimalV2()) {
+if (!t1.equals(compatibleType)) {
+castChild(compatibleType, 0);
+}
+} else if (t1.getPrimitiveType() != compatibleType.getPrimitiveType()) 
{
 castChild(compatibleType, 0);
 }
-if (t2.getPrimitiveType() != compatibleType.getPrimitiveType()) {
+
+if (t2.isDecimalV3() || t2.isDecimalV2()) {
+if (!t2.equals(compatibleType)) {
+castChild(compatibleType, 1);
+}
+} else if (t2.getPrimitiveType() != compatibleType.getPrimitiveType()) 
{
 castChild(compatibleType, 1);
 }
 return compatibleType;
diff --git 
a/regression-test/data/datatype_p0/decimalv3/test_predicate_with_implicit_cast.out
 
b/regression-test/data/datatype_p0/decimalv3/test_predicate_with_implicit_cast.out
new file mode 100644
index 000..600f0488fab
--- /dev/null
+++ 
b/regression-test/data/datatype_p0/decimalv3/test_predicate_with_implicit_cast.out
@@ -0,0 +1,19 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !decimalv3_1 --
+5.75.705.70
+
+-- !decimalv3_2 --
+5.75.705.70
+
+-- !decimalv3_3 --
+5.75.705.70
+
+-- !decimalv3_1 --
+5.75.705.70
+
+-- !decimalv3_2 --
+5.75.705.70
+
+-- !decimalv3_3 --
+5.75.705.70
+
diff --git 
a/regression-test/suites/datatype_p0/decimalv3/test_predicate_with_implicit_cast.groovy
 
b/regression-test/suites/datatype_p0/decimalv3/test_predicate_with_implicit_cast.groovy
new file mode 100644
index 000..70cc0f935aa
--- /dev/null
+++ 
b/regression-test/suites/datatype_p0/decimalv3/test_predicate_with_implicit_cast.groovy
@@ -0,0 +1,71 @@
+// 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_predicate_with_implicit_cast") {
+def tableName1 = "test_decimalv3_to_decimalv3_1"
+def tableName2 = "test_decimalv3_to_decimalv3_2"
+
+def prepare_test_decimalV3_to_decimalV3 = {
+sql "drop table if exists ${tableName1};"
+sql """
+create table ${tableName1}(
+a DECIMAL(2, 1), 
+b DECIMAL(3, 2)
+) 
+ENGINE=OLAP
+DUPLICATE KEY(a) COMMENT "OLAP"
+DISTRIBUTED BY HASH(a) BUCKETS auto
+PROPERTIES ( "replication_num" = "1" );
+"""
+sql "drop table if exists ${tableName2};"
+sql """
+create table ${tableName2}(
+   

(doris) branch master updated: [opt](nereids) do not change RuntimeFilter Type from IN-OR_BLOOM to BLOOM on broadcast join (#30148)

2024-01-21 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 45ca7d587ef [opt](nereids) do not change RuntimeFilter Type from 
IN-OR_BLOOM to BLOOM on broadcast join (#30148)
45ca7d587ef is described below

commit 45ca7d587ef9826e306e92f15ca3fd7c5d2b69a8
Author: minghong 
AuthorDate: Mon Jan 22 09:22:19 2024 +0800

[opt](nereids) do not change RuntimeFilter Type from IN-OR_BLOOM to BLOOM 
on broadcast join (#30148)


1. do not change RuntimeFilter Type from IN-OR_BLOOM to BLOOM on 
broadcast join
tpcds1T, q48 improved from 4.x sec to 1.x sec
2. skip some redunant runtime filter
example: A join B on A.a1=B.b and A.a1 = A.a2
RF B.b->(A.a1, A.a2)
however, RF(B.b->A.a2) is implied by RF(B.a->A.a1) and A.a1=A.a2
we skip RF(B.b->A.a2)
Issue Number: close #xxx
---
 .../glue/translator/RuntimeFilterTranslator.java   |  6 -
 .../processor/post/RuntimeFilterGenerator.java |  2 +-
 .../trees/plans/physical/AbstractPhysicalJoin.java | 15 
 .../trees/plans/physical/AbstractPhysicalPlan.java | 21 ++--
 .../trees/plans/physical/RuntimeFilter.java|  4 
 .../rf_prune/query64.out   | 16 ++---
 .../nereids_tpcds_shape_sf100_p0/shape/query64.out | 28 +++---
 7 files changed, 56 insertions(+), 36 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/RuntimeFilterTranslator.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/RuntimeFilterTranslator.java
index 91f97906097..30a69ff97de 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/RuntimeFilterTranslator.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/glue/translator/RuntimeFilterTranslator.java
@@ -38,7 +38,6 @@ import org.apache.doris.planner.JoinNodeBase;
 import org.apache.doris.planner.RuntimeFilter.RuntimeFilterTarget;
 import org.apache.doris.planner.ScanNode;
 import org.apache.doris.qe.ConnectContext;
-import org.apache.doris.qe.SessionVariable;
 import org.apache.doris.statistics.StatisticalType;
 import org.apache.doris.thrift.TRuntimeFilterType;
 
@@ -185,11 +184,6 @@ public class RuntimeFilterTranslator {
 origFilter.markFinalized();
 origFilter.assignToPlanNodes();
 origFilter.extractTargetsPosition();
-// Number of parallel instances are large for pipeline engine, so we 
prefer bloom filter.
-if (origFilter.hasRemoteTargets() && origFilter.getType() == 
TRuntimeFilterType.IN_OR_BLOOM
-&& SessionVariable.enablePipelineEngine()) {
-origFilter.setType(TRuntimeFilterType.BLOOM);
-}
 return origFilter;
 }
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterGenerator.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterGenerator.java
index 76d189ba63d..8a75ad36c5a 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterGenerator.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/RuntimeFilterGenerator.java
@@ -567,7 +567,7 @@ public class RuntimeFilterGenerator extends 
PlanPostProcessor {
 PhysicalHashJoin join = 
innerEntry.getValue();
 Preconditions.checkState(join != null);
 TRuntimeFilterType type = TRuntimeFilterType.IN_OR_BLOOM;
-if (ctx.getSessionVariable().getEnablePipelineEngine()) {
+if (ctx.getSessionVariable().getEnablePipelineEngine() && 
!join.isBroadCastJoin()) {
 type = TRuntimeFilterType.BLOOM;
 }
 EqualTo newEqualTo = ((EqualTo) 
JoinUtils.swapEqualToForChildrenOrder(
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/AbstractPhysicalJoin.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/AbstractPhysicalJoin.java
index 16ba68aac62..7d1c65b5899 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/AbstractPhysicalJoin.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/physical/AbstractPhysicalJoin.java
@@ -19,6 +19,8 @@ package org.apache.doris.nereids.trees.plans.physical;
 
 import org.apache.doris.nereids.hint.DistributeHint;
 import org.apache.doris.nereids.memo.GroupExpression;
+import org.apache.doris.nereids.properties.DistributionSpec;
+import org.apache.doris.nereids.properties.DistributionSpecReplicated;
 import org.apache.doris.nereids.properties.LogicalProperties;
 import org.apache.doris.nereids.properties.PhysicalProperties;
 import org.apache.doris.nereids.trees.expre

(doris) branch master updated: [fix](nereids)logicalhaving is in wrong place after logicalagg and logicalwindow (#29463)

2024-01-09 Thread starocean999
This is an automated email from the ASF dual-hosted git repository.

starocean999 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 c880a011757 [fix](nereids)logicalhaving is in wrong place after 
logicalagg and logicalwindow (#29463)
c880a011757 is described below

commit c880a0117578212a696d2ffcf25cded7eeb04111
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Wed Jan 10 09:57:29 2024 +0800

[fix](nereids)logicalhaving is in wrong place after logicalagg and 
logicalwindow (#29463)
---
 .../doris/nereids/jobs/executor/Analyzer.java  |   2 +
 .../org/apache/doris/nereids/rules/RuleType.java   |   1 +
 .../nereids/rules/analysis/FillUpMissingSlots.java |   5 -
 .../nereids/rules/analysis/HavingToFilter.java |  34 +++
 .../nereids/rules/analysis/NormalizeAggregate.java | 264 +++--
 .../nereids_p0/aggregate/agg_window_project.out|   4 +
 .../nereids_p0/aggregate/agg_window_project.groovy |  22 ++
 7 files changed, 208 insertions(+), 124 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java
index c88cf1c432f..95fb019ad53 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/executor/Analyzer.java
@@ -33,6 +33,7 @@ import 
org.apache.doris.nereids.rules.analysis.CollectSubQueryAlias;
 import org.apache.doris.nereids.rules.analysis.EliminateGroupByConstant;
 import org.apache.doris.nereids.rules.analysis.EliminateLogicalSelectHint;
 import org.apache.doris.nereids.rules.analysis.FillUpMissingSlots;
+import org.apache.doris.nereids.rules.analysis.HavingToFilter;
 import org.apache.doris.nereids.rules.analysis.LeadingJoin;
 import org.apache.doris.nereids.rules.analysis.NormalizeAggregate;
 import org.apache.doris.nereids.rules.analysis.NormalizeRepeat;
@@ -161,6 +162,7 @@ public class Analyzer extends AbstractBatchJobExecutor {
 bottomUp(new CheckAnalysis()),
 topDown(new EliminateGroupByConstant()),
 topDown(new NormalizeAggregate()),
+topDown(new HavingToFilter()),
 bottomUp(new SemiJoinCommute()),
 bottomUp(
 new CollectSubQueryAlias(),
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
index cede463c924..61efe9e32f0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/RuleType.java
@@ -63,6 +63,7 @@ public enum RuleType {
 RESOLVE_PROJECT_ALIAS(RuleTypeClass.REWRITE),
 RESOLVE_AGGREGATE_ALIAS(RuleTypeClass.REWRITE),
 PROJECT_TO_GLOBAL_AGGREGATE(RuleTypeClass.REWRITE),
+HAVING_TO_FILTER(RuleTypeClass.REWRITE),
 ONE_ROW_RELATION_EXTRACT_AGGREGATE(RuleTypeClass.REWRITE),
 PROJECT_WITH_DISTINCT_TO_AGGREGATE(RuleTypeClass.REWRITE),
 AVG_DISTINCT_TO_SUM_DIV_COUNT(RuleTypeClass.REWRITE),
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/FillUpMissingSlots.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/FillUpMissingSlots.java
index a500d9bb668..c8efc1a8917 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/FillUpMissingSlots.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/FillUpMissingSlots.java
@@ -30,7 +30,6 @@ import 
org.apache.doris.nereids.trees.expressions.SlotReference;
 import 
org.apache.doris.nereids.trees.expressions.functions.agg.AggregateFunction;
 import org.apache.doris.nereids.trees.plans.Plan;
 import org.apache.doris.nereids.trees.plans.algebra.Aggregate;
-import org.apache.doris.nereids.trees.plans.logical.LogicalFilter;
 import org.apache.doris.nereids.trees.plans.logical.LogicalHaving;
 import org.apache.doris.nereids.trees.plans.logical.LogicalProject;
 import org.apache.doris.nereids.trees.plans.logical.LogicalSort;
@@ -174,10 +173,6 @@ public class FillUpMissingSlots implements 
AnalysisRuleFactory {
 return new 
LogicalProject<>(ImmutableList.copyOf(project.getOutput()),
 having.withChildren(new 
LogicalProject<>(projects, project.child(;
 })
-),
-// Convert having to filter
-RuleType.FILL_UP_HAVING_PROJECT.build(
-logicalHaving().then(having -> new 
LogicalFilter<>(having.getConjuncts(), having.child()))
 )
 );
 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/HavingToFilter.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/a

  1   2   3   >