From 28a4351df7b6259d7bb211b651ee5616c33579a7 Mon Sep 17 00:00:00 2001 From: Praveen K B Date: Fri, 10 Jan 2025 10:46:01 +0530 Subject: [PATCH] Removed QueryEngine Logic --- src/api/query.ts | 1 - src/hooks/useCorrelationQueryLogs.tsx | 2 -- src/hooks/useFetchStreamData.tsx | 2 -- .../components/CorrelationFilters/index.tsx | 7 ++----- .../components/MultiEventTimeLineGraph.tsx | 3 +-- .../providers/CorrelationProvider.tsx | 10 ++-------- src/utils/queryBuilder.ts | 16 ++-------------- 7 files changed, 7 insertions(+), 34 deletions(-) diff --git a/src/api/query.ts b/src/api/query.ts index a47ef15c..b74d066a 100644 --- a/src/api/query.ts +++ b/src/api/query.ts @@ -18,7 +18,6 @@ type CorrelationLogs = { startTime: Date; endTime: Date; limit: number; - queryEngine?: QueryEngine; correlationCondition?: string; selectedFields?: string[]; }; diff --git a/src/hooks/useCorrelationQueryLogs.tsx b/src/hooks/useCorrelationQueryLogs.tsx index 309f5066..8615e10a 100644 --- a/src/hooks/useCorrelationQueryLogs.tsx +++ b/src/hooks/useCorrelationQueryLogs.tsx @@ -19,7 +19,6 @@ const { setStreamData } = correlationStoreReducers; export const useCorrelationQueryLogs = () => { const [error, setError] = useMountedState(null); const [{ selectedFields, correlationCondition, fields }, setCorrelationStore] = useCorrelationStore((store) => store); - const [queryEngine] = useAppStore((store) => store.instanceConfig?.queryEngine); const [streamInfo] = useStreamStore((store) => store.info); const [currentStream] = useAppStore((store) => store.currentStream); const timePartitionColumn = _.get(streamInfo, 'time_partition', 'p_timestamp'); @@ -32,7 +31,6 @@ export const useCorrelationQueryLogs = () => { const streamNames = Object.keys(fields); const defaultQueryOpts = { - queryEngine, startTime: timeRange.startTime, endTime: timeRange.endTime, limit: CORRELATION_LOAD_LIMIT, diff --git a/src/hooks/useFetchStreamData.tsx b/src/hooks/useFetchStreamData.tsx index 2adbbcd9..10136952 100644 --- a/src/hooks/useFetchStreamData.tsx +++ b/src/hooks/useFetchStreamData.tsx @@ -22,7 +22,6 @@ export const useFetchStreamData = () => { const [{ selectedFields, correlationCondition, fields, streamData }, setCorrelationStore] = useCorrelationStore( (store) => store, ); - const [queryEngine] = useAppStore((store) => store.instanceConfig?.queryEngine); const [streamInfo] = useStreamStore((store) => store.info); const [currentStream] = useAppStore((store) => store.currentStream); const timePartitionColumn = _.get(streamInfo, 'time_partition', 'p_timestamp'); @@ -45,7 +44,6 @@ export const useFetchStreamData = () => { }, [timeRange.startTime, timeRange.endTime]); const defaultQueryOpts = { - queryEngine, startTime: timeRange.startTime, endTime: timeRange.endTime, limit: STREAM_DATA_LOAD_LIMIT, diff --git a/src/pages/Correlation/components/CorrelationFilters/index.tsx b/src/pages/Correlation/components/CorrelationFilters/index.tsx index db4bc124..45f0579a 100644 --- a/src/pages/Correlation/components/CorrelationFilters/index.tsx +++ b/src/pages/Correlation/components/CorrelationFilters/index.tsx @@ -48,7 +48,6 @@ const ModalTitle = ({ title }: { title: string }) => { const QuerierModal = (props: { onClear: () => void; onFiltersApply: () => void }) => { const [currentStream] = useAppStore((store) => store.currentStream); - const [queryEngine] = useAppStore((store) => store.instanceConfig?.queryEngine); const [{ showQueryBuilder }, setLogsStore] = useLogsStore((store) => store.custQuerySearchState); const [streamInfo] = useStreamStore((store) => store.info); const [timeRange] = useAppStore((store) => store.timeRange); @@ -60,13 +59,12 @@ const QuerierModal = (props: { onClear: () => void; onFiltersApply: () => void } useEffect(() => { queryCodeEditorRef.current = defaultCustSQLQuery( - queryEngine, currentStream, timeRange.startTime, timeRange.endTime, timePartitionColumn, ); - }, [queryEngine, currentStream, timeRange.endTime, timeRange.startTime, timePartitionColumn]); + }, [currentStream, timeRange.endTime, timeRange.startTime, timePartitionColumn]); return ( { const [{ startTime, endTime }, setAppStore] = useAppStore((store) => store.timeRange); const { isQuerySearchActive, viewMode, showQueryBuilder, activeMode, savedFilterId } = custQuerySearchState; const [currentStream] = useAppStore((store) => store.currentStream); - const [queryEngine] = useAppStore((store) => store.instanceConfig?.queryEngine); const [activeSavedFilters] = useAppStore((store) => store.activeSavedFilters); const openBuilderModal = useCallback(() => { setLogsStore((store) => toggleQueryBuilder(store)); @@ -125,7 +122,7 @@ const CorrelationFilters = () => { if (!currentStream) return; const { isUncontrolled } = opts || {}; - const { parsedQuery } = parseQuery(queryEngine, query, currentStream, { + const { parsedQuery } = parseQuery(query, currentStream, { startTime, endTime, timePartitionColumn, diff --git a/src/pages/Correlation/components/MultiEventTimeLineGraph.tsx b/src/pages/Correlation/components/MultiEventTimeLineGraph.tsx index 77847838..0f62f864 100644 --- a/src/pages/Correlation/components/MultiEventTimeLineGraph.tsx +++ b/src/pages/Correlation/components/MultiEventTimeLineGraph.tsx @@ -304,7 +304,6 @@ const parseGraphData = ( const MultiEventTimeLineGraph = () => { const { fetchQueryMutation } = useQueryResult(); const [fields] = useCorrelationStore((store) => store.fields); - const [queryEngine] = useAppStore((store) => store.instanceConfig?.queryEngine); const [appliedQuery] = useFilterStore((store) => store.appliedQuery); const [timeRange] = useAppStore((store) => store.timeRange); const [multipleStreamData, setMultipleStreamData] = useState([]); @@ -323,7 +322,7 @@ const MultiEventTimeLineGraph = () => { endTime: modifiedEndTime, access: [], }; - const whereClause = parseQuery(queryEngine, appliedQuery, streamKey).where; + const whereClause = parseQuery(appliedQuery, streamKey).where; const query = generateCountQuery(streamKey, modifiedStartTime, modifiedEndTime, compactType, whereClause); const graphQuery = removeOffsetFromQuery(query); diff --git a/src/pages/Correlation/providers/CorrelationProvider.tsx b/src/pages/Correlation/providers/CorrelationProvider.tsx index 349eb002..b999f1af 100644 --- a/src/pages/Correlation/providers/CorrelationProvider.tsx +++ b/src/pages/Correlation/providers/CorrelationProvider.tsx @@ -4,7 +4,6 @@ import { Log, LogsResponseWithHeaders } from '@/@types/parseable/api/query'; import { LogStreamSchemaData } from '@/@types/parseable/api/stream'; import _ from 'lodash'; import { QueryType } from '@/pages/Stream/providers/FilterProvider'; -import { QueryEngineType } from '@/@types/parseable/api/about'; import { FilterQueryBuilder } from '@/utils/queryBuilder'; import { formatQuery } from 'react-querybuilder'; @@ -77,11 +76,7 @@ type CorrelationStoreReducers = { setCorrelationCondition: (store: CorrelationStore, correlationCondition: string) => ReducerOutput; setPageAndPageData: (store: CorrelationStore, pageNo: number, perPage?: number) => ReducerOutput; setIsCorrelatedFlag: (store: CorrelationStore, flag: boolean) => ReducerOutput; - parseQuery: ( - queryEngine: 'Parseable' | 'Trino' | undefined, - query: QueryType, - currentStream: string, - ) => { where: string; parsedQuery: string }; + parseQuery: (query: QueryType, currentStream: string) => { where: string; parsedQuery: string }; }; const initialState: CorrelationStore = { @@ -115,13 +110,12 @@ const initialState: CorrelationStore = { // Utilites -const parseQuery = (queryEngine: QueryEngineType, query: QueryType, currentStream: string) => { +const parseQuery = (query: QueryType, currentStream: string) => { // todo - custom rule processor to prevent converting number strings into numbers for text fields const where = formatQuery(query, { format: 'sql', parseNumbers: true, quoteFieldNamesWith: ['"', '"'] }); const timeRangeCondition = '(1=1)'; const filterQueryBuilder = new FilterQueryBuilder({ - queryEngine, streamName: currentStream, whereClause: where, timeRangeCondition, diff --git a/src/utils/queryBuilder.ts b/src/utils/queryBuilder.ts index a973ce2d..528d62e0 100644 --- a/src/utils/queryBuilder.ts +++ b/src/utils/queryBuilder.ts @@ -21,7 +21,6 @@ type FilterQueryBuilderType = { type CorrelationQueryBuilderType = { streamNames: string[]; limit: number; - queryEngine?: QueryEngine; correlationCondition?: string; selectedFields?: string[]; startTime: Date; @@ -101,7 +100,6 @@ export class FilterQueryBuilder { } export class CorrelationQueryBuilder { - queryEngine?: QueryEngine; streamNames: string[]; limit: number; correlationCondition?: string; @@ -112,13 +110,11 @@ export class CorrelationQueryBuilder { constructor({ streamNames, limit, - queryEngine, correlationCondition, selectedFields, startTime, endTime, }: CorrelationQueryBuilderType) { - this.queryEngine = queryEngine; this.streamNames = streamNames; this.startTime = startTime; this.endTime = endTime; @@ -154,18 +150,10 @@ export class CorrelationQueryBuilder { }; } getResourcePath(): string { - switch (this.queryEngine) { - case 'Trino': - return TRINO_RESOURCE_PATH; - default: - return PARSEABLE_RESOURCE_PATH; - } + return PARSEABLE_RESOURCE_PATH; } getQuery() { - switch (this.queryEngine) { - default: - return this.getParseableQuery(); - } + return this.getParseableQuery(); } }