-
Notifications
You must be signed in to change notification settings - Fork 288
Add stale query warning with revert button for query executions #1679
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
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d0e3cb2
Add execution snapshots and stale query warning
wbh123456 3e51487
Consolidate on agent rules
wbh123456 45166d2
Add revert button to stale query warning
wbh123456 bb5a173
Enhance contribution guidelines and testing instructions
wbh123456 a148612
Fix lint errors
wbh123456 5e6da88
Fix Prettier formatting
wbh123456 5ffa7f9
Update contribution guidelines with enhanced testing instructions
wbh123456 f5c9688
Remove Revert in stale query warning
wbh123456 756a40d
Resolve comments
wbh123456 8989468
Enhance stale query warning to determine saved vs. edited
wbh123456 7de31df
Resolve comments
wbh123456 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # Querybook | ||
|
|
||
| Querybook is Pinterest's open-source Big Data IDE for discovering, creating, and sharing data analyses. It combines a rich-text editor, SQL query engine, charting, scheduling, and table documentation in a single web app. | ||
|
|
||
| ## Tech Stack | ||
|
|
||
| - **Backend:** Python 3.10, Flask, SQLAlchemy (MySQL), Celery (Redis broker), Elasticsearch/OpenSearch, gevent + Flask-SocketIO (WebSockets), uWSGI (production) | ||
| - **Frontend:** React 17, TypeScript, Redux, Webpack 5, CodeMirror (SQL editor), Draft.js (rich text), Chart.js/D3/ReactFlow | ||
|
jasoncoffman marked this conversation as resolved.
|
||
|
|
||
| ## Directory Layout | ||
|
|
||
| - `querybook/server/` — Flask backend | ||
| - `app/` — app setup | ||
|
jasoncoffman marked this conversation as resolved.
|
||
| - `datasources/` — REST API endpoints | ||
|
jasoncoffman marked this conversation as resolved.
|
||
| - `logic/` — business logic | ||
| - `models/` — SQLAlchemy models | ||
| - `tasks/` — Celery tasks | ||
| - `lib/` — utilities, executors, metastores | ||
| - `env.py` — `QuerybookSettings` configuration | ||
| - `querybook/webapp/` — React/TypeScript frontend | ||
| - `components/` — React components | ||
| - `hooks/` — custom React hooks | ||
| - `redux/` — Redux store, actions, reducers | ||
| - `lib/` — frontend utilities | ||
| - `ui/` — reusable UI primitives | ||
| - `resource/` — API client layer | ||
| - `querybook/config/` — YAML config files | ||
| - `plugins/` — plugin stubs (extension point for custom behavior) | ||
| - `requirements/` — pip requirements (`base.txt`, `prod.txt`, `engine/*.txt`, `auth/*.txt`) | ||
| - `containers/` — Docker Compose files (dev, prod, test) | ||
| - `docs_website/` — Docusaurus documentation site | ||
| - `helm/` / `k8s/` — Kubernetes deployment manifests | ||
|
|
||
| ## Plugin System | ||
|
|
||
| Querybook is extended via plugins without forking. The env var `QUERYBOOK_PLUGIN` (default `./plugins`) points to a directory where plugin modules are discovered by `lib.utils.import_helper.import_module_with_default()`. | ||
|
|
||
| Each plugin module exports a well-known variable (e.g. `ALL_PLUGIN_EXECUTORS`) that the server merges with built-in defaults. | ||
|
|
||
| Key plugin types: `executor_plugin`, `metastore_plugin`, `auth_plugin`, `api_plugin`, `exporter_plugin`, `result_store_plugin`, `notifier_plugin`, `event_logger_plugin`, `stats_logger_plugin`, `job_plugin`, `tasks_plugin`, `dag_exporter_plugin`, `ai_assistant_plugin`, `vector_store_plugin`, `webpage_plugin`, `monkey_patch_plugin`, `query_validation_plugin`, `query_transpilation_plugin`, `engine_status_checker_plugin`, `table_uploader_plugin`. | ||
|
|
||
| ## Configuration | ||
|
|
||
| Priority: **env vars > `querybook_config.yaml` > `querybook_default_config.yaml`**. | ||
|
|
||
| Key settings live in `querybook/server/env.py` (`QuerybookSettings`). | ||
|
|
||
| ## Running Locally | ||
|
|
||
| Start the full stack (web server, worker, scheduler, and all dependencies) with Docker Compose: | ||
|
|
||
| ```bash | ||
| make | ||
| ``` | ||
|
|
||
| This brings up everything and serves the app at http://localhost:10001. This is the primary command for local development. | ||
|
|
||
| To restart individual services without bouncing the full stack: | ||
|
|
||
| ```bash | ||
| make web # web server only | ||
| make worker # celery worker | ||
| make scheduler # celery beat | ||
| ``` | ||
|
wbh123456 marked this conversation as resolved.
|
||
|
|
||
| ## Making Commits | ||
|
|
||
| When preparing a PR, run the relevant checks. CI runs all of the following via GitHub Actions (`.github/workflows/`), but must be manually triggered by a maintainer. | ||
|
|
||
| Always run tests via `make test`, which builds a `querybook-test` Docker image and runs checks inside it. This ensures an isolated, reproducible environment. Do not run test commands (pytest, yarn, webpack) directly on the host. | ||
|
|
||
| `make test` runs both backend and frontend checks: | ||
| - **Backend** (anything under `querybook/server/`): pytest | ||
| - **Frontend** (anything under `querybook/webapp/`): TypeScript type checking, Jest unit tests, ESLint, and production build verification | ||
|
|
||
| **Formatting (all changes) — common CI failure:** | ||
|
|
||
| `make test` does **not** run Prettier. CI runs Prettier separately via `pre-commit`, so formatting issues are a frequent cause of CI failures. After running `make test`, also run Prettier on changed files before pushing: | ||
|
|
||
| ```bash | ||
| npx prettier --write <files> | ||
| ``` | ||
|
|
||
| For a full formatting pass (Black for Python, Prettier for JS/TS, flake8): | ||
|
|
||
| ```bash | ||
| pre-commit run --all-files | ||
| ``` | ||
|
|
||
| ## Maintaining This File | ||
|
|
||
| **Include:** | ||
| - Repo purpose, tech stack, and high-level architecture | ||
| - Directory layout (key paths only) | ||
| - How to run, test, and lint locally | ||
| - Commit and PR workflow expectations | ||
| - Plugin system overview and extension points | ||
|
|
||
| **Do not include:** | ||
| - Detailed API docs or function-level documentation | ||
| - Inline code examples longer than 5 lines | ||
| - Deployment runbooks or operational procedures (keep in README or docs/) | ||
| - Credentials, secrets, or internal URLs | ||
| - Information that changes frequently (version numbers, dependency lists) | ||
| - Content already covered in README.md | ||
| - Content that can be easily derived by AI agents (e.g. reading file trees, package.json) | ||
| - References to internal/proprietary repos — this is an open-source project | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @AGENTS.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
querybook/webapp/__tests__/hooks/queryEditor/useExecutionSnapshots.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { addRunInputSnapshot } from 'hooks/queryEditor/useExecutionSnapshots'; | ||
|
|
||
| describe('addRunInputSnapshot', () => { | ||
| test('adds a snapshot to an empty record', () => { | ||
| const result = addRunInputSnapshot({}, 1, 'SELECT 1'); | ||
| expect(result).toEqual({ 1: 'SELECT 1' }); | ||
| }); | ||
|
|
||
| test('adds a new execution to existing snapshots', () => { | ||
| const prev = { 1: 'SELECT 1' }; | ||
| const result = addRunInputSnapshot(prev, 2, 'SELECT 2'); | ||
| expect(result).toEqual({ 1: 'SELECT 1', 2: 'SELECT 2' }); | ||
| }); | ||
|
|
||
| test('overwrites an existing execution snapshot', () => { | ||
| const prev = { 1: 'SELECT old' }; | ||
| const result = addRunInputSnapshot(prev, 1, 'SELECT new'); | ||
| expect(result).toEqual({ 1: 'SELECT new' }); | ||
| }); | ||
|
|
||
| test('does not mutate the original record', () => { | ||
| const prev = { 1: 'SELECT 1' }; | ||
| const result = addRunInputSnapshot(prev, 2, 'SELECT 2'); | ||
| expect(prev).toEqual({ 1: 'SELECT 1' }); | ||
| expect(result).not.toBe(prev); | ||
| }); | ||
|
|
||
| test('handles many snapshots without pruning', () => { | ||
| let record: Record<number, string> = {}; | ||
| for (let i = 0; i < 50; i++) { | ||
| record = addRunInputSnapshot(record, i, `SELECT ${i}`); | ||
| } | ||
| expect(Object.keys(record)).toHaveLength(50); | ||
| expect(record[0]).toBe('SELECT 0'); | ||
| expect(record[49]).toBe('SELECT 49'); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.