Skip to content

Commit

Permalink
add error message for NPE (#301) (#304)
Browse files Browse the repository at this point in the history
* add error message for NPE



* apply spotless



* Update src/main/java/org/opensearch/agent/tools/PPLTool.java




* fix spot less



---------




(cherry picked from commit 05def20)

Signed-off-by: xinyual <[email protected]>
Signed-off-by: Xinyuan Lu <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: zane-neo <[email protected]>
  • Loading branch information
3 people authored Apr 30, 2024
1 parent fc352a9 commit 1ddf2cd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/org/opensearch/agent/tools/PPLTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,11 @@ private String constructTableInfo(SearchHit[] searchHits, Map<String, MappingMet
String firstIndexName = (String) mappings.keySet().toArray()[0];
MappingMetadata mappingMetadata = mappings.get(firstIndexName);
Map<String, Object> mappingSource = (Map<String, Object>) mappingMetadata.getSourceAsMap().get("properties");
if (Objects.isNull(mappingSource)) {
throw new IllegalArgumentException(
"The querying index doesn't have mapping metadata, please add data to it or using another index."
);
}
Map<String, String> fieldsToType = new HashMap<>();
extractNamesTypes(mappingSource, fieldsToType, "");
StringJoiner tableInfoJoiner = new StringJoiner("\n");
Expand Down

0 comments on commit 1ddf2cd

Please sign in to comment.