Skip to content

[BUG] DIVIDE and MODULUS return an error when dividing by 0 with the Byte data type #1582

@matthewryanwells

Description

@matthewryanwells

What is the bug?
When you divide or modulus two byte values together using DIVIDE(), /, MODULUS(), MOD(), and % if the denominator value is 0 then the following error will be returned: TransportError(503, 'ArithmeticException', {'error': {'reason': 'There was internal problem at backend', 'details': '/ by zero', 'type': 'ArithmeticException'}, 'status': 503})

How can one reproduce the bug?
Start OpenSearch on localhost:9200.

Create and load mappings file: byte_mapping.json

{
    "mappings" : {
      "properties" : {
        "value" : {
          "type" : "byte"
        }
      }
    }
}

Load mappings file:

curl -H 'Content-Type: application/x-ndjson' -XPUT \
  'http://localhost:9200/byte_mapping.json?pretty' \
  -u admin:admin --insecure --data-binary @byte_mapping.json

Create and load mappings file: byte.json

{"index": {"_index": "byte", "_id": "1"}}
{ "value" : 0 }

Load mappings file:

curl -H 'Content-Type: application/x-ndjson' -XPOST \
  'http://localhost:9200/byte.json/_bulk?pretty' \
  -u admin:admin --insecure --data-binary @byte.json

Run SQL command:
SELECT DIVIDE(value, value) FROM byte;

What is the expected behavior?
a null value should be returned

What is your host/environment?

  • OS: MacOS
  • Version 13.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions