drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [drill] vdiravka commented on a change in pull request #1672: DRILL-7049 return VARBINARY as a string with escaped non printable bytes
Date Tue, 05 Mar 2019 15:16:29 GMT
vdiravka commented on a change in pull request #1672: DRILL-7049 return VARBINARY as a string
with escaped non printable bytes
URL: https://github.com/apache/drill/pull/1672#discussion_r262542111
 
 

 ##########
 File path: exec/java-exec/src/main/java/org/apache/drill/exec/util/ValueVectorElementFormatter.java
 ##########
 @@ -52,28 +52,51 @@ public ValueVectorElementFormatter(OptionManager options) {
    * @return the formatted value, null if failed
    */
   public String format(Object value, TypeProtos.MinorType minorType) {
+    String str = null;
     switch (minorType) {
       case TIMESTAMP:
         if (value instanceof LocalDateTime) {
-          return format((LocalDateTime) value,
+          str = format((LocalDateTime) value,
                         options.getString(ExecConstants.WEB_DISPLAY_FORMAT_TIMESTAMP),
                         (v, p) -> v.format(getTimestampFormatter(p)));
         }
+        else {
+          str = value.toString();
+        }
+        break;
       case DATE:
         if (value instanceof LocalDate) {
-          return format((LocalDate) value,
+          str = format((LocalDate) value,
                         options.getString(ExecConstants.WEB_DISPLAY_FORMAT_DATE),
                         (v, p) -> v.format(getDateFormatter(p)));
         }
+        else {
+          str = value.toString();
+        }
+        break;
       case TIME:
         if (value instanceof LocalTime) {
-          return format((LocalTime) value,
+          str = format((LocalTime) value,
                         options.getString(ExecConstants.WEB_DISPLAY_FORMAT_TIME),
                         (v, p) -> v.format(getTimeFormatter(p)));
         }
+        else {
+          str = value.toString();
+        }
+        break;
+      case VARBINARY:
+        if(value instanceof byte[]) {
+          byte[] bytes = (byte[]) value;
+          str = org.apache.drill.common.util.DrillStringUtils.toBinaryString(bytes);
+        }
+        else {
+          str = value.toString();
+        }
+      break;
       default:
-        return value.toString();
+        str = value.toString();
     }
+    return str;
 
 Review comment:
   Looks like you can remove all `else` blocks and put here `return value.toString();`.
   _Note:_ `break` statements should be present (as is in your code), return statements should
be preserved as earlier, default block can be omitted.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message