Skip to content

Commit 9bb9ccf

Browse files
Don't throw exceptions in the Analyzer
1 parent 6171a8c commit 9bb9ccf

File tree

2 files changed

+12
-16
lines changed
  • x-pack/plugin/esql

2 files changed

+12
-16
lines changed

x-pack/plugin/esql/qa/security/src/javaRestTest/java/org/elasticsearch/xpack/esql/EsqlSecurityIT.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -828,12 +828,7 @@ private void testLookupJoinFieldLevelSecurityHelper(boolean useExpressionJoin) t
828828
ResponseException error = expectThrows(ResponseException.class, () -> runESQLCommand("fls_user4_1", query));
829829
assertThat(error.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
830830
if (useExpressionJoin) {
831-
assertThat(
832-
error.getMessage(),
833-
containsString(
834-
"Join condition must be between one attribute on the left side and one attribute on the right side of the join"
835-
)
836-
);
831+
assertThat(error.getMessage(), containsString("Unsupported join filter expression:value_left == value"));
837832
} else {
838833
assertThat(error.getMessage(), containsString("Unknown column [value] in right side of join"));
839834
}
@@ -907,12 +902,7 @@ private void testLookupJoinFieldLevelSecurityOnAliasHelper(boolean useExpression
907902
ResponseException error = expectThrows(ResponseException.class, () -> runESQLCommand("fls_user4_1_alias", query));
908903
assertThat(error.getResponse().getStatusLine().getStatusCode(), equalTo(HttpStatus.SC_BAD_REQUEST));
909904
if (useExpressionJoin) {
910-
assertThat(
911-
error.getMessage(),
912-
containsString(
913-
"Join condition must be between one attribute on the left side and one attribute on the right side of the join"
914-
)
915-
);
905+
assertThat(error.getMessage(), containsString("Unsupported join filter expression:value_left == value"));
916906
} else {
917907
assertThat(error.getMessage(), containsString("Unknown column [value] in right side of join"));
918908
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Analyzer.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -757,9 +757,9 @@ private Expression resolveAndOrientJoinCondition(Expression condition, Attribute
757757
if (leftIsFromRight && rightIsFromLeft) {
758758
return comp.swapLeftAndRight(); // Swapped orientation
759759
}
760-
761-
// Invalid orientation (e.g., both from left or both from right)
762-
throw new IllegalArgumentException(
760+
return new UnresolvedAttribute(
761+
condition.source(),
762+
"unsupported",
763763
"Join condition must be between one attribute on the left side and "
764764
+ "one attribute on the right side of the join, but found: "
765765
+ condition.sourceText()
@@ -800,7 +800,13 @@ private Join resolveLookupJoin(LookupJoin join) {
800800
leftKeys.add(leftAttribute);
801801
rightKeys.add(rightAttribute);
802802
} else {
803-
throw new IllegalArgumentException("Unsupported join filter expression: " + expression);
803+
UnresolvedAttribute errorAttribute = new UnresolvedAttribute(
804+
expression.source(),
805+
"unsupported",
806+
"Unsupported join filter expression:" + expression.sourceText()
807+
);
808+
return join.withConfig(new JoinConfig(type, singletonList(errorAttribute), emptyList(), null));
809+
804810
}
805811
}
806812
} else {

0 commit comments

Comments
 (0)