It’s currently possible to display milliseconds when configured one column at a time. Is it also possible to configure this for all datetime columns globally?
Even if it’s not possible from the admin dashboard etc, a nudge towards where it’d be possible to change this in the codebase for a custom build would be useful as well.
It would probably be easier to create a script that just runs through all the “fields” rows of your metadata database.
Have a look in table
metabase_fields and set column
You can also do this manually via Admin > Data Model > (database) > (table) > (column) > Formatting
EDIT: I’ve tried to modify the global setting, but it doesn’t work with the time formatting - haven’t checked the code, but guess it doesn’t make a lookup globally.
EDIT: In case you want to modify the source, then I’m pretty sure it’s somewhere in https://github.com/metabase/metabase/blob/master/frontend/src/metabase/lib/formatting.js
Hi @flamber, thanks for the details! I was able to change the fields as you suggested, however it looks like those settings are only applying with “Custom” query types and not with “Native query” query types.
Any idea what might be causing the discrepancy?
Yes, when you do a native query, it’s the returned casting that defines what formatting is provided.
Example, let’s say you have a field
created_at in your Data Model, which is a
Timestamp in your database, but you could do anything to that column in SQL:
SELECT CAST(created_at AS date) AS ThisIsOnlyDate FROM table
You could have your script go through the table
visualization_settings, but that’s going to be much more difficult, since you need to inject the
"time_enabled":"milliseconds" into specific positions.
So if you need it to be totally global, it would probably be easier to change the formatting code and compile your own version.
Yes, trying to avoid having to do casts each time, so I’ll explore the formatting source a bit more and see if it’s possible to do from there.
Thanks for all the help, have a nice weekend!