Skip to content

Commit

Permalink
[SQLLab] user server for the query limit check. (apache#1230)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkyryliuk authored Oct 3, 2016
1 parent 472679b commit e11ef99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions caravel/assets/javascripts/SqlLab/components/SqlEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ class SqlEditor extends React.Component {
);
}
let limitWarning = null;
const rowLimit = 1000;
if (this.props.latestQuery && this.props.latestQuery.rows === rowLimit) {
if (this.props.latestQuery && this.props.latestQuery.limit_reached) {
const tooltip = (
<Tooltip id="tooltip">
It appears that the number of rows in the query results displayed
was limited on the server side to the {rowLimit} limit.
was limited on the server side to
the {this.props.latestQuery.rows} limit.
</Tooltip>
);
limitWarning = (
Expand Down
6 changes: 6 additions & 0 deletions caravel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,7 @@ class Query(Model):
# Could be configured in the caravel config.
limit = Column(Integer)
limit_used = Column(Boolean, default=False)
limit_reached = Column(Boolean, default=False)
select_as_cta = Column(Boolean)
select_as_cta_used = Column(Boolean, default=False)

Expand All @@ -1994,6 +1995,10 @@ class Query(Model):
sqla.Index('ti_user_id_changed_on', user_id, changed_on),
)

@property
def limit_reached(self):
return self.rows == self.limit if self.limit_used else False

def to_dict(self):
return {
'changedOn': self.changed_on,
Expand All @@ -2016,6 +2021,7 @@ def to_dict(self):
'tab': self.tab_name,
'tempTable': self.tmp_table_name,
'userId': self.user_id,
'limit_reached': self.limit_reached,
}

@property
Expand Down

0 comments on commit e11ef99

Please sign in to comment.