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_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:
[email protected]
With regards,
Apache Git Services