Skip to content

Conversation

@hendrikmuhs
Copy link

add support for unsigned_long, which required a change in
writing out integer results properly, because coerce is not
supported for unsigned_long

fixes #63871

writing out integer results properly, because coerce is not
supported for unsigned_long

fixes elastic#63871
@elasticmachine
Copy link
Collaborator

Pinging @elastic/ml-core (:ml/Transform)

@benwtrent benwtrent self-requested a review October 20, 2020 14:06
* @param value the value as double (aggs return double for everything)
* @return value if its floating point, a integer
*/
public static Object convertToIntegerTypeIfNeeded(String type, double value) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public static Object convertToIntegerTypeIfNeeded(String type, double value) {
public static Object convertToDiscreteNumeralTypeIfNeeded(String type, double value) {

Or some better name as this is is not an integer but instead some possibly large discrete numeral (big int or a long).

Copy link
Author

Choose a reason for hiding this comment

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

its referring to the mathematical definition of integer, that's why integer type, not integer. I can try to find a better name, maybe dropFloatingPointComponentIfNeeded, but lets not over-complicate it, the doc string defines what it does.

Comment on lines +68 to +75
if (NUMERIC_FIELD_MAPPER_TYPES.getOrDefault(type, true) == false) {
assert value % 1 == 0;
if (value < Long.MAX_VALUE) {
return (long) value;
}

// special case for unsigned long
return BigDecimal.valueOf(value).toBigInteger();
Copy link
Member

Choose a reason for hiding this comment

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

Its weird to me that there is not a blanket map doc value -> indexable value :(

This works in a pinch, I wonder if there is anyway to use DocValueFormat.UNSIGNED_LONG_SHIFTED.

But looking at it, there isn't a clean cut solution :/

@hendrikmuhs hendrikmuhs merged commit e13cf75 into elastic:master Oct 20, 2020
@hendrikmuhs hendrikmuhs deleted the transform-#63871 branch October 20, 2020 18:16
hendrikmuhs pushed a commit to hendrikmuhs/elasticsearch that referenced this pull request Oct 20, 2020
add support for unsigned_long, which required a change in
writing out integer results properly, because coerce is not
supported for unsigned_long
hendrikmuhs pushed a commit that referenced this pull request Oct 20, 2020
add support for unsigned_long, which required a change in
writing out integer results properly, because coerce is not
supported for unsigned_long

fixes #63871
backport #63940
hendrikmuhs pushed a commit that referenced this pull request Oct 20, 2020
add support for unsigned_long, which required a change in
writing out integer results properly, because coerce is not
supported for unsigned_long

fixes #63871
backport #63940
pugnascotia pushed a commit to pugnascotia/elasticsearch that referenced this pull request Oct 21, 2020
add support for unsigned_long, which required a change in
writing out integer results properly, because coerce is not
supported for unsigned_long

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Transform] Transform fails for unsigned long fields

4 participants