From aca62414cfdb987f91d821845231da807c02fedc Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 8 Aug 2025 17:11:55 +0000 Subject: [PATCH 01/14] latest --- .../Presto/PrestoResultsVirtualTable.tsx | 46 ++++++++++++++++++ .../SearchResultsTable/Presto/typings.tsx | 35 ++++++++++++++ .../Presto/usePrestoSearchResults.ts | 48 +++++++++++++++++++ .../SearchResultsVirtualTable.tsx | 48 +++++++++++++++++++ .../SearchResultsTable/index.tsx | 39 +++++---------- .../src/routes/api/presto-search/typings.ts | 0 .../src/routes/api/presto-search/utils.ts | 4 +- 7 files changed, 192 insertions(+), 28 deletions(-) create mode 100644 components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx create mode 100644 components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/typings.tsx create mode 100644 components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts create mode 100644 components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable.tsx create mode 100644 components/webui/server/src/routes/api/presto-search/typings.ts diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx new file mode 100644 index 0000000000..89e99b9650 --- /dev/null +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx @@ -0,0 +1,46 @@ +import {useEffect} from "react"; + +import VirtualTable from "../../../../../components/VirtualTable"; +import useSearchStore from "../../../SearchState/index"; +import { + getPrestoSearchResultsTableColumns, + PrestoSearchResult, +} from "./typings"; +import {usePrestoSearchResults} from "./usePrestoSearchResults"; + + +interface PrestoResultsVirtualTableProps { + tableHeight: number; +} + +/** + * Renders Presto search results in a virtual table. + * + * @param props + * @param props.tableHeight + * @return + */ +const PrestoResultsVirtualTable = ({tableHeight}: PrestoResultsVirtualTableProps) => { + const {updateNumSearchResultsTable} = useSearchStore(); + const prestoSearchResults = usePrestoSearchResults(); + + useEffect(() => { + const num = prestoSearchResults ? + prestoSearchResults.length : + 0; + + updateNumSearchResultsTable(num); + }, [prestoSearchResults, + updateNumSearchResultsTable]); + + return ( + + columns={getPrestoSearchResultsTableColumns(prestoSearchResults || [])} + dataSource={prestoSearchResults || []} + pagination={false} + rowKey={(record) => record._id} + scroll={{y: tableHeight}}/> + ); +}; + +export default PrestoResultsVirtualTable; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/typings.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/typings.tsx new file mode 100644 index 0000000000..f55a1d7a36 --- /dev/null +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/typings.tsx @@ -0,0 +1,35 @@ +import {TableProps} from "antd"; + + +/** + * Structure of Presto search results data (dynamic properties). + */ +interface PrestoSearchResult { + _id: string; + row: Record; +} + +/** + * Columns configuration for Presto query engine (dynamic based on data). + * + * @param data Array of Presto search results + * @return + */ +const getPrestoSearchResultsTableColumns = ( + data: PrestoSearchResult[] +): NonNullable["columns"]> => { + if (0 === data.length || "undefined" === typeof data[0] || "undefined" === typeof data[0].row) { + return []; + } + + return Object.keys(data[0].row) + .map((key) => ({ + dataIndex: ["row", + key], + key: key, + title: key, + })); +}; + +export type {PrestoSearchResult}; +export {getPrestoSearchResultsTableColumns}; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts new file mode 100644 index 0000000000..5dd75beb1e --- /dev/null +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts @@ -0,0 +1,48 @@ +import MongoSocketCollection from "../../../../../api/socket/MongoSocketCollection"; +import {useCursor} from "../../../../../api/socket/useCursor"; +import useSearchStore, {SEARCH_STATE_DEFAULT} from "../../../SearchState/index"; +import {SEARCH_MAX_NUM_RESULTS} from "../typings"; +import {PrestoSearchResult} from "./typings"; + + +/** + * Custom hook to get Presto search results for the current searchJobId. + * + * @return + */ +const usePrestoSearchResults = () => { + const {searchJobId} = useSearchStore(); + + const searchResultsCursor = useCursor( + () => { + // If there is no active search job, there are no results to fetch. The cursor will + // return null. + if (searchJobId === SEARCH_STATE_DEFAULT.searchJobId) { + return null; + } + + console.log( + `Subscribing to updates to Presto search results with job ID: ${searchJobId}` + ); + + // Retrieve 1k most recent results. + const options = { + sort: [ + [ + "_id", + "desc", + ], + ], + limit: SEARCH_MAX_NUM_RESULTS, + }; + + const collection = new MongoSocketCollection(searchJobId.toString()); + return collection.find({}, options); + }, + [searchJobId] + ); + + return searchResultsCursor; +}; + +export {usePrestoSearchResults}; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable.tsx new file mode 100644 index 0000000000..5e1967068d --- /dev/null +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable.tsx @@ -0,0 +1,48 @@ +import {useEffect} from "react"; + +import VirtualTable from "../../../../components/VirtualTable"; +import useSearchStore from "../../SearchState/index"; +import { + SearchResult, + searchResultsTableColumns, +} from "./typings"; +import {useSearchResults} from "./useSearchResults"; + + +interface SearchResultsVirtualTableProps { + tableHeight: number; +} + +/** + * Renders search results in a virtual table. + * + * @param props + * @param props.tableHeight + * @return + */ +const SearchResultsVirtualTable = ({tableHeight}: SearchResultsVirtualTableProps) => { + const {updateNumSearchResultsTable} = useSearchStore(); + const searchResults = useSearchResults(); + + useEffect(() => { + const num = searchResults ? + searchResults.length : + 0; + + updateNumSearchResultsTable(num); + }, [ + searchResults, + updateNumSearchResultsTable, + ]); + + return ( + + columns={searchResultsTableColumns} + dataSource={searchResults || []} + pagination={false} + rowKey={(record) => record._id.toString()} + scroll={{y: tableHeight}}/> + ); +}; + +export default SearchResultsVirtualTable; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/index.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/index.tsx index ffc81b0c50..5cdfcf6841 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/index.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/index.tsx @@ -4,14 +4,13 @@ import { useState, } from "react"; -import VirtualTable from "../../../../components/VirtualTable"; -import useSearchStore from "../../SearchState/index"; import { - SearchResult, - searchResultsTableColumns, - TABLE_BOTTOM_PADDING, -} from "./typings"; -import {useSearchResults} from "./useSearchResults"; + CLP_QUERY_ENGINES, + SETTINGS_QUERY_ENGINE, +} from "../../../../config"; +import PrestoResultsVirtualTable from "./Presto/PrestoResultsVirtualTable"; +import SearchResultsVirtualTable from "./SearchResultsVirtualTable"; +import {TABLE_BOTTOM_PADDING} from "./typings"; /** @@ -20,22 +19,9 @@ import {useSearchResults} from "./useSearchResults"; * @return */ const SearchResultsTable = () => { - const {updateNumSearchResultsTable} = useSearchStore(); - const searchResults = useSearchResults(); const [tableHeight, setTableHeight] = useState(0); const containerRef = useRef(null); - useEffect(() => { - const num = searchResults ? - searchResults.length : - 0; - - updateNumSearchResultsTable(num); - }, [ - searchResults, - updateNumSearchResultsTable, - ]); - // Antd table requires a fixed height for virtual scrolling. The effect sets a fixed height // based on the window height, container top, and fixed padding. useEffect(() => { @@ -60,12 +46,13 @@ const SearchResultsTable = () => { ref={containerRef} style={{outline: "none"}} > - - columns={searchResultsTableColumns} - dataSource={searchResults || []} - pagination={false} - rowKey={(record) => record._id.toString()} - scroll={{y: tableHeight}}/> + {CLP_QUERY_ENGINES.PRESTO === SETTINGS_QUERY_ENGINE ? + ( + + ) : + ( + + )} ); }; diff --git a/components/webui/server/src/routes/api/presto-search/typings.ts b/components/webui/server/src/routes/api/presto-search/typings.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/components/webui/server/src/routes/api/presto-search/utils.ts b/components/webui/server/src/routes/api/presto-search/utils.ts index 58daa27434..dc8b876b6f 100644 --- a/components/webui/server/src/routes/api/presto-search/utils.ts +++ b/components/webui/server/src/routes/api/presto-search/utils.ts @@ -21,7 +21,7 @@ const prestoRowToObject = ( obj[col.name] = row[idx]; }); - return obj; + return { row: obj }; }; /** @@ -38,7 +38,7 @@ const insertPrestoRowsToMongo = ( columns: {name: string}[], searchJobId: string, mongoDb: Db -): Promise> => { +): Promise => { const collection = mongoDb.collection(searchJobId); const resultDocs = data.map((row) => prestoRowToObject(row, columns)); return collection.insertMany(resultDocs); From 5eea062b782e1d1ac4b7b83b2ff254c183d0422f Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 8 Aug 2025 17:15:23 +0000 Subject: [PATCH 02/14] latest --- .../SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx | 6 ++++-- .../webui/server/src/routes/api/presto-search/typings.ts | 0 2 files changed, 4 insertions(+), 2 deletions(-) delete mode 100644 components/webui/server/src/routes/api/presto-search/typings.ts diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx index 89e99b9650..2f4406e333 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx @@ -30,8 +30,10 @@ const PrestoResultsVirtualTable = ({tableHeight}: PrestoResultsVirtualTableProps 0; updateNumSearchResultsTable(num); - }, [prestoSearchResults, - updateNumSearchResultsTable]); + }, [ + prestoSearchResults, + updateNumSearchResultsTable + ]); return ( diff --git a/components/webui/server/src/routes/api/presto-search/typings.ts b/components/webui/server/src/routes/api/presto-search/typings.ts deleted file mode 100644 index e69de29bb2..0000000000 From d23ba775ed06fa9a38a19b4c9b611155aa3e1976 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 8 Aug 2025 17:30:08 +0000 Subject: [PATCH 03/14] latest --- .../SearchPage/SearchControls/Presto/presto-search-requests.ts | 3 +++ .../SearchPage/SearchResults/SearchResultsTable/typings.tsx | 2 +- components/webui/server/src/routes/api/presto-search/index.ts | 2 ++ components/webui/server/src/routes/api/presto-search/utils.ts | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts b/components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts index a42e4110d1..40455b43ea 100644 --- a/components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts +++ b/components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts @@ -2,6 +2,7 @@ import { type PrestoQueryJobCreationSchema, submitQuery, } from "../../../../api/presto-search"; +import useSearchStore from "../../SearchState/"; /** @@ -10,9 +11,11 @@ import { * @param payload */ const handlePrestoQuerySubmit = (payload: PrestoQueryJobCreationSchema) => { + const store = useSearchStore.getState(); submitQuery(payload) .then((result) => { const {searchJobId} = result.data; + store.updateSearchJobId(searchJobId); console.debug( "Presto search job created - ", "Search job ID:", diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx index 495d3e050a..04560d0aca 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx @@ -25,7 +25,7 @@ interface SearchResult { } /** - * Columns configuration for the seach results table. + * Columns configuration for the search results table. */ const searchResultsTableColumns: NonNullable["columns"]> = [ { diff --git a/components/webui/server/src/routes/api/presto-search/index.ts b/components/webui/server/src/routes/api/presto-search/index.ts index 0517e00bf3..d5435a2fc0 100644 --- a/components/webui/server/src/routes/api/presto-search/index.ts +++ b/components/webui/server/src/routes/api/presto-search/index.ts @@ -115,6 +115,8 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => { throw error; } + await mongoDb.createCollection(searchJobId.toString()); + reply.code(StatusCodes.CREATED); return {searchJobId}; diff --git a/components/webui/server/src/routes/api/presto-search/utils.ts b/components/webui/server/src/routes/api/presto-search/utils.ts index dc8b876b6f..a09a574248 100644 --- a/components/webui/server/src/routes/api/presto-search/utils.ts +++ b/components/webui/server/src/routes/api/presto-search/utils.ts @@ -21,7 +21,7 @@ const prestoRowToObject = ( obj[col.name] = row[idx]; }); - return { row: obj }; + return {row: obj}; }; /** From af59d56d430937324495e87574559b5b94434736 Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 11 Aug 2025 14:00:59 +0000 Subject: [PATCH 04/14] latest --- .../Presto/PrestoResultsVirtualTable.tsx | 14 +++++++++++--- .../SearchResultsTable/Presto/typings.tsx | 4 ++-- .../Presto/usePrestoSearchResults.ts | 2 +- .../server/src/routes/api/presto-search/index.ts | 2 +- .../server/src/routes/api/presto-search/utils.ts | 1 + 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx index 2f4406e333..419569cb68 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx @@ -1,4 +1,7 @@ -import {useEffect} from "react"; +import { + useEffect, + useMemo, +} from "react"; import VirtualTable from "../../../../../components/VirtualTable"; import useSearchStore from "../../../SearchState/index"; @@ -24,6 +27,11 @@ const PrestoResultsVirtualTable = ({tableHeight}: PrestoResultsVirtualTableProps const {updateNumSearchResultsTable} = useSearchStore(); const prestoSearchResults = usePrestoSearchResults(); + const columns = useMemo( + () => getPrestoSearchResultsTableColumns(prestoSearchResults || []), + [prestoSearchResults] + ); + useEffect(() => { const num = prestoSearchResults ? prestoSearchResults.length : @@ -32,12 +40,12 @@ const PrestoResultsVirtualTable = ({tableHeight}: PrestoResultsVirtualTableProps updateNumSearchResultsTable(num); }, [ prestoSearchResults, - updateNumSearchResultsTable + updateNumSearchResultsTable, ]); return ( - columns={getPrestoSearchResultsTableColumns(prestoSearchResults || [])} + columns={columns} dataSource={prestoSearchResults || []} pagination={false} rowKey={(record) => record._id} diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/typings.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/typings.tsx index f55a1d7a36..c46f50861e 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/typings.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/typings.tsx @@ -2,7 +2,7 @@ import {TableProps} from "antd"; /** - * Structure of Presto search results data (dynamic properties). + * Structure of dynamic Presto search results data. */ interface PrestoSearchResult { _id: string; @@ -10,7 +10,7 @@ interface PrestoSearchResult { } /** - * Columns configuration for Presto query engine (dynamic based on data). + * Generates dynamic columns configuration for Presto query engine. * * @param data Array of Presto search results * @return diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts index 5dd75beb1e..8381ef0279 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts @@ -11,7 +11,7 @@ import {PrestoSearchResult} from "./typings"; * @return */ const usePrestoSearchResults = () => { - const {searchJobId} = useSearchStore(); + const searchJobId = useSearchStore((state) => state.searchJobId); const searchResultsCursor = useCursor( () => { diff --git a/components/webui/server/src/routes/api/presto-search/index.ts b/components/webui/server/src/routes/api/presto-search/index.ts index d5435a2fc0..5e7e3e29c8 100644 --- a/components/webui/server/src/routes/api/presto-search/index.ts +++ b/components/webui/server/src/routes/api/presto-search/index.ts @@ -115,7 +115,7 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => { throw error; } - await mongoDb.createCollection(searchJobId.toString()); + await mongoDb.createCollection(searchJobId); reply.code(StatusCodes.CREATED); diff --git a/components/webui/server/src/routes/api/presto-search/utils.ts b/components/webui/server/src/routes/api/presto-search/utils.ts index a09a574248..1cd06cca51 100644 --- a/components/webui/server/src/routes/api/presto-search/utils.ts +++ b/components/webui/server/src/routes/api/presto-search/utils.ts @@ -21,6 +21,7 @@ const prestoRowToObject = ( obj[col.name] = row[idx]; }); + // Object is wrapped in a `row` property to prevent conflicts with MongoDB's `_id` field. return {row: obj}; }; From e969603afca83a5b3600205f8226558155082a69 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 12 Aug 2025 17:24:40 +0000 Subject: [PATCH 05/14] latest --- .../index.tsx} | 12 +++++------ .../PrestoResultsVirtualTable/typings.tsx | 11 ++++++++++ .../Presto/usePrestoSearchResults.ts | 6 +++--- .../Presto/{typings.tsx => utils.ts} | 9 +------- .../index.tsx} | 6 +++--- .../typings.tsx | 21 ++++--------------- .../SearchResultsTable/typings.ts | 14 +++++++++++++ .../SearchResultsTable/useSearchResults.ts | 2 +- .../SearchResults/SearchResultsTable/utils.ts | 2 +- 9 files changed, 43 insertions(+), 40 deletions(-) rename components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/{PrestoResultsVirtualTable.tsx => PrestoResultsVirtualTable/index.tsx} (79%) create mode 100644 components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.tsx rename components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/{typings.tsx => utils.ts} (78%) rename components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/{SearchResultsVirtualTable.tsx => SearchResultsVirtualTable/index.tsx} (85%) rename components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/{ => SearchResultsVirtualTable}/typings.tsx (81%) create mode 100644 components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.ts diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx similarity index 79% rename from components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx rename to components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx index 419569cb68..49655cf3dd 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx @@ -3,13 +3,11 @@ import { useMemo, } from "react"; -import VirtualTable from "../../../../../components/VirtualTable"; -import useSearchStore from "../../../SearchState/index"; -import { - getPrestoSearchResultsTableColumns, - PrestoSearchResult, -} from "./typings"; -import {usePrestoSearchResults} from "./usePrestoSearchResults"; +import VirtualTable from "../../../../../../components/VirtualTable"; +import useSearchStore from "../../../../SearchState/index"; +import {PrestoSearchResult} from "./typings"; +import {getPrestoSearchResultsTableColumns} from "../utils"; +import {usePrestoSearchResults} from "../usePrestoSearchResults"; interface PrestoResultsVirtualTableProps { diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.tsx new file mode 100644 index 0000000000..f3fc277c55 --- /dev/null +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.tsx @@ -0,0 +1,11 @@ + +/** + * Structure of dynamic Presto search results data. + */ +interface PrestoSearchResult { + _id: string; + row: Record; +} + +export type {PrestoSearchResult}; +export {getPrestoSearchResultsTableColumns} from "../utils"; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts index 8381ef0279..4e1e1a8014 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts @@ -1,8 +1,8 @@ import MongoSocketCollection from "../../../../../api/socket/MongoSocketCollection"; import {useCursor} from "../../../../../api/socket/useCursor"; import useSearchStore, {SEARCH_STATE_DEFAULT} from "../../../SearchState/index"; -import {SEARCH_MAX_NUM_RESULTS} from "../typings"; -import {PrestoSearchResult} from "./typings"; +import {SEARCH_MAX_NUM_RESULTS} from "../SearchResultsVirtualTable/typings"; +import {PrestoSearchResult} from "./PrestoResultsVirtualTable/typings"; /** @@ -36,7 +36,7 @@ const usePrestoSearchResults = () => { limit: SEARCH_MAX_NUM_RESULTS, }; - const collection = new MongoSocketCollection(searchJobId.toString()); + const collection = new MongoSocketCollection(searchJobId); return collection.find({}, options); }, [searchJobId] diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/typings.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/utils.ts similarity index 78% rename from components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/typings.tsx rename to components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/utils.ts index c46f50861e..92c768055b 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/typings.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/utils.ts @@ -1,13 +1,7 @@ import {TableProps} from "antd"; +import {PrestoSearchResult} from "./PrestoResultsVirtualTable/typings"; -/** - * Structure of dynamic Presto search results data. - */ -interface PrestoSearchResult { - _id: string; - row: Record; -} /** * Generates dynamic columns configuration for Presto query engine. @@ -31,5 +25,4 @@ const getPrestoSearchResultsTableColumns = ( })); }; -export type {PrestoSearchResult}; export {getPrestoSearchResultsTableColumns}; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/index.tsx similarity index 85% rename from components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable.tsx rename to components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/index.tsx index 5e1967068d..cc3d788ec8 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/index.tsx @@ -1,12 +1,12 @@ import {useEffect} from "react"; -import VirtualTable from "../../../../components/VirtualTable"; -import useSearchStore from "../../SearchState/index"; +import VirtualTable from "../../../../../components/VirtualTable"; +import useSearchStore from "../../../SearchState/index"; import { SearchResult, searchResultsTableColumns, } from "./typings"; -import {useSearchResults} from "./useSearchResults"; +import {useSearchResults} from "../useSearchResults"; interface SearchResultsVirtualTableProps { diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/typings.tsx similarity index 81% rename from components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx rename to components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/typings.tsx index 04560d0aca..aefaa876b6 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/typings.tsx @@ -1,13 +1,13 @@ import {TableProps} from "antd"; import dayjs from "dayjs"; -import {DATETIME_FORMAT_TEMPLATE} from "../../../../typings/datetime"; +import {DATETIME_FORMAT_TEMPLATE} from "../../../../../typings/datetime"; import { CLP_STORAGE_ENGINES, SETTINGS_STORAGE_ENGINE, -} from ".././../../../config"; -import Message from "./Message"; -import {getStreamId} from "./utils"; +} from "../../../../../config"; +import Message from "../Message"; +import {getStreamId} from "../utils"; /** @@ -70,20 +70,7 @@ const searchResultsTableColumns: NonNullable["columns"] }, ]; -/** - * Padding for the table to the bottom of the page. - */ -const TABLE_BOTTOM_PADDING = 75; - -/** - * The maximum number of results to retrieve for a search. - */ -const SEARCH_MAX_NUM_RESULTS = 1000; - - export type {SearchResult}; export { - SEARCH_MAX_NUM_RESULTS, searchResultsTableColumns, - TABLE_BOTTOM_PADDING, }; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.ts new file mode 100644 index 0000000000..f23975edfc --- /dev/null +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.ts @@ -0,0 +1,14 @@ +/** + * Padding for the table to the bottom of the page. + */ +const TABLE_BOTTOM_PADDING = 75; + +/** + * The maximum number of results to retrieve for a search. + */ +const SEARCH_MAX_NUM_RESULTS = 1000; + +export { + SEARCH_MAX_NUM_RESULTS, + TABLE_BOTTOM_PADDING, +}; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/useSearchResults.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/useSearchResults.ts index e148ee91a5..31cfcf441b 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/useSearchResults.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/useSearchResults.ts @@ -4,7 +4,7 @@ import useSearchStore, {SEARCH_STATE_DEFAULT} from "../../SearchState/index"; import { SEARCH_MAX_NUM_RESULTS, SearchResult, -} from "./typings"; +} from "./SearchResultsVirtualTable/typings"; /** diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/utils.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/utils.ts index 071fb42800..3aa3cf6072 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/utils.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/utils.ts @@ -2,7 +2,7 @@ import { CLP_STORAGE_ENGINES, SETTINGS_STORAGE_ENGINE, } from "../../../../config"; -import type {SearchResult} from "./typings"; +import type {SearchResult} from "./SearchResultsVirtualTable/typings"; /** From d8bc69b80b9a8aa15a9ec7d50c5c07fac74307c2 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 12 Aug 2025 17:51:20 +0000 Subject: [PATCH 06/14] latest --- .../Presto/PrestoResultsVirtualTable/index.tsx | 4 ++-- .../Presto/PrestoResultsVirtualTable/typings.tsx | 6 ++++-- .../usePrestoSearchResults.ts | 10 +++++----- .../Presto/{ => PrestoResultsVirtualTable}/utils.ts | 5 +++-- .../SearchResultsVirtualTable/index.tsx | 2 +- .../SearchResultsVirtualTable/typings.tsx | 6 ++---- .../useSearchResults.ts | 12 +++++------- components/webui/common/index.ts | 6 ++++++ components/webui/server/src/plugins/app/Presto.ts | 5 +++-- .../server/src/routes/api/presto-search/utils.ts | 4 +++- 10 files changed, 34 insertions(+), 26 deletions(-) rename components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/{ => PrestoResultsVirtualTable}/usePrestoSearchResults.ts (75%) rename components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/{ => PrestoResultsVirtualTable}/utils.ts (79%) rename components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/{ => SearchResultsVirtualTable}/useSearchResults.ts (79%) diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx index 49655cf3dd..6e70d29aad 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx @@ -6,8 +6,8 @@ import { import VirtualTable from "../../../../../../components/VirtualTable"; import useSearchStore from "../../../../SearchState/index"; import {PrestoSearchResult} from "./typings"; -import {getPrestoSearchResultsTableColumns} from "../utils"; -import {usePrestoSearchResults} from "../usePrestoSearchResults"; +import {usePrestoSearchResults} from "./usePrestoSearchResults"; +import {getPrestoSearchResultsTableColumns} from "./utils"; interface PrestoResultsVirtualTableProps { diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.tsx index f3fc277c55..56906d468f 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.tsx @@ -1,11 +1,13 @@ +import {PRESTO_DATA_PROPERTY} from "../../../../../../../../common"; + /** * Structure of dynamic Presto search results data. */ interface PrestoSearchResult { _id: string; - row: Record; + [PRESTO_DATA_PROPERTY]: Record; } export type {PrestoSearchResult}; -export {getPrestoSearchResultsTableColumns} from "../utils"; +export {getPrestoSearchResultsTableColumns} from "./utils"; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/usePrestoSearchResults.ts similarity index 75% rename from components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts rename to components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/usePrestoSearchResults.ts index 4e1e1a8014..44e6b88bd4 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/usePrestoSearchResults.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/usePrestoSearchResults.ts @@ -1,8 +1,8 @@ -import MongoSocketCollection from "../../../../../api/socket/MongoSocketCollection"; -import {useCursor} from "../../../../../api/socket/useCursor"; -import useSearchStore, {SEARCH_STATE_DEFAULT} from "../../../SearchState/index"; -import {SEARCH_MAX_NUM_RESULTS} from "../SearchResultsVirtualTable/typings"; -import {PrestoSearchResult} from "./PrestoResultsVirtualTable/typings"; +import MongoSocketCollection from "../../../../../../api/socket/MongoSocketCollection"; +import {useCursor} from "../../../../../../api/socket/useCursor"; +import useSearchStore, {SEARCH_STATE_DEFAULT} from "../../../../SearchState/index"; +import {SEARCH_MAX_NUM_RESULTS} from "../../typings"; +import {PrestoSearchResult} from "./typings"; /** diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/utils.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts similarity index 79% rename from components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/utils.ts rename to components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts index 92c768055b..cad88a8da3 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/utils.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts @@ -1,6 +1,7 @@ import {TableProps} from "antd"; -import {PrestoSearchResult} from "./PrestoResultsVirtualTable/typings"; +import {PRESTO_DATA_PROPERTY} from "../../../../../../../../common"; +import {PrestoSearchResult} from "./typings"; /** @@ -18,7 +19,7 @@ const getPrestoSearchResultsTableColumns = ( return Object.keys(data[0].row) .map((key) => ({ - dataIndex: ["row", + dataIndex: [PRESTO_DATA_PROPERTY, key], key: key, title: key, diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/index.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/index.tsx index cc3d788ec8..e0e4e97f26 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/index.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/index.tsx @@ -6,7 +6,7 @@ import { SearchResult, searchResultsTableColumns, } from "./typings"; -import {useSearchResults} from "../useSearchResults"; +import {useSearchResults} from "./useSearchResults"; interface SearchResultsVirtualTableProps { diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/typings.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/typings.tsx index aefaa876b6..1ee1971a50 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/typings.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/typings.tsx @@ -1,11 +1,11 @@ import {TableProps} from "antd"; import dayjs from "dayjs"; -import {DATETIME_FORMAT_TEMPLATE} from "../../../../../typings/datetime"; import { CLP_STORAGE_ENGINES, SETTINGS_STORAGE_ENGINE, } from "../../../../../config"; +import {DATETIME_FORMAT_TEMPLATE} from "../../../../../typings/datetime"; import Message from "../Message"; import {getStreamId} from "../utils"; @@ -71,6 +71,4 @@ const searchResultsTableColumns: NonNullable["columns"] ]; export type {SearchResult}; -export { - searchResultsTableColumns, -}; +export {searchResultsTableColumns}; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/useSearchResults.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/useSearchResults.ts similarity index 79% rename from components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/useSearchResults.ts rename to components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/useSearchResults.ts index 31cfcf441b..69375c2e23 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/useSearchResults.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/SearchResultsVirtualTable/useSearchResults.ts @@ -1,10 +1,8 @@ -import MongoSocketCollection from "../../../../api/socket/MongoSocketCollection"; -import {useCursor} from "../../../../api/socket/useCursor"; -import useSearchStore, {SEARCH_STATE_DEFAULT} from "../../SearchState/index"; -import { - SEARCH_MAX_NUM_RESULTS, - SearchResult, -} from "./SearchResultsVirtualTable/typings"; +import MongoSocketCollection from "../../../../../api/socket/MongoSocketCollection"; +import {useCursor} from "../../../../../api/socket/useCursor"; +import useSearchStore, {SEARCH_STATE_DEFAULT} from "../../../SearchState/index"; +import {SEARCH_MAX_NUM_RESULTS} from "../typings"; +import {SearchResult} from "./typings"; /** diff --git a/components/webui/common/index.ts b/components/webui/common/index.ts index 55d08bdbf4..3750f1d1da 100644 --- a/components/webui/common/index.ts +++ b/components/webui/common/index.ts @@ -106,6 +106,11 @@ type PRESTO_SEARCH_SIGNAL = | "CANCELED" | "FAILED"; +/** + * Property name used to wrap result objects to prevent conflicts with MongoDB's _id field. + */ +const PRESTO_DATA_PROPERTY = "row"; + /** * CLP query engines. */ @@ -131,6 +136,7 @@ interface SearchResultsMetadataDocument { } export { CLP_QUERY_ENGINES, + PRESTO_DATA_PROPERTY, SEARCH_SIGNAL, }; export type { diff --git a/components/webui/server/src/plugins/app/Presto.ts b/components/webui/server/src/plugins/app/Presto.ts index dd6ccf31be..5aea097c69 100644 --- a/components/webui/server/src/plugins/app/Presto.ts +++ b/components/webui/server/src/plugins/app/Presto.ts @@ -4,6 +4,7 @@ import { ClientOptions, } from "presto-client"; +import {CLP_QUERY_ENGINES} from "../../../../common/index.js"; import settings from "../../../settings.json" with {type: "json"}; @@ -29,7 +30,7 @@ declare module "fastify" { export default fp( (fastify) => { - if ("presto" !== settings.ClpQueryEngine) { + if (CLP_QUERY_ENGINES.PRESTO !== settings.ClpQueryEngine as CLP_QUERY_ENGINES) { return; } @@ -40,7 +41,7 @@ export default fp( fastify.log.info( clientOptions, - "Initializing Presto" + "Initializing Presto client" ); fastify.decorate("Presto", new Presto(clientOptions)); }, diff --git a/components/webui/server/src/routes/api/presto-search/utils.ts b/components/webui/server/src/routes/api/presto-search/utils.ts index 1cd06cca51..915ac19019 100644 --- a/components/webui/server/src/routes/api/presto-search/utils.ts +++ b/components/webui/server/src/routes/api/presto-search/utils.ts @@ -3,6 +3,8 @@ import type { InsertManyResult, } from "mongodb"; +import {PRESTO_DATA_PROPERTY} from "../../../../../common/index.js"; + /** * Converts a Presto result row (array of values) into an object, using the provided column @@ -22,7 +24,7 @@ const prestoRowToObject = ( }); // Object is wrapped in a `row` property to prevent conflicts with MongoDB's `_id` field. - return {row: obj}; + return {[PRESTO_DATA_PROPERTY]: obj}; }; /** From 3c639fb1ae6bb72e1392ce503e967b537a27dc67 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 12 Aug 2025 21:13:41 +0000 Subject: [PATCH 07/14] latest --- .../Presto/PrestoResultsVirtualTable/utils.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts index cad88a8da3..cec15f34ed 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts @@ -13,13 +13,17 @@ import {PrestoSearchResult} from "./typings"; const getPrestoSearchResultsTableColumns = ( data: PrestoSearchResult[] ): NonNullable["columns"]> => { - if (0 === data.length || "undefined" === typeof data[0] || "undefined" === typeof data[0].row) { + if (0 === data.length || + "undefined" === typeof data[0] || + "undefined" === typeof data[0][PRESTO_DATA_PROPERTY] + ) { return []; } return Object.keys(data[0].row) .map((key) => ({ - dataIndex: [PRESTO_DATA_PROPERTY, + dataIndex: [ + PRESTO_DATA_PROPERTY, key], key: key, title: key, From db8e2eb5f465de0e6243a9ca695ada84d0e19909 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 13 Aug 2025 15:30:48 +0000 Subject: [PATCH 08/14] fix lint --- .../Presto/PrestoResultsVirtualTable/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts index cec15f34ed..00b7b9ea41 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts @@ -24,7 +24,8 @@ const getPrestoSearchResultsTableColumns = ( .map((key) => ({ dataIndex: [ PRESTO_DATA_PROPERTY, - key], + key, + ], key: key, title: key, })); From 4e055f52318c028c761f0ff5bc2dec135e9e2e5f Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 13 Aug 2025 21:10:14 +0000 Subject: [PATCH 09/14] latest --- .../Presto/PrestoResultsVirtualTable/typings.tsx | 5 +---- .../Presto/PrestoResultsVirtualTable/utils.ts | 6 ++---- components/webui/common/index.ts | 6 ------ .../webui/server/src/routes/api/presto-search/utils.ts | 4 +--- 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.tsx index 56906d468f..28e7da748d 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.tsx @@ -1,12 +1,9 @@ -import {PRESTO_DATA_PROPERTY} from "../../../../../../../../common"; - - /** * Structure of dynamic Presto search results data. */ interface PrestoSearchResult { _id: string; - [PRESTO_DATA_PROPERTY]: Record; + row: Record; } export type {PrestoSearchResult}; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts index 00b7b9ea41..20024ac1fb 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts @@ -1,6 +1,4 @@ import {TableProps} from "antd"; - -import {PRESTO_DATA_PROPERTY} from "../../../../../../../../common"; import {PrestoSearchResult} from "./typings"; @@ -15,7 +13,7 @@ const getPrestoSearchResultsTableColumns = ( ): NonNullable["columns"]> => { if (0 === data.length || "undefined" === typeof data[0] || - "undefined" === typeof data[0][PRESTO_DATA_PROPERTY] + "undefined" === typeof data[0].row ) { return []; } @@ -23,7 +21,7 @@ const getPrestoSearchResultsTableColumns = ( return Object.keys(data[0].row) .map((key) => ({ dataIndex: [ - PRESTO_DATA_PROPERTY, + "row", key, ], key: key, diff --git a/components/webui/common/index.ts b/components/webui/common/index.ts index 3750f1d1da..55d08bdbf4 100644 --- a/components/webui/common/index.ts +++ b/components/webui/common/index.ts @@ -106,11 +106,6 @@ type PRESTO_SEARCH_SIGNAL = | "CANCELED" | "FAILED"; -/** - * Property name used to wrap result objects to prevent conflicts with MongoDB's _id field. - */ -const PRESTO_DATA_PROPERTY = "row"; - /** * CLP query engines. */ @@ -136,7 +131,6 @@ interface SearchResultsMetadataDocument { } export { CLP_QUERY_ENGINES, - PRESTO_DATA_PROPERTY, SEARCH_SIGNAL, }; export type { diff --git a/components/webui/server/src/routes/api/presto-search/utils.ts b/components/webui/server/src/routes/api/presto-search/utils.ts index 915ac19019..1cd06cca51 100644 --- a/components/webui/server/src/routes/api/presto-search/utils.ts +++ b/components/webui/server/src/routes/api/presto-search/utils.ts @@ -3,8 +3,6 @@ import type { InsertManyResult, } from "mongodb"; -import {PRESTO_DATA_PROPERTY} from "../../../../../common/index.js"; - /** * Converts a Presto result row (array of values) into an object, using the provided column @@ -24,7 +22,7 @@ const prestoRowToObject = ( }); // Object is wrapped in a `row` property to prevent conflicts with MongoDB's `_id` field. - return {[PRESTO_DATA_PROPERTY]: obj}; + return {row: obj}; }; /** From 52819375b04dbdf777576b33454b0d0db678e1db Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 13 Aug 2025 21:11:46 +0000 Subject: [PATCH 10/14] latest --- .../Presto/PrestoResultsVirtualTable/{typings.tsx => typings.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/{typings.tsx => typings.ts} (100%) diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.ts similarity index 100% rename from components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.tsx rename to components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.ts From 527cb19275ffb6e3e6cda6e1b2531e8c868bd266 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 13 Aug 2025 21:13:38 +0000 Subject: [PATCH 11/14] latest --- .../Presto/PrestoResultsVirtualTable/typings.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.ts index 28e7da748d..2e1ce76104 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.ts @@ -7,4 +7,3 @@ interface PrestoSearchResult { } export type {PrestoSearchResult}; -export {getPrestoSearchResultsTableColumns} from "./utils"; From 085ba38c9cbff19729d78144077ae417106561a7 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 14 Aug 2025 16:12:50 +0000 Subject: [PATCH 12/14] latest --- .../Presto/PrestoResultsVirtualTable/typings.ts | 6 ++++-- .../Presto/PrestoResultsVirtualTable/utils.ts | 1 + components/webui/common/index.ts | 9 +++++++++ .../webui/server/src/routes/api/presto-search/utils.ts | 3 ++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.ts index 2e1ce76104..1243f18c40 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.ts @@ -1,9 +1,11 @@ +import type {PrestoRowObject} from "../../../../../../../../common/index.js"; + + /** * Structure of dynamic Presto search results data. */ -interface PrestoSearchResult { +interface PrestoSearchResult extends PrestoRowObject { _id: string; - row: Record; } export type {PrestoSearchResult}; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts index 20024ac1fb..c858daffe1 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts @@ -1,4 +1,5 @@ import {TableProps} from "antd"; + import {PrestoSearchResult} from "./typings"; diff --git a/components/webui/common/index.ts b/components/webui/common/index.ts index 55d08bdbf4..e6df44353d 100644 --- a/components/webui/common/index.ts +++ b/components/webui/common/index.ts @@ -129,12 +129,21 @@ interface SearchResultsMetadataDocument { numTotalResults?: number; queryEngine: CLP_QUERY_ENGINES; } + +/** + * Presto row wrapped in a `row` property to prevent conflicts with MongoDB's `_id` field. + */ +interface PrestoRowObject { + row: Record; +} + export { CLP_QUERY_ENGINES, SEARCH_SIGNAL, }; export type { PRESTO_SEARCH_SIGNAL, + PrestoRowObject, SearchResultsMetadataDocument, ClientToServerEvents, Err, diff --git a/components/webui/server/src/routes/api/presto-search/utils.ts b/components/webui/server/src/routes/api/presto-search/utils.ts index 1cd06cca51..7440417e4a 100644 --- a/components/webui/server/src/routes/api/presto-search/utils.ts +++ b/components/webui/server/src/routes/api/presto-search/utils.ts @@ -3,6 +3,7 @@ import type { InsertManyResult, } from "mongodb"; +import type {PrestoRowObject} from "../../../../../common/index.js"; /** * Converts a Presto result row (array of values) into an object, using the provided column @@ -15,7 +16,7 @@ import type { const prestoRowToObject = ( row: unknown[], columns: {name: string}[] -): Record => { +): PrestoRowObject => { const obj: Record = {}; columns.forEach((col, idx) => { obj[col.name] = row[idx]; From 2118902d259f8287e6028a4934f72fa7d3a5ffcd Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 14 Aug 2025 18:38:55 +0000 Subject: [PATCH 13/14] latest --- .../Presto/PrestoResultsVirtualTable/index.tsx | 2 +- .../Presto/PrestoResultsVirtualTable/typings.ts | 11 ----------- .../usePrestoSearchResults.ts | 2 +- .../Presto/PrestoResultsVirtualTable/utils.ts | 2 +- components/webui/common/index.ts | 9 ++++++++- 5 files changed, 11 insertions(+), 15 deletions(-) delete mode 100644 components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.ts diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx index 6e70d29aad..e7455674f0 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx @@ -3,9 +3,9 @@ import { useMemo, } from "react"; +import type {PrestoSearchResult} from "../../../../../../../../common/index.js"; import VirtualTable from "../../../../../../components/VirtualTable"; import useSearchStore from "../../../../SearchState/index"; -import {PrestoSearchResult} from "./typings"; import {usePrestoSearchResults} from "./usePrestoSearchResults"; import {getPrestoSearchResultsTableColumns} from "./utils"; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.ts deleted file mode 100644 index 1243f18c40..0000000000 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/typings.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type {PrestoRowObject} from "../../../../../../../../common/index.js"; - - -/** - * Structure of dynamic Presto search results data. - */ -interface PrestoSearchResult extends PrestoRowObject { - _id: string; -} - -export type {PrestoSearchResult}; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/usePrestoSearchResults.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/usePrestoSearchResults.ts index 44e6b88bd4..0e43b1d242 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/usePrestoSearchResults.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/usePrestoSearchResults.ts @@ -1,8 +1,8 @@ +import type {PrestoSearchResult} from "../../../../../../../../common/index.js"; import MongoSocketCollection from "../../../../../../api/socket/MongoSocketCollection"; import {useCursor} from "../../../../../../api/socket/useCursor"; import useSearchStore, {SEARCH_STATE_DEFAULT} from "../../../../SearchState/index"; import {SEARCH_MAX_NUM_RESULTS} from "../../typings"; -import {PrestoSearchResult} from "./typings"; /** diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts index c858daffe1..5ca3b2cfb6 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts @@ -1,6 +1,6 @@ import {TableProps} from "antd"; -import {PrestoSearchResult} from "./typings"; +import type {PrestoSearchResult} from "../../../../../../../../common/index.js"; /** diff --git a/components/webui/common/index.ts b/components/webui/common/index.ts index d984e0989c..c6efc11857 100644 --- a/components/webui/common/index.ts +++ b/components/webui/common/index.ts @@ -137,14 +137,21 @@ interface PrestoRowObject { row: Record; } +/** + * Presto search result in MongoDB. + */ +interface PrestoSearchResult extends PrestoRowObject { + _id: string; +} + export { CLP_QUERY_ENGINES, PRESTO_SEARCH_SIGNAL, SEARCH_SIGNAL, }; export type { - PRESTO_SEARCH_SIGNAL, PrestoRowObject, + PrestoSearchResult, SearchResultsMetadataDocument, ClientToServerEvents, Err, From 90caa4e895d556da627f30532e4571ce0388192e Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 14 Aug 2025 18:41:25 +0000 Subject: [PATCH 14/14] latest --- components/webui/server/src/routes/api/presto-search/utils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/components/webui/server/src/routes/api/presto-search/utils.ts b/components/webui/server/src/routes/api/presto-search/utils.ts index 7440417e4a..33681f32a9 100644 --- a/components/webui/server/src/routes/api/presto-search/utils.ts +++ b/components/webui/server/src/routes/api/presto-search/utils.ts @@ -5,6 +5,7 @@ import type { import type {PrestoRowObject} from "../../../../../common/index.js"; + /** * Converts a Presto result row (array of values) into an object, using the provided column * definitions to assign property names.