mirror of
https://github.com/apache/superset.git
synced 2026-08-19 06:31:14 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e322f0d96 | ||
|
|
097c99b19c | ||
|
|
5ce52e531d |
+1
-1
@@ -29,7 +29,7 @@
|
||||
"dependencies:python":
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- 'superset/requirements/**'
|
||||
- 'requirements/**'
|
||||
- 'superset/translations/requirements.txt'
|
||||
- 'RELEASING/requirements.txt'
|
||||
|
||||
|
||||
+32
@@ -207,6 +207,38 @@ describe('AdhocFilter', () => {
|
||||
expect(adhocFilter10.isValid()).toBe(true);
|
||||
});
|
||||
|
||||
test('is invalid when a comparator-taking operator has no comparator', () => {
|
||||
// A comparator that was never set, or that was cleared through the value
|
||||
// Select's clear affordance, is `undefined` rather than `null` or `[]`.
|
||||
const adhocFilter1 = new AdhocFilter({
|
||||
expressionType: ExpressionTypes.Simple,
|
||||
subject: 'is_intro',
|
||||
operator: 'IN',
|
||||
comparator: undefined,
|
||||
clause: Clauses.Where,
|
||||
});
|
||||
expect(adhocFilter1.isValid()).toBe(false);
|
||||
|
||||
const adhocFilter2 = new AdhocFilter({
|
||||
expressionType: ExpressionTypes.Simple,
|
||||
subject: 'is_intro',
|
||||
operator: '==',
|
||||
comparator: undefined,
|
||||
clause: Clauses.Where,
|
||||
});
|
||||
expect(adhocFilter2.isValid()).toBe(false);
|
||||
|
||||
// `false` is a legitimate boolean comparator, not a missing value
|
||||
const adhocFilter3 = new AdhocFilter({
|
||||
expressionType: ExpressionTypes.Simple,
|
||||
subject: 'is_intro',
|
||||
operator: '==',
|
||||
comparator: false,
|
||||
clause: Clauses.Where,
|
||||
});
|
||||
expect(adhocFilter3.isValid()).toBe(true);
|
||||
});
|
||||
|
||||
test('can translate from simple expressions to sql expressions', () => {
|
||||
const adhocFilter1 = new AdhocFilter({
|
||||
expressionType: ExpressionTypes.Simple,
|
||||
|
||||
+4
-2
@@ -163,8 +163,10 @@ export default class AdhocFilter {
|
||||
// A non-empty array of values ('IN' or 'NOT IN' clauses)
|
||||
return this.comparator.length > 0;
|
||||
}
|
||||
// A value has been selected or typed
|
||||
return this.comparator !== null;
|
||||
// A value has been selected or typed. An unset comparator is
|
||||
// `undefined` rather than `null`: picking a new subject resets it, and
|
||||
// the value Select's clear affordance emits `undefined` too.
|
||||
return this.comparator != null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
@@ -181,6 +181,29 @@ describe('AdhocFilterEditPopover', () => {
|
||||
expect(saveButton).toBeDisabled();
|
||||
});
|
||||
|
||||
test('disables save button when a boolean column has no value selected', async () => {
|
||||
const booleanColumn = { type: 'BOOL', column_name: 'is_intro' };
|
||||
renderPopover({
|
||||
adhocFilter: new AdhocFilter({
|
||||
expressionType: ExpressionTypes.Simple,
|
||||
clause: Clauses.Where,
|
||||
}),
|
||||
options: [booleanColumn],
|
||||
datasource: { columns: [booleanColumn], filter_select: false },
|
||||
});
|
||||
|
||||
// Picking the subject resets the comparator to `undefined`; the value
|
||||
// control is then left untouched, mirroring the reported repro.
|
||||
await userEvent.click(screen.getByTestId('select-element'));
|
||||
await userEvent.click(
|
||||
await screen.findByRole('option', { name: /is_intro/ }),
|
||||
);
|
||||
|
||||
expect(
|
||||
screen.getByTestId('adhoc-filter-edit-popover-save-button'),
|
||||
).toBeDisabled();
|
||||
});
|
||||
|
||||
test('initiates resize when resize handle is dragged', async () => {
|
||||
const onResize = jest.fn();
|
||||
renderPopover({ onResize });
|
||||
|
||||
@@ -83,7 +83,7 @@ The tables below (generated via `python superset/db_engine_specs/lib.py`) summar
|
||||
| Databricks (legacy) | 70 | Supported | Partial | Supported | Partial | Partial | Not supported |
|
||||
| StarRocks | 69 | Supported | Partial | Supported | Partial | Partial | Partial |
|
||||
| SingleStore | 68 | Supported | Partial | Supported | Not supported | Partial | Not supported |
|
||||
| ClickHouse Connect (Superset) | 61 | Supported | Partial | Partial | Partial | Partial | Not supported |
|
||||
| ClickHouse Connect (Superset) | 62 | Supported | Partial | Supported | Partial | Partial | Not supported |
|
||||
| Google Sheets | 61 | Supported | Partial | Supported | Supported | Partial | Partial |
|
||||
| Aurora MySQL (Data API) | 59 | Supported | Partial | Supported | Partial | Partial | Not supported |
|
||||
| MariaDB | 59 | Supported | Partial | Supported | Partial | Partial | Not supported |
|
||||
@@ -91,7 +91,7 @@ The tables below (generated via `python superset/db_engine_specs/lib.py`) summar
|
||||
| OceanBase | 59 | Supported | Partial | Supported | Partial | Partial | Not supported |
|
||||
| MotherDuck | 58 | Supported | Partial | Supported | Not supported | Partial | Not supported |
|
||||
| KustoSQL | 54 | Supported | Partial | Supported | Partial | Partial | Not supported |
|
||||
| ClickHouse | 51 | Supported | Partial | Partial | Partial | Partial | Not supported |
|
||||
| ClickHouse | 52 | Supported | Partial | Supported | Partial | Partial | Not supported |
|
||||
| Databend | 51 | Supported | Partial | Supported | Partial | Partial | Not supported |
|
||||
| Apache Drill | 50 | Supported | Partial | Supported | Partial | Partial | Partial |
|
||||
| Apache Druid | 47 | Partial | Partial | Supported | Partial | Partial | Not supported |
|
||||
@@ -293,8 +293,8 @@ The tables below (generated via `python superset/db_engine_specs/lib.py`) summar
|
||||
| Aurora MySQL (Data API) | True | True | True | True | True | True | True | True |
|
||||
| Aurora PostgreSQL (Data API) | True | True | True | True | True | True | True | True |
|
||||
| Azure Synapse | True | True | True | True | True | True | True | True |
|
||||
| ClickHouse | False | True | True | True | True | True | True | True |
|
||||
| ClickHouse Connect (Superset) | False | True | True | True | True | True | True | True |
|
||||
| ClickHouse | True | True | True | True | True | True | True | True |
|
||||
| ClickHouse Connect (Superset) | True | True | True | True | True | True | True | True |
|
||||
| CockroachDB | True | True | True | True | True | True | True | True |
|
||||
| Couchbase | True | True | True | True | False | True | True | True |
|
||||
| CrateDB | True | True | True | True | True | True | True | True |
|
||||
|
||||
@@ -112,6 +112,7 @@ class ClickHouseBaseEngineSpec(BaseEngineSpec):
|
||||
|
||||
_time_grain_expressions = {
|
||||
None: "{col}",
|
||||
"PT1S": "toStartOfSecond(toDateTime64({col}, 3))",
|
||||
"PT1M": "toStartOfMinute(toDateTime({col}))",
|
||||
"PT5M": "toDateTime(intDiv(toUInt32(toDateTime({col})), 300)*300)",
|
||||
"PT10M": "toDateTime(intDiv(toUInt32(toDateTime({col})), 600)*600)",
|
||||
|
||||
@@ -62,6 +62,20 @@ def test_convert_dttm(
|
||||
assert_convert_dttm(spec, target_type, expected_result, dttm)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"time_grain,expected",
|
||||
[
|
||||
(None, "{col}"),
|
||||
("PT1S", "toStartOfSecond(toDateTime64({col}, 3))"),
|
||||
("PT1M", "toStartOfMinute(toDateTime({col}))"),
|
||||
],
|
||||
)
|
||||
def test_time_grain_expressions(time_grain: Optional[str], expected: str) -> None:
|
||||
from superset.db_engine_specs.clickhouse import ClickHouseBaseEngineSpec
|
||||
|
||||
assert ClickHouseBaseEngineSpec._time_grain_expressions[time_grain] == expected
|
||||
|
||||
|
||||
def test_convert_dttm_normalizes_aware_datetime_to_utc() -> None:
|
||||
from superset.db_engine_specs.clickhouse import (
|
||||
ClickHouseEngineSpec as spec, # noqa: N813
|
||||
|
||||
Reference in New Issue
Block a user