Skip to content

Commit

Permalink
[hotfix] getting presto on track
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and mistercrunch committed Aug 31, 2016
1 parent 9f8eef4 commit 508feb2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ class SqlEditorTopToolbar extends React.Component {
});
return `SELECT ${cols}\nFROM ${table.name}`;
}
selectStar(table) {
this.props.actions.queryEditorSetSql(this.props.queryEditor, this.getSql(table));
}
popTab(table) {
const qe = {
id: shortid.generate(),
Expand Down Expand Up @@ -169,7 +166,7 @@ class SqlEditorTopToolbar extends React.Component {
</div>
<hr />
<div className="m-t-5">
{tables.map((table) => <TableElement table={table} />)}
{tables.map((table) => <TableElement table={table} queryEditor={this.props.queryEditor} />)}
</div>
</div>
);
Expand Down
14 changes: 10 additions & 4 deletions caravel/assets/javascripts/SqlLab/components/TableElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ class TableElement extends React.Component {
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 = {
id: shortid.generate(),
title: this.props.table.name,
dbId: this.props.table.dbId,
autorun: true,
sql,
sql: this.selectStar(),
};
this.props.actions.addQueryEditor(qe);
}
Expand Down Expand Up @@ -68,13 +73,13 @@ class TableElement extends React.Component {
<ButtonGroup className="ws-el-controls pull-right">
<Link
className="fa fa-pencil m-l-2"
onClick={this.selectStar.bind(this)}
onClick={this.setSelectStar.bind(this)}
tooltip="Run query in a new tab"
href="#"
/>
<Link
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"
href="#"
/>
Expand All @@ -92,6 +97,7 @@ class TableElement extends React.Component {
}
TableElement.propTypes = {
table: React.PropTypes.object,
queryEditor: React.PropTypes.object,
actions: React.PropTypes.object,
};
TableElement.defaultProps = {
Expand Down
2 changes: 1 addition & 1 deletion caravel/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"react-redux": "^4.4.5",
"react-resizable": "^1.3.3",
"react-select": "^1.0.0-beta14",
"react-syntax-highlighter": "^2.1.1",
"react-syntax-highlighter": "^2.3.0",
"reactable": "^0.13.2",
"redux": "^3.5.2",
"redux-localstorage": "^0.4.1",
Expand Down
4 changes: 1 addition & 3 deletions caravel/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,8 @@ def get_sql_results(query_id, return_results=True):
if progress > query.progress:
query.progress = progress
db.session.commit()
time.sleep(200)

time.sleep(1)
polled = cursor.poll()
# TODO(b.kyryliuk): check for the kill signal.

columns = None
data = None
Expand Down
1 change: 1 addition & 0 deletions caravel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def init(caravel):
'Security',
'UserDBModelView',
'SQL Lab'):

sm.add_permission_role(alpha, perm)
sm.add_permission_role(admin, perm)
gamma = sm.add_role("Gamma")
Expand Down
7 changes: 4 additions & 3 deletions caravel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
from flask_babel import lazy_gettext as _
from flask_appbuilder.models.sqla.filters import BaseFilter

from sqlalchemy import create_engine, select, text
from sqlalchemy.sql.expression import TextAsFrom
from sqlalchemy import create_engine
from werkzeug.routing import BaseConverter
from wtforms.validators import ValidationError

Expand All @@ -38,6 +37,7 @@
config = app.config
log_this = models.Log.log_this
can_access = utils.can_access
QueryStatus = models.QueryStatus


class BaseCaravelView(BaseView):
Expand Down Expand Up @@ -1415,7 +1415,7 @@ def json_error_response(msg, status=None):
if not mydb:
json_error_response(
'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
self.can_access('database_access', mydb.perm)):
Expand All @@ -1431,6 +1431,7 @@ def json_error_response(msg, status=None):
select_as_cta=request.form.get('select_as_cta') == 'true',
start_time=utils.now_as_float(),
tab_name=request.form.get('tab'),
status=QueryStatus.PENDING if async else QueryStatus.RUNNING,
sql_editor_id=request.form.get('sql_editor_id'),
tmp_table_name=request.form.get('tmp_table_name'),
user_id=int(g.user.get_id()),
Expand Down

0 comments on commit 508feb2

Please sign in to comment.