Skip to content

Commit

Permalink
validate exclusion in parser
Browse files Browse the repository at this point in the history
  • Loading branch information
fang-xing-esql committed Aug 23, 2024
1 parent f8334f9 commit 83b3d98
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,20 @@ private static void validateIndexPattern(String indexPattern, EsqlBaseParser.Ind
if (index.strip().isEmpty()) {
continue;
}
if (index.startsWith("<") && index.endsWith(">")) {
index = IndexNameExpressionResolver.resolveDateMathExpression(index);
if (index.charAt(0) == '-') {
index = index.substring(1);
}
MetadataCreateIndexService.validateIndexOrAliasName(index.strip(), InvalidIndexNameException::new);
MetadataCreateIndexService.validateIndexOrAliasName(
removeExclusion(IndexNameExpressionResolver.resolveDateMathExpression(removeExclusion(index))),
InvalidIndexNameException::new
);
}
} catch (InvalidIndexNameException | ElasticsearchParseException e) {
throw new ParsingException(e, source(ctx), e.getMessage());
}
}

private static String removeExclusion(String indexPattern) {
return indexPattern.charAt(0) == '-' ? indexPattern.substring(1) : indexPattern;
}
}

0 comments on commit 83b3d98

Please sign in to comment.