diff --git a/ui/src/views/Forecast.jsx b/ui/src/views/Forecast.jsx index 2da34f5..4fbd522 100644 --- a/ui/src/views/Forecast.jsx +++ b/ui/src/views/Forecast.jsx @@ -919,6 +919,10 @@ export default function Forecast({ sources = [], sourceId, versions = [], versio // // Removing an ordering removes its column: leaving a stale Bucket expression // behind would keep ordering by an order that no longer exists. + function dbgOrder(msg, extra) { + console.log(`[pf-order] ${msg}`, extra) + } + async function syncOrderExpressions() { const viewer = viewerRef.current if (!viewer) return @@ -934,7 +938,19 @@ export default function Forecast({ sources = [], sourceId, versions = [], versio Object.assign(next, wanted) const same = JSON.stringify(next) === JSON.stringify(current) - if (same) return + if (same) { + // Nothing to do is a legitimate outcome, but "nothing was ordered" and + // "the ordering is already applied" look identical from the outside. + if (Object.keys(wanted).length === 0) { + dbgOrder('no ordering to apply', { + bucket_order: version?.bucket_order, + seqs: Object.entries(logMeta || {}) + .filter(([, m]) => m.seq != null) + .map(([id, m]) => `${id}:${m.tag || m.note}=${m.seq}`), + }) + } + return + } // An expression the pivot is using cannot simply vanish; drop it from the // axes first or restore() rejects the config. @@ -948,8 +964,13 @@ export default function Forecast({ sources = [], sourceId, versions = [], versio split_by: (cfg.split_by || []).filter(stillValid), sort: (cfg.sort || []).filter(([c]) => stillValid(c)), }) + dbgOrder('applied', Object.keys(next)) } catch (err) { - console.error('[syncOrderExpressions]', err) + // Surfaced rather than logged: this failing silently is what made the + // missing Bucket and Segment columns so hard to pin down -- the columns + // simply were not there, with nothing to say why. + console.error('[syncOrderExpressions]', err, { wanted, next }) + flash(`Column ordering failed: ${err.message || err}`, 'error') } }