mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
chore: removing Druid from front- and back- end (#20338)
* first pass at removing native Druid nosql * removing having_druid * addressing comments, linting * fixed all tests * addressing comments * redirected to ui-core TimeGranularity type * query form metric linting * fixed broken chart type * implementing feedback
This commit is contained in:
@@ -174,9 +174,7 @@ const isTimeSection = (section: ControlPanelSectionConfig): boolean =>
|
||||
sections.legacyTimeseriesTime.label === section.label);
|
||||
|
||||
const hasTimeColumn = (datasource: Dataset): boolean =>
|
||||
datasource?.columns?.some(c => c.is_dttm) ||
|
||||
datasource.type === DatasourceType.Druid;
|
||||
|
||||
datasource?.columns?.some(c => c.is_dttm);
|
||||
const sectionsToExpand = (
|
||||
sections: ControlPanelSectionConfig[],
|
||||
datasource: Dataset,
|
||||
|
||||
@@ -222,14 +222,8 @@ export const DndFilterSelect = (props: DndFilterSelectProps) => {
|
||||
// via datasource saved metric
|
||||
if (filterOptions.saved_metric_name) {
|
||||
return new AdhocFilter({
|
||||
expressionType:
|
||||
datasource.type === 'druid'
|
||||
? EXPRESSION_TYPES.SIMPLE
|
||||
: EXPRESSION_TYPES.SQL,
|
||||
subject:
|
||||
datasource.type === 'druid'
|
||||
? filterOptions.saved_metric_name
|
||||
: getMetricExpression(filterOptions.saved_metric_name),
|
||||
expressionType: EXPRESSION_TYPES.SQL,
|
||||
subject: getMetricExpression(filterOptions.saved_metric_name),
|
||||
operator:
|
||||
OPERATOR_ENUM_TO_OPERATOR_TYPE[Operators.GREATER_THAN].operation,
|
||||
operatorId: Operators.GREATER_THAN,
|
||||
@@ -240,14 +234,8 @@ export const DndFilterSelect = (props: DndFilterSelectProps) => {
|
||||
// has a custom label, meaning it's custom column
|
||||
if (filterOptions.label) {
|
||||
return new AdhocFilter({
|
||||
expressionType:
|
||||
datasource.type === 'druid'
|
||||
? EXPRESSION_TYPES.SIMPLE
|
||||
: EXPRESSION_TYPES.SQL,
|
||||
subject:
|
||||
datasource.type === 'druid'
|
||||
? filterOptions.label
|
||||
: new AdhocMetric(option).translateToSql(),
|
||||
expressionType: EXPRESSION_TYPES.SQL,
|
||||
subject: new AdhocMetric(option).translateToSql(),
|
||||
operator:
|
||||
OPERATOR_ENUM_TO_OPERATOR_TYPE[Operators.GREATER_THAN].operation,
|
||||
operatorId: Operators.GREATER_THAN,
|
||||
|
||||
@@ -241,14 +241,8 @@ class AdhocFilterControl extends React.Component {
|
||||
// via datasource saved metric
|
||||
if (option.saved_metric_name) {
|
||||
return new AdhocFilter({
|
||||
expressionType:
|
||||
this.props.datasource.type === 'druid'
|
||||
? EXPRESSION_TYPES.SIMPLE
|
||||
: EXPRESSION_TYPES.SQL,
|
||||
subject:
|
||||
this.props.datasource.type === 'druid'
|
||||
? option.saved_metric_name
|
||||
: this.getMetricExpression(option.saved_metric_name),
|
||||
expressionType: EXPRESSION_TYPES.SQL,
|
||||
subject: this.getMetricExpression(option.saved_metric_name),
|
||||
operator:
|
||||
OPERATOR_ENUM_TO_OPERATOR_TYPE[Operators.GREATER_THAN].operation,
|
||||
comparator: 0,
|
||||
@@ -258,14 +252,8 @@ class AdhocFilterControl extends React.Component {
|
||||
// has a custom label, meaning it's custom column
|
||||
if (option.label) {
|
||||
return new AdhocFilter({
|
||||
expressionType:
|
||||
this.props.datasource.type === 'druid'
|
||||
? EXPRESSION_TYPES.SIMPLE
|
||||
: EXPRESSION_TYPES.SQL,
|
||||
subject:
|
||||
this.props.datasource.type === 'druid'
|
||||
? option.label
|
||||
: new AdhocMetric(option).translateToSql(),
|
||||
expressionType: EXPRESSION_TYPES.SQL,
|
||||
subject: new AdhocMetric(option).translateToSql(),
|
||||
operator:
|
||||
OPERATOR_ENUM_TO_OPERATOR_TYPE[Operators.GREATER_THAN].operation,
|
||||
comparator: 0,
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Button from 'src/components/Button';
|
||||
import { Tooltip } from 'src/components/Tooltip';
|
||||
import { styled, t } from '@superset-ui/core';
|
||||
|
||||
import ErrorBoundary from 'src/components/ErrorBoundary';
|
||||
@@ -227,20 +226,7 @@ export default class AdhocFilterEditPopover extends React.Component {
|
||||
<Tabs.TabPane
|
||||
className="adhoc-filter-edit-tab"
|
||||
key={EXPRESSION_TYPES.SQL}
|
||||
tab={
|
||||
datasource?.type === 'druid' ? (
|
||||
<Tooltip
|
||||
title={t(
|
||||
'Custom SQL ad-hoc filters are not available for the native Druid connector',
|
||||
)}
|
||||
>
|
||||
{t('Custom SQL')}
|
||||
</Tooltip>
|
||||
) : (
|
||||
t('Custom SQL')
|
||||
)
|
||||
}
|
||||
disabled={datasource?.type === 'druid'}
|
||||
tab={t('Custom SQL')}
|
||||
>
|
||||
<ErrorBoundary>
|
||||
<AdhocFilterEditPopoverSqlTabContent
|
||||
|
||||
@@ -235,17 +235,9 @@ describe('AdhocFilterEditPopoverSimpleTabContent', () => {
|
||||
it('will filter operators for table datasources', () => {
|
||||
const { props } = setup({ datasource: { type: 'table' } });
|
||||
const { isOperatorRelevant } = useSimpleTabFilterProps(props);
|
||||
expect(isOperatorRelevant(Operators.REGEX, 'value')).toBe(false);
|
||||
expect(isOperatorRelevant(Operators.LIKE, 'value')).toBe(true);
|
||||
});
|
||||
|
||||
it('will filter operators for druid datasources', () => {
|
||||
const { props } = setup({ datasource: { type: 'druid' } });
|
||||
const { isOperatorRelevant } = useSimpleTabFilterProps(props);
|
||||
expect(isOperatorRelevant(Operators.REGEX, 'value')).toBe(true);
|
||||
expect(isOperatorRelevant(Operators.LIKE, 'value')).toBe(false);
|
||||
});
|
||||
|
||||
it('will show LATEST PARTITION operator', () => {
|
||||
const { props } = setup({
|
||||
datasource: {
|
||||
|
||||
@@ -23,8 +23,6 @@ import { t, SupersetClient, SupersetTheme, styled } from '@superset-ui/core';
|
||||
import {
|
||||
Operators,
|
||||
OPERATORS_OPTIONS,
|
||||
TABLE_ONLY_OPERATORS,
|
||||
DRUID_ONLY_OPERATORS,
|
||||
HAVING_OPERATORS,
|
||||
MULTI_OPERATORS,
|
||||
CUSTOM_OPERATORS,
|
||||
@@ -140,13 +138,9 @@ export const useSimpleTabFilterProps = (props: Props) => {
|
||||
operator === Operators.IS_NULL || operator === Operators.IS_NOT_NULL
|
||||
);
|
||||
}
|
||||
return !(
|
||||
(props.datasource.type === 'druid' &&
|
||||
TABLE_ONLY_OPERATORS.indexOf(operator) >= 0) ||
|
||||
(props.datasource.type === 'table' &&
|
||||
DRUID_ONLY_OPERATORS.indexOf(operator) >= 0) ||
|
||||
(props.adhocFilter.clause === CLAUSES.HAVING &&
|
||||
HAVING_OPERATORS.indexOf(operator) === -1)
|
||||
return (
|
||||
props.adhocFilter.clause !== CLAUSES.HAVING ||
|
||||
HAVING_OPERATORS.indexOf(operator) !== -1
|
||||
);
|
||||
};
|
||||
const onSubjectChange = (id: string) => {
|
||||
@@ -316,23 +310,13 @@ const AdhocFilterEditPopoverSimpleTabContent: React.FC<Props> = props => {
|
||||
placeholder: '',
|
||||
};
|
||||
|
||||
if (props.datasource.type === 'druid') {
|
||||
subjectSelectProps.placeholder = t(
|
||||
'%s column(s) and metric(s)',
|
||||
columns.length,
|
||||
);
|
||||
} else {
|
||||
// we cannot support simple ad-hoc filters for metrics because we don't know what type
|
||||
// the value should be cast to (without knowing the output type of the aggregate, which
|
||||
// becomes a rather complicated problem)
|
||||
subjectSelectProps.placeholder =
|
||||
props.adhocFilter.clause === CLAUSES.WHERE
|
||||
? t('%s column(s)', columns.length)
|
||||
: t('To filter on a metric, use Custom SQL tab.');
|
||||
columns = props.options.filter(
|
||||
option => 'column_name' in option && option.column_name,
|
||||
);
|
||||
}
|
||||
subjectSelectProps.placeholder =
|
||||
props.adhocFilter.clause === CLAUSES.WHERE
|
||||
? t('%s column(s)', columns.length)
|
||||
: t('To filter on a metric, use Custom SQL tab.');
|
||||
columns = props.options.filter(
|
||||
option => 'column_name' in option && option.column_name,
|
||||
);
|
||||
|
||||
const operatorSelectProps = {
|
||||
placeholder: t(
|
||||
|
||||
@@ -80,18 +80,6 @@ test('Should render correct elements for SQL', () => {
|
||||
expect(screen.getByRole('tabpanel', { name: 'Saved' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('Should render correct elements for native Druid', () => {
|
||||
const props = { ...createProps(), datasource: { type: 'druid' } };
|
||||
render(<AdhocMetricEditPopover {...props} />);
|
||||
expect(screen.getByRole('tab', { name: 'Custom SQL' })).toHaveAttribute(
|
||||
'aria-disabled',
|
||||
'true',
|
||||
);
|
||||
expect(screen.getByRole('tab', { name: 'Simple' })).toBeEnabled();
|
||||
expect(screen.getByRole('tab', { name: 'Saved' })).toBeEnabled();
|
||||
expect(screen.getByRole('tabpanel', { name: 'Saved' })).toBeVisible();
|
||||
});
|
||||
|
||||
test('Should render correct elements for allow ad-hoc metrics', () => {
|
||||
const props = {
|
||||
...createProps(),
|
||||
|
||||
@@ -323,15 +323,6 @@ export default class AdhocMetricEditPopover extends React.PureComponent {
|
||||
autoFocus: true,
|
||||
};
|
||||
|
||||
if (
|
||||
this.props.datasource?.type === 'druid' &&
|
||||
aggregateSelectProps.options
|
||||
) {
|
||||
aggregateSelectProps.options = aggregateSelectProps.options.filter(
|
||||
aggregate => aggregate !== 'AVG',
|
||||
);
|
||||
}
|
||||
|
||||
const stateIsValid = adhocMetric.isValid() || savedMetric?.metric_name;
|
||||
const hasUnsavedChanges =
|
||||
!adhocMetric.equals(propsAdhocMetric) ||
|
||||
@@ -431,18 +422,11 @@ export default class AdhocMetricEditPopover extends React.PureComponent {
|
||||
<Tabs.TabPane
|
||||
key={EXPRESSION_TYPES.SQL}
|
||||
tab={
|
||||
extra.disallow_adhoc_metrics ||
|
||||
this.props.datasource?.type === 'druid' ? (
|
||||
extra.disallow_adhoc_metrics ? (
|
||||
<Tooltip
|
||||
title={
|
||||
this.props.datasource?.type === 'druid'
|
||||
? t(
|
||||
'Custom SQL ad-hoc metrics are not available for the native Druid connector',
|
||||
)
|
||||
: t(
|
||||
'Custom SQL ad-hoc metrics are not enabled for this dataset',
|
||||
)
|
||||
}
|
||||
title={t(
|
||||
'Custom SQL ad-hoc metrics are not enabled for this dataset',
|
||||
)}
|
||||
>
|
||||
{t('Custom SQL')}
|
||||
</Tooltip>
|
||||
@@ -451,10 +435,7 @@ export default class AdhocMetricEditPopover extends React.PureComponent {
|
||||
)
|
||||
}
|
||||
data-test="adhoc-metric-edit-tab#custom"
|
||||
disabled={
|
||||
extra.disallow_adhoc_metrics ||
|
||||
this.props.datasource?.type === 'druid'
|
||||
}
|
||||
disabled={extra.disallow_adhoc_metrics}
|
||||
>
|
||||
<SQLEditor
|
||||
data-test="sql-editor"
|
||||
|
||||
Reference in New Issue
Block a user