McClone commented on issue #29968:
URL: https://github.com/apache/doris/issues/29968#issuecomment-1894839684

   `package org.apache.doris.udf;
   
   import org.apache.commons.collections.CollectionUtils;
   import org.apache.hadoop.hive.ql.exec.UDF;
   
   import java.util.ArrayList;
   import java.util.Stack;
   
   public class IsDif extends UDF {
   
       public int evaluate(ArrayList<String> values) {
           try {
               if (CollectionUtils.isEmpty(values)) {
                   return 0;
               }
               Stack<String> stack = new Stack<>();
               for (String value : values) {
                   if (stack.empty()) {
                       stack.push(value);
                   } else {
                       String top = stack.peek();
                       if (!top.equals(value)) {
                           if (stack.contains(value)) {
                               return 1;
                           }
                           stack.push(value);
                       }
                   }
               }
           } catch (Exception e) {
               e.printStackTrace();
               System.out.println(e.getMessage());
           }
           return 0;
       }
   }
   `


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to