In https://github.com/getredash/redash/pull/4595 we added logic that sorts schema tokens alphabetically. But this logic silently ignores all keys in the schema dictionary except for name and columns. However, if REDASH_SCHEMA_RUN_TABLE_SIZE_CALCULATIONS is enabled, each table will also include a size key which is now being silently dropped.
The _sort_schema() method needs to be re-written as follows:
# current version
def _sort_schema(self, schema):
return [
{"name": i["name"], "columns": sorted(i["columns"], key=lambda x: x["name"] if isinstance(x, dict) else x)}
for i in sorted(schema, key=lambda x: x["name"])
]
# fixed
def _sort_schema(self, schema):
return [
{**i, "columns": sorted(i["columns"], key=lambda x: x["name"] if isinstance(x, dict) else x)}
for i in sorted(schema, key=lambda x: x["name"])
]
Steps to Reproduce
Set REDASH_SCHEMA_RUN_TABLE_SIZE_CALCULATIONS=true
Connect to postgres database
Observe that row counts in each table are not displayed in the schema browser
Hi @susodapop,
Is there any updates on this feature? I really like to have this sort feature on the redash.
I'm using Redash version: 24.04.0-dev using Bitnami Helm Charts.
Issue Summary
In https://github.com/getredash/redash/pull/4595 we added logic that sorts schema tokens alphabetically. But this logic silently ignores all keys in the schema dictionary except for
name
andcolumns
. However, ifREDASH_SCHEMA_RUN_TABLE_SIZE_CALCULATIONS
is enabled, each table will also include asize
key which is now being silently dropped.The
_sort_schema()
method needs to be re-written as follows:Steps to Reproduce
REDASH_SCHEMA_RUN_TABLE_SIZE_CALCULATIONS=true
Technical details:
master