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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to