xuefuz commented on a change in pull request #8769: [FLINK-12875][hive] support 
converting input args of char, varchar, bytes, timestamp, date for Hive 
functions
URL: https://github.com/apache/flink/pull/8769#discussion_r294601274
 
 

 ##########
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/functions/hive/conversion/HiveInspectors.java
 ##########
 @@ -119,9 +141,45 @@ public static HiveObjectConversion 
getConversion(ObjectInspector inspector) {
                                } else {
                                        return IdentityConversion.INSTANCE;
                                }
+                       } else if (inspector instanceof 
JavaDateObjectInspector) {
+                               if (((JavaDateObjectInspector) 
inspector).preferWritable()) {
+                                       return o -> new DateWritable((Date) o);
+                               } else {
+                                       return IdentityConversion.INSTANCE;
+                               }
+                       } else if (inspector instanceof 
JavaTimestampObjectInspector) {
+                               if (((JavaTimestampObjectInspector) 
inspector).preferWritable()) {
+                                       return o -> new 
TimestampWritable((Timestamp) o);
+                               } else {
+                                       return IdentityConversion.INSTANCE;
+                               }
+                       } else if (inspector instanceof 
JavaBinaryObjectInspector) {
+                               if (((JavaBinaryObjectInspector) 
inspector).preferWritable()) {
+                                       return o -> new BytesWritable((byte[]) 
o);
+                               } else {
+                                       return IdentityConversion.INSTANCE;
+                               }
+                       } else if (inspector instanceof 
JavaHiveCharObjectInspector) {
+                               if (((JavaHiveCharObjectInspector) 
inspector).preferWritable()) {
+                                       return o -> new HiveCharWritable(
+                                               new HiveChar((String) o, 
((CharType) dataType.getLogicalType()).getLength()));
+                               } else {
+                                       return IdentityConversion.INSTANCE;
 
 Review comment:
   If o is a String (as the code shows), then identity conversion might not be 
expected because for char(p) type, Hive expects a HiveChar object instead of a 
string. However, I'm not 100% sure.
   
   Same for varchar.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to