Explicit message when no results are returned

For SELECT 0 query results, it would be nice to have an explicit message displayed instead of the table of results, so that especially on dashboard views it is clear that the query succeeded but there are simply no results.

An empty query result set shows up with just the title, a large white space and the last refreshed timestamp. I think it would be neater if a statement such as: “The query returned no results” was displayed instead.

Redash already does this. If a query has no results a placeholder is displayed.

But “no result” is different from “no rows returned”. And from what I’ve seen: Redash is not unique in displaying this literally as an empty table (see examples from SMSS and TablePlus further down).

SMSS

TablePlus

This seems a bit like an “off light”. The default assumption in Redash (and any query tool) is that a query executed successfully. If any errors occurred these will be identified with (usually) red indicators:

It may be useful in a narrow-case: but in this situation it would probably be more meaningful to write your query to perform a COUNT() aggregation and display this with a big counter visualisation, thus granting context to the query result. For example:

Non-Empty Table

Empty Table


Nevertheless, if you want to implement this on your own some things to consider:

  • What will be displayed instead? An image? Plain text? Will it be user configurable?
  • Will this work for non-table visualisations also? How will you implement this in a backwards compatible form?
  • Will the setting apply to all visualisations of a query? Configurable per organisation? Per user?

Thanks for the detailed reply, I appreciate the effort!

My main motivation here is to help the user see that the query has succeeded and there just aren’t any results from the server, so that’s distinct from the Query has no result message which I understand as being a Redash-specific indication.

One thing that stands out to me here especially when comparing the SELECT 0 result with TablePlus is that they do at least show the column names. I think that already makes it more obvious that the query succeeded and there’s just no data to display.


The column names are returned from /api/query_results/[id] so this should already be easy to implement!

I like your reasoning here. And agree this should be easy to implement without any changes to the API (which makes it a much more straightforward change). Is this something you’d like to try? Or shall we leave it for another member of the community?

Happy to try, do we have a support channel where I could get some pointers on things like where in source the front-end stuff would be for this? :slight_smile:

Awesome!

For now, this forum is the go-to place for support. However if a public slack or a discord channel makes more sense we’d consider it.

Having not looked too deeply into this, the first place I would check is QueryView.jsx. It appears there’s some logic that checks whether the query result returned from the API has a length > 0. If not, the Table visualisation is not rendered. The proposed change is to render the visualisation anyway, since we know the column names.

For reference, this is how similar functionality in SQL Server Reporting Services works: Set a No Data Message for a Data Region (Report Builder) - SQL Server Reporting Services (SSRS) | Microsoft Docs

I think we could stick with just including columns for now.

Looks like the fix will be in the Redash viz library.

lib/visualizations/table/Renderer.js
163   if (data.rows.length === 0) {

I see there’s a No Data icon for when 0 rows are selected now anyway. Is that how we plan to address this? It’s in master.