Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/144826.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
area: ES|QL
issues:
- 144329
pr: 144826
summary: Propagate empty local relation past joins
type: bug
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public abstract class GenerativeRestTest extends ESRestTestCase implements Query
// full-text functions are not allowed to match on fields that come from lookup indices
"cannot operate on \\[.*\\], supplied by an index \\[.*\\] in non-STANDARD mode \\[lookup\\]",
"Can only use fuzzy queries on keyword and text fields - not on \\[.*\\] which is of type \\[.*\\]",
// multi_match query receiving a non-boolean value for a boolean type field
// full-text function receiving a non-boolean value for a boolean type field
"Can't parse boolean value \\[.*\\], expected \\[true\\] or \\[false\\]",
// full-text function trying to parse text as date field and failing
"failed to parse date field \\[.*\\] with format",
Expand Down
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth adding a test with a filter on null (WHERE null, EVAL x = NULL | WHERE x::int > 0 or along the lines)?

Original file line number Diff line number Diff line change
Expand Up @@ -5873,3 +5873,319 @@ warning:Line 13:24: java.lang.IllegalArgumentException: single-value function en
language_name:keyword | country:text | other2:integer | YEcxuCOHsGzb:keyword | other1:keyword | date:datetime | date_nanos:date_nanos | id_int:integer | ip_addr:ip | is_active_bool:boolean | name_str:keyword

;

whereFalseBeforeLookupJoin
required_capability: join_lookup_v12

FROM employees
| WHERE false
| EVAL language_code = languages
| LOOKUP JOIN languages_lookup ON language_code
| KEEP emp_no, language_code, language_name
;

emp_no:integer | language_code:integer | language_name:keyword
;

whereFalseBeforeLookupJoinWithFilterAfter
required_capability: join_lookup_v12

FROM employees
| WHERE false
| EVAL language_code = languages
| LOOKUP JOIN languages_lookup ON language_code
| WHERE emp_no > 100
| KEEP emp_no, language_code, language_name
;

emp_no:integer | language_code:integer | language_name:keyword
;

whereFalseBeforeLookupJoinWithStatsAfter
required_capability: join_lookup_v12

FROM employees
| WHERE false
| EVAL language_code = languages
| LOOKUP JOIN languages_lookup ON language_code
| STATS c = COUNT(*)
;

c:long
0
;

impossibleFilterBeforeLookupJoin
required_capability: join_lookup_v12

FROM employees
| EVAL a = 1, b = a + 1, c = b + a
| WHERE c > 10
| EVAL language_code = languages
| LOOKUP JOIN languages_lookup ON language_code
| WHERE language_name IS NOT NULL
| KEEP emp_no, language_name
;

emp_no:integer | language_name:keyword
;

// See https://github.com/elastic/elasticsearch/issues/144329
whereFalseBeforeLookupJoinWithMatch
required_capability: join_lookup_v12
required_capability: match_function
required_capability: propagate_empty_relation_past_joins

FROM sample_data
| WHERE false
| LOOKUP JOIN message_types_lookup ON message
| WHERE match(message, "Connection error")
| KEEP message, type
;

message:keyword | type:keyword
;

// See https://github.com/elastic/elasticsearch/issues/144329
whereFalseBeforeLookupJoinWithMatchPhrase
required_capability: join_lookup_v12
required_capability: match_phrase_function
required_capability: propagate_empty_relation_past_joins

FROM sample_data
| WHERE false
| LOOKUP JOIN message_types_lookup ON message
| WHERE match_phrase(message, "Connection error")
| KEEP message, type
;

message:keyword | type:keyword
;

// See https://github.com/elastic/elasticsearch/issues/144329
whereFalseBeforeLookupJoinWithMatchOperator
required_capability: join_lookup_v12
required_capability: match_operator_colon
required_capability: propagate_empty_relation_past_joins

FROM sample_data
| WHERE false
| LOOKUP JOIN message_types_lookup ON message
| WHERE message:"Connection error"
| KEEP message, type
;

message:keyword | type:keyword
;

// See https://github.com/elastic/elasticsearch/issues/144329
whereFalseWithEvalBeforeLookupJoinAndMatch
required_capability: join_lookup_v12
required_capability: match_function
required_capability: propagate_empty_relation_past_joins

FROM sample_data
| WHERE false
| EVAL msg = message
| LOOKUP JOIN message_types_lookup ON message
| WHERE match(message, "Connection error")
| KEEP message, type
;

message:keyword | type:keyword
;

// See https://github.com/elastic/elasticsearch/issues/144329
whereFalseBeforeLookupJoinWithFullTextDisjunction
required_capability: join_lookup_v12
required_capability: full_text_functions_disjunctions_compute_engine
required_capability: propagate_empty_relation_past_joins

FROM sample_data
| WHERE false
| LOOKUP JOIN message_types_lookup ON message
| WHERE match(message, "Connection error") OR type LIKE "Success"
| KEEP message, type
;

message:keyword | type:keyword
;

// See https://github.com/elastic/elasticsearch/issues/144329
whereFalseBeforeLookupJoinWithMatchAndStats
required_capability: join_lookup_v12
required_capability: match_function
required_capability: propagate_empty_relation_past_joins

FROM sample_data
| WHERE false
| LOOKUP JOIN message_types_lookup ON message
| WHERE match(message, "Connection error")
| STATS c = COUNT(*)
;

c:long
0
;

// See https://github.com/elastic/elasticsearch/issues/144329
whereFalseBeforeLookupJoinWithMultipleFullTextFunctions
required_capability: join_lookup_v12
required_capability: match_function
required_capability: match_phrase_function
required_capability: propagate_empty_relation_past_joins

FROM sample_data
| WHERE false
| LOOKUP JOIN message_types_lookup ON message
| WHERE match(message, "Connection") AND match_phrase(message, "Connection error")
| KEEP message, type
;

message:keyword | type:keyword
;

// See https://github.com/elastic/elasticsearch/issues/144329
whereFalseBeforeLookupJoinWithMatchOnEmployees
required_capability: join_lookup_v12
required_capability: match_function
required_capability: propagate_empty_relation_past_joins

FROM employees
| WHERE false
| EVAL language_code = languages
| LOOKUP JOIN languages_lookup ON language_code
| WHERE match(first_name, "Georgi")
| KEEP emp_no, first_name, language_name
;

emp_no:integer | first_name:keyword | language_name:keyword
;

whereNullBeforeLookupJoin
required_capability: join_lookup_v12

FROM employees
| WHERE null
| EVAL language_code = languages
| LOOKUP JOIN languages_lookup ON language_code
| KEEP emp_no, language_code, language_name
;

emp_no:integer | language_code:integer | language_name:keyword
;

evalNullFilterBeforeLookupJoin
required_capability: join_lookup_v12

FROM employees
| EVAL x = null
| WHERE x::int > 0
| EVAL language_code = languages
| LOOKUP JOIN languages_lookup ON language_code
| KEEP emp_no, language_code, language_name
;

emp_no:integer | language_code:integer | language_name:keyword
;

whereNullBeforeLookupJoinWithStatsAfter
required_capability: join_lookup_v12

FROM employees
| WHERE null
| EVAL language_code = languages
| LOOKUP JOIN languages_lookup ON language_code
| STATS c = COUNT(*)
;

c:long
0
;

whereNullBeforeLookupJoinWithFilterAfter
required_capability: join_lookup_v12

FROM employees
| WHERE null
| EVAL language_code = languages
| LOOKUP JOIN languages_lookup ON language_code
| WHERE emp_no > 100
| KEEP emp_no, language_code, language_name
;

emp_no:integer | language_code:integer | language_name:keyword
;

nullArithmeticFilterBeforeLookupJoin
required_capability: join_lookup_v12

FROM employees
| WHERE 1 + null > 0
| EVAL language_code = languages
| LOOKUP JOIN languages_lookup ON language_code
| KEEP emp_no, language_code, language_name
;

emp_no:integer | language_code:integer | language_name:keyword
;

whereNullConjunctionBeforeLookupJoin
required_capability: join_lookup_v12

FROM employees
| WHERE null AND emp_no > 0
| EVAL language_code = languages
| LOOKUP JOIN languages_lookup ON language_code
| KEEP emp_no, language_code, language_name
;

emp_no:integer | language_code:integer | language_name:keyword
;

whereNullDisjunctionBeforeLookupJoin
required_capability: join_lookup_v12

FROM employees
| WHERE null OR false
| EVAL language_code = languages
| LOOKUP JOIN languages_lookup ON language_code
| KEEP emp_no, language_code, language_name
;

emp_no:integer | language_code:integer | language_name:keyword
;

// See https://github.com/elastic/elasticsearch/issues/144329
whereNullBeforeLookupJoinWithMatch
required_capability: join_lookup_v12
required_capability: match_function
required_capability: propagate_empty_relation_past_joins

FROM sample_data
| WHERE null
| LOOKUP JOIN message_types_lookup ON message
| WHERE match(message, "Connection error")
| KEEP message, type
;

message:keyword | type:keyword
;

// See https://github.com/elastic/elasticsearch/issues/144329
evalNullFilterBeforeLookupJoinWithMatch
required_capability: join_lookup_v12
required_capability: match_function
required_capability: propagate_empty_relation_past_joins

FROM sample_data
| EVAL x = null
| WHERE x::int > 0
| LOOKUP JOIN message_types_lookup ON message
| WHERE match(message, "Connection error")
| KEEP message, type
;

message:keyword | type:keyword
;

Loading
Loading