Source:
private void buildColumns(ElasticsearchTableDescription tableDescription) { Set<ElasticsearchColumn> columns = new HashSet(); Client client = clients.get(tableDescription.getClusterName()); verify(client != null); try { GetMappingsRequest mappingsRequest = new GetMappingsRequest().types(tableDescription.getType()); String index = tableDescription.getIndex(); if (!isNullOrEmpty(index)) { mappingsRequest.indices(index); } ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = client.admin().indices().getMappings(mappingsRequest).actionGet(timeout.toMillis()).getMappings(); Iterator<String> indexIterator = mappings.keysIt(); while (indexIterator.hasNext()) { MappingMetaData mappingMetaData = mappings.get(indexIterator.next()).get(tableDescription.getType()); JSONObject mappingObject = new JSONObject(mappingMetaData.source().toString()).getJSONObject(tableDescription.getType()); JSONObject properties = mappingObject.getJSONObject("properties"); List<String> lists = new ArrayList<String>(); if (properties.has("_meta")) { JSONObject meta = mappingObject.getJSONObject("_meta"); if (meta.has("lists")) { JSONArray arrays = meta.getJSONArray("lists"); for (int i = 0; i < arrays.length(); i++) { lists.add(arrays.getString(i)); } } } for (String columnMetadata : getColumnsMetadata(null, properties)) { Optional<ElasticsearchColumn> column = createColumn(columnMetadata, lists); if (!column.isPresent()) { continue; } if (columns.stream().noneMatch(col -> col.getName().equals(column.get().getName()))) { columns.add(column.get()); } } } columns.add(createColumn("_id.type:string", ImmutableList.of()).get()); columns.add(createColumn("_index.type:string", ImmutableList.of()).get()); tableDescription.setColumns(ImmutableList.copyOf(columns)); tableDescription.setColumnsMetadata(columns.stream().map(ElasticsearchColumnMetadata::new).collect(Collectors.toList())); } catch (JSONException e) { throw new PrestoException(ELASTIC_SEARCH_MAPPING_REQUEST_ERROR, e); } }

Target:
private void buildColumns(ElasticsearchTableDescription tableDescription) { List<ElasticsearchColumn> columns = new ArrayList<>(); TransportClient client = clients.get(tableDescription.getClusterName()); verify(client != null, "TransportClient should not be null"); for (String index : getIndices(tableDescription)) { try { GetMappingsRequest mappingsRequest = new GetMappingsRequest().types(tableDescription.getType()); if (!isNullOrEmpty(index)) { mappingsRequest.indices(index); } ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings = client.admin() .indices() .getMappings(mappingsRequest) .actionGet(timeout.toMillis()) .getMappings(); Iterator<String> indexIterator = mappings.keysIt(); while (indexIterator.hasNext()) { MappingMetaData mappingMetaData = mappings.get(indexIterator.next()).get(tableDescription.getType()); JsonNode rootNode = OBJECT_MAPPER.readTree(mappingMetaData.source().uncompressed()); JsonNode mappingNode = rootNode.get(tableDescription.getType()); JsonNode propertiesNode = mappingNode.get("properties"); List<String> lists = new ArrayList<>(); JsonNode metaNode = mappingNode.get("_meta"); if (metaNode != null) { JsonNode arrayNode = metaNode.get("lists"); if (arrayNode != null && arrayNode.isArray()) { ArrayNode arrays = (ArrayNode) arrayNode; for (int i = 0; i < arrays.size(); i++) { lists.add(arrays.get(i).textValue()); } } } populateColumns(propertiesNode, lists, columns); } tableDescription.setColumns(columns); tableDescription.setColumnsMetadata(columns.stream() .map(ElasticsearchColumnMetadata::new) .collect(Collectors.toList())); } catch (IOException e) { throw new PrestoException(ELASTIC_SEARCH_MAPPING_REQUEST_ERROR, e); } } }