Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV format does not retain timezone information for timestamp type columns in query result #4820

Open
bimalkant-lauhny opened this issue Apr 21, 2020 · 2 comments

Comments

@bimalkant-lauhny
Copy link

Issue Summary

I use Postgres for storing timestamp with timezone for some columns (timestamptz type). When I download the query results in CSV, the timezone information is missing. I can confirm that timezone info in CSV was there in Redash v7. It is also there if I download the results in Excel format for Redash v8.

Steps to Reproduce

  1. Run some query which produces timestamp in results. For example, in Postgres, one can run this query:
SELECT NOW();
  1. Download the result in CSV format. The timestamp value will not have timezone information. For example, my CSV contents after running the query in Step 1 were as below:
now
2020-04-21 20:49

Excel format file had the contents as below:

now
2020-04-21T20:49:00.224+07:00

Why do you consider this to be a bug?

It seems like the CSV just stores local timezone and the precision is also less (there is no seconds info). This can be very confusing if someone is accessing Query results in other timezone, or comparing query results of multiple timezones.

What did you expect to happen instead?

Just like in Excel format, the CSV format should also have timezone information for timestamp columns.

Technical details:

  • Redash Version: 8.0.2
  • Browser/OS: Chrome/Ubuntu 18.04
  • How did you install Redash:
@susodapop
Copy link
Contributor

I reproduced this on our preview instance. It affects the latest alpha build of V9 as well.

@tim5go
Copy link
Contributor

tim5go commented Sep 17, 2020

@susodapop
From here:

for row in query_data["rows"]:
for col_name, converter in special_columns.items():
if col_name in row:
row[col_name] = converter(row[col_name])
writer.writerow(row)
return s.getvalue()

We see that the query result value is formatted by the converter.

If we trace back several steps, we will find that the time format is controlled by the environment variable.

TIME_FORMAT = os.environ.get("REDASH_TIME_FORMAT", "HH:mm")

I believe you can overwrite the format whatever you want, and personally I won't consider this behaviour as a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants