You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "stinodego (via GitHub)" <gi...@apache.org> on 2023/04/09 19:51:54 UTC
[GitHub] [arrow-adbc] stinodego opened a new issue, #578: Writing to `SQLite` database erroneously rounds floats
stinodego opened a new issue, #578:
URL: https://github.com/apache/arrow-adbc/issues/578
This surfaced in the tests for Polars, where we use `adbc` for our `write_database` functionality.
When writing and then reading back floats, they come back rounded.
### Reproducible example
```python
import os
import sqlite3
import tempfile
import polars as pl
df = pl.DataFrame(
{
"id": [1, 2],
"name": ["misc", "other"],
"value": [100.0, -99.5],
"date": ["2020-01-01", "2021-12-31"],
}
)
def create_temp_sqlite_db(test_db: str) -> None:
conn = sqlite3.connect(test_db)
conn.executescript(
"""
CREATE TABLE test_data (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
value FLOAT,
date DATE
);
INSERT INTO test_data(name,value,date)
VALUES ('misc',100.0,'2020-01-01'), ('other',-99.5,'2021-12-31');
"""
)
conn.close()
with tempfile.TemporaryDirectory() as tmpdir_name:
test_db = os.path.join(tmpdir_name, "test.db")
df.write_database(
table_name="test_data",
connection_uri=f"sqlite:///{test_db}",
if_exists="replace",
engine="adbc",
)
result = pl.read_database("SELECT * FROM test_data", f"sqlite:///{test_db}")
print(result)
```
Results in:
```
shape: (2, 4)
┌─────┬───────┬───────┬────────────┐
│ id ┆ name ┆ value ┆ date │
│ --- ┆ --- ┆ --- ┆ --- │
│ i64 ┆ str ┆ f64 ┆ str │
╞═════╪═══════╪═══════╪════════════╡
│ 1 ┆ misc ┆ 100.0 ┆ 2020-01-01 │
│ 2 ┆ other ┆ -99.0 ┆ 2021-12-31 │
└─────┴───────┴───────┴────────────┘
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-adbc] lidavidm closed issue #578: c/driver/sqlite: writing to `SQLite` database erroneously rounds floats
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm closed issue #578: c/driver/sqlite: writing to `SQLite` database erroneously rounds floats
URL: https://github.com/apache/arrow-adbc/issues/578
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-adbc] lidavidm commented on issue #578: Writing to `SQLite` database erroneously rounds floats
Posted by "lidavidm (via GitHub)" <gi...@apache.org>.
lidavidm commented on issue #578:
URL: https://github.com/apache/arrow-adbc/issues/578#issuecomment-1504269391
Hmm, that's quite concerning. Thanks for the report.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-adbc] paleolimbot commented on issue #578: Writing to `SQLite` database erroneously rounds floats
Posted by "paleolimbot (via GitHub)" <gi...@apache.org>.
paleolimbot commented on issue #578:
URL: https://github.com/apache/arrow-adbc/issues/578#issuecomment-1506879266
I think it's here:
https://github.com/apache/arrow-adbc/blob/1568815791594d6cd2e4cf1299d4d33e6aded78b/c/driver/sqlite/statement_reader.c#L185
(should be `double` instead of `int64_t`)
I can PR a fix later today!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org