Skip to content

[BUG] TRUNCATE functions returns incorrect result #1043

@Yury-Fridlyand

Description

@Yury-Fridlyand

What is the bug?

TRUNCATE functions returns incorrect result for some input data.

How can one reproduce the bug?

Test data:
ddouble_mapping.json.txt
ddouble.json.txt

curl -s -H 'Content-Type: application/json' -XPUT "http://localhost:9200/ddouble?pretty" -u admin:admin --insecure --data-binary @ddouble_mapping.json
curl -s -H 'Content-Type: application/json' -XPOST "http://localhost:9200/ddouble/_bulk?pretty" -u admin:admin --insecure --data-binary @ddouble.json | grep -i error
SELECT `ddouble`.`key`, `ddouble`.`val`, TRUNCATE(`ddouble`.`val`, 1) AS `EXPR$2` FROM `ddouble`

What is your host/environment?

2.x @ 21373b9

Do you have any screenshots?

image

Do you have any additional context?

Reported on behalf of @kylepbit

new BigDecimal(x.doubleValue()).setScale(y.integerValue(),
RoundingMode.DOWN).doubleValue())),

import java.math.BigDecimal
import java.math.RoundingMode

new BigDecimal(-1.2D).setScale(1, RoundingMode.DOWN).doubleValue() = -1.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions