Skip to content

Commit

Permalink
Merge pull request apache#3 from SetuHQ/sync-upstream
Browse files Browse the repository at this point in the history
Sync upstream
  • Loading branch information
mittalsuraj18 authored Mar 8, 2023
2 parents abfa03d + 33d0f22 commit 3602f49
Show file tree
Hide file tree
Showing 164 changed files with 2,889 additions and 953 deletions.
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@
# Notify E2E test maintainers of changes

/superset-frontend/cypress-base/ @jinghua-qa @geido @eschutho @rusackas @betodealmeida

# Notify PMC members of changes to Github Actions

/.github/ @villebro @geido @eschutho @rusackas @betodealmeida @nytai @mistercrunch @craig-rueda @john-bodley
1 change: 1 addition & 0 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ assists people when migrating to a new version.

## Next

- [23186](https://github.com/apache/superset/pull/23186): Superset will refuse to start if a default `SECRET_KEY` is detected on a non Flask debug setting.
- [22022](https://github.com/apache/superset/pull/22022): HTTP API endpoints `/superset/approve` and `/superset/request_access` have been deprecated and their HTTP methods were changed from GET to POST
- [20606](https://github.com/apache/superset/pull/20606): When user clicks on chart title or "Edit chart" button in Dashboard page, Explore opens in the same tab. Clicking while holding cmd/ctrl opens Explore in a new tab. To bring back the old behaviour (always opening Explore in a new tab), flip feature flag `DASHBOARD_EDIT_CHART_IN_NEW_TAB` to `True`.
- [20799](https://github.com/apache/superset/pull/20799): Presto and Trino engine will now display tracking URL for running queries in SQL Lab. If for some reason you don't want to show the tracking URL (for example, when your data warehouse hasn't enabled access for to Presto or Trino UI), update `TRACKING_URL_TRANSFORMER` in `config.py` to return `None`.
Expand Down
1 change: 1 addition & 0 deletions docker/.env-non-dev
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ REDIS_PORT=6379
FLASK_ENV=production
SUPERSET_ENV=production
SUPERSET_LOAD_EXAMPLES=yes
SUPERSET_SECRET_KEY=TEST_NON_DEV_SECRET
CYPRESS_CONFIG=false
SUPERSET_PORT=8088
MAPBOX_API_KEY=''
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ to get visual feedback.
<img src={useBaseUrl("/img/tutorial/tutorial_explore_run.jpg" )} />

In the following screenshot, we craft a grouped Time-series Bar Chart to visualize
our quarterly sales data by product line just be clicking options in drop-down menus.
our quarterly sales data by product line just by clicking options in drop-down menus.

<img src={useBaseUrl("/img/tutorial/tutorial_explore_settings.jpg" )} />

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/installation/configuring-superset.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ SUPERSET_WEBSERVER_PORT = 8088
# Your App secret key will be used for securely signing the session cookie
# and encrypting sensitive information on the database
# Make sure you are changing this key for your deployment with a strong key.
# You can generate a strong key using `openssl rand -base64 42`
# You can generate a strong key using `openssl rand -base64 42`.
# Alternatively you can set it with `SUPERSET_SECRET_KEY` environment variable.
SECRET_KEY = 'YOUR_OWN_RANDOM_GENERATED_SECRET_KEY'
# The SQLAlchemy connection string to your database backend
Expand Down
6 changes: 6 additions & 0 deletions docs/docs/installation/installing-superset-from-scratch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ superset load_examples
# Create default roles and permissions
superset init
# Build javascript assets
cd superset-frontend
npm ci
npm run build
cd ..
# To start a development web server on port 8088, use -p to bind to another port
superset run -p 8088 --with-threads --reload --debugger
```
Expand Down
4 changes: 2 additions & 2 deletions requirements/integration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ packaging==21.3
# tox
pep517==0.11.0
# via build
pip-compile-multi==2.6.1
pip-compile-multi==2.6.2
# via -r integration.in
pip-tools==6.8.0
# via pip-compile-multi
platformdirs==2.6.2
# via virtualenv
pluggy==0.13.1
# via tox
pre-commit==3.0.4
pre-commit==3.1.0
# via -r integration.in
py==1.10.0
# via tox
Expand Down
4 changes: 2 additions & 2 deletions superset-embedded-sdk/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion superset-embedded-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@superset-ui/embedded-sdk",
"version": "0.1.0-alpha.8",
"version": "0.1.0-alpha.9",
"description": "SDK for embedding resources from Superset into your own application",
"access": "public",
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions superset-embedded-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export async function embedDashboard({
});

iframe.src = `${supersetDomain}/embedded/${id}${dashboardConfig}${filterConfigUrlParams}`;
//@ts-ignore
mountPoint.replaceChildren(iframe);
log('placed the iframe')
});
Expand All @@ -173,6 +174,7 @@ export async function embedDashboard({

function unmount() {
log('unmounting');
//@ts-ignore
mountPoint.replaceChildren();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ function prepareDashboardFilters(
});
if (dashboardId) {
const jsonMetadata = {
show_native_filters: true,
native_filter_configuration: allFilters,
timed_refresh_immune_slices: [],
expanded_slices: {},
Expand Down
12 changes: 6 additions & 6 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,16 @@ import {
getXAxisLabel,
} from '@superset-ui/core';
import { PostProcessingFactory } from './types';
import { extractExtraMetrics } from './utils';

export const pivotOperator: PostProcessingFactory<PostProcessingPivot> = (
formData,
queryObject,
) => {
const metricLabels = ensureIsArray(queryObject.metrics).map(getMetricLabel);
const metricLabels = [
...ensureIsArray(queryObject.metrics),
...extractExtraMetrics(formData),
].map(getMetricLabel);
const xAxisLabel = getXAxisLabel(formData);
const columns = queryObject.series_columns || queryObject.columns;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
PostProcessingSort,
} from '@superset-ui/core';
import { PostProcessingFactory } from './types';
import { extractExtraMetrics } from './utils';

export const sortOperator: PostProcessingFactory<PostProcessingSort> = (
formData,
Expand All @@ -34,7 +35,8 @@ export const sortOperator: PostProcessingFactory<PostProcessingSort> = (
// the sortOperator only used in the barchart v2
const sortableLabels = [
getXAxisLabel(formData),
...ensureIsArray(formData.metrics).map(metric => getMetricLabel(metric)),
...ensureIsArray(formData.metrics).map(getMetricLabel),
...extractExtraMetrics(formData).map(getMetricLabel),
].filter(Boolean);

if (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* 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 {
getMetricLabel,
QueryFormData,
QueryFormMetric,
} from '@superset-ui/core';

export function extractExtraMetrics(
formData: QueryFormData,
): QueryFormMetric[] {
const { groupby, timeseries_limit_metric, x_axis_sort } = formData;
const extra_metrics: QueryFormMetric[] = [];
if (
!(groupby || []).length &&
timeseries_limit_metric &&
getMetricLabel(timeseries_limit_metric) === x_axis_sort
) {
extra_metrics.push(timeseries_limit_metric);
}
return extra_metrics;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
export { getMetricOffsetsMap } from './getMetricOffsetsMap';
export { isTimeComparison } from './isTimeComparison';
export { isDerivedSeries } from './isDerivedSeries';
export { extractExtraMetrics } from './extractExtraMetrics';
export { TIME_COMPARISON_SEPARATOR } from './constants';
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ import {
getColumnLabel,
getMetricLabel,
isDefined,
isEqualArray,
QueryFormColumn,
QueryFormMetric,
t,
} from '@superset-ui/core';
import { ControlPanelState, ControlState, ControlStateMapping } from '../types';
import {
ControlPanelState,
ControlState,
ControlStateMapping,
isDataset,
} from '../types';
import { isTemporalColumn } from '../utils';

export const contributionModeControl = {
Expand Down Expand Up @@ -59,39 +63,42 @@ export const xAxisSortControl = {
name: 'x_axis_sort',
config: {
type: 'XAxisSortControl',
label: t('X-Axis Sort By'),
description: t('Whether to sort descending or ascending on the X-Axis.'),
shouldMapStateToProps: (
prevState: ControlPanelState,
state: ControlPanelState,
) => {
const prevOptions = [
getColumnLabel(prevState?.controls?.x_axis?.value as QueryFormColumn),
...ensureIsArray(prevState?.controls?.metrics?.value).map(metric =>
getMetricLabel(metric as QueryFormMetric),
),
];
const currOptions = [
getColumnLabel(state?.controls?.x_axis?.value as QueryFormColumn),
...ensureIsArray(state?.controls?.metrics?.value).map(metric =>
getMetricLabel(metric as QueryFormMetric),
),
];
return !isEqualArray(prevOptions, currOptions);
},
mapStateToProps: (
{ controls }: { controls: ControlStateMapping },
controlState: ControlState,
) => {
const choices = [
getColumnLabel(controls?.x_axis?.value as QueryFormColumn),
...ensureIsArray(controls?.metrics?.value).map(metric =>
getMetricLabel(metric as QueryFormMetric),
),
label: (state: ControlPanelState) =>
state.form_data?.orientation === 'horizontal'
? t('Y-Axis Sort By')
: t('X-Axis Sort By'),
description: t('Decides which column to sort the base axis by.'),
shouldMapStateToProps: () => true,
mapStateToProps: (state: ControlPanelState, controlState: ControlState) => {
const { controls, datasource } = state;
const dataset = isDataset(datasource) ? datasource : undefined;
const columns = [controls?.x_axis?.value as QueryFormColumn].filter(
Boolean,
);
const metrics = [
...ensureIsArray(controls?.metrics?.value as QueryFormMetric),
controls?.timeseries_limit_metric?.value as QueryFormMetric,
].filter(Boolean);
const options = [
...columns.map(column => {
const value = getColumnLabel(column);
return {
value,
label: dataset?.verbose_map?.[value] || value,
};
}),
...metrics.map(metric => {
const value = getMetricLabel(metric);
return {
value,
label: dataset?.verbose_map?.[value] || value,
};
}),
];

const shouldReset = !(
typeof controlState.value === 'string' &&
choices.includes(controlState.value) &&
options.map(option => option.value).includes(controlState.value) &&
!isTemporalColumn(
getColumnLabel(controls?.x_axis?.value as QueryFormColumn),
controls?.datasource?.datasource,
Expand All @@ -100,10 +107,7 @@ export const xAxisSortControl = {

return {
shouldReset,
options: choices.map(entry => ({
value: entry,
label: entry,
})),
options,
};
},
visibility: xAxisSortVisibility,
Expand All @@ -114,9 +118,12 @@ export const xAxisSortAscControl = {
name: 'x_axis_sort_asc',
config: {
type: 'CheckboxControl',
label: t('X-Axis Sort Ascending'),
label: (state: ControlPanelState) =>
state.form_data?.orientation === 'horizontal'
? t('Y-Axis Sort Ascending')
: t('X-Axis Sort Ascending'),
default: true,
description: t('Whether to sort descending or ascending on the X-Axis.'),
description: t('Whether to sort ascending or descending on the base Axis.'),
visibility: xAxisSortVisibility,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,33 @@ test('pivot by adhoc x_axis', () => {
},
});
});

test('pivot by x_axis with extra metrics', () => {
expect(
pivotOperator(
{
...formData,
x_axis: 'foo',
x_axis_sort: 'bar',
groupby: [],
timeseries_limit_metric: 'bar',
},
{
...queryObject,
series_columns: [],
},
),
).toEqual({
operation: 'pivot',
options: {
index: ['foo'],
columns: [],
aggregates: {
'count(*)': { operator: 'mean' },
'sum(val)': { operator: 'mean' },
bar: { operator: 'mean' },
},
drop_missing_columns: false,
},
});
});
Loading

0 comments on commit 3602f49

Please sign in to comment.