Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/Logs/providers/LogsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ const setData = (store: LogsStore, data: Log[]) => {
// only if pageoffset is 1
const newHeaders =
filteredData && existingData.schema && custQuerySearchState.isQuerySearchActive
? makeHeadersfromData(existingData.schema, custQuerySearchState.custSearchQuery)
? makeHeadersfromData(filteredData)
: makeHeadersFromSchema(existingData.schema);

return {
Expand Down
22 changes: 14 additions & 8 deletions src/pages/Logs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@ export const makeHeadersFromSchema = (schema: LogStreamSchemaData | null): strin
}
};

export const makeHeadersfromData = (schema: LogStreamSchemaData, custSearchQuery: string | null): string[] => {
const allColumns = makeHeadersFromSchema(schema);
if (custSearchQuery === null) return allColumns;
export const makeHeadersfromData = (data: Log[]): string[] => {
const allKeys: string[] = [];

const selectClause = custSearchQuery.match(/SELECT(.*?)FROM/i)?.[1];
if (!selectClause || selectClause.includes('*')) return allColumns;
// cannot parse cust search query and get the possible keys.
// and also its not necessary that each record will have all the specified columns
// so go through all the records and get the keys
data.forEach((obj) => {
Object.keys(obj).forEach((key) => {
if (!allKeys.includes(key)) {
allKeys.push(key);
}
});
});

const commonColumns = allColumns.filter((column) => selectClause.includes(column));
return commonColumns;
};
return allKeys;
};