From 7738322062e1f677730e906df49d9d278c9be9b6 Mon Sep 17 00:00:00 2001 From: Arina Ielchiieva Date: Thu, 17 Nov 2016 12:44:34 +0000 Subject: [PATCH] DRILL-5047: When session option is string, query profile is displayed incorrectly on Web UI --- .../server/rest/profile/ProfileWrapper.java | 20 +++++++++++++++++-- .../main/resources/rest/profile/profile.ftl | 9 +++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileWrapper.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileWrapper.java index 84cff7afe43..d9edf3a6984 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileWrapper.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/profile/ProfileWrapper.java @@ -24,6 +24,7 @@ import java.util.Map; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.collect.Maps; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.drill.exec.proto.UserBitShared.CoreOperatorType; import org.apache.drill.exec.proto.UserBitShared.MajorFragmentProfile; @@ -32,6 +33,7 @@ import org.apache.drill.exec.proto.UserBitShared.QueryProfile; import org.apache.drill.exec.proto.helper.QueryIdHelper; import org.apache.drill.exec.server.options.OptionList; +import org.apache.drill.exec.server.options.OptionValue; import static com.fasterxml.jackson.databind.SerializationFeature.INDENT_OUTPUT; @@ -150,7 +152,21 @@ public String getOperatorsJSON() { return sb.append("}").toString(); } - public OptionList getOptionList() { - return options; + /** + * Generates sorted map with properties used to display on Web UI, + * where key is property name and value is property string value. + * When property value is null, it would be replaced with 'null', + * this is achieved using {@link String#valueOf(Object)} method. + * Options will be stored in ascending key order, sorted according + * to the natural order for the option name represented by {@link String}. + * + * @return map with properties names and string values + */ + public Map getOptions() { + final Map map = Maps.newTreeMap(); + for (OptionValue option : options) { + map.put(option.getName(), String.valueOf(option.getValue())); + } + return map; } } diff --git a/exec/java-exec/src/main/resources/rest/profile/profile.ftl b/exec/java-exec/src/main/resources/rest/profile/profile.ftl index c0f2d8e588a..792739f2649 100644 --- a/exec/java-exec/src/main/resources/rest/profile/profile.ftl +++ b/exec/java-exec/src/main/resources/rest/profile/profile.ftl @@ -107,7 +107,8 @@

FOREMAN: ${model.getProfile().getForeman().getAddress()}

TOTAL FRAGMENTS: ${model.getProfile().getTotalFragments()}

- <#if (model.getOptionList()?size > 0)> + <#assign options = model.getOptions()> + <#if (options?keys?size > 0)>

Session Options

@@ -129,10 +130,10 @@ - <#list model.getOptionList() as option> + <#list options?keys as name> - ${option.getName()} - ${option.getValue()?c} + ${name} + ${options[name]}