You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2024/06/26 13:25:58 UTC
(superset) branch 4.0 updated (df93420d2e -> ecb3b58e77)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a change to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git
from df93420d2e chore: Adds 4.0.2 RC1 data to CHANGELOG.md
new a7b7b7d199 fix(permalink): adding anchor to dashboard permalink generation (#28744)
new efab0dd169 fix: filters not updating with force update when caching is enabled (#29291)
new 64e9a44c44 fix(sqllab): invalid empty state on switch tab (#29278)
new e7be247164 fix(metastore-cache): prune before add (#29301)
new 800340aa1e fix: Remove recursive repr call (#29314)
new 35f3a490d5 fix: Cannot delete empty column inside a tab using the dashboard editor (#29346)
new df8b61b284 fix(explore): restored hidden field values has discarded (#29349)
new fc97a818eb chore: Rename Totals to Summary in table chart (#29360)
new 626d7aa418 fix(revert 27883): Excess padding in horizontal Bar charts (#29345)
new 6d5e38c266 fix(explore): don't respect y-axis formatting (#29367)
new ecb3b58e77 fix: adds the ability to disallow SQL functions per engine (#28639)
The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../src/Timeseries/transformProps.ts | 1 -
.../src/Timeseries/transformers.ts | 12 +-----
.../test/Timeseries/transformProps.test.ts | 1 -
.../src/plugin/controls/metrics.tsx | 2 +-
.../plugins/plugin-chart-table/package.json | 1 +
.../plugins/plugin-chart-table/src/TableChart.tsx | 30 +++++++++++++--
.../plugin-chart-table/src/controlPanel.tsx | 2 +-
.../src/SqlLab/components/SqlEditor/index.tsx | 12 ++----
.../SqlLab/components/SqlEditorLeftBar/index.tsx | 12 +-----
.../src/SqlLab/reducers/getInitialState.ts | 1 +
.../HeaderActionsDropdown.test.tsx | 7 ++--
.../Header/HeaderActionsDropdown/index.jsx | 16 ++++++--
.../src/dashboard/components/Header/index.jsx | 4 +-
.../src/dashboard/components/Header/types.ts | 6 +++
.../components/RefreshIntervalModal.test.tsx | 2 +-
.../src/dashboard/components/menu/HoverMenu.tsx | 2 +-
.../FilterBar/FilterControls/FilterValue.tsx | 2 +-
.../src/explore/actions/exploreActions.test.js | 4 +-
.../StashFormDataContainer.test.tsx | 30 ++++++++++++++-
.../components/StashFormDataContainer/index.tsx | 9 +----
.../src/explore/reducers/exploreReducer.js | 18 +++++----
.../src/explore/reducers/exploreReducer.test.js | 45 ++++++++++++++++++++++
superset/commands/exceptions.py | 2 +-
superset/config.py | 8 ++++
superset/db_engine_specs/base.py | 6 +++
superset/db_engine_specs/trino.py | 11 ++++--
superset/exceptions.py | 15 ++++++++
superset/extensions/metastore_cache.py | 2 +-
superset/sql_parse.py | 42 ++++++++++++++++++++
.../extensions/metastore_cache_test.py | 17 +++++++-
tests/unit_tests/db_engine_specs/test_trino.py | 24 +++++++-----
tests/unit_tests/sql_parse_tests.py | 26 +++++++++++++
32 files changed, 288 insertions(+), 84 deletions(-)
create mode 100644 superset-frontend/src/explore/reducers/exploreReducer.test.js
(superset) 02/11: fix: filters not updating with force update when caching is enabled (#29291)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit efab0dd1691c430c7b46953e23bd485329534e90
Author: ka-weihe <k...@weihe.dk>
AuthorDate: Tue Jun 18 18:56:56 2024 +0200
fix: filters not updating with force update when caching is enabled (#29291)
(cherry picked from commit 527f1d20ad25ed98216feb8c768be7b7ee8a5c8e)
---
.../components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx
index 5041fa3c97..2e626636c7 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx
@@ -174,7 +174,7 @@ const FilterValue: React.FC<FilterControlProps> = ({
setIsRefreshing(true);
getChartDataRequest({
formData: newFormData,
- force: false,
+ force: shouldRefresh,
ownState: filterOwnState,
})
.then(({ response, json }) => {
(superset) 07/11: fix(explore): restored hidden field values has discarded (#29349)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit df8b61b284ef1e04867a9a49068ff391e26a5578
Author: JUST.in DO IT <ju...@airbnb.com>
AuthorDate: Mon Jun 24 14:52:32 2024 -0700
fix(explore): restored hidden field values has discarded (#29349)
(cherry picked from commit 160cece017d656039c36b1ba5a5dc238e5cce16e)
---
.../src/explore/actions/exploreActions.test.js | 4 +--
.../src/explore/reducers/exploreReducer.js | 2 +-
.../src/explore/reducers/exploreReducer.test.js | 35 ++++++++++++++++++++++
3 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/superset-frontend/src/explore/actions/exploreActions.test.js b/superset-frontend/src/explore/actions/exploreActions.test.js
index 700987a0e5..12bbdce4e7 100644
--- a/superset-frontend/src/explore/actions/exploreActions.test.js
+++ b/superset-frontend/src/explore/actions/exploreActions.test.js
@@ -231,9 +231,7 @@ describe('reducers', () => {
newState,
actions.setStashFormData(false, ['y_axis_format']),
);
- expect(updatedState.hiddenFormData).toEqual({
- y_axis_format: defaultState.form_data.y_axis_format,
- });
+ expect(updatedState.hiddenFormData.y_axis_format).toBeFalsy();
expect(updatedState.form_data.y_axis_format).toEqual(
defaultState.form_data.y_axis_format,
);
diff --git a/superset-frontend/src/explore/reducers/exploreReducer.js b/superset-frontend/src/explore/reducers/exploreReducer.js
index 9eddd2f678..8985f032c7 100644
--- a/superset-frontend/src/explore/reducers/exploreReducer.js
+++ b/superset-frontend/src/explore/reducers/exploreReducer.js
@@ -267,7 +267,7 @@ export default function exploreReducer(state = {}, action) {
...form_data,
...restoredField,
},
- hiddenFormData,
+ hiddenFormData: omit(hiddenFormData, fieldNames),
};
},
[actions.SLICE_UPDATED]() {
diff --git a/superset-frontend/src/explore/reducers/exploreReducer.test.js b/superset-frontend/src/explore/reducers/exploreReducer.test.js
new file mode 100644
index 0000000000..37f072d9e7
--- /dev/null
+++ b/superset-frontend/src/explore/reducers/exploreReducer.test.js
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import exploreReducer from './exploreReducer';
+import { setStashFormData } from '../actions/exploreActions';
+
+test('reset hiddenFormData on SET_STASH_FORM_DATA', () => {
+ const initialState = {
+ form_data: { a: 3, c: 4 },
+ };
+ const action = setStashFormData(true, ['a', 'c']);
+ const newState = exploreReducer(initialState, action);
+ expect(newState.form_data).toEqual({});
+ expect(newState.hiddenFormData).toEqual({ a: 3, c: 4 });
+ const restoreAction = setStashFormData(false, ['c']);
+ const newState2 = exploreReducer(newState, restoreAction);
+ expect(newState2.form_data).toEqual({ c: 4 });
+ expect(newState2.hiddenFormData).toEqual({ a: 3 });
+});
(superset) 04/11: fix(metastore-cache): prune before add (#29301)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit e7be24716499c352868143d8d9081cb87865732c
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Thu Jun 20 14:59:32 2024 +0300
fix(metastore-cache): prune before add (#29301)
(cherry picked from commit 172ddb47d54749db781ea6443bd29a2d650efb99)
---
superset/extensions/metastore_cache.py | 2 +-
.../extensions/metastore_cache_test.py | 17 +++++++++++++++--
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/superset/extensions/metastore_cache.py b/superset/extensions/metastore_cache.py
index 435c38ced8..1c89e84597 100644
--- a/superset/extensions/metastore_cache.py
+++ b/superset/extensions/metastore_cache.py
@@ -101,6 +101,7 @@ class SupersetMetastoreCache(BaseCache):
from superset.commands.key_value.create import CreateKeyValueCommand
try:
+ self._prune()
CreateKeyValueCommand(
resource=RESOURCE,
value=value,
@@ -108,7 +109,6 @@ class SupersetMetastoreCache(BaseCache):
key=self.get_key(key),
expires_on=self._get_expiry(timeout),
).run()
- self._prune()
return True
except KeyValueCreateFailedError:
return False
diff --git a/tests/integration_tests/extensions/metastore_cache_test.py b/tests/integration_tests/extensions/metastore_cache_test.py
index eeb7279fe1..9b90d5bc32 100644
--- a/tests/integration_tests/extensions/metastore_cache_test.py
+++ b/tests/integration_tests/extensions/metastore_cache_test.py
@@ -77,16 +77,29 @@ def test_caching_flow(app_context: AppContext, cache: SupersetMetastoreCache) ->
def test_expiry(app_context: AppContext, cache: SupersetMetastoreCache) -> None:
delta = timedelta(days=90)
dttm = datetime(2022, 3, 18, 0, 0, 0)
+
+ # 1. initialize cached values, ensure they're found
with freeze_time(dttm):
- cache.set(FIRST_KEY, FIRST_KEY_INITIAL_VALUE, int(delta.total_seconds()))
+ assert (
+ cache.set(FIRST_KEY, FIRST_KEY_INITIAL_VALUE, int(delta.total_seconds()))
+ is True
+ )
assert cache.get(FIRST_KEY) == FIRST_KEY_INITIAL_VALUE
+
+ # 2. ensure cached values are available a moment before expiration
with freeze_time(dttm + delta - timedelta(seconds=1)):
- assert cache.has(FIRST_KEY)
+ assert cache.has(FIRST_KEY) is True
assert cache.get(FIRST_KEY) == FIRST_KEY_INITIAL_VALUE
+
+ # 3. ensure cached entries expire
with freeze_time(dttm + delta + timedelta(seconds=1)):
assert cache.has(FIRST_KEY) is False
assert cache.get(FIRST_KEY) is None
+ # adding a value with the same key as an expired entry works
+ assert cache.add(FIRST_KEY, SECOND_VALUE, int(delta.total_seconds())) is True
+ assert cache.get(FIRST_KEY) == SECOND_VALUE
+
@pytest.mark.parametrize(
"input_,codec,expected_result",
(superset) 01/11: fix(permalink): adding anchor to dashboard permalink generation (#28744)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit a7b7b7d199ea4b8c0971f7332f5d977e55c16a0b
Author: Jack <41...@users.noreply.github.com>
AuthorDate: Mon Jun 17 10:52:31 2024 -0500
fix(permalink): adding anchor to dashboard permalink generation (#28744)
---
.../HeaderActionsDropdown/HeaderActionsDropdown.test.tsx | 7 ++++---
.../components/Header/HeaderActionsDropdown/index.jsx | 14 ++++++++++++--
.../src/dashboard/components/Header/index.jsx | 4 ++--
superset-frontend/src/dashboard/components/Header/types.ts | 6 ++++++
.../src/dashboard/components/RefreshIntervalModal.test.tsx | 2 +-
5 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/HeaderActionsDropdown.test.tsx b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/HeaderActionsDropdown.test.tsx
index cefdbafa73..2a64f75309 100644
--- a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/HeaderActionsDropdown.test.tsx
+++ b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/HeaderActionsDropdown.test.tsx
@@ -24,9 +24,9 @@ import userEvent from '@testing-library/user-event';
import fetchMock from 'fetch-mock';
import { HeaderDropdownProps } from 'src/dashboard/components/Header/types';
import injectCustomCss from 'src/dashboard/util/injectCustomCss';
-import HeaderActionsDropdown from '.';
+import { HeaderActionsDropdown } from '.';
-const createProps = () => ({
+const createProps = (): HeaderDropdownProps => ({
addSuccessToast: jest.fn(),
addDangerToast: jest.fn(),
customCss: '.ant-menu {margin-left: 100px;}',
@@ -67,6 +67,7 @@ const createProps = () => ({
userCanCurate: false,
lastModifiedTime: 0,
isDropdownVisible: true,
+ manageEmbedded: jest.fn(),
dataMask: {},
logEvent: jest.fn(),
});
@@ -229,9 +230,9 @@ test('should show the properties modal', async () => {
describe('UNSAFE_componentWillReceiveProps', () => {
let wrapper: any;
+
const mockedProps = createProps();
const props = { ...mockedProps, customCss: '' };
-
beforeEach(() => {
wrapper = shallow(<HeaderActionsDropdown {...props} />);
wrapper.setState({ css: props.customCss });
diff --git a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx
index 1926a975bb..6cdd6e4778 100644
--- a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx
+++ b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx
@@ -19,6 +19,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { isEmpty } from 'lodash';
+import { connect } from 'react-redux';
import { t } from '@superset-ui/core';
import { Menu } from 'src/components/Menu';
import { URL_PARAMS } from 'src/constants';
@@ -45,6 +46,7 @@ const propTypes = {
customCss: PropTypes.string,
colorNamespace: PropTypes.string,
colorScheme: PropTypes.string,
+ directPathToChild: PropTypes.array,
onChange: PropTypes.func.isRequired,
updateCss: PropTypes.func.isRequired,
forceRefreshAllCharts: PropTypes.func.isRequired,
@@ -90,7 +92,11 @@ const MENU_KEYS = {
MANAGE_EMAIL_REPORT: 'manage-email-report',
};
-class HeaderActionsDropdown extends React.PureComponent {
+const mapStateToProps = state => ({
+ directPathToChild: state.dashboardState.directPathToChild,
+});
+
+export class HeaderActionsDropdown extends PureComponent {
static discardChanges() {
window.location.reload();
}
@@ -186,6 +192,7 @@ class HeaderActionsDropdown extends React.PureComponent {
addDangerToast,
setIsDropdownVisible,
isDropdownVisible,
+ directPathToChild,
...rest
} = this.props;
@@ -204,6 +211,8 @@ class HeaderActionsDropdown extends React.PureComponent {
const refreshIntervalOptions =
dashboardInfo.common?.conf?.DASHBOARD_AUTO_REFRESH_INTERVALS;
+ const dashboardComponentId = [...(directPathToChild || [])].pop();
+
return (
<Menu selectable={false} data-test="header-actions-menu" {...rest}>
{!editMode && (
@@ -299,6 +308,7 @@ class HeaderActionsDropdown extends React.PureComponent {
addSuccessToast={addSuccessToast}
addDangerToast={addDangerToast}
dashboardId={dashboardId}
+ dashboardComponentId={dashboardComponentId}
/>
</Menu.SubMenu>
)}
@@ -367,4 +377,4 @@ class HeaderActionsDropdown extends React.PureComponent {
HeaderActionsDropdown.propTypes = propTypes;
HeaderActionsDropdown.defaultProps = defaultProps;
-export default HeaderActionsDropdown;
+export default connect(mapStateToProps)(HeaderActionsDropdown);
diff --git a/superset-frontend/src/dashboard/components/Header/index.jsx b/superset-frontend/src/dashboard/components/Header/index.jsx
index 485185d607..e7d11299c8 100644
--- a/superset-frontend/src/dashboard/components/Header/index.jsx
+++ b/superset-frontend/src/dashboard/components/Header/index.jsx
@@ -41,7 +41,7 @@ import { AntdButton } from 'src/components/';
import { findPermission } from 'src/utils/findPermission';
import { Tooltip } from 'src/components/Tooltip';
import { safeStringify } from 'src/utils/safeStringify';
-import HeaderActionsDropdown from 'src/dashboard/components/Header/HeaderActionsDropdown';
+import ConnectedHeaderActionsDropdown from 'src/dashboard/components/Header/HeaderActionsDropdown';
import PublishedStatus from 'src/dashboard/components/PublishedStatus';
import UndoRedoKeyListeners from 'src/dashboard/components/UndoRedoKeyListeners';
import PropertiesModal from 'src/dashboard/components/PropertiesModal';
@@ -643,7 +643,7 @@ class Header extends React.PureComponent {
onVisibleChange: this.setIsDropdownVisible,
}}
additionalActionsMenu={
- <HeaderActionsDropdown
+ <ConnectedHeaderActionsDropdown
addSuccessToast={this.props.addSuccessToast}
addDangerToast={this.props.addDangerToast}
dashboardId={dashboardInfo.id}
diff --git a/superset-frontend/src/dashboard/components/Header/types.ts b/superset-frontend/src/dashboard/components/Header/types.ts
index 89ea756988..f3a35586a2 100644
--- a/superset-frontend/src/dashboard/components/Header/types.ts
+++ b/superset-frontend/src/dashboard/components/Header/types.ts
@@ -54,7 +54,13 @@ export interface HeaderDropdownProps {
updateCss: () => void;
userCanEdit: boolean;
userCanSave: boolean;
+ userCanShare: boolean;
+ userCanCurate: boolean;
+ isDropdownVisible: boolean;
+ manageEmbedded: () => void;
+ dataMask: any;
lastModifiedTime: number;
+ logEvent: () => void;
}
export interface HeaderProps {
diff --git a/superset-frontend/src/dashboard/components/RefreshIntervalModal.test.tsx b/superset-frontend/src/dashboard/components/RefreshIntervalModal.test.tsx
index 17c08e0701..ef419ba20f 100644
--- a/superset-frontend/src/dashboard/components/RefreshIntervalModal.test.tsx
+++ b/superset-frontend/src/dashboard/components/RefreshIntervalModal.test.tsx
@@ -22,7 +22,7 @@ import userEvent from '@testing-library/user-event';
import fetchMock from 'fetch-mock';
import RefreshIntervalModal from 'src/dashboard/components/RefreshIntervalModal';
-import HeaderActionsDropdown from 'src/dashboard/components/Header/HeaderActionsDropdown';
+import { HeaderActionsDropdown } from 'src/dashboard/components/Header/HeaderActionsDropdown';
const createProps = () => ({
addSuccessToast: jest.fn(),
(superset) 08/11: chore: Rename Totals to Summary in table chart (#29360)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit fc97a818ebbcbe9d4d1bcdf6614ea4a81e358249
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Tue Jun 25 13:33:16 2024 -0300
chore: Rename Totals to Summary in table chart (#29360)
---
.../src/plugin/controls/metrics.tsx | 2 +-
.../plugins/plugin-chart-table/package.json | 1 +
.../plugins/plugin-chart-table/src/TableChart.tsx | 30 +++++++++++++++++++---
.../plugin-chart-table/src/controlPanel.tsx | 2 +-
4 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/metrics.tsx b/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/metrics.tsx
index 67a55cff0d..dd1516098a 100644
--- a/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/metrics.tsx
+++ b/superset-frontend/plugins/plugin-chart-handlebars/src/plugin/controls/metrics.tsx
@@ -102,7 +102,7 @@ export const showTotalsControlSetItem: ControlSetItem = {
name: 'show_totals',
config: {
type: 'CheckboxControl',
- label: t('Show totals'),
+ label: t('Show summary'),
default: false,
description: t(
'Show total aggregations of selected metrics. Note that row limit does not apply to the result.',
diff --git a/superset-frontend/plugins/plugin-chart-table/package.json b/superset-frontend/plugins/plugin-chart-table/package.json
index 6df1ceb33e..d43e33808e 100644
--- a/superset-frontend/plugins/plugin-chart-table/package.json
+++ b/superset-frontend/plugins/plugin-chart-table/package.json
@@ -37,6 +37,7 @@
"xss": "^1.0.14"
},
"peerDependencies": {
+ "@ant-design/icons": "^5.0.1",
"@superset-ui/chart-controls": "*",
"@superset-ui/core": "*",
"@testing-library/dom": "^7.29.4",
diff --git a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
index ed2d9319c5..a6a27eb8a3 100644
--- a/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
+++ b/superset-frontend/plugins/plugin-chart-table/src/TableChart.tsx
@@ -48,8 +48,11 @@ import {
css,
t,
tn,
+ useTheme,
} from '@superset-ui/core';
-
+import { isNumber } from 'lodash';
+import { InfoCircleOutlined } from '@ant-design/icons';
+import { Tooltip } from '@superset-ui/chart-controls';
import { DataColumnMeta, TableChartTransformedProps } from './types';
import DataTable, {
DataTableProps,
@@ -250,6 +253,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
});
// keep track of whether column order changed, so that column widths can too
const [columnOrderToggle, setColumnOrderToggle] = useState(false);
+ const theme = useTheme();
// only take relevant page size options
const pageSizeOptions = useMemo(() => {
@@ -572,7 +576,7 @@ export default function TableChart<D extends DataRecord = DataRecord>(
/* The following classes are added to support custom CSS styling */
className={cx(
'cell-bar',
- value && value < 0 ? 'negative' : 'positive',
+ isNumber(value) && value < 0 ? 'negative' : 'positive',
)}
css={cellBarStyles}
/>
@@ -639,7 +643,27 @@ export default function TableChart<D extends DataRecord = DataRecord>(
),
Footer: totals ? (
i === 0 ? (
- <th>{t('Totals')}</th>
+ <th>
+ <div
+ css={css`
+ display: flex;
+ align-items: center;
+ & svg {
+ margin-left: ${theme.gridUnit}px;
+ color: ${theme.colors.grayscale.dark1} !important;
+ }
+ `}
+ >
+ {t('Summary')}
+ <Tooltip
+ overlay={t(
+ 'Show total aggregations of selected metrics. Note that row limit does not apply to the result.',
+ )}
+ >
+ <InfoCircleOutlined />
+ </Tooltip>
+ </div>
+ </th>
) : (
<td style={sharedStyle}>
<strong>{formatColumnValue(column, totals[key])[1]}</strong>
diff --git a/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx
index ad39b504cb..e58bb6751a 100644
--- a/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx
+++ b/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx
@@ -339,7 +339,7 @@ const config: ControlPanelConfig = {
name: 'show_totals',
config: {
type: 'CheckboxControl',
- label: t('Show totals'),
+ label: t('Show summary'),
default: false,
description: t(
'Show total aggregations of selected metrics. Note that row limit does not apply to the result.',
(superset) 03/11: fix(sqllab): invalid empty state on switch tab (#29278)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 64e9a44c440cf4739fc80a1107709ba96c542394
Author: JUST.in DO IT <ju...@airbnb.com>
AuthorDate: Tue Jun 18 11:45:09 2024 -0700
fix(sqllab): invalid empty state on switch tab (#29278)
---
superset-frontend/src/SqlLab/components/SqlEditor/index.tsx | 12 ++++--------
.../src/SqlLab/components/SqlEditorLeftBar/index.tsx | 12 +-----------
superset-frontend/src/SqlLab/reducers/getInitialState.ts | 1 +
3 files changed, 6 insertions(+), 19 deletions(-)
diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx
index 0bf256b3a3..bd8ea71179 100644
--- a/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx
+++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx
@@ -298,7 +298,10 @@ const SqlEditor: React.FC<Props> = ({
);
const [showCreateAsModal, setShowCreateAsModal] = useState(false);
const [createAs, setCreateAs] = useState('');
- const [showEmptyState, setShowEmptyState] = useState(false);
+ const showEmptyState = useMemo(
+ () => !database || isEmpty(database),
+ [database],
+ );
const sqlEditorRef = useRef<HTMLDivElement>(null);
const northPaneRef = useRef<HTMLDivElement>(null);
@@ -557,12 +560,6 @@ const SqlEditor: React.FC<Props> = ({
// TODO: Remove useEffectEvent deps once https://github.com/facebook/react/pull/25881 is released
}, [onBeforeUnload, loadQueryEditor, isActive]);
- useEffect(() => {
- if (!database || isEmpty(database)) {
- setShowEmptyState(true);
- }
- }, [database]);
-
useEffect(() => {
// setup hotkeys
const hotkeys = getHotkeyConfig();
@@ -893,7 +890,6 @@ const SqlEditor: React.FC<Props> = ({
<SqlEditorLeftBar
database={database}
queryEditorId={queryEditor.id}
- setEmptyState={bool => setShowEmptyState(bool)}
/>
</StyledSidebar>
)}
diff --git a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx
index 15a1735626..e6d097084a 100644
--- a/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx
+++ b/superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx
@@ -16,14 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import React, {
- useEffect,
- useCallback,
- useMemo,
- useState,
- Dispatch,
- SetStateAction,
-} from 'react';
+import React, { useEffect, useCallback, useMemo, useState } from 'react';
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
import querystring from 'query-string';
@@ -59,7 +52,6 @@ export interface SqlEditorLeftBarProps {
queryEditorId: string;
height?: number;
database?: DatabaseObject;
- setEmptyState?: Dispatch<SetStateAction<boolean>>;
}
const StyledScrollbarContainer = styled.div`
@@ -107,7 +99,6 @@ const SqlEditorLeftBar = ({
database,
queryEditorId,
height = 500,
- setEmptyState,
}: SqlEditorLeftBarProps) => {
const tables = useSelector<SqlLabRootState, Table[]>(
({ sqlLab }) =>
@@ -143,7 +134,6 @@ const SqlEditorLeftBar = ({
};
const onDbChange = ({ id: dbId }: { id: number }) => {
- setEmptyState?.(false);
dispatch(queryEditorSetDb(queryEditor, dbId));
};
diff --git a/superset-frontend/src/SqlLab/reducers/getInitialState.ts b/superset-frontend/src/SqlLab/reducers/getInitialState.ts
index bcdc1f40c3..947e7b7a0f 100644
--- a/superset-frontend/src/SqlLab/reducers/getInitialState.ts
+++ b/superset-frontend/src/SqlLab/reducers/getInitialState.ts
@@ -101,6 +101,7 @@ export default function getInitialState({
id: id.toString(),
loaded: false,
name: label,
+ dbId: undefined,
};
}
queryEditors = {
(superset) 09/11: fix(revert 27883): Excess padding in horizontal Bar charts (#29345)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 626d7aa4182a651c7e323eec22f345fda4e20f30
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Tue Jun 25 13:33:53 2024 -0300
fix(revert 27883): Excess padding in horizontal Bar charts (#29345)
(cherry picked from commit 708afb71462fa616209bbff9b23000880158810e)
---
.../plugin-chart-echarts/src/Timeseries/transformProps.ts | 1 -
.../plugin-chart-echarts/src/Timeseries/transformers.ts | 12 ++----------
.../test/Timeseries/transformProps.test.ts | 1 -
3 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
index afee184e85..3c12de9a3a 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts
@@ -513,7 +513,6 @@ export default function transformProps(
if (isHorizontal) {
[xAxis, yAxis] = [yAxis, xAxis];
[padding.bottom, padding.left] = [padding.left, padding.bottom];
- yAxis.inverse = true;
}
const echartOptions: EChartsCoreOption = {
diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
index b4aded89bf..bc441da3c0 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts
@@ -569,10 +569,6 @@ export function getPadding(
? TIMESERIES_CONSTANTS.yAxisLabelTopOffset
: 0;
const xAxisOffset = addXAxisTitleOffset ? Number(xAxisTitleMargin) || 0 : 0;
- const showLegendTopOffset =
- isHorizontal && showLegend && legendOrientation === LegendOrientation.Top
- ? 100
- : 0;
return getChartPadding(
showLegend,
@@ -581,12 +577,8 @@ export function getPadding(
{
top:
yAxisTitlePosition && yAxisTitlePosition === 'Top'
- ? TIMESERIES_CONSTANTS.gridOffsetTop +
- showLegendTopOffset +
- (Number(yAxisTitleMargin) || 0)
- : TIMESERIES_CONSTANTS.gridOffsetTop +
- showLegendTopOffset +
- yAxisOffset,
+ ? TIMESERIES_CONSTANTS.gridOffsetTop + (Number(yAxisTitleMargin) || 0)
+ : TIMESERIES_CONSTANTS.gridOffsetTop + yAxisOffset,
bottom:
zoomable && !isHorizontal
? TIMESERIES_CONSTANTS.gridOffsetBottomZoomable + xAxisOffset
diff --git a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
index cda213d72b..bbb6271cc3 100644
--- a/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
+++ b/superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts
@@ -119,7 +119,6 @@ describe('EchartsTimeseries transformProps', () => {
name: 'New York',
}),
]),
- yAxis: expect.objectContaining({ inverse: true }),
}),
}),
);
(superset) 10/11: fix(explore): don't respect y-axis formatting (#29367)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 6d5e38c266f90364de212cc7fa3121031beb78c3
Author: JUST.in DO IT <ju...@airbnb.com>
AuthorDate: Wed Jun 26 04:16:36 2024 -0700
fix(explore): don't respect y-axis formatting (#29367)
---
.../StashFormDataContainer.test.tsx | 30 +++++++++++++++++++++-
.../components/StashFormDataContainer/index.tsx | 9 ++-----
.../src/explore/reducers/exploreReducer.js | 18 +++++++------
.../src/explore/reducers/exploreReducer.test.js | 10 ++++++++
4 files changed, 51 insertions(+), 16 deletions(-)
diff --git a/superset-frontend/src/explore/components/StashFormDataContainer/StashFormDataContainer.test.tsx b/superset-frontend/src/explore/components/StashFormDataContainer/StashFormDataContainer.test.tsx
index 1316411945..2d7358b149 100644
--- a/superset-frontend/src/explore/components/StashFormDataContainer/StashFormDataContainer.test.tsx
+++ b/superset-frontend/src/explore/components/StashFormDataContainer/StashFormDataContainer.test.tsx
@@ -18,7 +18,7 @@
*/
import React from 'react';
import { defaultState } from 'src/explore/store';
-import { render } from 'spec/helpers/testing-library';
+import { render, waitFor } from 'spec/helpers/testing-library';
import { useSelector } from 'react-redux';
import { ExplorePageState } from 'src/explore/types';
import StashFormDataContainer from '.';
@@ -55,3 +55,31 @@ test('should stash form data from fieldNames', () => {
'granularity_sqla',
);
});
+
+test('should restore form data from fieldNames', async () => {
+ const { granularity_sqla, ...formData } = defaultState.form_data;
+ const { container } = render(
+ <StashFormDataContainer
+ shouldStash={false}
+ fieldNames={['granularity_sqla']}
+ >
+ <FormDataMock />
+ </StashFormDataContainer>,
+ {
+ useRedux: true,
+ initialState: {
+ explore: {
+ form_data: formData,
+ hiddenFormData: {
+ granularity_sqla,
+ },
+ },
+ },
+ },
+ );
+ await waitFor(() =>
+ expect(container.querySelector('div')).toHaveTextContent(
+ 'granularity_sqla',
+ ),
+ );
+});
diff --git a/superset-frontend/src/explore/components/StashFormDataContainer/index.tsx b/superset-frontend/src/explore/components/StashFormDataContainer/index.tsx
index 9684ddf774..114eaa68bd 100644
--- a/superset-frontend/src/explore/components/StashFormDataContainer/index.tsx
+++ b/superset-frontend/src/explore/components/StashFormDataContainer/index.tsx
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import React, { useEffect, useRef } from 'react';
+import React, { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { setStashFormData } from 'src/explore/actions/exploreActions';
import useEffectEvent from 'src/hooks/useEffectEvent';
@@ -32,16 +32,11 @@ const StashFormDataContainer: React.FC<Props> = ({
children,
}) => {
const dispatch = useDispatch();
- const isMounted = useRef(false);
const onVisibleUpdate = useEffectEvent((shouldStash: boolean) =>
dispatch(setStashFormData(shouldStash, fieldNames)),
);
useEffect(() => {
- if (!isMounted.current && !shouldStash) {
- isMounted.current = true;
- } else {
- onVisibleUpdate(shouldStash);
- }
+ onVisibleUpdate(shouldStash);
}, [shouldStash, onVisibleUpdate]);
return <>{children}</>;
diff --git a/superset-frontend/src/explore/reducers/exploreReducer.js b/superset-frontend/src/explore/reducers/exploreReducer.js
index 8985f032c7..377a66d5b5 100644
--- a/superset-frontend/src/explore/reducers/exploreReducer.js
+++ b/superset-frontend/src/explore/reducers/exploreReducer.js
@@ -261,14 +261,16 @@ export default function exploreReducer(state = {}, action) {
}
const restoredField = pick(hiddenFormData, fieldNames);
- return {
- ...state,
- form_data: {
- ...form_data,
- ...restoredField,
- },
- hiddenFormData: omit(hiddenFormData, fieldNames),
- };
+ return Object.keys(restoredField).length === 0
+ ? state
+ : {
+ ...state,
+ form_data: {
+ ...form_data,
+ ...restoredField,
+ },
+ hiddenFormData: omit(hiddenFormData, fieldNames),
+ };
},
[actions.SLICE_UPDATED]() {
return {
diff --git a/superset-frontend/src/explore/reducers/exploreReducer.test.js b/superset-frontend/src/explore/reducers/exploreReducer.test.js
index 37f072d9e7..bcc585630b 100644
--- a/superset-frontend/src/explore/reducers/exploreReducer.test.js
+++ b/superset-frontend/src/explore/reducers/exploreReducer.test.js
@@ -33,3 +33,13 @@ test('reset hiddenFormData on SET_STASH_FORM_DATA', () => {
expect(newState2.form_data).toEqual({ c: 4 });
expect(newState2.hiddenFormData).toEqual({ a: 3 });
});
+
+test('skips updates when the field is already updated on SET_STASH_FORM_DATA', () => {
+ const initialState = {
+ form_data: { a: 3, c: 4 },
+ hiddenFormData: { b: 2 },
+ };
+ const restoreAction = setStashFormData(false, ['c', 'd']);
+ const newState = exploreReducer(initialState, restoreAction);
+ expect(newState).toBe(initialState);
+});
(superset) 11/11: fix: adds the ability to disallow SQL functions per engine (#28639)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit ecb3b58e772924d2ff98e1edb80c5c750f673023
Author: Daniel Vaz Gaspar <da...@gmail.com>
AuthorDate: Wed May 29 10:51:28 2024 +0100
fix: adds the ability to disallow SQL functions per engine (#28639)
---
.../Header/HeaderActionsDropdown/index.jsx | 2 +-
superset/config.py | 8 +++++
superset/db_engine_specs/base.py | 6 ++++
superset/db_engine_specs/trino.py | 11 +++---
superset/exceptions.py | 15 ++++++++
superset/sql_parse.py | 42 ++++++++++++++++++++++
tests/unit_tests/db_engine_specs/test_trino.py | 24 +++++++------
tests/unit_tests/sql_parse_tests.py | 26 ++++++++++++++
8 files changed, 119 insertions(+), 15 deletions(-)
diff --git a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx
index 6cdd6e4778..1d201f53e2 100644
--- a/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx
+++ b/superset-frontend/src/dashboard/components/Header/HeaderActionsDropdown/index.jsx
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import React from 'react';
+import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { isEmpty } from 'lodash';
import { connect } from 'react-redux';
diff --git a/superset/config.py b/superset/config.py
index 197e4bac42..433dbfbe48 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -1203,6 +1203,14 @@ DASHBOARD_TEMPLATE_ID = None
# as such `create_engine(url, **params)`
DB_CONNECTION_MUTATOR = None
+# A set of disallowed SQL functions per engine. This is used to restrict the use of
+# unsafe SQL functions in SQL Lab and Charts. The keys of the dictionary are the engine
+# names, and the values are sets of disallowed functions.
+DISALLOWED_SQL_FUNCTIONS: dict[str, set[str]] = {
+ "postgresql": {"version", "query_to_xml", "inet_server_addr", "inet_client_addr"},
+ "clickhouse": {"url"},
+ "mysql": {"version"},
+}
# A function that intercepts the SQL to be executed and can alter it.
# The use case is can be around adding some sort of comment header
diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py
index 5b850913ed..62704268db 100644
--- a/superset/db_engine_specs/base.py
+++ b/superset/db_engine_specs/base.py
@@ -59,6 +59,7 @@ from superset import security_manager, sql_parse
from superset.constants import TimeGrain as TimeGrainConstants
from superset.databases.utils import make_url_safe
from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
+from superset.exceptions import DisallowedSQLFunction
from superset.sql_parse import ParsedQuery, Table
from superset.superset_typing import ResultSetColumnType, SQLAColumnType
from superset.utils import core as utils
@@ -1584,6 +1585,11 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
"""
if not cls.allows_sql_comments:
query = sql_parse.strip_comments_from_sql(query, engine=cls.engine)
+ disallowed_functions = current_app.config["DISALLOWED_SQL_FUNCTIONS"].get(
+ cls.engine, set()
+ )
+ if sql_parse.check_sql_functions_exist(query, disallowed_functions, cls.engine):
+ raise DisallowedSQLFunction(disallowed_functions)
if cls.arraysize:
cursor.arraysize = cls.arraysize
diff --git a/superset/db_engine_specs/trino.py b/superset/db_engine_specs/trino.py
index 6d95f9589e..c48e3df9dd 100644
--- a/superset/db_engine_specs/trino.py
+++ b/superset/db_engine_specs/trino.py
@@ -23,7 +23,7 @@ import time
from typing import Any, TYPE_CHECKING
import simplejson as json
-from flask import current_app
+from flask import current_app, Flask
from sqlalchemy.engine.reflection import Inspector
from sqlalchemy.engine.url import URL
from sqlalchemy.exc import NoSuchTableError
@@ -206,11 +206,14 @@ class TrinoEngineSpec(PrestoBaseEngineSpec):
execute_result: dict[str, Any] = {}
execute_event = threading.Event()
- def _execute(results: dict[str, Any], event: threading.Event) -> None:
+ def _execute(
+ results: dict[str, Any], event: threading.Event, app: Flask
+ ) -> None:
logger.debug("Query %d: Running query: %s", query_id, sql)
try:
- cls.execute(cursor, sql)
+ with app.app_context():
+ cls.execute(cursor, sql)
except Exception as ex: # pylint: disable=broad-except
results["error"] = ex
finally:
@@ -218,7 +221,7 @@ class TrinoEngineSpec(PrestoBaseEngineSpec):
execute_thread = threading.Thread(
target=_execute,
- args=(execute_result, execute_event),
+ args=(execute_result, execute_event, current_app._get_current_object()), # pylint: disable=protected-access
)
execute_thread.start()
diff --git a/superset/exceptions.py b/superset/exceptions.py
index 3642a9279e..a7e811a088 100644
--- a/superset/exceptions.py
+++ b/superset/exceptions.py
@@ -295,3 +295,18 @@ class SupersetMarshmallowValidationError(SupersetErrorException):
extra={"messages": exc.messages, "payload": payload},
)
super().__init__(error)
+
+
+class DisallowedSQLFunction(SupersetErrorException):
+ """
+ Disallowed function found on SQL statement
+ """
+
+ def __init__(self, functions: set[str]):
+ super().__init__(
+ SupersetError(
+ message=f"SQL statement contains disallowed function(s): {functions}",
+ error_type=SupersetErrorType.SYNTAX_ERROR,
+ level=ErrorLevel.ERROR,
+ )
+ )
diff --git a/superset/sql_parse.py b/superset/sql_parse.py
index 657fde1982..6aa435240d 100644
--- a/superset/sql_parse.py
+++ b/superset/sql_parse.py
@@ -36,6 +36,7 @@ from sqlglot.optimizer.scope import Scope, ScopeType, traverse_scope
from sqlparse import keywords
from sqlparse.lexer import Lexer
from sqlparse.sql import (
+ Function,
Identifier,
IdentifierList,
Parenthesis,
@@ -219,6 +220,19 @@ def get_cte_remainder_query(sql: str) -> tuple[str | None, str]:
return cte, remainder
+def check_sql_functions_exist(
+ sql: str, function_list: set[str], engine: str | None = None
+) -> bool:
+ """
+ Check if the SQL statement contains any of the specified functions.
+
+ :param sql: The SQL statement
+ :param function_list: The list of functions to search for
+ :param engine: The engine to use for parsing the SQL statement
+ """
+ return ParsedQuery(sql, engine=engine).check_functions_exist(function_list)
+
+
def strip_comments_from_sql(statement: str, engine: str | None = None) -> str:
"""
Strips comments from a SQL statement, does a simple test first
@@ -288,6 +302,34 @@ class ParsedQuery:
self._tables = self._extract_tables_from_sql()
return self._tables
+ def _check_functions_exist_in_token(
+ self, token: Token, functions: set[str]
+ ) -> bool:
+ if (
+ isinstance(token, Function)
+ and token.get_name() is not None
+ and token.get_name().lower() in functions
+ ):
+ return True
+ if hasattr(token, "tokens"):
+ for inner_token in token.tokens:
+ if self._check_functions_exist_in_token(inner_token, functions):
+ return True
+ return False
+
+ def check_functions_exist(self, functions: set[str]) -> bool:
+ """
+ Check if the SQL statement contains any of the specified functions.
+
+ :param functions: A set of functions to search for
+ :return: True if the statement contains any of the specified functions
+ """
+ for statement in self._parsed:
+ for token in statement.tokens:
+ if self._check_functions_exist_in_token(token, functions):
+ return True
+ return False
+
def _extract_tables_from_sql(self) -> set[Table]:
"""
Extract all table references in a query.
diff --git a/tests/unit_tests/db_engine_specs/test_trino.py b/tests/unit_tests/db_engine_specs/test_trino.py
index 22c5f10649..7f175e8fa5 100644
--- a/tests/unit_tests/db_engine_specs/test_trino.py
+++ b/tests/unit_tests/db_engine_specs/test_trino.py
@@ -396,7 +396,7 @@ def test_handle_cursor_early_cancel(
assert cancel_query_mock.call_args is None
-def test_execute_with_cursor_in_parallel(mocker: MockerFixture):
+def test_execute_with_cursor_in_parallel(app, mocker: MockerFixture):
"""Test that `execute_with_cursor` fetches query ID from the cursor"""
from superset.db_engine_specs.trino import TrinoEngineSpec
@@ -411,16 +411,20 @@ def test_execute_with_cursor_in_parallel(mocker: MockerFixture):
mock_cursor.query_id = query_id
mock_cursor.execute.side_effect = _mock_execute
+ with patch.dict(
+ "superset.config.DISALLOWED_SQL_FUNCTIONS",
+ {},
+ clear=True,
+ ):
+ TrinoEngineSpec.execute_with_cursor(
+ cursor=mock_cursor,
+ sql="SELECT 1 FROM foo",
+ query=mock_query,
+ )
- TrinoEngineSpec.execute_with_cursor(
- cursor=mock_cursor,
- sql="SELECT 1 FROM foo",
- query=mock_query,
- )
-
- mock_query.set_extra_json_key.assert_called_once_with(
- key=QUERY_CANCEL_KEY, value=query_id
- )
+ mock_query.set_extra_json_key.assert_called_once_with(
+ key=QUERY_CANCEL_KEY, value=query_id
+ )
def test_get_columns(mocker: MockerFixture):
diff --git a/tests/unit_tests/sql_parse_tests.py b/tests/unit_tests/sql_parse_tests.py
index 5150c37987..8abb569495 100644
--- a/tests/unit_tests/sql_parse_tests.py
+++ b/tests/unit_tests/sql_parse_tests.py
@@ -32,6 +32,7 @@ from superset.exceptions import (
)
from superset.sql_parse import (
add_table_name,
+ check_sql_functions_exist,
extract_table_references,
extract_tables_from_jinja_sql,
get_rls_for_table,
@@ -1292,6 +1293,31 @@ def test_strip_comments_from_sql() -> None:
)
+def test_check_sql_functions_exist() -> None:
+ """
+ Test that comments are stripped out correctly.
+ """
+ assert not (
+ check_sql_functions_exist("select a, b from version", {"version"}, "postgresql")
+ )
+
+ assert check_sql_functions_exist("select version()", {"version"}, "postgresql")
+
+ assert check_sql_functions_exist(
+ "select version from version()", {"version"}, "postgresql"
+ )
+
+ assert check_sql_functions_exist(
+ "select 1, a.version from (select version from version()) as a",
+ {"version"},
+ "postgresql",
+ )
+
+ assert check_sql_functions_exist(
+ "select 1, a.version from (select version()) as a", {"version"}, "postgresql"
+ )
+
+
def test_sanitize_clause_valid():
# regular clauses
assert sanitize_clause("col = 1") == "col = 1"
(superset) 06/11: fix: Cannot delete empty column inside a tab using the dashboard editor (#29346)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 35f3a490d54c4d6c447956b9ea0cb5b47fbd8405
Author: Michael S. Molina <70...@users.noreply.github.com>
AuthorDate: Mon Jun 24 14:36:18 2024 -0300
fix: Cannot delete empty column inside a tab using the dashboard editor (#29346)
(cherry picked from commit ee5227733b7d3d1a79ffeda160731ca30cac02a1)
---
superset-frontend/src/dashboard/components/menu/HoverMenu.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/superset-frontend/src/dashboard/components/menu/HoverMenu.tsx b/superset-frontend/src/dashboard/components/menu/HoverMenu.tsx
index 43d7683ce3..23e71ba9a6 100644
--- a/superset-frontend/src/dashboard/components/menu/HoverMenu.tsx
+++ b/superset-frontend/src/dashboard/components/menu/HoverMenu.tsx
@@ -32,7 +32,7 @@ const HoverStyleOverrides = styled.div`
.hover-menu {
opacity: 0;
position: absolute;
- z-index: 10;
+ z-index: 11; // one more than DragDroppable
font-size: ${({ theme }) => theme.typography.sizes.m};
}
(superset) 05/11: fix: Remove recursive repr call (#29314)
Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 4.0
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 800340aa1e2e6588540deca737d9cf30236478eb
Author: Jessie R <j...@scjr.me>
AuthorDate: Fri Jun 21 14:24:50 2024 +0700
fix: Remove recursive repr call (#29314)
(cherry picked from commit 9444c6bd4b04a9ab509a8edead604f78c22f4d3e)
---
superset/commands/exceptions.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/superset/commands/exceptions.py b/superset/commands/exceptions.py
index 4fb36c5b57..aac7c7096f 100644
--- a/superset/commands/exceptions.py
+++ b/superset/commands/exceptions.py
@@ -28,7 +28,7 @@ class CommandException(SupersetException):
def __repr__(self) -> str:
if self._exception:
return repr(self._exception)
- return repr(self)
+ return super().__repr__()
class ObjectNotFoundError(CommandException):