MarkyMan4/filequery

CSV None not translated to NULL

Closed this issue · 4 comments

I saved a query to the database from filequery TUI, and the results with NULL values were saved as None in the CSV. When the saved file was queried, the None values came in as a string and did not count as NULL values.
An option would be to leave the CSV blank when there is a null value and also check when reading a CSV if there is a None value.
I did not test this with parquet or json formats.

Removing the None values from the CSV worked fine when loaded into the TUI.

select * from table where line1 is null returns every result in the table.

id line1 line2 full_address
1 123 Address Way None 123 Address Way
2 None None 234 Address Way
3 345 Address Way Lot 1 None

I think this has to do with the way I'm exporting query results from the TUI. The query result is a DataTable from Textual, so my code is doing the work of converting that into a CSV file instead of just letting DuckDB handle it (like it does when you just use the CLI). I'm looking into a better way to handle CSV export from the TUI

I'm working on a way to do this now. My initial thoughts are:

  1. keep track of the last query executed
  2. when a user goes to save query results, run a DuckDB copy statement to copy the last query to a CSV file

The CLI uses copy statements to save query results to files, so this should make that functionality more consistent between the CLI and TUI.

I just release v0.2.5 if you want to upgrade and give it a spin. It should fix the issues you were having!

Tested with the TUI and saved a CSV where the query result had NULL results. Worked perfect. Thank you!