aminghadersohi commented on code in PR #45612:
URL: https://github.com/apache/superset/pull/45612#discussion_r4365999091
##########
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilter/index.ts:
##########
@@ -140,6 +146,11 @@ export default class AdhocFilter {
operator: this.operator,
operatorId: this.operatorId,
comparator: this.comparator,
+ // A grain belongs to its subject's time buckets.
+ timeGrain:
+ nextFields.subject === undefined || nextFields.subject === this.subject
+ ? this.timeGrain
+ : undefined,
Review Comment:
Fixed in af948501a626031148cc4caee71f6e81195a58bc. `duplicateWith` drops the
inherited grain when the operator changes, including the date picker's `==` →
`TEMPORAL_RANGE` transition. Comparator-only and clause-only edits keep the
grain.
Regression test: `picking a date range on a drilled bucket filters raw dates
without a grain` in
`superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/AdhocFilterEditPopoverSimpleTabContent.test.tsx`
invokes the real date-picker handler with `2004-01-15 : 2004-02-15` and
asserts the complete converted query predicate has no `grain`. That test, the
sibling operator-handler test, and three `duplicateWith` operator-change cases
fail at 78ee7a2f25055ed453e32491435320634b54e1e4 (5 failed / 83 passed) and
pass with this change.
The sibling Custom SQL conversion is guarded in
2964b59c82b3325924e450d5deeb5335000ef0ce: a bucket predicate has no portable
raw SQL representation, so its SQL tab is unavailable while the grain is
present. Regression test: `a drilled bucket cannot be converted to raw Custom
SQL that loses its grain` in
`superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopover/AdhocFilterEditPopover.test.tsx`
failed before that guard (1 failed / 9 passed) and passes after it. The guard
covers both SQL clause and SQL expression handlers; ordinary SQL filters keep
their existing tab.
Validation: broader Jest scope 1,058 passed; chart plugin scope 130 passed;
final FilterControl scope 128 passed. Docker backend siblings 321 passed; the
CI-equivalent semantic-layer gate 1,827 passed with 100.00% statement/branch
coverage. Changed-branch-file pre-commit passed with the repository-pinned
Ruff. Live UI/SQL acceptance was not run because the local health endpoint is
unavailable.
Siblings checked:
-
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilter/index.ts:143
— fixed in af948501a626031148cc4caee71f6e81195a58bc
-
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx:278
— fixed in af948501a626031148cc4caee71f6e81195a58bc
-
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx:333
— fixed in af948501a626031148cc4caee71f6e81195a58bc
-
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx:345
— fixed in af948501a626031148cc4caee71f6e81195a58bc
-
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx:375
— fixed in af948501a626031148cc4caee71f6e81195a58bc
-
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx:357
— not affected: comparator-only changes intentionally keep the bucket grain,
covered by the Explore-edits test
-
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx:366
— not affected: clearing the operator makes the filter invalid; selecting a
replacement operator drops the grain through duplicateWith
-
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopover/index.tsx:374
— fixed in 2964b59c82b3325924e450d5deeb5335000ef0ce
-
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopover/index.tsx:271
— not affected: the save clone only changes layerFilterScope, not column or
operator
-
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSqlTabContent/index.tsx:65
— fixed in 2964b59c82b3325924e450d5deeb5335000ef0ce
-
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSqlTabContent/index.tsx:74
— fixed in 2964b59c82b3325924e450d5deeb5335000ef0ce
-
superset-frontend/src/explore/components/controls/MetricControl/AdhocMetric.ts
— not affected: duplicateWith belongs to a different class without filter
timeGrain
- superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx:255 — not
affected: conversion and further drills preserve the original bucket metadata
without editing its operator
- superset-frontend/src/components/Chart/DrillBy/DrillByModal.tsx:278 — not
affected: the alternate query filter field uses the same grain-preserving
conversion
- superset-frontend/src/utils/simpleFilterToAdhoc.ts:98 — not affected:
preserving grain when constructing a bucket is intentional, rather than an
operator edit
-
superset-frontend/src/explore/controlUtils/getFormDataWithDashboardContext.ts:98
— not affected: dashboard-context conversion does not change a bucket operator
-
superset-frontend/src/explore/controlUtils/getFormDataWithDashboardContext.ts:155
— not affected: the alternate dashboard filter conversion likewise does not
edit the predicate
- superset-frontend/src/components/Chart/DrillDetail/utils.ts:27 — not
affected: Drill to detail and downloads forward query filter metadata without
editing predicates
- superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx:227
— not affected: query and download at line 311 both use getDrillPayload, not
adhoc operator edits
-
superset-frontend/src/explore/components/DataTablesPane/components/SamplesPane.tsx:97
— not affected: delegates to the same payload builder without an operator edit
-
superset-frontend/plugins/plugin-chart-echarts/src/utils/xAxisDrillByFilter.ts:177
— not affected: constructs the clicked bucket, where retaining its grain is
required
-
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx:713
— not affected: calls the bucket constructor, not an editor
-
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/EchartsMixedTimeseries.tsx:251
— not affected: calls the same bucket constructor for the clicked query
- superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/utils.ts:169 —
not affected: constructs a bucket like Drill to detail, not an edited date range
- superset-frontend/packages/superset-ui-core/src/query/convertFilter.ts:43
— not affected: serializes the edited filter without grain; the new date-picker
test asserts the complete query-filter payload
- superset/common/form_data_query_context.py:258 — not affected: only emits
grain when timeGrain is present in the adhoc filter
- superset/utils/core.py:1553 — not affected: the alternate adhoc-to-query
conversion has the same conditional grain emission
- superset/common/query_context_factory.py:436 — not affected: preserving
explicit bucket predicates during time-column overrides is intentional; edited
ranges have no grain
- superset/models/helpers.py:5432 — not affected: no filter grain means a
raw-date comparison; explicit grained predicates still need bucket semantics
- superset/semantic_layers/mapper.py:908 — not affected: grained equality is
a bucket; TEMPORAL_RANGE follows the separate raw-date range path
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]