Gabriel39 commented on code in PR #9440:
URL: https://github.com/apache/incubator-doris/pull/9440#discussion_r872942595


##########
fe/java-udf/src/main/java/org/apache/doris/udf/UdfExecutor.java:
##########
@@ -307,50 +324,113 @@ private boolean storeUdfResult(Object obj, long row) 
throws UdfRuntimeException
         switch (retType_) {
             case BOOLEAN: {
                 boolean val = (boolean) obj;
-                UdfUtils.UNSAFE.putByte(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(), val ? (byte) 1 : 0);
+                UdfUtils.UNSAFE.putByte(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(),
+                        val ? (byte) 1 : 0);
                 return true;
             }
             case TINYINT: {
-                UdfUtils.UNSAFE.putByte(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(), (byte) obj);
+                UdfUtils.UNSAFE.putByte(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(),
+                        (byte) obj);
                 return true;
             }
             case SMALLINT: {
-                UdfUtils.UNSAFE.putShort(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(), (short) obj);
+                UdfUtils.UNSAFE.putShort(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(),
+                        (short) obj);
                 return true;
             }
             case INT: {
-                UdfUtils.UNSAFE.putInt(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(), (int) obj);
+                UdfUtils.UNSAFE.putInt(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(),
+                        (int) obj);
                 return true;
             }
             case BIGINT: {
-                UdfUtils.UNSAFE.putLong(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(), (long) obj);
+                UdfUtils.UNSAFE.putLong(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(),
+                        (long) obj);
                 return true;
             }
             case FLOAT: {
-                UdfUtils.UNSAFE.putFloat(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(), (float) obj);
+                UdfUtils.UNSAFE.putFloat(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(),
+                        (float) obj);
                 return true;
             }
             case DOUBLE: {
-                UdfUtils.UNSAFE.putDouble(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(), (double) obj);
+                UdfUtils.UNSAFE.putDouble(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(),
+                        (double) obj);
+                return true;
+            }
+            case DATE: {
+                LocalDate date = (LocalDate) obj;
+                long time =
+                        convertDateTimeToLong(date.getYear(), 
date.getMonthValue(), date.getDayOfMonth(), 0, 0, 0,
+                                true);
+                UdfUtils.UNSAFE.putLong(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(),
+                        time);
+                return true;
+            }
+            case DATETIME: {
+                LocalDateTime date = (LocalDateTime) obj;
+                long time =
+                        convertDateTimeToLong(date.getYear(), 
date.getMonthValue(), date.getDayOfMonth(),
+                                date.getHour(),
+                                date.getMinute(), date.getSecond(), false);
+                UdfUtils.UNSAFE.putLong(UdfUtils.UNSAFE.getLong(null, 
outputBufferPtr_) + row * retType_.getLen(),
+                        time);
+                return true;
+            }
+            case LARGEINT: {
+                BigInteger data = (BigInteger) obj;
+                byte[] bytes = convertByteOrder(data.toByteArray());
+
+                //here  value is 16 bytes, so if result data greater than the 
maximum of 16 bytes
+                //it will return a wrong num to backend;

Review Comment:
   If a decimal scale is beyond our limit in BE, we should log a warning and 
just return NULL.



-- 
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