[hotfix] getting presto on track

This commit is contained in:
maxime.beauchemin@airbnb.com 2016-08-31 00:09:55 +00:00 committed by Maxime Beauchemin
parent 9f8eef498c
commit 508feb2bad
6 changed files with 18 additions and 15 deletions

View File

@ -36,9 +36,6 @@ class SqlEditorTopToolbar extends React.Component {
}); });
return `SELECT ${cols}\nFROM ${table.name}`; return `SELECT ${cols}\nFROM ${table.name}`;
} }
selectStar(table) {
this.props.actions.queryEditorSetSql(this.props.queryEditor, this.getSql(table));
}
popTab(table) { popTab(table) {
const qe = { const qe = {
id: shortid.generate(), id: shortid.generate(),
@ -169,7 +166,7 @@ class SqlEditorTopToolbar extends React.Component {
</div> </div>
<hr /> <hr />
<div className="m-t-5"> <div className="m-t-5">
{tables.map((table) => <TableElement table={table} />)} {tables.map((table) => <TableElement table={table} queryEditor={this.props.queryEditor} />)}
</div> </div>
</div> </div>
); );

View File

@ -15,13 +15,18 @@ class TableElement extends React.Component {
cols += ', '; cols += ', ';
} }
}); });
const sql = `SELECT ${cols}\nFROM ${this.props.table.name}`; return `SELECT ${cols}\nFROM ${this.props.table.name}`;
}
setSelectStar () {
this.props.actions.queryEditorSetSql(this.props.queryEditor, this.selectStar());
}
popSelectStar() {
const qe = { const qe = {
id: shortid.generate(), id: shortid.generate(),
title: this.props.table.name, title: this.props.table.name,
dbId: this.props.table.dbId, dbId: this.props.table.dbId,
autorun: true, autorun: true,
sql, sql: this.selectStar(),
}; };
this.props.actions.addQueryEditor(qe); this.props.actions.addQueryEditor(qe);
} }
@ -68,13 +73,13 @@ class TableElement extends React.Component {
<ButtonGroup className="ws-el-controls pull-right"> <ButtonGroup className="ws-el-controls pull-right">
<Link <Link
className="fa fa-pencil m-l-2" className="fa fa-pencil m-l-2"
onClick={this.selectStar.bind(this)} onClick={this.setSelectStar.bind(this)}
tooltip="Run query in a new tab" tooltip="Run query in a new tab"
href="#" href="#"
/> />
<Link <Link
className="fa fa-plus-circle m-l-2" className="fa fa-plus-circle m-l-2"
onClick={this.selectStar.bind(this)} onClick={this.popSelectStar.bind(this)}
tooltip="Run query in a new tab" tooltip="Run query in a new tab"
href="#" href="#"
/> />
@ -92,6 +97,7 @@ class TableElement extends React.Component {
} }
TableElement.propTypes = { TableElement.propTypes = {
table: React.PropTypes.object, table: React.PropTypes.object,
queryEditor: React.PropTypes.object,
actions: React.PropTypes.object, actions: React.PropTypes.object,
}; };
TableElement.defaultProps = { TableElement.defaultProps = {

View File

@ -70,7 +70,7 @@
"react-redux": "^4.4.5", "react-redux": "^4.4.5",
"react-resizable": "^1.3.3", "react-resizable": "^1.3.3",
"react-select": "^1.0.0-beta14", "react-select": "^1.0.0-beta14",
"react-syntax-highlighter": "^2.1.1", "react-syntax-highlighter": "^2.3.0",
"reactable": "^0.13.2", "reactable": "^0.13.2",
"redux": "^3.5.2", "redux": "^3.5.2",
"redux-localstorage": "^0.4.1", "redux-localstorage": "^0.4.1",

View File

@ -94,10 +94,8 @@ def get_sql_results(query_id, return_results=True):
if progress > query.progress: if progress > query.progress:
query.progress = progress query.progress = progress
db.session.commit() db.session.commit()
time.sleep(200) time.sleep(1)
polled = cursor.poll() polled = cursor.poll()
# TODO(b.kyryliuk): check for the kill signal.
columns = None columns = None
data = None data = None

View File

@ -211,6 +211,7 @@ def init(caravel):
'Security', 'Security',
'UserDBModelView', 'UserDBModelView',
'SQL Lab'): 'SQL Lab'):
sm.add_permission_role(alpha, perm) sm.add_permission_role(alpha, perm)
sm.add_permission_role(admin, perm) sm.add_permission_role(admin, perm)
gamma = sm.add_role("Gamma") gamma = sm.add_role("Gamma")

View File

@ -25,8 +25,7 @@ from flask_babel import gettext as __
from flask_babel import lazy_gettext as _ from flask_babel import lazy_gettext as _
from flask_appbuilder.models.sqla.filters import BaseFilter from flask_appbuilder.models.sqla.filters import BaseFilter
from sqlalchemy import create_engine, select, text from sqlalchemy import create_engine
from sqlalchemy.sql.expression import TextAsFrom
from werkzeug.routing import BaseConverter from werkzeug.routing import BaseConverter
from wtforms.validators import ValidationError from wtforms.validators import ValidationError
@ -38,6 +37,7 @@ from caravel import (
config = app.config config = app.config
log_this = models.Log.log_this log_this = models.Log.log_this
can_access = utils.can_access can_access = utils.can_access
QueryStatus = models.QueryStatus
class BaseCaravelView(BaseView): class BaseCaravelView(BaseView):
@ -1415,7 +1415,7 @@ class Caravel(BaseCaravelView):
if not mydb: if not mydb:
json_error_response( json_error_response(
'Database with id {} is missing.'.format(database_id), 'Database with id {} is missing.'.format(database_id),
models.QueryStatus.FAILED) QueryStatus.FAILED)
if not (self.can_access('all_datasource_access', 'all_datasource_access') or if not (self.can_access('all_datasource_access', 'all_datasource_access') or
self.can_access('database_access', mydb.perm)): self.can_access('database_access', mydb.perm)):
@ -1431,6 +1431,7 @@ class Caravel(BaseCaravelView):
select_as_cta=request.form.get('select_as_cta') == 'true', select_as_cta=request.form.get('select_as_cta') == 'true',
start_time=utils.now_as_float(), start_time=utils.now_as_float(),
tab_name=request.form.get('tab'), tab_name=request.form.get('tab'),
status=QueryStatus.PENDING if async else QueryStatus.RUNNING,
sql_editor_id=request.form.get('sql_editor_id'), sql_editor_id=request.form.get('sql_editor_id'),
tmp_table_name=request.form.get('tmp_table_name'), tmp_table_name=request.form.get('tmp_table_name'),
user_id=int(g.user.get_id()), user_id=int(g.user.get_id()),