Skip to content

Commit

Permalink
moved validateGeoIpProperty to relevant class
Browse files Browse the repository at this point in the history
Signed-off-by: Kenrick Yap <[email protected]>
  • Loading branch information
kenrickyap committed Dec 19, 2024
1 parent e037672 commit 406d2c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,22 +457,14 @@ public UnresolvedExpression visitGeoIpPropertyList(OpenSearchPPLParser.GeoIpProp
if (ctx != null) {
for (OpenSearchPPLParser.GeoIpPropertyContext property : ctx.geoIpProperty()) {
String propertyName = property.getText().toUpperCase();
validateGeoIpProperty(propertyName);
GeoIpCatalystLogicalPlanTranslator.validateGeoIpProperty(propertyName);
properties.add(new Literal(propertyName, DataType.STRING));
}
}

return new AttributeList(properties.build());
}

private static void validateGeoIpProperty(String propertyName) {
try {
GeoIpCatalystLogicalPlanTranslator.GeoIpProperty.valueOf(propertyName);
} catch (NullPointerException | IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid properties used.");
}
}

private List<UnresolvedExpression> timestampFunctionArguments(
OpenSearchPPLParser.TimestampFunctionCallContext ctx) {
List<UnresolvedExpression> args =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,12 @@ enum GeoIpProperty {
TIME_ZONE,
LOCATION
}

public static void validateGeoIpProperty(String propertyName) {
try {
GeoIpProperty.valueOf(propertyName);
} catch (NullPointerException | IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid properties used.");
}
}
}

0 comments on commit 406d2c9

Please sign in to comment.