mirror of
https://github.com/apache/druid.git
synced 2025-02-17 07:25:02 +00:00
Support segment metadata in rune (#7371)
This commit is contained in:
parent
347779b17a
commit
2ad9544242
@ -29,7 +29,8 @@ const SUPPORTED_QUERY_TYPES: string[] = [
|
||||
'timeBoundary',
|
||||
'dataSourceMetadata',
|
||||
'select',
|
||||
'scan'
|
||||
'scan',
|
||||
'segmentMetadata'
|
||||
];
|
||||
|
||||
function flatArrayToHeaderRows(a: Record<string, any>[], headerOverride?: string[]): HeaderRows {
|
||||
@ -73,6 +74,13 @@ function processScan(rune: any[]): HeaderRows {
|
||||
return flatArrayToHeaderRows([].concat(...rune.map(r => r.events)), header);
|
||||
}
|
||||
|
||||
function processSegmentMetadata(rune: any[]): HeaderRows {
|
||||
const flatArray = ([] as any).concat(...rune.map(r => Object.keys(r.columns).map(
|
||||
k => Object.assign({id: r.id, column: k}, r.columns[k])
|
||||
)));
|
||||
return flatArrayToHeaderRows(flatArray);
|
||||
}
|
||||
|
||||
export function decodeRune(runeQuery: any, runeResult: any[]): HeaderRows {
|
||||
let queryType = runeQuery.queryType;
|
||||
if (typeof queryType !== 'string') throw new Error('must have queryType');
|
||||
@ -122,6 +130,9 @@ export function decodeRune(runeQuery: any, runeResult: any[]): HeaderRows {
|
||||
}
|
||||
return processScan(runeResult);
|
||||
|
||||
case 'segmentMetadata':
|
||||
return processSegmentMetadata(runeResult);
|
||||
|
||||
default:
|
||||
throw new Error(`Should never get here.`);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user