You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2019/03/25 10:13:00 UTC

[jira] [Commented] (DRILL-7049) REST API returns the toString of byte arrays (VARBINARY types)

    [ https://issues.apache.org/jira/browse/DRILL-7049?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16800538#comment-16800538 ] 

ASF GitHub Bot commented on DRILL-7049:
---------------------------------------

vdiravka commented on pull request #1672: DRILL-7049 return VARBINARY as a string with escaped non printable bytes
URL: https://github.com/apache/drill/pull/1672#discussion_r268565353
 
 

 ##########
 File path: exec/java-exec/src/main/java/org/apache/drill/exec/util/ValueVectorElementFormatter.java
 ##########
 @@ -52,28 +52,47 @@ public ValueVectorElementFormatter(OptionManager options) {
    * @return the formatted value, null if failed
    */
   public String format(Object value, TypeProtos.MinorType minorType) {
+    boolean handled = false;
+	String str = null;
     switch (minorType) {
       case TIMESTAMP:
         if (value instanceof LocalDateTime) {
-          return format((LocalDateTime) value,
+          handled = true;
+          str = format((LocalDateTime) value,
                         options.getString(ExecConstants.WEB_DISPLAY_FORMAT_TIMESTAMP),
                         (v, p) -> v.format(getTimestampFormatter(p)));
         }
+        break;
       case DATE:
         if (value instanceof LocalDate) {
-          return format((LocalDate) value,
+          handled = true;
+          str = format((LocalDate) value,
                         options.getString(ExecConstants.WEB_DISPLAY_FORMAT_DATE),
                         (v, p) -> v.format(getDateFormatter(p)));
         }
+        break;
       case TIME:
         if (value instanceof LocalTime) {
-          return format((LocalTime) value,
+          handled = true;
+          str = format((LocalTime) value,
                         options.getString(ExecConstants.WEB_DISPLAY_FORMAT_TIME),
                         (v, p) -> v.format(getTimeFormatter(p)));
         }
-      default:
-        return value.toString();
+        break;
+      case VARBINARY:
+        if (value instanceof byte[]) {
+          handled = true;
+          byte[] bytes = (byte[]) value;
+          str = org.apache.drill.common.util.DrillStringUtils.toBinaryString(bytes);
+        }
+        break;
+    }
+
+    if (!handled) {
 
 Review comment:
   It looks like current code execution is the same as in your PR. But logic from PR is more complex: additional flag `handled`, breaks in switch statements...
   I think we can leave current code from Drill master and add  your `case VARBINARY`.
   Seems it will be enough.
 
----------------------------------------------------------------
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


> REST API returns the toString of byte arrays (VARBINARY types)
> --------------------------------------------------------------
>
>                 Key: DRILL-7049
>                 URL: https://issues.apache.org/jira/browse/DRILL-7049
>             Project: Apache Drill
>          Issue Type: Bug
>          Components:  Server, Web Server
>    Affects Versions: 1.15.0
>            Reporter: jean-claude
>            Priority: Minor
>             Fix For: 1.16.0
>
>
> Doing a query using the REST API will return VARBINARY columns as a Java byte array hashcode instead of the actual data of the VARBINARY.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)