eschutho opened a new pull request, #41204:
URL: https://github.com/apache/superset/pull/41204
## What changed
**Deprecation warning found in production Datadog logs:**
```
The field `groupby` is deprecated, please use `columns` instead.
file: query_object.py, line 219, func: _rename_deprecated_fields
env: production, service: superset
```
Charts with a stored `query_context` column (in `slices.query_context`) that
was saved
using the old `groupby` key emit this warning on **every render** via
`Slice.get_query_context()`. That path parses the stored JSON and calls
`QueryContextFactory.create()` directly, bypassing the Marshmallow
`ChartDataQueryObjectSchema.rename_deprecated_fields` `@post_load` hook that
the
REST API path relies on. By the time `QueryObject._rename_deprecated_fields`
sees
`groupby` in `**kwargs`, there is no caller who can act on the warning — it
is pure
noise in production logs.
## What was changed
`QueryObjectFactory.create()` now normalises `DEPRECATED_FIELDS` (the same
set the
schema `@post_load` uses) **before** any downstream processing. This ensures
that:
1. `groupby` (and `granularity_sqla`, `timeseries_limit`,
`timeseries_limit_metric`)
are renamed to their canonical forms before `_process_time_range` reads
`columns`
from `kwargs`.
2. `QueryObject._rename_deprecated_fields` never sees the old keys for the
factory
path, so no warning is emitted.
3. If both the deprecated key and the canonical key are present, the
canonical key
wins (`setdefault` semantics) — consistent with keeping explicitly-set
values.
## No behavior change
Charts that use stored `query_context` with `groupby` continue to work
exactly as
before. The only change is that the deprecation warning is no longer emitted
for
these already-known-deprecated internal representations.
## Test plan
- [ ] New unit tests in `test_query_object_factory.py`:
- `test_deprecated_groupby_renamed_to_columns` — verifies `groupby` is
silently
renamed to `columns` and not exposed as a `QueryObject` attribute.
- `test_deprecated_groupby_does_not_overwrite_columns` — verifies that an
explicit
`columns` value takes precedence over a stale `groupby`.
- [ ] All existing `TestQueryObjectFactory` tests continue to pass.
- [ ] CI green.
--
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]