Skip to content

Conversation

@not-napoleon
Copy link
Member

The bug occurs when terms incorrectly chooses the LowCardinality optimization with a flattened field. This can only happen if supportsGlobalOrdinalsMapping is true, which it usually is not for flattened fields. But, when we wrap the ValuesSource to add in the missing value, we weren't delegating that method, which led to this bug.

Draft because I still need to do some more testing, and probably supportsGlobalOrdinalsMapping should be abstract so this doesn't happen anywhere else.

@elasticsearchmachine
Copy link
Collaborator

Hi @not-napoleon, I've created a changelog YAML for you.

@nik9000
Copy link
Member

nik9000 commented Jun 6, 2022

Draft because I still need to do some more testing, and probably supportsGlobalOrdinalsMapping should be abstract so this doesn't happen anywhere else.

👍

public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory {
static Boolean REMAP_GLOBAL_ORDS, COLLECT_SEGMENT_ORDS;

protected static final Logger logger = LogManager.getLogger(TermsAggregatorFactory.class);
Copy link
Member

Choose a reason for hiding this comment

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

I'd go with private just for a bit of paranoia.

For what it's worth LogManger.getLogger() is very very fast. I still use the getLogger(class) mostly though.

}

// TODO: [Zach] we might want refactor and remove ExecutionMode#create(), moving that logic outside the enum
logger.info("Creating bytes terms aggregator with execution mode [" + execution + "]");
Copy link
Member

Choose a reason for hiding this comment

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

These'd probably be fine to keep with debug if you like. Though you should do the [{}]` substitution thing.

@Override
public boolean supportsGlobalOrdinalsMapping() {
return valuesSource.supportsGlobalOrdinalsMapping();
}
Copy link
Member

Choose a reason for hiding this comment

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

💥

@not-napoleon not-napoleon marked this pull request as ready for review June 6, 2022 20:16
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jun 6, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

@sethmlarson sethmlarson added the Team:Clients Meta label for clients team label Jun 6, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/clients-team (Team:Clients)

@not-napoleon not-napoleon requested a review from nik9000 June 7, 2022 13:46
@not-napoleon not-napoleon added auto-backport Automatically create backport pull requests when merged and removed auto-backport-and-merge labels Jun 8, 2022
@not-napoleon not-napoleon merged commit c9af118 into elastic:master Jun 8, 2022
@not-napoleon not-napoleon deleted the flattened-field-terms-agg-bug branch June 8, 2022 12:08
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
7.17
8.3
not-napoleon added a commit to not-napoleon/elasticsearch that referenced this pull request Jun 8, 2022
The root cause here was that missing did not correctly delegate `supportsGlobalOrdinalsMappnig` to the wrapped values source, instead falling back to the default. I've added the delegation, and made the base method abstract so this doesn't happen again.
not-napoleon added a commit to not-napoleon/elasticsearch that referenced this pull request Jun 8, 2022
The root cause here was that missing did not correctly delegate `supportsGlobalOrdinalsMappnig` to the wrapped values source, instead falling back to the default. I've added the delegation, and made the base method abstract so this doesn't happen again.
not-napoleon added a commit that referenced this pull request Jun 8, 2022
…87507) The root cause here was that missing did not correctly delegate `supportsGlobalOrdinalsMappnig` to the wrapped values source, instead falling back to the default. I've added the delegation, and made the base method abstract so this doesn't happen again.
not-napoleon added a commit that referenced this pull request Jun 8, 2022
…#87506) * Fix a bug with flattened fields in terms aggregations (#87392) The root cause here was that missing did not correctly delegate `supportsGlobalOrdinalsMappnig` to the wrapped values source, instead falling back to the default. I've added the delegation, and made the base method abstract so this doesn't happen again. * BWC version dance, part one * Fix flattened object format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/Aggregations Aggregations auto-backport Automatically create backport pull requests when merged >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:Clients Meta label for clients team v7.17.5 v8.3.1 v8.4.0

5 participants