diff --git a/caravel/assets/javascripts/SqlLab/components/SqlEditorLeft.jsx b/caravel/assets/javascripts/SqlLab/components/SqlEditorLeft.jsx
index 7543c8ca8e..da26d953ff 100644
--- a/caravel/assets/javascripts/SqlLab/components/SqlEditorLeft.jsx
+++ b/caravel/assets/javascripts/SqlLab/components/SqlEditorLeft.jsx
@@ -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(),
@@ -169,7 +166,7 @@ class SqlEditorTopToolbar extends React.Component {
- {tables.map((table) =>
)}
+ {tables.map((table) =>
)}
);
diff --git a/caravel/assets/javascripts/SqlLab/components/TableElement.jsx b/caravel/assets/javascripts/SqlLab/components/TableElement.jsx
index 1d256ad341..c4fb8f1dff 100644
--- a/caravel/assets/javascripts/SqlLab/components/TableElement.jsx
+++ b/caravel/assets/javascripts/SqlLab/components/TableElement.jsx
@@ -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);
}
@@ -68,13 +73,13 @@ class TableElement extends React.Component {
@@ -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 = {
diff --git a/caravel/assets/package.json b/caravel/assets/package.json
index fe5ef1c49d..e725a6043d 100644
--- a/caravel/assets/package.json
+++ b/caravel/assets/package.json
@@ -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",
diff --git a/caravel/sql_lab.py b/caravel/sql_lab.py
index ffc4f4e826..ec5186f9cf 100644
--- a/caravel/sql_lab.py
+++ b/caravel/sql_lab.py
@@ -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
diff --git a/caravel/utils.py b/caravel/utils.py
index 806c7c0bcd..707f842dc5 100644
--- a/caravel/utils.py
+++ b/caravel/utils.py
@@ -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")
diff --git a/caravel/views.py b/caravel/views.py
index 7be0e1306e..d3b8af67ad 100755
--- a/caravel/views.py
+++ b/caravel/views.py
@@ -25,8 +25,7 @@ from flask_babel import gettext as __
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
@@ -38,6 +37,7 @@ from caravel import (
config = app.config
log_this = models.Log.log_this
can_access = utils.can_access
+QueryStatus = models.QueryStatus
class BaseCaravelView(BaseView):
@@ -1415,7 +1415,7 @@ class Caravel(BaseCaravelView):
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)):
@@ -1431,6 +1431,7 @@ class Caravel(BaseCaravelView):
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()),