Skip to content

Conversation

@qujoux
Copy link
Contributor

@qujoux qujoux commented Aug 20, 2025

Description

Updates float formatting to express full values. Switches from %f to %g, which according to Golang docs will use as many digits as necessary to express the value.

for %g [the default precision] is the smallest number of digits necessary to identify the value uniquely.

I had trouble getting t to run. A new unit test passes with:

go test github.com/hypermodeinc/dgraph/v25/query

Closes #9491.

Discussion

This changes the output format but not semantics of float values in result data. Currently floats have a fixed precision of 6, filled with trailing zeros as necessary.

{ "float": 1.000000 }

The new specifier %g drops unnecessary trailing zeros.

{ "float": 1 }

I think this OK as they are semantically equivalent. Since unnecessary characters are dropped, it also saves bytes on the wire. It also aligns with the bigfloat format, which never gives trailing zeros.

Checklist

  • Code compiles correctly and linting passes locally
  • For all code changes, an entry added to the CHANGELOG.md file describing and linking to this PR
  • Tests added for new functionality, or regression tests for bug fixes added as applicable

@qujoux qujoux requested a review from a team August 20, 2025 01:29
@mangalaman93 mangalaman93 enabled auto-merge (squash) August 20, 2025 23:48
@qujoux
Copy link
Contributor Author

qujoux commented Aug 22, 2025

Thank you for reviewing. Just a note that I've got t running and I'm working on getting these tests cleaned up.

@matthewmcneely
Copy link
Contributor

Thank you for reviewing. Just a note that I've got t running and I'm working on getting these tests cleaned up.

@qujoux Be aware I'm in the middle of improving the t harness, not sure what you're planning when you say "cleaned up", but wanted to avoid duplicate efforts: #9485

@qujoux
Copy link
Contributor Author

qujoux commented Aug 22, 2025

Thank you! I'm just aiming to get tests passing for this PR, I see there are JSON comparisons scattered around that expect the old float format. Faster testing will be a nice improvement.

qujoux added 2 commits August 26, 2025 03:47
Updates JSON comparisons to recognize full float format.
auto-merge was automatically disabled August 26, 2025 04:59

Head branch was pushed to by a user without write access

@qujoux
Copy link
Contributor Author

qujoux commented Aug 26, 2025

Some tests are giving Docker errors I don't understand, but they seem to have no float comparisons in them. I think all the relevant tests are passing now.

@matthewmcneely matthewmcneely added kind/bug Something is broken. dgraph Issue or PR created by an internal Dgraph contributor. labels Aug 26, 2025
@matthewmcneely matthewmcneely merged commit 9d4cb77 into dgraph-io:main Aug 26, 2025
12 of 14 checks passed
@qujoux
Copy link
Contributor Author

qujoux commented Aug 26, 2025

Sorry about the bumpy road, and thank you for reviewing!

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

Labels

dgraph Issue or PR created by an internal Dgraph contributor. kind/bug Something is broken.

Development

Successfully merging this pull request may close these issues.

Return full float value in query results

3 participants