Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing OFFSET during SQL sanitisation #367

Merged
merged 2 commits into from
Nov 11, 2024
Merged
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
8 changes: 7 additions & 1 deletion src/pages/Stream/components/EventTimeLineGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ function extractWhereClause(sql: string) {
return '(1 = 1)';
}

function removeOffsetFromQuery(query: string): string {
const offsetRegex = /\sOFFSET\s+\d+/i;
return query.replace(offsetRegex, '');
}

const getCompactType = (interval: number): CompactInterval => {
const totalMinutes = interval / (1000 * 60);
if (totalMinutes <= 60) {
Expand Down Expand Up @@ -283,10 +288,11 @@ const EventTimeLineGraph = () => {
? extractWhereClause(custSearchQuery)
: parseQuery(queryEngine, appliedQuery, localStream).where;
const query = generateCountQuery(localStream, modifiedStartTime, modifiedEndTime, compactType, whereClause);
const graphQuery = removeOffsetFromQuery(query);
fetchQueryMutation.mutate({
queryEngine: 'Parseable', // query for graph should always hit the endpoint for parseable query
logsQuery,
query,
query: graphQuery,
});
}, [localStream, startTime.toISOString(), endTime.toISOString(), custSearchQuery]);

Expand Down
Loading