Skip to content

Commit 0962902

Browse files
authored
Merge pull request #238 from alison985/m10_rc
M10 rc
2 parents 0c80396 + 437236d commit 0962902

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

client/app/pages/queries/query-editor.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function queryEditor(QuerySnippet) {
9393
editor.focus();
9494
},
9595
};
96-
96+
/*
9797
function removeExtraSchemaInfo(data) {
9898
let newColumns = [];
9999
data.forEach((table) => {
@@ -114,11 +114,11 @@ function queryEditor(QuerySnippet) {
114114
newColumns = []; // linter complains without this line
115115
return data;
116116
}
117-
117+
*/
118118
const schemaCompleter = {
119119
getCompletions(state, session, pos, prefix, callback) {
120120
// make a variable for the auto completion in the query editor
121-
$scope.autoCompleteSchema = removeExtraSchemaInfo($scope.schema);
121+
$scope.autoCompleteSchema = $scope.schema; // removeExtraSchemaInfo(
122122

123123
if (prefix.length === 0 || !$scope.autoCompleteSchema) {
124124
callback(null, []);
@@ -131,7 +131,16 @@ function queryEditor(QuerySnippet) {
131131
$scope.autoCompleteSchema.forEach((table) => {
132132
keywords[table.name] = 'Table';
133133

134-
table.autoCompleteColumns.forEach((c) => {
134+
table.columns.forEach((c) => { // autoCompleteColumns
135+
if (c.charAt(c.length - 1) === ')') {
136+
let parensStartAt = c.indexOf('(') - 1;
137+
c = c.substring(0, parensStartAt);
138+
parensStartAt = 1; // linter complains without this line
139+
}
140+
// remove '[P] ' for partition keys
141+
if (c.charAt(0) === '[') {
142+
c = c.substring(4, c.length);
143+
}
135144
keywords[c] = 'Column';
136145
keywords[`${table.name}.${c}`] = 'Column';
137146
});

redash/query_runner/presto.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def get_schema(self, get_stats=False):
9090
SELECT table_schema, table_name, column_name, data_type as column_type, extra_info
9191
FROM information_schema.columns
9292
WHERE table_schema NOT IN ('pg_catalog', 'information_schema')
93+
ORDER BY 1, 5 DESC
9394
"""
9495

9596
results, error = self.run_query(query, None)
@@ -107,12 +108,12 @@ def get_schema(self, get_stats=False):
107108

108109
if row['extra_info'] == 'partition key':
109110
schema[table_name]['columns'].append('[P] ' + row['column_name'] + ' (' + row['column_type'] + ')')
110-
elif row['column_type'][0:3] == 'row(':
111-
schema[table_name]['columns'].append(row['column_name'] + ' (row())')
112-
elif row['column_type'][0:3] == 'map(':
113-
schema[table_name]['columns'].append(row['column_name'] + ' (map())')
114-
else:
111+
elif row['column_type'] == 'integer' or row['column_type'] == 'varchar' or row['column_type'] == 'timestamp' or row['column_type'] == 'boolean' or row['column_type'] == 'bigint':
115112
schema[table_name]['columns'].append(row['column_name'] + ' (' + row['column_type'] + ')')
113+
elif row['column_type'][0:2] == 'row' or row['column_type'][0:2] == 'map' or row['column_type'][0:2] == 'arr':
114+
schema[table_name]['columns'].append(row['column_name'] + ' (row or map or array)')
115+
else:
116+
schema[table_name]['columns'].append(row['column_name'])
116117

117118
return schema.values()
118119

0 commit comments

Comments
 (0)