in data/src/main/java/com/microsoft/azure/kusto/data/KustoOperationResult.java [83:119]
private void createFromV1Response(String response) {
try {
JsonNode jsonObject = objectMapper.readTree(response);
if (jsonObject.has(TABLES_LIST_PROPERTY_NAME) && jsonObject.get(TABLES_LIST_PROPERTY_NAME).isArray()) {
ArrayNode jsonArray = (ArrayNode) jsonObject.get(TABLES_LIST_PROPERTY_NAME);
for (int i = 0; i < jsonArray.size(); i++) {
JsonNode table = jsonArray.get(i);
resultTables.add(new KustoResultSetTable(table));
}
} else {
throw new JsonPropertyMissingException("Tables Property missing from V1 response json");
}
} catch (JsonProcessingException | JsonPropertyMissingException e) {
log.error("Json processing error occurred while parsing string to json with exception", e);
throw new KustoServiceQueryError("Json processing error occurred while parsing string to json with exception " + e.getMessage());
}
if (resultTables.size() <= 2) {
resultTables.get(0).setTableKind(WellKnownDataSet.PrimaryResult);
resultTables.get(0).setTableId(Integer.toString(0));
if (resultTables.size() == 2) {
resultTables.get(1).setTableKind(WellKnownDataSet.QueryProperties);
resultTables.get(1).setTableId(Integer.toString(1));
}
} else {
KustoResultSetTable toc = resultTables.get(resultTables.size() - 1);
toc.setTableKind(WellKnownDataSet.TableOfContents);
toc.setTableId(Integer.toString(resultTables.size() - 1));
for (int i = 0; i < resultTables.size() - 1; i++) {
toc.next();
resultTables.get(i).setTableName(toc.getString(TABLE_NAME_PROPERTY_NAME));
resultTables.get(i).setTableId(toc.getString(TABLE_ID_PROPERTY_NAME));
resultTables.get(i).setTableKind(tablesKindsMap.get(toc.getString(TABLE_KIND_PROPERTY_NAME)));
}
}
}