I'm using Apache Superset to visualise data. As one of the inputs I have a Google Sheets. I can display the values directly stored in the table, but I am unable to calculate a difference between two dates.
Let's say I have a table:
| A | B | C | |
|---|---|---|---|
| dateStarted | dateFinished | calculatedDiff | |
| 1 | 1-Jan-2022 | 15-Jan-2022 | 14 |
If I just calculate the difference between the columns in Google Sheets, I get the correct answer, which is 14 days. But I don't want to have these calculation columns in Google Sheets, I would like to do the calculations on the fly with Superset.
In Superset I try to run a query:
SELECT dateStarted, dateFinished, dateFinished-dateStartedFROM "https://docs.google.com/spreadsheets/d/*******"I get:
| dateStarted | dateFinished | dateFinished-dateStarted | |
|---|---|---|---|
| 1 | 1-Jan-2022 | 15-Jan-2022 | 0 |
Which is not correct, I would expect to get 14.
Things I already tried:
- I checked and Superset recognizes dateStarted and dateFinished as DATETIME type
- If I sum the dates I get 4044, which implies only the year is considered
- If I compare the dates it compares them correctly (not just by year)
- datediff(dateFinished, dateStarted) doesn't work, I get an error
gsheets error: SQLError: no such function: datediff
I was looking for documentation specifically for Superset + Google Sheets integration, but couldn't find anything useful.
- https://developers.google.com/chart/interactive/docs/querylanguage - this one suggests datediff function, which doesn't work
- https://shillelagh.readthedocs.io/en/latest/adapters.html#google-sheets - this one doesn't mention anything about the difference between dates
Any help will be much appreciated.