mirror of
https://github.com/apache/superset.git
synced 2026-05-22 00:05:15 +00:00
fix(charts): use separator-aware matching for time shift column grouping
The `endswith(ts)` check in `get_column_groups` matched columns
incorrectly when time shifts shared a numeric suffix — e.g.
"metric__22 weeks ago".endswith("2 weeks ago") returned True,
causing columns to be misclassified. Use `endswith(TIME_COMPARISON + ts)`
to include the "__" separator in the match.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Sophie
parent
4aa4415d8f
commit
6c00ee2eec
@@ -24,7 +24,7 @@ from flask_babel import gettext as _
|
||||
from pandas import DataFrame, MultiIndex
|
||||
|
||||
from superset.exceptions import InvalidPostProcessingError
|
||||
from superset.utils.core import PostProcessingContributionOrientation
|
||||
from superset.utils.core import PostProcessingContributionOrientation, TIME_COMPARISON
|
||||
from superset.utils.pandas_postprocessing.utils import validate_column_args
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ def get_column_groups(
|
||||
time_shift = None
|
||||
if time_shifts and isinstance(col_0, str):
|
||||
for ts in time_shifts:
|
||||
if col_0.endswith(ts):
|
||||
if col_0.endswith(TIME_COMPARISON + ts):
|
||||
time_shift = ts
|
||||
break
|
||||
if time_shift is not None:
|
||||
|
||||
Reference in New Issue
Block a user