Skip to content

Commit

Permalink
Merge branch 'main' into err-retry-view
Browse files Browse the repository at this point in the history
  • Loading branch information
praveen5959 authored Jan 8, 2025
2 parents bb0b892 + 43b4f30 commit 70e979d
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 105 deletions.
3 changes: 0 additions & 3 deletions src/@types/parseable/api/about.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export type QueryEngineType = 'Trino' | 'Parseable' | undefined;

export type AboutData = {
commit: string;
deploymentId: string;
Expand All @@ -18,5 +16,4 @@ export type AboutData = {
analytics: {
clarityTag: string;
};
queryEngine: QueryEngineType;
};
2 changes: 0 additions & 2 deletions src/@types/parseable/api/query.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { QueryEngineType } from '@/@types/parseable/api/about';
export type LogsQuery = {
queryEngine?: QueryEngineType;
streamName: string;
startTime: Date;
endTime: Date;
Expand Down
3 changes: 0 additions & 3 deletions src/api/query.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { Axios } from './axios';
import { LOG_QUERY_URL } from './constants';
import { Log, LogsQuery, LogsResponseWithHeaders } from '@/@types/parseable/api/query';
import { QueryEngineType } from '@/@types/parseable/api/about';
import timeRangeUtils from '@/utils/timeRangeUtils';
import { QueryBuilder } from '@/utils/queryBuilder';

const { formatDateAsCastType } = timeRangeUtils;
type QueryEngine = QueryEngineType;
type QueryLogs = {
queryEngine: QueryEngine;
streamName: string;
startTime: Date;
endTime: Date;
Expand Down
3 changes: 1 addition & 2 deletions src/hooks/useQueryLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export const useQueryLogs = () => {

// refactor
const defaultQueryOpts = {
queryEngine,
streamName: currentStream || '',
startTime: timeRange.startTime,
endTime: timeRange.endTime,
Expand All @@ -90,7 +89,7 @@ export const useQueryLogs = () => {
refetchSchema();
if (isQuerySearchActive) {
if (activeMode === 'filters' && isQueryFromParams === false) {
const { parsedQuery } = parseQuery(queryEngine, appliedQuery, currentStream || '', {
const { parsedQuery } = parseQuery(appliedQuery, currentStream || '', {
startTime: timeRange.startTime,
endTime: timeRange.endTime,
timePartitionColumn,
Expand Down
5 changes: 1 addition & 4 deletions src/hooks/useQueryResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ import { useFilterStore, filterStoreReducers } from '@/pages/Stream/providers/Fi
import _ from 'lodash';
import { useAppStore } from '@/layouts/MainLayout/providers/AppProvider';
import { notifyError } from '@/utils/notification';
import { QueryEngineType } from '@/@types/parseable/api/about';

const { parseQuery } = filterStoreReducers;

type QueryData = {
queryEngine: QueryEngineType;
logsQuery: LogsQuery;
query: string;
onSuccess?: () => void;
useTrino?: boolean;
};

export const useQueryResult = () => {
Expand Down Expand Up @@ -71,7 +68,7 @@ export const useFetchCount = () => {
const finalQuery = `WITH user_query_count as ( ${custSearchQuery} )SELECT count(*) as count from user_query_count`;

if (activeMode === 'filters') {
const { where } = parseQuery('Parseable', appliedQuery, '');
const { where } = parseQuery(appliedQuery, '');
const finalQuery = defaultQuery + ' ' + 'where' + ' ' + where;
return finalQuery;
} else {
Expand Down
9 changes: 6 additions & 3 deletions src/pages/Stream/Views/Explore/LogsViewConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ const ColumnsList = (props: { isLoading: boolean }) => {
onChangeHandler={onSearchHandler}
disabled={_.isEmpty(headers)}
/>
<Stack style={{ height: '100%' }} gap={0}>
<Stack style={{ flex: 1, overflowY: 'auto' }} gap={0}>
<Group
gap={8}
style={{ display: 'flex', justifyContent: 'flex-start', padding: '0 1rem', marginBottom: '0.3rem' }}>
Expand All @@ -272,7 +272,7 @@ const ColumnsList = (props: { isLoading: boolean }) => {
Clear All
</Text>
</Group>
<ScrollArea scrollbars="y">
<ScrollArea style={{ flex: 1 }}>
<DragDropContext onDragEnd={onDropEnd}>
<Droppable droppableId="columns">
{(provided) => (
Expand Down Expand Up @@ -323,10 +323,13 @@ const LogsViewConfig = (props: { schemaLoading: boolean; logsLoading: boolean; i
ref={divRef}
style={{
borderRight: '1px solid var(--mantine-color-gray-2)',
display: sideBarOpen ? 'none' : 'block',
width: sideBarOpen ? 0 : LOGS_CONFIG_SIDEBAR_WIDTH,
transition: 'width 0.5s',
}}>
<Stack style={{ width: LOGS_CONFIG_SIDEBAR_WIDTH, height: height - 30 }} className={classes.container}>
<Stack
style={{ width: LOGS_CONFIG_SIDEBAR_WIDTH, height: height - 30, overflowY: 'hidden', flex: 1 }}
className={classes.container}>
<Header />
{configViewType === 'schema' ? (
<SchemaList isLoading={props.schemaLoading || props.infoLoading} />
Expand Down
4 changes: 1 addition & 3 deletions src/pages/Stream/Views/Explore/StaticLogTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ const makeHeaderOpts = (
style={{
display: isFirstSelectedRow && isFirstColumn ? 'flex' : '',
}}>
{isSecureHTTPContext
? sanitizedValue && <IconDotsVertical stroke={1.2} size={'0.8rem'} color="#545beb" />
: null}
{isSecureHTTPContext ? <IconDotsVertical stroke={1.2} size={'0.8rem'} color="#545beb" /> : null}
</div>
{sanitizedValue}
<div className={tableStyles.copyIconContainer}>
Expand Down
3 changes: 1 addition & 2 deletions src/pages/Stream/components/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ const Column: FC<Column> = (props) => {
(e: ChangeEvent<HTMLInputElement>) => {
const searchStr = e.target.value.trim();
inputValueRef.current = searchStr;
const regexPattern = new RegExp(searchStr, 'i');
const matches = _.chain(uniqueValues)
.filter((uniqueValue) => regexPattern.test(uniqueValue))
.filter((uniqueValue) => uniqueValue.toLowerCase().includes(searchStr.toLowerCase()))
.value();
setFilteredValues(matches);
},
Expand Down
6 changes: 1 addition & 5 deletions src/pages/Stream/components/EventTimeLineGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ function ChartTooltip({ payload }: ChartTooltipProps) {
const EventTimeLineGraph = () => {
const { fetchQueryMutation } = useQueryResult();
const [currentStream] = useAppStore((store) => store.currentStream);
const [queryEngine] = useAppStore((store) => store.instanceConfig?.queryEngine);
const [appliedQuery] = useFilterStore((store) => store.appliedQuery);
const [{ activeMode, custSearchQuery }, setLogStore] = useLogsStore((store) => store.custQuerySearchState);
const [{ interval, startTime, endTime }] = useAppStore((store) => store.timeRange);
Expand All @@ -289,13 +288,10 @@ const EventTimeLineGraph = () => {
access: [],
};
const whereClause =
activeMode === 'sql'
? extractWhereClause(custSearchQuery)
: parseQuery(queryEngine, appliedQuery, localStream).where;
activeMode === 'sql' ? extractWhereClause(custSearchQuery) : parseQuery(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: graphQuery,
});
Expand Down
5 changes: 0 additions & 5 deletions src/pages/Stream/components/Querier/QueryCodeEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { FC, MutableRefObject, useCallback, useEffect, useState, useRef } from 'react';
import Editor from '@monaco-editor/react';
import { Box, Button, Flex, ScrollArea, Stack, Text, TextInput } from '@mantine/core';
import { QueryEngineType } from '@/@types/parseable/api/about';
import { ErrorMarker, errChecker } from '../ErrorMarker';
import useMountedState from '@/hooks/useMountedState';
import { notify } from '@/utils/notification';
Expand Down Expand Up @@ -33,15 +32,13 @@ const genColumnConfig = (fields: Field[]) => {
};

export const defaultCustSQLQuery = (
queryEngine: QueryEngineType,
streamName: string | null,
startTime: Date,
endTime: Date,
timePartitionColumn: string,
) => {
if (streamName && streamName.length > 0) {
const { query } = formQueryOpts({
queryEngine,
streamName: streamName || '',
limit: LOAD_LIMIT,
startTime,
Expand All @@ -62,7 +59,6 @@ const QueryCodeEditor: FC<{
}> = (props) => {
const [instanceConfig] = useAppStore((store) => store.instanceConfig);
const llmActive = _.get(instanceConfig, 'llmActive', false);
const queryEngine = _.get(instanceConfig, 'queryEngine', 'Parseable');
const [streamInfo] = useStreamStore((store) => store.info);
const timePartitionColumn = _.get(streamInfo, 'time_partition', 'p_timestamp');
const [{ isQuerySearchActive, activeMode, savedFilterId, custSearchQuery }] = useLogsStore(
Expand All @@ -85,7 +81,6 @@ const QueryCodeEditor: FC<{
useEffect(() => {
if (props.queryCodeEditorRef.current === '' || currentStream !== localStreamName) {
props.queryCodeEditorRef.current = defaultCustSQLQuery(
queryEngine,
currentStream,
timeRange.startTime,
timeRange.endTime,
Expand Down
10 changes: 2 additions & 8 deletions src/pages/Stream/components/Querier/SavedFiltersModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const SavedFilterItem = (props: {
onSqlSearchApply: (query: string, id: string, time_filter: null | { from: string; to: string }) => void;
onFilterBuilderQueryApply: (query: QueryType, id: string) => void;
currentStream: string;
queryEngine: 'Parseable' | 'Trino' | undefined;
savedFilterId: string | null;
isStoredAndCurrentTimeRangeAreSame: (from: string, to: string) => boolean;
hardRefresh: () => void;
Expand Down Expand Up @@ -89,10 +88,7 @@ const SavedFilterItem = (props: {
setFilterStore((store) => setAppliedFilterQuery(store, query.filter_query));
} else if (query.filter_builder) {
setFilterStore((store) =>
setAppliedFilterQuery(
store,
parseQuery(props.queryEngine, query.filter_builder as QueryType, stream_name).parsedQuery,
),
setAppliedFilterQuery(store, parseQuery(query.filter_builder as QueryType, stream_name).parsedQuery),
);
}
setFilterStore((store) => toggleSavedFiltersModal(store, false));
Expand Down Expand Up @@ -171,7 +167,7 @@ const SavedFilterItem = (props: {
_.isString(query.filter_query)
? query.filter_query
: query.filter_builder
? parseQuery(props.queryEngine, query.filter_builder, stream_name).parsedQuery
? parseQuery(query.filter_builder, stream_name).parsedQuery
: ''
}
language="sql"
Expand All @@ -197,7 +193,6 @@ const SavedFiltersModal = () => {
const [savedFilters] = useAppStore((store) => store.savedFilters);
const [activeSavedFilters] = useAppStore((store) => store.activeSavedFilters);
const [currentStream] = useAppStore((store) => store.currentStream);
const [queryEngine] = useAppStore((store) => store.instanceConfig?.queryEngine);
const { isLoading, refetch, isError } = useSavedFiltersQuery();
const onSqlSearchApply = useCallback(
(query: string, id: string, time_filter: null | { from: string; to: string }) => {
Expand Down Expand Up @@ -281,7 +276,6 @@ const SavedFiltersModal = () => {
onSqlSearchApply={onSqlSearchApply}
onFilterBuilderQueryApply={onFilterBuilderQueryApply}
currentStream={currentStream || ''}
queryEngine={queryEngine}
savedFilterId={savedFilterId}
isStoredAndCurrentTimeRangeAreSame={isStoredAndCurrentTimeRangeAreSame}
hardRefresh={hardRefresh}
Expand Down
7 changes: 2 additions & 5 deletions src/pages/Stream/components/Querier/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const QuerierModal = (props: {
onFiltersApply: () => void;
}) => {
const [currentStream] = useAppStore((store) => store.currentStream);
const [queryEngine] = useAppStore((store) => store.instanceConfig?.queryEngine);
const [{ showQueryBuilder, viewMode }, setLogsStore] = useLogsStore((store) => store.custQuerySearchState);
const [streamInfo] = useStreamStore((store) => store.info);
const [timeRange] = useAppStore((store) => store.timeRange);
Expand All @@ -87,13 +86,12 @@ const QuerierModal = (props: {

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 (
<Modal
Expand Down Expand Up @@ -126,7 +124,6 @@ const Querier = () => {
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));
Expand Down Expand Up @@ -160,7 +157,7 @@ const Querier = () => {
if (!currentStream) return;

const { isUncontrolled } = opts || {};
const { parsedQuery } = parseQuery(queryEngine, query, currentStream, {
const { parsedQuery } = parseQuery(query, currentStream, {
startTime,
endTime,
timePartitionColumn,
Expand Down
3 changes: 1 addition & 2 deletions src/pages/Stream/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const Stream: FC = () => {
const { isStoreSynced } = useParamsController();
const [maximized] = useAppStore((store) => store.maximized);
const [instanceConfig] = useAppStore((store) => store.instanceConfig);
const queryEngine = instanceConfig?.queryEngine;
const [, setStreamStore] = useStreamStore((store) => store.sideBarOpen);
const { getStreamInfoRefetch, getStreamInfoLoading, getStreamInfoRefetching } = useGetStreamInfo(
currentStream || '',
Expand All @@ -70,7 +69,7 @@ const Stream: FC = () => {
useEffect(() => {
if (isStoreSynced) {
if (!_.isEmpty(currentStream)) {
if (view === 'explore' && queryEngine && queryEngine !== 'Parseable') {
if (view === 'explore') {
setStreamStore(streamChangeCleanup);
getStreamInfoRefetch();
} else {
Expand Down
4 changes: 0 additions & 4 deletions src/pages/Stream/providers/FilterProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { FilterQueryBuilder } from '@/utils/queryBuilder';
import { Field, RuleGroupType, RuleType, formatQuery } from 'react-querybuilder';
import { LOAD_LIMIT } from './LogsProvider';
import { timeRangeSQLCondition } from '@/api/query';
import { QueryEngineType } from '@/@types/parseable/api/about';

// write transformer (for saved filters) if you are updating the operators below
export const textFieldOperators = [
Expand Down Expand Up @@ -136,7 +135,6 @@ type FilterStoreReducers = {
updateRule: (store: FilterStore, groupId: string, ruleId: string, updateOpts: RuleUpdateOpts) => ReducerOutput;
updateQuery: (store: FilterStore, query: QueryType) => ReducerOutput;
parseQuery: (
queryEngine: 'Parseable' | 'Trino' | undefined,
query: QueryType,
currentStream: string,
timeRangeOpts?: { startTime: Date; endTime: Date; timePartitionColumn: string },
Expand Down Expand Up @@ -275,7 +273,6 @@ const toggleSubmitBtn = (_store: FilterStore, val: boolean) => {

// todo - custom rule processor to prevent converting number strings into numbers for text fields
const parseQuery = (
queryEngine: QueryEngineType,
query: QueryType,
currentStream: string,
timeRangeOpts?: { startTime: Date; endTime: Date; timePartitionColumn: string },
Expand All @@ -287,7 +284,6 @@ const parseQuery = (
: '(1=1)';

const filterQueryBuilder = new FilterQueryBuilder({
queryEngine,
streamName: currentStream,
whereClause: where,
timeRangeCondition,
Expand Down
Loading

0 comments on commit 70e979d

Please sign in to comment.