microsoft / microsoft/Qcodes

SQLite timestamp columns have incorrect types

Open
#1,862 10 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
459
Forks
359
Avg merge
3d 6h
Merged PRs (30d)
73

Description

The two columns `run_timestamp` and `completed_timestamp` in the `runs` table of the SQLite database have type `INTEGER`, but are in fact used to store floats.

![image](https://user-images.githubusercontent.com/23165537/70224382-74ef9380-174d-11ea-9470-207ae3df2393.png)

I am not really sure how or why that even works in QCoDeS, in particular, which converter is used to read back these numbers? Why not `int`?

In any case, that typing becomes a problem when third-party applications try to parse the DB file, since these applications will most likely "Believe the type". In the best case, doing so leads to the timestamps losing their sub-second precision, will can cause hard-to-debug problems down the line, since identical datasets will have slightly different timestamps. In the worst case, the timestamps simply appear to be invalid.

I propose that we make a type converting DB upgrade, changing these two `INTEGER` types to `REAL`. Alternatively, we could use an integer number of milliseconds, but that is WAY more work and seems like the wrong solution to me.

@QCoDeS/core

Contributor guide

Open the contributing guide

Research direction

Start by locating the SQLite schema for the runs table and the database upgrade or migration path that handles existing files. Confirm how run_timestamp and completed_timestamp are written and read, then ensure the schema reports REAL without losing existing sub-second precision; done means new and upgraded databases expose both columns with the correct type.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlite
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.