Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/preset-io/superset into f…
Browse files Browse the repository at this point in the history
…eat-blankstate-metrics-columns
  • Loading branch information
hughhhh committed Jul 25, 2022
2 parents 6073777 + e3c6380 commit dc74d2b
Show file tree
Hide file tree
Showing 180 changed files with 3,568 additions and 1,693 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/superset-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ jobs:
if: steps.check.outcome == 'failure'
working-directory: ./superset-frontend
run: npm run plugins:build-storybook
- name: superset-ui/core coverage
if: steps.check.outcome == 'failure'
working-directory: ./superset-frontend
run: |
npm run core:cover
- name: unit tests
if: steps.check.outcome == 'failure'
working-directory: ./superset-frontend
Expand Down
5 changes: 4 additions & 1 deletion docker/docker-frontend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
#
set -e

# Packages needed for puppeteer:
apt update
apt install -y chromium

cd /app/superset-frontend
npm install -g npm@7
npm install -f --no-optional --global webpack webpack-cli
npm install -f --no-optional

Expand Down
5 changes: 1 addition & 4 deletions docs/docs/databases/databricks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ You also need to add the following configuration to "Other" -> "Engine Parameter

```json
{
"connect_args": {"http_path": "sql/protocolv1/o/****"},
"http_headers": [["User-Agent", "Apache Superset"]]
"connect_args": {"http_path": "sql/protocolv1/o/****"}
}
```

The `User-Agent` header is optional, but helps Databricks identify traffic from Superset. If you need to use a different header please reach out to Databricks and let them know.

## Older driver

Originally Superset used `databricks-dbapi` to connect to Databricks. You might want to try it if you're having problems with the official Databricks connector:
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/installation/sql-templating.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ Here's a concrete example:

It's possible to query physical and virtual datasets using the `dataset` macro. This is useful if you've defined computed columns and metrics on your datasets, and want to reuse the definition in adhoc SQL Lab queries.

To use the macro, first you need to find the ID of the dataset. This can be done by going to the view showing all the datasets, hovering over the dataset you're interested in, and looking at its URL. For example, if the URL for a dataset is https://superset.example.org/superset/explore/table/42/ its ID is 42.
To use the macro, first you need to find the ID of the dataset. This can be done by going to the view showing all the datasets, hovering over the dataset you're interested in, and looking at its URL. For example, if the URL for a dataset is https://superset.example.org/explore/?dataset_type=table&dataset_id=42 its ID is 42.

Once you have the ID you can query it as if it were a table:

Expand Down
4 changes: 3 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ geopy==2.2.0
# via apache-superset
graphlib-backport==1.0.3
# via apache-superset
greenlet==1.1.2
# via sqlalchemy
gunicorn==20.1.0
# via apache-superset
hashids==1.3.1
Expand Down Expand Up @@ -259,7 +261,7 @@ six==1.16.0
# wtforms-json
slackclient==2.5.0
# via apache-superset
sqlalchemy==1.3.24
sqlalchemy==1.4.36
# via
# alembic
# apache-superset
Expand Down
2 changes: 1 addition & 1 deletion requirements/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pexpect==4.8.0
# via ipython
pickleshare==0.7.5
# via ipython
pillow==9.1.0
pillow==9.1.1
# via apache-superset
progress==1.6
# via -r requirements/development.in
Expand Down
2 changes: 0 additions & 2 deletions requirements/docker.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# -r requirements/docker.in
gevent==21.8.0
# via -r requirements/docker.in
greenlet==1.1.1
# via gevent
psycopg2-binary==2.9.1
# via apache-superset
zope-event==4.5.0
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def get_git_sha() -> str:
"selenium>=3.141.0",
"simplejson>=3.15.0",
"slackclient==2.5.0", # PINNED! slack changes file upload api in the future versions
"sqlalchemy>=1.3.16, <1.4, !=1.3.21",
"sqlalchemy>=1.4, <2",
"sqlalchemy-utils>=0.37.8, <0.38",
"sqlparse==0.3.0", # PINNED! see https://github.com/andialbrecht/sqlparse/issues/562
"tabulate==0.8.9",
Expand Down Expand Up @@ -167,7 +167,7 @@ def get_git_sha() -> str:
], # PINNED! 1.2.5 introduced breaking changes requiring sqlalchemy>=1.4.0
"spark": ["pyhive[hive]>=0.6.5", "tableschema", "thrift>=0.11.0, <1.0.0"],
"teradata": ["teradatasql>=16.20.0.23"],
"thumbnails": ["Pillow>=9.0.1, <10.0.0"],
"thumbnails": ["Pillow>=9.1.1, <10.0.0"],
"vertica": ["sqlalchemy-vertica-python>=0.5.9, < 0.6"],
"netezza": ["nzalchemy>=11.0.2"],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('Test datatable', () => {
});
it('Datapane loads view samples', () => {
cy.intercept(
'api/v1/explore/samples?force=false&datasource_type=table&datasource_id=*',
'datasource/samples?force=false&datasource_type=table&datasource_id=*',
).as('Samples');
cy.contains('Samples')
.click()
Expand Down
1 change: 1 addition & 0 deletions superset-frontend/package-lock.json

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

2 changes: 2 additions & 0 deletions superset-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"build-storybook": "build-storybook",
"check-translation": "prettier --check ../superset/translations/**/LC_MESSAGES/*.json",
"clean-translation": "prettier --write ../superset/translations/**/LC_MESSAGES/*.json",
"core:cover": "cross-env NODE_ENV=test jest --coverage --coverageThreshold='{\"global\":{\"statements\":100,\"branches\":100,\"functions\":100,\"lines\":100}}' --collectCoverageFrom='[\"packages/**/src/**/*.{js,ts}\", \"!packages/superset-ui-demo/**/*\"]' packages",
"cover": "cross-env NODE_ENV=test jest --coverage",
"dev": "webpack --mode=development --color --watch",
"dev-server": "cross-env NODE_ENV=development BABEL_ENV=development node --max_old_space_size=4096 ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --mode=development",
Expand Down Expand Up @@ -298,6 +299,7 @@
"exports-loader": "^0.7.0",
"fetch-mock": "^7.7.3",
"fork-ts-checker-webpack-plugin": "^6.3.3",
"history": "^4.10.1",
"ignore-styles": "^5.0.1",
"imports-loader": "^3.0.0",
"jest": "^26.6.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const getColumnTooltipNode = (
labelRef?: React.RefObject<any>,
): ReactNode => {
if (
!column.verbose_name &&
(!column.column_name || !column.verbose_name) &&
!column.description &&
!isLabelTruncated(labelRef)
) {
Expand All @@ -77,7 +77,9 @@ export const getColumnTooltipNode = (

return (
<>
<TooltipSection label={t('Column name')} text={column.column_name} />
{column.column_name && (
<TooltipSection label={t('Column name')} text={column.column_name} />
)}
{column.verbose_name && (
<TooltipSection label={t('Label')} text={column.verbose_name} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import type {
QueryFormData,
QueryFormMetric,
QueryResponse,
GenericDataType,
} from '@superset-ui/core';
import { sharedControls } from './shared-controls';
import sharedControlComponents from './shared-controls/components';
Expand Down Expand Up @@ -67,7 +66,6 @@ export interface Dataset {
id: number;
type: DatasourceType;
columns: ColumnMeta[];
column_types?: GenericDataType[];
metrics: Metric[];
column_format: Record<string, string>;
verbose_map: Record<string, string>;
Expand All @@ -81,7 +79,6 @@ export interface Dataset {
description: string | null;
uid?: string;
owners?: Owner[];
table_name?: string;
}

export interface ControlPanelState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { ParentSize } from '@vx/responsive';
import { createSelector } from 'reselect';
import { withTheme } from '@emotion/react';
import { parseLength, Dimension } from '../../dimension';
import getChartMetadataRegistry from '../registries/ChartMetadataRegistrySingleton';
import SuperChartCore, { Props as SuperChartCoreProps } from './SuperChartCore';
import DefaultFallbackComponent from './FallbackComponent';
import ChartProps, { ChartPropsConfig } from '../models/ChartProps';
Expand Down Expand Up @@ -140,6 +141,9 @@ class SuperChart extends React.PureComponent<Props, {}> {
this.core = core;
};

private getQueryCount = () =>
getChartMetadataRegistry().get(this.props.chartType)?.queryObjectCount ?? 1;

renderChart(width: number, height: number) {
const {
id,
Expand Down Expand Up @@ -174,9 +178,11 @@ class SuperChart extends React.PureComponent<Props, {}> {
const noResultQueries =
enableNoResults &&
(!queriesData ||
queriesData.every(
({ data }) => !data || (Array.isArray(data) && data.length === 0),
));
queriesData
.slice(0, this.getQueryCount())
.every(
({ data }) => !data || (Array.isArray(data) && data.length === 0),
));
if (noResultQueries) {
chart = noResults || (
<NoResultsComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface ChartMetadataConfig {
// label: ChartLabel.DEPRECATED which will display a "deprecated" label on the chart.
label?: ChartLabel | null;
labelExplanation?: string | null;
queryObjectCount?: number;
}

export default class ChartMetadata {
Expand Down Expand Up @@ -87,6 +88,8 @@ export default class ChartMetadata {

labelExplanation?: string | null;

queryObjectCount: number;

constructor(config: ChartMetadataConfig) {
const {
name,
Expand All @@ -106,6 +109,7 @@ export default class ChartMetadata {
deprecated = false,
label = null,
labelExplanation = null,
queryObjectCount = 1,
} = config;

this.name = name;
Expand Down Expand Up @@ -134,6 +138,7 @@ export default class ChartMetadata {
this.deprecated = deprecated;
this.label = label;
this.labelExplanation = labelExplanation;
this.queryObjectCount = queryObjectCount;
}

canBeAnnotationType(type: string): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function isAdhocColumn(column?: any): column is AdhocColumn {
typeof column !== 'string' &&
column?.sqlExpression !== undefined &&
column?.label !== undefined &&
column?.expressionType === 'SQL'
(column?.expressionType === undefined || column?.expressionType === 'SQL')
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ export type Filters = {
[filterId: string]: Filter | Divider;
};

export type PartialFilters = {
[filterId: string]: Partial<Filters[keyof Filters]>;
};

export type NativeFiltersState = {
filters: Filters;
filterSets: FilterSets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,4 @@ export const DEFAULT_METRICS: Metric[] = [
},
];

export const isValidDatasourceType = (datasource: DatasourceType) =>
Object.values(DatasourceType).includes(datasource);

export default {};
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@
import { DatasourceKey } from '@superset-ui/core';

describe('DatasourceKey', () => {
const tableKey = '5__table';

it('should handle table data sources', () => {
const datasourceKey = new DatasourceKey(tableKey);
expect(datasourceKey.toString()).toBe(tableKey);
const datasourceKey = new DatasourceKey('5__table');
expect(datasourceKey.toString()).toBe('5__table');
expect(datasourceKey.toObject()).toEqual({ id: 5, type: 'table' });
});

it('should handle query data sources', () => {
const datasourceKey = new DatasourceKey('5__query');
expect(datasourceKey.toString()).toBe('5__query');
expect(datasourceKey.toObject()).toEqual({ id: 5, type: 'query' });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
const queryObjectCount = {
mixed_timeseries: 2,
};
import { DatasourceType, DEFAULT_METRICS } from '@superset-ui/core';

export const getQueryCount = (vizType: string): number =>
queryObjectCount?.[vizType] || 1;
test('DEFAULT_METRICS', () => {
expect(DEFAULT_METRICS).toEqual([
{
metric_name: 'COUNT(*)',
expression: 'COUNT(*)',
},
]);
});

test('DatasourceType', () => {
expect(Object.keys(DatasourceType).length).toBe(5);
expect(DatasourceType.Table).toBe('table');
expect(DatasourceType.Query).toBe('query');
expect(DatasourceType.Dataset).toBe('dataset');
expect(DatasourceType.SlTable).toBe('sl_table');
expect(DatasourceType.SavedQuery).toBe('saved_query');
});
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import syria from './countries/syria.geojson';
import tanzania from './countries/tanzania.geojson';
import thailand from './countries/thailand.geojson';
import timorleste from './countries/timorleste.geojson';
import turkey from './countries/turkey.geojson';
import united_arab_emirates from './countries/united_arab_emirates.geojson';
import uganda from './countries/uganda.geojson';
import uk from './countries/uk.geojson';
Expand Down Expand Up @@ -137,6 +138,7 @@ export const countries = {
tanzania,
thailand,
timorleste,
turkey,
united_arab_emirates,
uganda,
uk,
Expand Down
Loading

0 comments on commit dc74d2b

Please sign in to comment.