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

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


The following commit(s) were added to refs/heads/master by this push:
     new 9abf32324b [improvement](jdbc) add `timestamp` put to `datev2` (#21680)
9abf32324b is described below

commit 9abf32324befde7aa737e63b75d052825b5602bc
Author: lsy3993 <[email protected]>
AuthorDate: Wed Jul 26 09:10:34 2023 +0800

    [improvement](jdbc) add `timestamp` put to `datev2` (#21680)
---
 .../java/org/apache/doris/jdbc/JdbcExecutor.java   | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git 
a/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/JdbcExecutor.java
 
b/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/JdbcExecutor.java
index 0716a10dc2..fae5c32459 100644
--- 
a/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/JdbcExecutor.java
+++ 
b/fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/JdbcExecutor.java
@@ -1141,6 +1141,29 @@ public class JdbcExecutor {
         }
     }
 
+    private void timestampPutToInt(Object[] column, boolean isNullable, int 
numRows, long nullMapAddr,
+            long columnAddr, int startRowForNullable) {
+        if (isNullable) {
+            for (int i = startRowForNullable; i < numRows; i++) {
+                if (column[i] == null) {
+                    UdfUtils.UNSAFE.putByte(nullMapAddr + i, (byte) 1);
+                } else {
+                    LocalDateTime date = ((java.sql.Timestamp) 
column[i]).toLocalDateTime();
+                    UdfUtils.UNSAFE.putInt(columnAddr + (i * 4L),
+                            UdfUtils.convertToDateV2(date.getYear(), 
date.getMonthValue(),
+                                    date.getDayOfMonth()));
+                }
+            }
+        } else {
+            for (int i = 0; i < numRows; i++) {
+                LocalDateTime date = ((java.sql.Timestamp) 
column[i]).toLocalDateTime();
+                UdfUtils.UNSAFE.putLong(columnAddr + (i * 4L),
+                        UdfUtils.convertToDateV2(date.getYear(), 
date.getMonthValue(),
+                                date.getDayOfMonth()));
+            }
+        }
+    }
+
     public void copyBatchDateV2Result(Object columnObj, boolean isNullable, 
int numRows, long nullMapAddr,
             long columnAddr) {
         Object[] column = (Object[]) columnObj;
@@ -1155,6 +1178,8 @@ public class JdbcExecutor {
             localDatePutToInt(column, isNullable, numRows, nullMapAddr, 
columnAddr, firstNotNullIndex);
         } else if (column[firstNotNullIndex] instanceof Date) {
             datePutToInt(column, isNullable, numRows, nullMapAddr, columnAddr, 
firstNotNullIndex);
+        } else if (column[firstNotNullIndex] instanceof Timestamp) {
+            timestampPutToInt(column, isNullable, numRows, nullMapAddr, 
columnAddr, firstNotNullIndex);
         }
     }
 


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

Reply via email to