How to tell the difference between NULL and empty string

When I run my query in Redash, I get the results and am generally very happy with the way they’re displayed - I also export to spreadsheets sometimes. However, for my latest use-case I need to be able to tell the difference between an empty string and a null value but I don’t seem to see any difference in either the UI or the spreadsheet export. Am I missing something? Is there a setting for this?

Interesting question. See the workaround at the end.

Discussion

Internally, Redash knows the difference between a null and an empty string. You can see this in the JSON payload from the /results API.

CleanShot 2021-06-16 at 09.05.54

The table visualisation and Excel export are separate processes:

Table Vis: there’s no setting for how Null’s are displayed. This is a good idea though. Would you mind making a feature request for it here on the forum? Or I can move this thread into the feature request category.

Excel export: I wonder if things will this PR might solve your concern.

Workaround

For now you can work around this in your query by CASE-ing NULL values into a string you prefer. Here’s how you’d do it in postgres or mssql, for example:

SELECT COALESCE([table].[field], '<None>') FROM ...

I put together a quick demo of how we could displays NULLs explicitly in the table visualisation.

CleanShot 2021-06-16 at 11.29.52

That’s really helpful, thank you. Actually, just looking at the JSON returned in the developer console will suit me fine for now.