-
Notifications
You must be signed in to change notification settings - Fork 82
feat(webui): Add support for deleting Presto query results. #1187
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
Conversation
WalkthroughAdds a client API to clear Presto query results, invokes it before submitting a new Presto query from the UI, and adds a server DELETE /api/presto-search/results route that drops the MongoDB collection for a given searchJobId. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant UI as WebUI (Presto Controls)
participant CA as Client API (presto-search)
participant S as Server /api/presto-search
participant DB as MongoDB
U->>UI: Submit Presto query
UI->>UI: handlePrestoQuerySubmit()
UI->>UI: handlePrestoClearResults()
UI->>CA: clearQueryResults({ searchJobId })
CA->>S: DELETE /results { searchJobId }
S->>DB: dropCollection(searchJobId)
DB-->>S: result
S-->>CA: 204 No Content
CA-->>UI: success
UI->>CA: submitQuery(...)
CA->>S: POST /submit ...
S-->>CA: response
CA-->>UI: response
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}⚙️ CodeRabbit Configuration File
Files:
🧬 Code Graph Analysis (1)components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (2)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 7
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
components/webui/client/src/api/presto-search/index.ts
(1 hunks)components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts
(4 hunks)components/webui/server/src/routes/api/presto-search/index.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}
⚙️ CodeRabbit Configuration File
- Prefer
false == <expression>
rather than!<expression>
.
Files:
components/webui/client/src/api/presto-search/index.ts
components/webui/server/src/routes/api/presto-search/index.ts
components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts
🧬 Code Graph Analysis (3)
components/webui/client/src/api/presto-search/index.ts (1)
components/webui/server/src/schemas/presto-search.ts (1)
PrestoQueryJobSchema
(22-22)
components/webui/server/src/routes/api/presto-search/index.ts (3)
components/webui/client/src/api/presto-search/index.ts (1)
PrestoQueryJobSchema
(61-61)components/webui/server/src/schemas/presto-search.ts (1)
PrestoQueryJobSchema
(22-22)components/webui/server/src/schemas/error.ts (1)
ErrorSchema
(8-8)
components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts (1)
components/webui/client/src/api/presto-search/index.ts (1)
clearQueryResults
(66-66)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: lint-check (ubuntu-24.04)
components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts
Show resolved
Hide resolved
components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (4)
components/webui/server/src/routes/api/presto-search/index.ts (4)
184-201
: Use a path param instead of a DELETE body for RESTfulness and intermediary compatibilityDELETE requests with bodies can be dropped or mishandled by proxies. Model the resource with a path param and switch schema to params.
Apply this diff:
- fastify.delete( - "/results", + fastify.delete<{ Params: { searchJobId: string } }>( + "/results/:searchJobId", { schema: { - body: PrestoQueryJobSchema, + params: Type.Object({ searchJobId: Type.String() }), response: { [StatusCodes.NO_CONTENT]: Type.Null(), + [StatusCodes.BAD_REQUEST]: ErrorSchema, [StatusCodes.INTERNAL_SERVER_ERROR]: ErrorSchema, }, tags: ["Presto Search"], }, }, - async (request, reply) => { - const {searchJobId} = request.body; + async (request, reply) => { + const {searchJobId} = request.params;
187-193
: Add 400 BAD_REQUEST mapping to document validation failuresYou’ll be adding input validation (see next comment). Reflect that in the OpenAPI response schema.
Apply this diff:
response: { [StatusCodes.NO_CONTENT]: Type.Null(), + [StatusCodes.BAD_REQUEST]: ErrorSchema, [StatusCodes.INTERNAL_SERVER_ERROR]: ErrorSchema, },
197-203
: Validate/sanitise searchJobId to prevent arbitrary collection dropsRight now any collection name can be dropped. Allowlist to alnum/underscore/hyphen and return 400 on failure.
Apply this diff:
async (request, reply) => { - const {searchJobId} = request.body; + const {searchJobId} = request.params; request.log.info({ searchJobId, }, "api/presto-search/results args"); + // Validate collection name (allow only alnum, underscore, hyphen) + if (false === /^[A-Za-z0-9_-]+$/.test(searchJobId)) { + request.log.warn({searchJobId}, "Invalid searchJobId for results deletion"); + reply.code(StatusCodes.BAD_REQUEST); + return { + message: "Invalid searchJobId", + } as never; + }
203-207
: Make deletion idempotent; ignore “not found” errorsDropping a non-existent collection can throw (e.g., code 26), which should not produce a 500. Wrap and ignore NamespaceNotFound.
Apply this diff:
- await mongoDb.collection(searchJobId).drop(); + try { + const dropped = await mongoDb.collection(searchJobId).drop(); + request.log.info({searchJobId, dropped}, "Dropped Presto results collection"); + } catch (err: unknown) { + const {code, codeName} = err as {code?: number; codeName?: string}; + // Ignore "namespace not found" (collection does not exist) + if (26 === code || "NamespaceNotFound" === codeName) { + request.log.info({searchJobId}, "Results collection not found; nothing to delete"); + } else { + request.log.error(err, "Failed to drop Presto results collection"); + throw err; + } + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
components/webui/server/src/routes/api/presto-search/index.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}
⚙️ CodeRabbit Configuration File
- Prefer
false == <expression>
rather than!<expression>
.
Files:
components/webui/server/src/routes/api/presto-search/index.ts
🧬 Code Graph Analysis (1)
components/webui/server/src/routes/api/presto-search/index.ts (3)
components/webui/client/src/api/presto-search/index.ts (1)
PrestoQueryJobSchema
(61-61)components/webui/server/src/schemas/presto-search.ts (1)
PrestoQueryJobSchema
(22-22)components/webui/server/src/schemas/error.ts (1)
ErrorSchema
(8-8)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: antlr-code-committed (macos-15)
- GitHub Check: lint-check (ubuntu-24.04)
- GitHub Check: lint-check (macos-15)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look great. small comments
components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deferring to @davemarco's review.
Description
Checklist
breaking change.
Validation performed
Summary by CodeRabbit
New Features
Improvements
Backend