Skip to content

Commit 4bca438

Browse files
committed
only handel special case 0
1 parent 2c64f6e commit 4bca438

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

ibis-server/app/util.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ def _to_datetime_and_format(series: pd.Series) -> pd.Series:
2929

3030

3131
def _to_json_obj(df: pd.DataFrame) -> dict:
32-
data = df.map(
33-
lambda x: f"{x:.9g}"
34-
if isinstance(x, float)
35-
else f"{x:.3f}"
36-
if isinstance(x, decimal.Decimal)
37-
else x
38-
).to_dict(orient="split")
32+
def format_value(x):
33+
if isinstance(x, float):
34+
# Special case for zero to avoid scientific notation
35+
if x == 0:
36+
return "0"
37+
return f"{x:.9g}"
38+
else:
39+
return x
40+
41+
data = df.map(format_value).to_dict(orient="split", index=False)
3942

4043
def default(obj):
4144
if pd.isna(obj):

ibis-server/tests/routers/v2/connector/test_bigquery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ async def test_scientific_notation(client, manifest_str):
209209
)
210210
assert response.status_code == 200
211211
result = response.json()
212-
assert result["data"][0] == ["0.000"]
212+
assert result["data"][0] == ["0"]
213213

214214

215215
async def test_query_empty_json(client, manifest_str):

0 commit comments

Comments
 (0)