File tree Expand file tree Collapse file tree 3 files changed +21
-15
lines changed Expand file tree Collapse file tree 3 files changed +21
-15
lines changed Original file line number Diff line number Diff line change @@ -178,18 +178,3 @@ def import_query_runners(query_runner_imports):
178
178
for runner_import in query_runner_imports :
179
179
__import__ (runner_import )
180
180
181
-
182
- # for athena and presto
183
- def format_schema (results ):
184
- schema = {}
185
- for row in results ['rows' ]:
186
- table_name = '{}.{}' .format (row ['table_schema' ], row ['table_name' ])
187
- if table_name not in schema :
188
- schema [table_name ] = {'name' : table_name , 'columns' : []}
189
-
190
- row_to_add = row ['column_name' ] + ' (' + row ['column_type' ] + ')'
191
- if row ['extra_info' ] == 'partition key' :
192
- row_to_add = '[P] ' + row_to_add
193
- schema [table_name ]['columns' ].append (row_to_add )
194
-
195
- return schema
Original file line number Diff line number Diff line change 5
5
from redash .query_runner import *
6
6
from redash .settings import parse_boolean
7
7
from redash .utils import JSONEncoder
8
+ from .presto import format_schema
8
9
9
10
logger = logging .getLogger (__name__ )
10
11
ANNOTATE_QUERY = parse_boolean (os .environ .get ('ATHENA_ANNOTATE_QUERY' , 'true' ))
Original file line number Diff line number Diff line change 31
31
}
32
32
33
33
34
+ # for athena and presto
35
+ def format_schema (results ):
36
+ """
37
+ This function formats the schema, table, and columsn of Athena and Presto
38
+ for display in the UI schema browser.
39
+ """
40
+ schema = {}
41
+ for row in results ['rows' ]:
42
+ table_name = '{}.{}' .format (row ['table_schema' ], row ['table_name' ])
43
+ if table_name not in schema :
44
+ schema [table_name ] = {'name' : table_name , 'columns' : []}
45
+
46
+ row_to_add = row ['column_name' ] + ' (' + row ['column_type' ] + ')'
47
+ if row ['extra_info' ] == 'partition key' :
48
+ row_to_add = '[P] ' + row_to_add
49
+ schema [table_name ]['columns' ].append (row_to_add )
50
+
51
+ return schema
52
+
53
+
34
54
class Presto (BaseQueryRunner ):
35
55
noop_query = 'SHOW TABLES'
36
56
You can’t perform that action at this time.
0 commit comments