google / google/googlesql

Float formatting in SQLBuilder is locale specific

Open
#30 0 comments 0 reactions 1 assignee Claimed by @matthewcbrown View on GitHub
bug
Dominant language
C++
Stars
2.6k
Forks
260
PR merge metrics
No merged PRs in 30d

Description

I am using the `SQLBuilder` to produce SQL from a `ResolvedAST`. The AST contains very small floating point literals, e. g. `0.000146511`, which are rendered as `146511E-4` by default.

It seems that the SQL Builder eventually uses standard C `printf` to produce a string for a given floating point, which will use a comma as decimal separator for certain locales, e. g. `de_DE.UTF-8`.

The above literal will produce the SQL expression `(0, 146511)` which is of type `STRUCT` instead of `FLOAT`.

As a workaround, I set `LC_NUMERIC=C`, which fixes this behaviour.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.