Skip to content

Conversation

@markjhoy
Copy link
Contributor

@markjhoy markjhoy commented Dec 11, 2025

Adds MV_INTERSECTION function to ES|QL.

Returns a subset of the inputs sets that contains the intersection of values in provided multi-valued arguments.

Example:

Given set A = {"a","b","c"} and set B = {"b","c","d"}
MV_INTERSECTION(A, B) returns {"b", "c"}

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

@github-actions
Copy link
Contributor

ℹ️ Important: Docs version tagging

👋 Thanks for updating the docs! Just a friendly reminder that our docs are now cumulative. This means all 9.x versions are documented on the same page and published off of the main branch, instead of creating separate pages for each minor version.

We use applies_to tags to mark version-specific features and changes.

Expand for a quick overview

When to use applies_to tags:

✅ At the page level to indicate which products/deployments the content applies to (mandatory)
✅ When features change state (e.g. preview, ga) in a specific version
✅ When availability differs across deployments and environments

What NOT to do:

❌ Don't remove or replace information that applies to an older version
❌ Don't add new information that applies to a specific version without an applies_to tag
❌ Don't forget that applies_to tags can be used at the page, section, and inline level

🤔 Need help?

@markjhoy markjhoy added >enhancement :Analytics/ES|QL AKA ESQL Team:SearchOrg Meta label for the Search Org (Enterprise Search) labels Dec 12, 2025
@markjhoy markjhoy marked this pull request as ready for review December 12, 2025 14:25
@markjhoy markjhoy requested review from a team and ioanatia December 12, 2025 14:25
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Dec 12, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @markjhoy, I've created a changelog YAML for you.

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/search-eng (Team:SearchOrg)

@Example(file = "mv_intersect", tag = "testMvIntersectWithBooleanValues"),
@Example(file = "mv_intersect", tag = "testMvIntersectWithDoubleValues"),
@Example(file = "mv_intersect", tag = "testMvIntersectWithBytesRefValues") },
appliesTo = { @FunctionAppliesTo(lifeCycle = FunctionAppliesToLifecycle.PREVIEW, version = "9.3.0") }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to doublecheck - are the tags here correct? (Preview for 9.3.0?)

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM!

@markjhoy markjhoy requested a review from a team December 12, 2025 15:03
Copy link
Member

@kderusso kderusso left a comment

Choose a reason for hiding this comment

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

Changes LGTM, will defer to Ioana to approve after her feedback is met. Thanks!


}

public void testMvIntersectValidatesDataTypesAreEqual() {
Copy link
Member

Choose a reason for hiding this comment

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

Any tests needed for null input, etc?

Copy link
Contributor Author

@markjhoy markjhoy Dec 15, 2025

Choose a reason for hiding this comment

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

There's one at least in the IT tests ({null, null} -> {null}) as well as others that check for null as the first or second argument - so, I don't think it needs to be in the verifier... however the validation is going to change a bit from Ioana's suggestions...

@craigtaverner
Copy link
Contributor

When comparing this with the geospatial functions, I would naturally think this function should be called MV_INTERSECTION, because the term MV_INTERSECT sounds too much like it should return a boolean.

Class Operation Spatial MV/List/Array
Predicate Intersects ST_INTERSECTS MV_INTERSECTS
Predicate Contains ST_CONTAINS MV_CONTAINS
Set Intersection ST_INTERSECTION MV_INTERSECTION

Copy link
Contributor

@craigtaverner craigtaverner left a comment

Choose a reason for hiding this comment

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

I think we need to re-think the name. I propose MV_INTERSECTION both to better match set-theory as well as better symmetry with related GIS functions.

@ioanatia
Copy link
Contributor

When comparing this with the geospatial functions, I would naturally think this function should be called MV_INTERSECTION, because the term MV_INTERSECT sounds too much like it should return a boolean.

@craigtaverner that makes sense to change it to MV_INTERSECTION - we just took the name from #98545 and we assumed it was the right name

@markjhoy
Copy link
Contributor Author

Good call @craigtaverner - I'll refactor, and I've also updated the meta issue as well to reflect this.

@markjhoy markjhoy changed the title ES|QL: Add MV_INTERSECT Function ES|QL: Add MV_INTERSECTION Function Dec 15, 2025
@craigtaverner
Copy link
Contributor

Good call @craigtaverner - I'll refactor, and I've also updated the meta issue as well to reflect this.

Thanks! Great that you fixed the meta-issue too. Sometimes those issues are just a first guess as to what we need, so always good to second-guess! 😄

Copy link
Contributor

@craigtaverner craigtaverner left a comment

Choose a reason for hiding this comment

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

Much nicer with the name change!

Copy link
Contributor

@leemthompo leemthompo left a comment

Choose a reason for hiding this comment

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

Thanks for iterating on the docs! One tiny little thing left to add: an inline applies_to tag in the list :)

@markjhoy
Copy link
Contributor Author

Thanks for iterating on the docs! One tiny little thing left to add: an inline applies_to tag in the list :)

All set. Thanks for your help!

@markjhoy
Copy link
Contributor Author

buildkite test this

@markjhoy markjhoy enabled auto-merge (squash) December 16, 2025 18:55
@markjhoy markjhoy merged commit f78dee1 into elastic:main Dec 16, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:SearchOrg Meta label for the Search Org (Enterprise Search) v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants