mistercrunch opened a new pull request, #34296:
URL: https://github.com/apache/superset/pull/34296
## Summary
Fixes duplicate query issue in BigNumber with Trendline charts and
improves the View Query modal UX. PR #33407 introduced duplicate identical
queries for `LAST_VALUE` aggregation (the default), causing unnecessary
database load and
confusing query inspection.
<img width="427" height="181" alt="Screenshot 2025-07-23 at 9 14 05 PM"
src="https://github.com/user-attachments/assets/6f0ab29f-5b09-4644-ada2-d638343bd039"
/>
## Changes
**Query Optimization:**
- **`LAST_VALUE`**: Now uses 1 query (most recent trendline value)
- **`None`**: Preserves 2 queries (trendline + raw server aggregation)
- **Math aggregations**: Uses client-side computation from trendline data
**UI Improvements:**
- Wrapped each query in AntD Cards for better visual separation
- Moved action buttons below SQL code with secondary styling
- Improved spacing and layout using theme units
- Enhanced aggregation tooltip explaining cross-timeseries behavior
## Background
PR #33407 by @LevisNgigi always generated 2 queries regardless of
aggregation type:
```typescript
// Before: Always 2 queries even when identical
return buildQueryContext(formData, baseQueryObject => [
{ /* trendline query */ },
{ /* aggregation query */ } // Duplicate for LAST_VALUE
]);
For LAST_VALUE (default), both queries were functionally identical since
the big number is just the most recent trendline point.
Query Logic
- LAST_VALUE: 1 query → big number from most recent trendline value
- None: 2 queries → trendline + raw metric over entire time period
- sum/mean/min/max/median: 1 query → client-side aggregation from trendline
Why "None" Needs 2 Queries
For non-additive metrics like COUNT(DISTINCT user_id):
- Query 1: Daily counts [100, 120, 95] for trendline
- Query 2: Total distinct users 250 across period (can't sum daily counts)
Testing
- ✅ Updated tests to match new query behavior
- ✅ All aggregation methods produce correct results
- ✅ View Query modal shows clean card layout
Fixes performance regression from #33407 while preserving correct behavior
for legitimate multi-query scenarios.
--
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]