Skip to content

fix(c/driver/sqlite): preserve REAL precision on string inference - #4878

Open
efegokdemir wants to merge 12 commits into
apache:mainfrom
efegokdemir:efe/adbc-sqlite-double-precision
Open

efegokdemir wants to merge 12 commits into
apache:mainfrom
efegokdemir:efe/adbc-sqlite-double-precision

Conversation

@efegokdemir

@efegokdemir efegokdemir commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

What

During mixed-type inference, the finite REAL conversion now uses SQLite’s locale-independent %!.17g formatter. This preserves binary64 round-trip precision and renders integral REAL values with .0; non-finite values retain the existing SQLite formatting.

Closes #4862

@efegokdemir
efegokdemir requested a review from lidavidm as a code owner October 10, 2026 08:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new formatting produces invalid output under decimal-comma locales.

1 open finding
What changed in this PR

Preserves binary64 precision when SQLite REAL values are inferred as strings.

Changes:

  • Formats finite doubles with 17 significant digits.
  • Retains .0 for integral REAL values.
  • Adds round-trip precision tests for both conversion paths.
File Description
c/​driver/​sqlite/​statement_reader.c Updates REAL-to-string formatting.
c/​driver/​sqlite/​sqlite_test.cc Adds precision regression coverage.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread c/driver/sqlite/statement_reader.c Outdated
Comment thread c/driver/sqlite/sqlite_test.cc Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation addresses both conversion paths and includes focused regression coverage.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

Comment thread c/driver/sqlite/sqlite_test.cc Outdated
Signed-off-by: Efe Gökdemir <gokdemirefe1903@gmail.com>

@lidavidm lidavidm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't love this; it smacks too much of using AI to apply patches on patches to "fix" an issue, especially now that we're futzing with locales inside the conversion path.

Are we sure that SQLite's printf isn't consistent with what it outputs when you request a string from a statement?

@lidavidm

Copy link
Copy Markdown
Member

Also, why does preserving the .0 matter so much?

@efegokdemir

Copy link
Copy Markdown
Contributor Author

I used AI assistance. I’ve switched to SQLite’s %!.17g formatter, which keeps locale-independent, round-trippable REAL text and preserves .0 for integral values. The SQLite test binary passed: 129 passed, 16 skipped.

Comment thread c/driver/sqlite/statement_reader.c Outdated
Comment thread c/driver/sqlite/sqlite_test.cc Outdated
Comment thread c/driver/sqlite/sqlite_test.cc Outdated

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

c/driver/sqlite: REAL values lose precision when a column is inferred as string

3 participants