Skip to content

Commit

Permalink
Address minor review comments.
Browse files Browse the repository at this point in the history
Signed-off-by: currantw <[email protected]>
  • Loading branch information
currantw committed Nov 7, 2024
1 parent 08af013 commit 4b05c24
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ public class QueryEngineException extends RuntimeException {
public QueryEngineException(String message) {
super(message);
}

public QueryEngineException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

/** Semantic Check Exception. */
public class SemanticCheckException extends QueryEngineException {

public SemanticCheckException(String message) {
super(message);
}

public SemanticCheckException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ private ExprValue exprCidrMatch(ExprValue addressExprValue, ExprValue rangeExprV
try {
address.validate();
} catch (AddressStringException e) {
throw new SemanticCheckException(
String msg =
String.format(
"IP address '%s' is not valid. Error details: %s", addressString, e.getMessage()));
"IP address '%s' is not valid. Error details: %s", addressString, e.getMessage());
throw new SemanticCheckException(msg, e);
}

// Get and validate CIDR IP address range.
Expand All @@ -76,19 +77,21 @@ private ExprValue exprCidrMatch(ExprValue addressExprValue, ExprValue rangeExprV
try {
range.validate();
} catch (AddressStringException e) {
throw new SemanticCheckException(
String msg =
String.format(
"CIDR IP address range '%s' is not valid. Error details: %s",
rangeString, e.getMessage()));
rangeString, e.getMessage());
throw new SemanticCheckException(msg, e);
}

// Address and range must use the same IP version (IPv4 or IPv6).
if (address.isIPv4() ^ range.isIPv4()) {
throw new SemanticCheckException(
String msg =
String.format(
"IP address '%s' and CIDR IP address range '%s' are not compatible. Both must be"
+ " either IPv4 or IPv6.",
addressString, rangeString));
addressString, rangeString);
throw new SemanticCheckException(msg);
}

return ExprValueUtils.booleanValue(range.contains(address));
Expand Down
9 changes: 5 additions & 4 deletions docs/category.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
"user/ppl/cmd/where.rst",
"user/ppl/general/identifiers.rst",
"user/ppl/general/datatypes.rst",
"user/ppl/functions/math.rst",
"user/ppl/functions/datetime.rst",
"user/ppl/functions/string.rst",
"user/ppl/functions/condition.rst",
"user/ppl/functions/datetime.rst",
"user/ppl/functions/expressions.rst",
"user/ppl/functions/ip.rst",
"user/ppl/functions/math.rst",
"user/ppl/functions/relevance.rst",
"user/ppl/functions/expressions.rst"
"user/ppl/functions/string.rst"
],
"sql_cli": [
"user/dql/expressions.rst",
Expand Down

0 comments on commit 4b05c24

Please sign in to comment.