Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions superset-frontend/src/SqlLab/components/ResultSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import shortid from 'shortid';
import rison from 'rison';
import { styled, t, makeApi } from '@superset-ui/core';
import { debounce } from 'lodash';

import Icon from 'src/components/Icon';
import ErrorMessageWithStackTrace from 'src/components/ErrorMessage/ErrorMessageWithStackTrace';
import { SaveDatasetModal } from 'src/SqlLab/components/SaveDatasetModal';
import { put as updateDatset } from 'src/api/dataset';
Expand Down Expand Up @@ -100,11 +100,23 @@ const MonospaceDiv = styled.div`
white-space: pre-wrap;
`;

const ReturnedRows = styled.div`
font-size: 13px;
line-height: 24px;
.returnedRowsImage {
color: ${({ theme }) => theme.colors.warning.base};
vertical-align: bottom;
margin-right: ${({ theme }) => theme.gridUnit * 2}px;
}
.limitMessage {
color: ${({ theme }) => theme.colors.secondary.light1};
margin-left: ${({ theme }) => theme.gridUnit * 2}px;
}
`;
const ResultSetControls = styled.div`
display: flex;
justify-content: space-between;
padding: ${({ theme }) => 2 * theme.gridUnit}px 0;
position: fixed;
`;

const ResultSetButtons = styled.div`
Expand Down Expand Up @@ -498,6 +510,28 @@ export default class ResultSet extends React.PureComponent<
return <div />;
}

renderRowsReturned() {
const { results, rows } = this.props.query;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this.props.query always have a value?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup! It will only render if query.results exists.

const limitReached = results?.displayLimitReached;
const limitWarning = <Icon className="returnedRowsImage" name="warning" />;
return (
<ReturnedRows>
{limitReached && limitWarning}
<span>{t(`%s rows returned`, rows)}</span>
{limitReached && (
<span className="limitMessage">
{t(
`It appears that the number of rows in the query results displayed
was limited on the server side to
the %s limit.`,
rows,
)}
</span>
)}
</ReturnedRows>
);
}

render() {
const { query } = this.props;
const height = Math.max(
Expand Down Expand Up @@ -587,6 +621,7 @@ export default class ResultSet extends React.PureComponent<
return (
<>
{this.renderControls()}
{this.renderRowsReturned()}
{sql}
<FilterableTable
data={data}
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/SqlLab/components/SouthPane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ const StyledPane = styled.div`
.ant-tabs .ant-tabs-content-holder {
overflow: visible;
}

.SouthPaneTabs {
height: 100%;
display: flex;
flex-direction: column;
}
.tab-content {
overflow: hidden;
.alert {
margin-top: ${({ theme }) => theme.gridUnit * 2}px;
}
Expand Down
22 changes: 0 additions & 22 deletions superset-frontend/src/SqlLab/components/SqlEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ import debounce from 'lodash/debounce';
import throttle from 'lodash/throttle';
import StyledModal from 'src/common/components/Modal';
import Mousetrap from 'mousetrap';

import { Tooltip } from 'src/common/components/Tooltip';
import Label from 'src/components/Label';
import Button from 'src/components/Button';
import Timer from 'src/components/Timer';
import {
Expand Down Expand Up @@ -563,23 +560,6 @@ class SqlEditor extends React.PureComponent {

renderEditorBottomBar() {
const { queryEditor: qe } = this.props;
let limitWarning = null;
if (this.props.latestQuery?.results?.displayLimitReached) {
limitWarning = (
<Tooltip
id="tooltip"
placement="left"
title={t(
`It appears that the number of rows in the query results displayed
was limited on the server side to
the %s limit.`,
this.props.latestQuery.rows,
)}
>
<Label type="warning">LIMIT</Label>
</Tooltip>
);
}

const { allow_ctas: allowCTAS, allow_cvas: allowCVAS } =
this.props.database || {};
Expand Down Expand Up @@ -650,7 +630,6 @@ class SqlEditor extends React.PureComponent {
/>
</span>
)}
{limitWarning}
<span>
<LimitSelectStyled>
<Dropdown overlay={this.renderQueryLimit()} trigger="click">
Expand Down Expand Up @@ -690,7 +669,6 @@ class SqlEditor extends React.PureComponent {
<span>
<ShareSqlLabQuery queryEditor={qe} />
</span>
{limitWarning}
<Dropdown overlay={this.renderDropdown()} trigger="click">
<Icon name="more-horiz" />
</Dropdown>
Expand Down
3 changes: 2 additions & 1 deletion superset-frontend/src/SqlLab/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ body {
height: 100%;
position: relative;
background-color: @lightest;
overflow: auto;
overflow-x: auto;
overflow-y: hidden;

> .ant-tabs-tabpane {
position: absolute;
Expand Down
3 changes: 3 additions & 0 deletions superset-frontend/src/SqlLab/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type Query = {
link?: string;
progress: number;
results: {
displayLimitReached: boolean;
columns: Column[];
data: Record<string, unknown>[];
expanded_columns: Column[];
Expand All @@ -60,4 +61,6 @@ export type Query = {
tempTable: string;
trackingUrl: string | null;
templateParams: any;
rows: number;
queryLimit: number;
};
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const JSON_TREE_THEME = {

const StyledFilterableTable = styled.div`
overflow-x: auto;
margin-top: ${({ theme }) => theme.gridUnit * 12}px;
margin-top: ${({ theme }) => theme.gridUnit * 2}px;
`;

// when more than MAX_COLUMNS_FOR_TABLE are returned, switch from table to grid view
Expand Down