Skip to content

Inferred schemas treat integers as floats, may silently alter data #2377

@aphyr

Description

@aphyr

Since at least 1.0.2 and through 1.0.5-dev 5b93fb4, Dgraph will infer the type of new predicates with integer values as float, which means that unless users specify a schema up front, users could write 0, and read back 0.0. In languages with aggressive numeric type coercion, this may work fine, until users attempt to write a number which is not cleanly representable as a float. For instance, if one writes 9007199254740993 to a predicate without a schema, then attempts to read that value back, dgraph will return 9007199254740992 instead. Write 27670116110564327426, and 2.7670116110564327E19 comes back--426 less than the value written.

You can reproduce this with Jepsen 56dce4d5b875bc2eec841564f865b72168c91938 by running

lein run test --package-url https://github.com/dgraph-io/dgraph/releases/download/nightly/dgraph-linux-amd64.tar.gz --force-download --workload types --nemesis none --sequencing server --time-limit 500

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/maintenanceMaintenance tasks, such as refactoring, with no impact in features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions