Skip to content

Commit

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

Signed-off-by: xinyual <[email protected]>

* apply spotless

Signed-off-by: xinyual <[email protected]>

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

Co-authored-by: zane-neo <[email protected]>
Signed-off-by: Xinyuan Lu <[email protected]>

* fix spot less

Signed-off-by: xinyual <[email protected]>

---------

Signed-off-by: xinyual <[email protected]>
Signed-off-by: Xinyuan Lu <[email protected]>
Co-authored-by: zane-neo <[email protected]>
  • Loading branch information
xinyual and zane-neo authored Apr 30, 2024
1 parent 5588571 commit 05def20
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 @@ -387,6 +387,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 05def20

Please sign in to comment.