Skip to content
11 changes: 10 additions & 1 deletion redash/handlers/data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def get(self, data_source_id):
response = {}

try:
response["schema"] = data_source.get_schema(refresh)
schema = data_source.get_schema(refresh)
except NotSupported:
response["error"] = {
"code": 1,
Expand All @@ -199,6 +199,15 @@ def get(self, data_source_id):
except Exception:
response["error"] = {"code": 2, "message": "Error retrieving schema."}

try:
sorted_schema = [{"name": i['name'], "columns": sorted(i['columns'])} for i in schema]
response["schema"] = sorted_schema
except Exception:
logging.exception(
"Error sorting schema columns for data_source {}"\
.format(self.data_source.id))
response['schema'] = schema

return response


Expand Down