Skip to content

Commit

Permalink
Improved optimizer tests on categorize
Browse files Browse the repository at this point in the history
  • Loading branch information
ivancea committed Nov 27, 2024
1 parent f37d2bd commit d10709b
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1220,8 +1220,15 @@ public void testCombineProjectionWithCategorizeGrouping() {

var limit = as(plan, Limit.class);
var agg = as(limit.child(), Aggregate.class);
assertThat(agg.child(), instanceOf(EsRelation.class));

assertThat(Expressions.names(agg.aggregates()), contains("s", "cat"));
assertThat(Expressions.names(agg.groupings()), contains("cat"));

var categorizeAlias = as(agg.groupings().get(0), Alias.class);
var categorize = as(categorizeAlias.child(), Categorize.class);
var categorizeField = as(categorize.field(), FieldAttribute.class);
assertThat(categorizeField.name(), is("first_name"));
}

/**
Expand Down Expand Up @@ -3933,9 +3940,10 @@ public void testNestedExpressionsInGroups() {
/**
* Expects
* Limit[1000[INTEGER]]
* \_Aggregate[[emp_no%2{r}#6],[COUNT(salary{f}#12) AS c, emp_no%2{r}#6]]
* \_Eval[[emp_no{f}#7 % 2[INTEGER] AS emp_no%2]]
* \_EsRelation[test][_meta_field{f}#13, emp_no{f}#7, first_name{f}#8, ge..]
* \_Aggregate[STANDARD,[CATEGORIZE(CATEGORIZE(CONCAT(first_name, "abc")){r$}#18) AS CATEGORIZE(CONCAT(first_name, "abc"))],[CO
* UNT(salary{f}#13,true[BOOLEAN]) AS c, CATEGORIZE(CONCAT(first_name, "abc")){r}#3]]
* \_Eval[[CONCAT(first_name{f}#9,[61 62 63][KEYWORD]) AS CATEGORIZE(CONCAT(first_name, "abc"))]]
* \_EsRelation[test][_meta_field{f}#14, emp_no{f}#8, first_name{f}#9, ge..]
*/
public void testNestedExpressionsInGroupsWithCategorize() {
var plan = optimizedPlan("""
Expand Down

0 comments on commit d10709b

Please sign in to comment.