opensearch-project / OpenSearch-Dashboards

📊 Open source visualization dashboards for OpenSearch.
https://opensearch.org/docs/latest/dashboards/index/
Apache License 2.0
1.63k stars 849 forks source link

[BUG] Buckets cannot be removed when data table columns are sorted by metrics #6965

Open jgough opened 2 months ago

jgough commented 2 months ago

Describe the bug When data tables are custom sorted by a metric, removal of buckets is broken and results in the error dataGridColumns[sort.colIndex] is undefined

To Reproduce Steps to reproduce the behavior:

  1. Create a data table visualisation with metrics and at least one bucket, or go this playground link&_a=(filters:!(),linked:!f,query:(language:kuery,query:''),uiState:(vis:(sortColumn:(colIndex:0,direction:asc))),vis:(aggs:!((enabled:!t,id:'1',params:(),schema:metric,type:count),(enabled:!t,id:'3',params:(field:bytes,percents:!(50)),schema:metric,type:median),(enabled:!t,id:'2',params:(field:bytes),schema:metric,type:min),(enabled:!t,id:'4',params:(field:bytes),schema:metric,type:max),(enabled:!t,id:'5',params:(field:request.keyword,missingBucket:!f,missingBucketLabel:Missing,order:desc,orderBy:'1',otherBucket:!f,otherBucketLabel:Other,size:20),schema:bucket,type:terms)),params:(perPage:10,percentageCol:'',showMetricsAtAllLevels:!f,showPartialRows:!f,showTotal:!f,totalFunc:sum),title:'(Table)%20Bytes%20by%20request%20stats%20summary',type:table))) for the visualisation called "(Table) Bytes by request stats summary"
  2. Click on the metric column (Max bytes if using above link) and then Sort desc
  3. Now using the sidebar, delete (or hide) the Bucket aggregation (Split rows: request.keyword) and click Update
  4. The error dataGridColumns[sort.colIndex] is undefined is returned

TableVisComponent/sortedColumns<@https://playground.opensearch.org/9084337273/bundles/plugin/visTypeTable/visTypeTable.plugin.js:4:60723
fa@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:61568
__osdSharedDeps__</t.useMemo@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:419:5984
TableVisComponent@https://playground.opensearch.org/9084337273/bundles/plugin/visTypeTable/visTypeTable.plugin.js:4:60714
$i@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:57931
Na@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:66792
gs@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:105389
uc@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:96720
sc@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:96643
Qs@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:93673
Vo/<@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45315
__osdSharedDeps__</t.unstable_runWithPriority@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:443:3844
Xo@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45024
Vo@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45262
Yo@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:45195
$s@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:90458
Nc@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:111885
jc@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:112759
__osdSharedDeps__</t.render@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:435:116094
render@https://playground.opensearch.org/9084337273/bundles/plugin/visTypeTable/visTypeTable.plugin.js:4:65400
render_ExpressionRenderHandler/<@https://playground.opensearch.org/9084337273/bundles/plugin/expressions/expressions.plugin.js:6:32796
render@https://playground.opensearch.org/9084337273/bundles/plugin/expressions/expressions.plugin.js:6:37483
loader_ExpressionLoader/<@https://playground.opensearch.org/9084337273/bundles/plugin/expressions/expressions.plugin.js:6:36639
__osdSharedDeps__</p</t.prototype.__tryOrUnsub@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:21:42297
__osdSharedDeps__</p</t.prototype.next@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:21:41442
__osdSharedDeps__</l</t.prototype._next@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:21:40518
__osdSharedDeps__</l</t.prototype.next@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:21:40189
__osdSharedDeps__</p</t.prototype.next@https://playground.opensearch.org/9084337273/bundles/osd-ui-shared-deps/osd-ui-shared-deps.js:349:76903
loader_ExpressionLoader/<@https://playground.opensearch.org/9084337273/bundles/plugin/expressions/expressions.plugin.js:6:35849

OpenSearch Version: 2.14.0 Dashboards Version: 2.14.0

bandinib-amzn commented 2 months ago

Thanks @jgough for reporting the issue. I’m able to reproduce the issue by following the described steps using playground.