Skip to content

Conversation

timgrein
Copy link
Contributor

Follow-up for #132729.

This PR adds unsigned_long support to the decay(...) function

@timgrein timgrein added >non-issue test-release Trigger CI checks against release build v9.2.0 :Search Relevance/ES|QL Search functionality in ES|QL labels Sep 10, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Sep 10, 2025
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?

Copy link
Member

@carlosdelest carlosdelest left a comment

Choose a reason for hiding this comment

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

It's a good start! But I think it doesn't address unsigned long values - please check the comments

testCaseSuppliers.addAll(longRandomTestCases());

// Unsigned Long Linear
testCaseSuppliers.addAll(unsignedLongTestCase(0L, 10L, 10000000L, 200L, 0.33, "linear", 1.0));
Copy link
Member

Choose a reason for hiding this comment

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

Check how unsigned long test cases are generated for some ideas on how to generate numbers that don't fit into long

} else if (isMillisOrNanos(valueType)) {
return validateOriginAndScale(DataType::isMillisOrNanos, "datetime or date_nanos", DataType::isTimeDuration, "time_duration");
} else if (isUnsignedLong(valueType)) {
return validateOriginAndScale(DataType::isUnsignedLong, "unsigned long", DataType::isUnsignedLong, "unsigned_long");
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it's enough to check if origin and scale are numeric? It should be possible to mix and match numeric types, i.e. use an unsigned long origin but an int scale etc

Copy link
Contributor Author

@timgrein timgrein Sep 17, 2025

Choose a reason for hiding this comment

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

That's a good point, I wanted to restrict it first to make it a bit simpler, but giving it a second thought it definitely makes sense to support mixed numeric types.

Adjusted with:

Full disclosure: we need to the same for offset. I'll add it to #134789, which I've opened yesterday and address it in a separate PR.

@timgrein timgrein changed the title ES|QL: Add unsigned long support to Decay function ES|QL: Add unsigned long and mixed numeric types support to Decay function Sep 17, 2025
}

private Object convertToExpectedType(Object value, DataType valueType, DataType targetType) {
if (targetType == INTEGER && value instanceof Integer) {
Copy link
Member

Choose a reason for hiding this comment

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

I think you can use EsqlDataTypeConverter.convert() here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@carlosdelest carlosdelest left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @timgrein !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>non-issue :Search Relevance/ES|QL Search functionality in ES|QL Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch test-release Trigger CI checks against release build v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants