SteNicholas commented on a change in pull request #13983:
URL: https://github.com/apache/flink/pull/13983#discussion_r531982527



##########
File path: 
flink-python/src/main/java/org/apache/flink/api/common/python/PythonBridgeUtils.java
##########
@@ -266,6 +278,92 @@ private static Object getPickledBytesFromJavaObject(Object 
obj, LogicalType data
                }
        }
 
+       public static Object getPickledBytesFromJavaObject(Object obj, 
TypeInformation<?> dataType) throws IOException {
+               Pickler pickler = new Pickler();
+               initialize();
+               if (obj == null) {
+                       return new byte[0];
+               } else {
+                       if (dataType instanceof SqlTimeTypeInfo) {
+                               SqlTimeTypeInfo<?> sqlTimeTypeInfo = 
SqlTimeTypeInfo.getInfoFor(dataType.getTypeClass());
+                               if (sqlTimeTypeInfo == DATE) {
+                                       long time;
+                                       if (obj instanceof LocalDate) {
+                                               time = ((LocalDate) 
(obj)).toEpochDay();
+                                       } else {
+                                               time = ((Date) 
obj).toLocalDate().toEpochDay();

Review comment:
       @dianfu , for `DateType` and `DATE`, the object could both be pickled 
directly, but for `DateType` this has the type check to pickle the Date object. 
IMO, this should be unified for `DateType` and `DATE`.




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

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


Reply via email to