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

morningman 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 2a35adbba8 [vectorized](udaf) fix java-udaf case of P0 is unstable 
(#18054)
2a35adbba8 is described below

commit 2a35adbba8f996a8df94edae13add5187612c87f
Author: zhangstar333 <[email protected]>
AuthorDate: Fri Mar 24 09:10:58 2023 +0800

    [vectorized](udaf) fix java-udaf case of P0 is unstable (#18054)
    
    the udaf case is unstable reason:
    when enable_pipeline_engine=true, the case of agg function only 1 instance,
    so not merge the default value, but if instance>1, will merge the default 
value
---
 .../javaudf_p0/test_javaudaf_my_date_datetime.out  |  8 ++---
 .../main/java/org/apache/doris/udf/MyDayDate.java  | 37 +++++++++++-----------
 2 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/regression-test/data/javaudf_p0/test_javaudaf_my_date_datetime.out 
b/regression-test/data/javaudf_p0/test_javaudaf_my_date_datetime.out
index d22867bf1c..64a31eece3 100644
--- a/regression-test/data/javaudf_p0/test_javaudaf_my_date_datetime.out
+++ b/regression-test/data/javaudf_p0/test_javaudaf_my_date_datetime.out
@@ -11,16 +11,16 @@
 1      2022-01-01      2022-01-01T11:11:11     2022-01-01      
2022-01-01T11:11:11
 
 -- !select1 --
-2022-01-11
+2022-01-09
 
 -- !select2 --
-1      2022-01-10
+1      2022-01-09
 
 -- !select3 --
-2022-01-11
+2022-01-09
 
 -- !select4 --
-1      2022-01-10
+1      2022-01-09
 
 -- !select5 --
 2022-01-01T03:00
diff --git 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/MyDayDate.java
 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/MyDayDate.java
index 2c0de4084f..d699fa34b0 100644
--- 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/MyDayDate.java
+++ 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/MyDayDate.java
@@ -24,11 +24,11 @@ import java.time.LocalDate;
 public class MyDayDate {
     private static final Logger LOG = Logger.getLogger(MyDayDate.class);
     public static class State {
-        public LocalDate counter = LocalDate.of(2022,01,01);
+        public LocalDate counter;
+        public boolean inited = false;
     }
 
     public State create() {
-        LOG.info("call create func");
         return new State();
     }
 
@@ -36,39 +36,40 @@ public class MyDayDate {
     }
 
     public void add(State state, LocalDate val1) {
-        if (val1 == null) {
-            LOG.info("add val is null");
-            return;
+        if (val1 == null) return;
+        if (!state.inited) {
+            state.inited = true;
+            state.counter = 
LocalDate.of(val1.getYear(),val1.getMonthValue(),val1.getDayOfMonth());
+        } else {
+            state.counter = state.counter.plusDays(val1.getDayOfMonth());
         }
-        LOG.info("val1: " + val1.toString());
-        LOG.info("add before state is: " + state.counter.toString());
-        state.counter = state.counter.plusDays(val1.getDayOfMonth());
-        LOG.info("add after state is: " + state.counter.toString());
     }
 
     public void serialize(State state, DataOutputStream out) throws 
IOException {
-        LOG.info("serialize state is: " + state.counter.toString());
         out.writeInt(state.counter.getYear());
         out.writeInt(state.counter.getMonthValue());
         out.writeInt(state.counter.getDayOfMonth());
+        out.writeBoolean(state.inited);
     }
 
     public void deserialize(State state, DataInputStream in) throws 
IOException {
-        LOG.info("deserialize before state is: " + state.counter.toString());
         state.counter = LocalDate.of(in.readInt(),in.readInt(),in.readInt());
-        LOG.info("deserialize after state is: " + state.counter.toString());
+        state.inited = in.readBoolean();
     }
 
     public void merge(State state, State rhs) {
-        LOG.info("merge rhs state is: " + rhs.counter.toString());
-        LOG.info("merge before state is: " + state.counter.toString());
-        state.counter = state.counter.plusDays(rhs.counter.getDayOfMonth());
-        LOG.info("merge after state is: " + state.counter.toString());
+        if (!rhs.inited) {
+            return;
+        }
+        if (!state.inited) {
+            state.inited = true;
+            state.counter = 
LocalDate.of(rhs.counter.getYear(),rhs.counter.getMonthValue(),rhs.counter.getDayOfMonth());
+        } else {
+            state.counter = 
state.counter.plusDays(rhs.counter.getDayOfMonth());
+        }
     }
 
     public LocalDate getValue(State state) {
-        LOG.info("getValue state is: " + state.counter.toString());
-        LOG.info("------------------------------end----------------------");
         return state.counter;
     }
 }
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to