diff --git a/core/src/main/java/com/amazon/opendistroforelasticsearch/sql/data/model/ExprCollectionValue.java b/core/src/main/java/com/amazon/opendistroforelasticsearch/sql/data/model/ExprCollectionValue.java index 4d71e260e2..ba66f95c5d 100644 --- a/core/src/main/java/com/amazon/opendistroforelasticsearch/sql/data/model/ExprCollectionValue.java +++ b/core/src/main/java/com/amazon/opendistroforelasticsearch/sql/data/model/ExprCollectionValue.java @@ -18,11 +18,10 @@ import com.amazon.opendistroforelasticsearch.sql.data.type.ExprCoreType; import com.amazon.opendistroforelasticsearch.sql.data.type.ExprType; import com.google.common.base.Objects; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; -import lombok.EqualsAndHashCode; import lombok.RequiredArgsConstructor; /** @@ -34,7 +33,11 @@ public class ExprCollectionValue extends AbstractExprValue { @Override public Object value() { - return valueList; + List results = new ArrayList<>(); + for (ExprValue exprValue : valueList) { + results.add(exprValue.value()); + } + return results; } @Override diff --git a/protocol/src/test/java/com/amazon/opendistroforelasticsearch/sql/protocol/response/format/SimpleJsonResponseFormatterTest.java b/protocol/src/test/java/com/amazon/opendistroforelasticsearch/sql/protocol/response/format/SimpleJsonResponseFormatterTest.java index f29937fad3..f7d8d6e710 100644 --- a/protocol/src/test/java/com/amazon/opendistroforelasticsearch/sql/protocol/response/format/SimpleJsonResponseFormatterTest.java +++ b/protocol/src/test/java/com/amazon/opendistroforelasticsearch/sql/protocol/response/format/SimpleJsonResponseFormatterTest.java @@ -129,6 +129,25 @@ void formatResponseWithTupleValue() { formatter.format(response)); } + @Test + void formatResponseWithArrayValue() { + QueryResult response = + new QueryResult( + schema, + Arrays.asList( + tupleValue(ImmutableMap + .of("name", "Smith", + "address", Arrays.asList( + ImmutableMap.of("state", "WA"), ImmutableMap.of("state", "NYC") + ))))); + SimpleJsonResponseFormatter formatter = new SimpleJsonResponseFormatter(COMPACT); + assertEquals( + "{\"schema\":[{\"name\":\"firstname\",\"type\":\"string\"}," + + "{\"name\":\"age\",\"type\":\"integer\"}]," + + "\"datarows\":[[\"Smith\",[{\"state\":\"WA\"},{\"state\":\"NYC\"}]]]," + + "\"total\":1,\"size\":1}", + formatter.format(response)); + } @Test void formatError() {