Skip to content

feat: Add include_sql to Search Pipeline Run API#135

Open
yuechao-qin wants to merge 1 commit intoycq/search-pipeline-run-pagination-cursorfrom
ycq/search-pipeline-run-include-sql-2
Open

feat: Add include_sql to Search Pipeline Run API#135
yuechao-qin wants to merge 1 commit intoycq/search-pipeline-run-pagination-cursorfrom
ycq/search-pipeline-run-include-sql-2

Conversation

@yuechao-qin
Copy link
Collaborator

@yuechao-qin yuechao-qin commented Feb 28, 2026

TL;DR

Added optional SQL query debugging to the pipeline runs list API endpoint.

What changed?

Functional

  • Added include_sql parameter to API
GET /api/pipeline_runs/?include_sql=true&filter_query=<QUERY>
  • Added sql field to ListPipelineJobsResponse to optionally return the generated SQL query
{
  "pipeline_runs": [...],
  "next_page_token": <TOKEN>,
  "sql": "SELECT * FROM pipeline_run WHERE ... ORDER BY ..."
}

How to test?

uv run pytest tests/test_api_server_sql.py
  • Call the list endpoint with include_sql=True to verify the SQL query is returned in the response
  • Test with various filter queries and pagination tokens to ensure the SQL compilation works correctly
  • Verify that when include_sql=False or is omitted, the sql field remains None

Why make this change?

  • This enables debugging and monitoring of the actual SQL queries generated by the pipeline runs list endpoint.
  • This is required by E2E testing (PR here) to be able to log and report what SQL statement was used per API request.

@yuechao-qin yuechao-qin marked this pull request as ready for review February 28, 2026 10:38
@yuechao-qin yuechao-qin requested a review from Ark-kun as a code owner February 28, 2026 10:38
@yuechao-qin yuechao-qin changed the base branch from ycq/search-pipeline-run-pagination-cursor to graphite-base/135 March 1, 2026 03:23
@yuechao-qin yuechao-qin force-pushed the ycq/search-pipeline-run-include-sql-2 branch from 6cede38 to 91f679a Compare March 1, 2026 03:23
@yuechao-qin yuechao-qin changed the base branch from graphite-base/135 to ycq/search-pipeline-run-pagination-cursor March 1, 2026 03:23
@Ark-kun
Copy link
Contributor

Ark-kun commented Mar 3, 2026

I'm not sure we should support this in public API.
This could also become problematic if we support alternative non-SQL search methods like ElasticSearch/OpenSearch.

It's pretty simple to locally compile arbitrary filter_query or page_token to arbitrary SQL dialect.

Let's discuss the primary use case and decide how to accomplish that goal without adding this debug information to the public API surface.

Copy link
Collaborator Author

@yuechao-qin yuechao-qin changed the base branch from ycq/search-pipeline-run-pagination-cursor to graphite-base/135 March 4, 2026 00:42
@yuechao-qin yuechao-qin force-pushed the ycq/search-pipeline-run-include-sql-2 branch from 91f679a to 4845319 Compare March 4, 2026 00:42
class ListPipelineJobsResponse:
pipeline_runs: list[PipelineRunResponse]
next_page_token: str | None = None
sql: str | None = None
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brainstorming ideas:

@yuechao-qin yuechao-qin changed the base branch from graphite-base/135 to ycq/search-pipeline-run-pagination-cursor March 4, 2026 00:42
@yuechao-qin yuechao-qin changed the base branch from ycq/search-pipeline-run-pagination-cursor to graphite-base/135 March 4, 2026 04:57
@yuechao-qin yuechao-qin force-pushed the ycq/search-pipeline-run-include-sql-2 branch from 4845319 to ba1db33 Compare March 4, 2026 05:00
@yuechao-qin yuechao-qin changed the base branch from graphite-base/135 to ycq/search-pipeline-run-pagination-cursor March 4, 2026 05:00
@yuechao-qin yuechao-qin changed the base branch from ycq/search-pipeline-run-pagination-cursor to graphite-base/135 March 4, 2026 05:07
@yuechao-qin yuechao-qin force-pushed the ycq/search-pipeline-run-include-sql-2 branch from ba1db33 to 44d878f Compare March 4, 2026 05:07
@yuechao-qin yuechao-qin changed the base branch from graphite-base/135 to ycq/search-pipeline-run-pagination-cursor March 4, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants