Skip to content

Commit

Permalink
Google spreadsheets (apache#5915)
Browse files Browse the repository at this point in the history
* Google spreadsheets

* Fetch table metadata in SQL Lab

* Show full URL for spreadsheet

* Fix version

* Remove sqllab changes

(cherry picked from commit f366bbe)
  • Loading branch information
betodealmeida committed Jan 30, 2019
1 parent 63e78b4 commit e5c56db
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def get_git_sha():
'flask-wtf',
'flower', # deprecated
'geopy',
'gsheetsdb>=0.1.8',
'gunicorn', # deprecated
'humanize',
'idna',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,12 @@ class ExploreResultsButton extends React.PureComponent {
);
}
render() {
const allowsSubquery = this.props.database && this.props.database.allows_subquery;
return (
<Button
bsSize="small"
onClick={this.onClick}
disabled={!this.props.database.allows_subquery}
disabled={!allowsSubquery}
tooltip={t('Explore the result set in the data exploration view')}
>
<Dialog
Expand Down
2 changes: 1 addition & 1 deletion superset/assets/src/SqlLab/components/SouthPane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SouthPane extends React.PureComponent {
}
const dataPreviewTabs = props.dataPreviewQueries.map(query => (
<Tab
title={t('Preview: `%s`', query.tableName)}
title={t('Preview: `%s`', decodeURIComponent(query.tableName))}
eventKey={query.id}
key={query.id}
>
Expand Down
7 changes: 7 additions & 0 deletions superset/db_engine_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,13 @@ class DruidEngineSpec(BaseEngineSpec):
}


class GSheetsEngineSpec(SqliteEngineSpec):
"""Engine for Google spreadsheets"""
engine = 'gsheets'
inner_joins = False
allows_subquery = False


class KylinEngineSpec(BaseEngineSpec):
"""Dialect for Apache Kylin"""

Expand Down
6 changes: 4 additions & 2 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2277,10 +2277,11 @@ def sqllab_viz(self):
}))

@has_access
@expose('/table/<database_id>/<table_name>/<schema>/')
@expose('/table/<database_id>/<path:table_name>/<schema>/')
@log_this
def table(self, database_id, table_name, schema):
schema = utils.js_string_to_python(schema)
table_name = parse.unquote_plus(table_name)
mydb = db.session.query(models.Database).filter_by(id=database_id).one()
payload_columns = []
indexes = []
Expand Down Expand Up @@ -2336,10 +2337,11 @@ def table(self, database_id, table_name, schema):
return json_success(json.dumps(tbl))

@has_access
@expose('/extra_table_metadata/<database_id>/<table_name>/<schema>/')
@expose('/extra_table_metadata/<database_id>/<path:table_name>/<schema>/')
@log_this
def extra_table_metadata(self, database_id, table_name, schema):
schema = utils.js_string_to_python(schema)
table_name = parse.unquote_plus(table_name)
mydb = db.session.query(models.Database).filter_by(id=database_id).one()
payload = mydb.db_engine_spec.extra_table_metadata(
mydb, table_name, schema)
Expand Down

0 comments on commit e5c56db

Please sign in to comment.