cyq89051127 commented on a change in pull request #12289:
URL: https://github.com/apache/flink/pull/12289#discussion_r430279519



##########
File path: 
flink-connectors/flink-hbase/src/main/java/org/apache/flink/addons/hbase/util/HBaseTypeUtils.java
##########
@@ -81,13 +81,16 @@ public static Object deserializeToObject(byte[] value, int 
typeIdx, Charset stri
         * Serialize the Java Object to byte array with the given type.
         */
        public static byte[] serializeFromObject(Object value, int typeIdx, 
Charset stringCharset) {
+               if (value == null){
+                       return EMPTY_BYTES;

Review comment:
       @wuchong , Hi, when i handle the empty byte by returning a null value, 
Some tests go wrong, like 'testTableSourceSinkWithDDL','testTableSink' . 
Because they expect an empty string when the value is empty bytes.  Here we 
have two options :
   
   1. **Only return a null value when the type is not string (typeIdx ==1), for 
string type , return an empty string "".**
   ```java
   if (Arrays.equals(value, EMPTY_BYTES)){
        if (typeIdx == 1){
                return "";
        }else{
                return null;
        }
   }
   ```
   2. **modifying the test case; making the expect null other than empty string 
when the value of an column in hbase is empty bytes**
   
   I think we'd better modifying the test case, because when flink writes a 
null to hbase, we should read it from hbase as null. Even for an existing hbase 
table, if the value of a column is empty bytes , we take it  as null .  It also 
works in the same logic. 
   
   How do you think about it?
   
   




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