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
5 changes: 5 additions & 0 deletions docs/changelog/127383.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 127383
summary: Don't push down filters on the right hand side of an inlinejoin
area: ES|QL
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import static org.elasticsearch.xpack.esql.EsqlTestUtils.classpathResources;
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINESTATS;
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINESTATS_V2;
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINESTATS_V5;
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.INLINESTATS_V6;
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_LOOKUP_V12;
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_PLANNING_V1;
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.METADATA_FIELDS_REMOTE_TEST;
Expand Down Expand Up @@ -126,7 +126,7 @@ protected void shouldSkipTest(String testName) throws IOException {
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(INLINESTATS.capabilityName()));
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(INLINESTATS_V2.capabilityName()));
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(JOIN_PLANNING_V1.capabilityName()));
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(INLINESTATS_V5.capabilityName()));
assumeFalse("INLINESTATS not yet supported in CCS", testCase.requiredCapabilities.contains(INLINESTATS_V6.capabilityName()));
assumeFalse("LOOKUP JOIN not yet supported in CCS", testCase.requiredCapabilities.contains(JOIN_LOOKUP_V12.capabilityName()));
// Unmapped fields require a coorect capability response from every cluster, which isn't currently implemented.
assumeFalse("UNMAPPED FIELDS not yet supported in CCS", testCase.requiredCapabilities.contains(UNMAPPED_FIELDS.capabilityName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//

maxOfInt
required_capability: inlinestats_v5
required_capability: inlinestats_v6
// tag::max-languages[]
FROM employees
| KEEP emp_no, languages
Expand All @@ -25,7 +25,7 @@ emp_no:integer | languages:integer | max_lang:integer
;

maxOfIntByKeyword
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no, languages, gender
Expand All @@ -43,7 +43,7 @@ emp_no:integer | languages:integer | max_lang:integer | gender:keyword
;

maxOfLongByKeyword
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no, avg_worked_seconds, gender
Expand All @@ -58,7 +58,7 @@ emp_no:integer | avg_worked_seconds:long | max_avg_worked_seconds:long | gender:
;

maxOfLong
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no, avg_worked_seconds, gender
Expand All @@ -71,7 +71,7 @@ emp_no:integer | avg_worked_seconds:long | gender:keyword | max_avg_worked_secon
;

maxOfLongByCalculatedKeyword
required_capability: inlinestats_v5
required_capability: inlinestats_v6

// tag::longest-tenured-by-first[]
FROM employees
Expand All @@ -94,7 +94,7 @@ emp_no:integer | avg_worked_seconds:long | last_name:keyword | max_avg_worked_se
;

maxOfLongByCalculatedNamedKeyword
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no, avg_worked_seconds, last_name
Expand All @@ -113,7 +113,7 @@ emp_no:integer | avg_worked_seconds:long | last_name:keyword | max_avg_worked_se
;

maxOfLongByCalculatedDroppedKeyword
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| INLINESTATS max_avg_worked_seconds = MAX(avg_worked_seconds) BY l = SUBSTRING(last_name, 0, 1)
Expand All @@ -132,7 +132,7 @@ emp_no:integer | avg_worked_seconds:long | last_name:keyword | max_avg_worked_se
;

maxOfLongByEvaledKeyword
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| EVAL l = SUBSTRING(last_name, 0, 1)
Expand All @@ -152,7 +152,7 @@ emp_no:integer | avg_worked_seconds:long | max_avg_worked_seconds:long | l:keywo
;

maxOfLongByInt
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no, avg_worked_seconds, languages
Expand All @@ -170,7 +170,7 @@ emp_no:integer | avg_worked_seconds:long | max_avg_worked_seconds:long | languag
;

maxOfLongByIntDouble
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no, avg_worked_seconds, languages, height
Expand Down Expand Up @@ -205,8 +205,8 @@ emp_no:integer | languages:integer | avg_worked_seconds:long | gender:keyword |
10007 | 4 | 393084805 | F | 2.863684210555556E8 | 5
;

byMultivaluedSimple-Ignore
required_capability: join_planning_v1
byMultivaluedSimple
required_capability: inlinestats_v6

// tag::mv-group[]
FROM airports
Expand All @@ -223,8 +223,8 @@ abbrev:keyword | type:keyword | scalerank:integer | min_scalerank:integer
// end::mv-group-result[]
;

byMultivaluedMvExpand-Ignore
required_capability: join_planning_v1
byMultivaluedMvExpand
required_capability: inlinestats_v6

// tag::mv-expand[]
FROM airports
Expand All @@ -237,14 +237,14 @@ FROM airports
;

// tag::mv-expand-result[]
abbrev:keyword | type:keyword | scalerank:integer | min_scalerank:integer
GWL | mid | 9 | 2
GWL | military | 9 | 4
abbrev:keyword | scalerank:integer | min_scalerank:integer | type:keyword
GWL |9 |2 |mid
GWL |9 |4 |military
// end::mv-expand-result[]
;

byMvExpand
required_capability: inlinestats_v5
required_capability: inlinestats_v6

// tag::extreme-airports[]
FROM airports
Expand Down Expand Up @@ -308,7 +308,7 @@ count:long | country:keyword | avg:double
;

afterWhere
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM airports
| WHERE country != "United States"
Expand Down Expand Up @@ -367,7 +367,7 @@ abbrev:keyword | city:keyword | region:text | "COUNT(*)":long
;

beforeStats
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM airports
| EVAL lat = ST_Y(location)
Expand All @@ -380,7 +380,7 @@ northern:long | southern:long
;

beforeKeepSort
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| INLINESTATS max_salary = MAX(salary) by languages
Expand All @@ -394,8 +394,8 @@ emp_no:integer | languages:integer | max_salary:integer
10003 | 4 | 74572
;

beforeKeepWhere-Ignore
required_capability: join_planning_v1
beforeKeepWhere
required_capability: inlinestats_v6

FROM employees
| INLINESTATS max_salary = MAX(salary) by languages
Expand All @@ -407,8 +407,10 @@ emp_no:integer | languages:integer | max_salary:integer
10003 | 4 | 74572
;

beforeEnrich-Ignore
beforeEnrich
required_capability: join_planning_v1
required_capability: inlinestats_v6
required_capability: enrich_load

FROM airports
| KEEP abbrev, type, city
Expand All @@ -419,10 +421,10 @@ FROM airports
| LIMIT 3
;

abbrev:keyword | type:keyword | city:keyword | "COUNT(*)":long | region:text
ABJ | mid | Abidjan | 499 | Abidjan
ABV | major | Abuja | 385 | Municipal Area Council
ACA | major | Acapulco de Juárez | 385 | Acapulco de Juárez
abbrev:keyword |city:keyword |"COUNT(*)":long|type:keyword | region:text
ABJ |Abidjan |499 |mid |Abidjan
ABV |Abuja |385 |major |Municipal Area Council
ACA |Acapulco de Juárez|385 |major |Acapulco de Juárez
;

beforeAndAfterEnrich-Ignore
Expand Down Expand Up @@ -501,7 +503,7 @@ Zürich | Zürich
;

byConstant
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no, languages
Expand All @@ -520,7 +522,7 @@ emp_no:integer | languages:integer | max_lang:integer | y:integer
;

aggConstant
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no
Expand All @@ -538,7 +540,7 @@ one:integer | emp_no:integer
;

percentile
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no, salary
Expand All @@ -557,7 +559,7 @@ emp_no:integer | salary:integer | ninety_fifth_salary:double
;

byTwoCalculated
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM airports
| WHERE abbrev IS NOT NULL
Expand Down Expand Up @@ -642,7 +644,7 @@ abbrev:keyword | scalerank:integer | location:geo_point
;

groupShadowsField
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no, salary, hire_date
Expand All @@ -661,7 +663,7 @@ emp_no:integer | salary:integer | avg_salary:double | hire_date:datetime
;

groupByExpression_And_ExistentField
required_capability: inlinestats_v5
required_capability: inlinestats_v6
FROM employees
| KEEP emp_no, languages, gender
| EVAL x = "ABC"
Expand All @@ -679,7 +681,7 @@ emp_no:integer | languages:integer | x:keyword | max_lang:integer | y:keyword |
;

groupByRenamedColumn
required_capability: inlinestats_v5
required_capability: inlinestats_v6
FROM employees
| KEEP emp_no, languages, gender
| INLINESTATS max_lang = MAX(languages) BY y = gender
Expand Down Expand Up @@ -787,7 +789,7 @@ emp_no:integer | languages:integer | gender:keyword|max_lang:integer| y:keyword
;

twoAggregatesGroupedBy_AField_And_AnExpression
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no, languages, gender, last_name
Expand All @@ -809,7 +811,7 @@ emp_no:integer |languages:integer|last_name:keyword|max_lang:integer|min_lang:in
;

groupByMultipleRenamedColumns_InversedOrder
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no, languages, still_hired, gender
Expand All @@ -827,7 +829,7 @@ emp_no:integer |languages:integer|still_hired:boolean| gender:keyword|max_lang:i
;

groupByMultipleRenamedColumns_InversedOrder_ComplexEval
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no, languages, still_hired, gender
Expand All @@ -846,7 +848,7 @@ emp_no:integer |languages:integer|still_hired:boolean| gender:keyword|multilingu
;

groupByMultipleRenamedColumns_AndComplexEval
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no, languages, still_hired, gender
Expand Down Expand Up @@ -888,7 +890,7 @@ emp_no:integer |languages:integer|gender:keyword |first_name:keyword | x:keyw
;

groupByRenamedExpression
required_capability: inlinestats_v5
required_capability: inlinestats_v6

FROM employees
| KEEP emp_no, languages, gender, last_name
Expand All @@ -908,4 +910,62 @@ emp_no:integer |languages:integer|last_name:keyword|max_lang:integer|min_lang:in
10049 |5 |Tramer |5 |5 |T |F
10028 |null |Tempesti |1 |1 |T |M
;

doubleFilterOnLeftAndRight_InlineStats_Sides
required_capability: inlinestats_v6

FROM employees
| INLINESTATS max_salary = MAX(salary), min_salary = MIN(salary) by languages
| KEEP emp_no, languages, *salary
| WHERE salary > 65000 and languages > 2
| SORT emp_no
;

emp_no:integer |languages:integer|salary:integer |max_salary:integer|min_salary:integer
10007 |4 |74572 |74572 |27215
10030 |3 |67492 |74970 |26436
10045 |3 |74970 |74970 |26436
10054 |4 |65367 |74572 |27215
10062 |3 |65030 |74970 |26436
10094 |5 |66817 |66817 |25324
10097 |3 |71165 |74970 |26436
10100 |4 |68431 |74572 |27215
;

filterOnInlineStatsAggs
required_capability: inlinestats_v6

FROM employees
| INLINESTATS max_salary = MAX(salary), min_salary = MIN(salary) by languages
| KEEP emp_no, languages, *salary
| WHERE min_salary > 27000 or max_salary < 70000
| sort salary desc
| limit 5
;

emp_no:integer |languages:integer|salary:integer |max_salary:integer|min_salary:integer
10029 |null |74999 |74999 |28336
10007 |4 |74572 |74572 |27215
10027 |null |73851 |74999 |28336
10099 |2 |73578 |73578 |29175
10078 |2 |69904 |73578 |29175
;

filterOnInlineStatsAggsValues_And_Groupings
required_capability: inlinestats_v6

FROM employees
| INLINESTATS max_salary = MAX(salary), min_salary = MIN(salary) by languages
| KEEP emp_no, languages, *salary
| WHERE (min_salary > 27000 or max_salary < 70000) and languages > 3
| sort salary
| limit 5
;

emp_no:integer |languages:integer|salary:integer |max_salary:integer|min_salary:integer
10015 |5 |25324 |66817 |25324
10035 |5 |25945 |66817 |25324
10057 |4 |27215 |74572 |27215
10011 |5 |31120 |66817 |25324
10066 |5 |31897 |66817 |25324
;
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ public enum Cap {
* Fixes a series of issues with inlinestats which had an incomplete implementation after lookup and inlinestats
* were refactored.
*/
INLINESTATS_V5(EsqlPlugin.INLINESTATS_FEATURE_FLAG),
INLINESTATS_V6(EsqlPlugin.INLINESTATS_FEATURE_FLAG),

/**
* Allow mixed numeric types in conditional functions - case, greatest and least
Expand Down
Loading