|
1 | 1 | # Repository Guidelines |
2 | 2 |
|
3 | | -## Project Structure & Module Organization |
4 | | -Databend is a Rust workspace rooted at `Cargo.toml`. The query engine (`src/query/`), meta service (`src/meta/`), and shared crates (`src/common/`) compile into binaries stored under `src/binaries/`. Tests live in `tests/` with SQL suites (`suites/`), sqllogic cases, and meta-specific harnesses, while performance experiments sit in `benchmark/`. Tooling and deployment helpers are collected in `scripts/` and `docker/`, fixtures in `_data/`, and the `Makefile` lists every supported task. |
5 | | - |
6 | | -## Build, Test, and Development Commands |
7 | | -- `make setup` – install cargo components plus linters (taplo, shfmt, typos, machete, ruff). |
8 | | -- `make build` / `make build-release` – compile debug or optimized `databend-{query,meta,metactl}` into `target/`. |
9 | | -- `make run-debug` / `make kill` – launch or stop a local standalone deployment using the latest build. |
10 | | -- `make unit-test`, `make stateless-test`, `make sqllogic-test`, `make metactl-test` – run focused suites; `make test` expands to the default CI matrix. |
11 | | -- `make fmt` and `make lint` – enforce formatting and clippy checks before committing. |
12 | | - |
13 | | -## Coding Style & Naming Conventions |
14 | | -Rust sources follow `rustfmt.toml` (4-space indent, 100-column width) and must pass `cargo clippy -- -D warnings`. Keep modules and files in `snake_case`, exposed types and traits in `CamelCase`, and SQL suite files prefixed with the numeric order already in `tests/suites/`. Favor `common/exception` helpers plus `tracing` spans for errors and observability. Python utilities in `tests/` should satisfy Ruff defaults, and shell scripts must round-trip through `shfmt -l -w`. |
15 | | - |
16 | | -## Debug Guidelines |
17 | | -Always use `cargo clippy` to make sure there are no compilation errors. Fully verifying the whole project may take too long, partial verification can speed things up, but eventually a full verification will be needed. |
18 | | - |
19 | | -## Testing Guidelines |
20 | | -Unit tests stay close to the affected crate (`#[cfg(test)]` modules), and integration behavior belongs in the relevant SQL suites or meta harness (`tests/metactl`, `tests/meta-kvapi`). Every planner, executor, or storage change should add at least one regression SQL file plus expected output when deterministic. Use cluster variants (`make stateless-cluster-test` and TLS mode) whenever coordination, transactions, or auth are involved. Document new fixtures or configs in `tests/README.md` (or inline comments) so CI remains reproducible. |
21 | | - |
22 | | - |
23 | | -## Commit & Pull Request Guidelines |
24 | | - |
25 | | -History follows a Conventional-style subject such as `fix(storage): avoid stale snapshot (#19174)` or `feat: support self join elimination (#19169)`; keep the first line imperative and under 72 characters. Commits should stay scoped to a logical change set and include formatting/linting updates in the same patch. PRs must outline motivation, implementation notes, and validation commands, plus link issues or RFCs, and the final description should follow `PULL_REQUEST_TEMPLATE.md` (checkboxes, verification, screenshots when needed). Attach screenshots or sample queries when UI, SQL plans, or system tables change, and call out rollout risks (migrations, config toggles, backfills) so reviewers can plan accordingly. |
26 | | - |
27 | | -There is the example of pull requests: |
28 | | - |
29 | | -```` |
30 | | -I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/ |
31 | | -
|
32 | | -## Summary |
33 | | -
|
34 | | -- Enable table functions like `generate_series` and `range` to accept scalar subqueries as arguments |
35 | | -- Return NULL for empty scalar subqueries to align with existing scalar subquery semantics |
36 | | -
|
37 | | -## Changes |
38 | | -
|
39 | | -This PR enables SQL like: |
40 | | -
|
41 | | -```sql |
42 | | -SELECT generate_series AS install_date |
43 | | -FROM generate_series( |
44 | | - (SELECT count() FROM numbers(10))::int, |
45 | | - (SELECT count() FROM numbers(39))::int |
46 | | -); |
47 | | -```` |
48 | | - |
49 | | -Previously, table function arguments could only be constants. Now they can be scalar subqueries that return a single value. |
50 | | - |
51 | | -## Implementation |
52 | | - |
53 | | -1. Added `contains_subquery()` function to detect subqueries in AST expressions |
54 | | -2. Added `execute_subquery_for_scalar()` to execute and extract scalar values from subqueries |
55 | | -3. Modified `bind_table_args` to try constant folding first, then fall back to subquery execution |
56 | | -4. The subquery executor is passed from the binder to enable runtime evaluation |
57 | | -5. Returns `Scalar::Null` for empty subquery results (aligns with LeftSingleJoin behavior) |
58 | | - |
59 | | -## Tests |
60 | | - |
61 | | -- [x] Unit Test |
62 | | -- [x] Logic Test |
63 | | -- [ ] Benchmark Test |
64 | | -- [ ] No Test - Pair with the reviewer to explain why |
65 | | - |
66 | | -Added tests in `02_0063_function_generate_series.test` for: |
67 | | - |
68 | | -- `generate_series` with subquery arguments |
69 | | -- `range` with subquery arguments |
70 | | - |
71 | | -## Type of change |
72 | | - |
73 | | -- [x] New feature (non-breaking change which adds functionality) |
74 | | - |
75 | | -<!-- Reviewable:start --> |
76 | | - |
77 | | ---- |
78 | | - |
79 | | -This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/databendlabs/databend/19213) |
80 | | - |
81 | | -<!-- Reviewable:end --> |
82 | | - |
83 | | -``` |
84 | | -
|
85 | | -
|
86 | | -Pull request mus be pushed into fork and create pr into origin. |
87 | | -You can use gh tools to do it. |
88 | | -``` |
89 | | - |
| 3 | +This file is the entry point for repository-specific working rules. Keep it focused on overall direction; read the matching detail documents in `agents/` before making changes in that area. |
| 4 | + |
| 5 | +## Core Workflow |
| 6 | +- Build context from the codebase first. Databend is a multi-crate Rust workspace, so understand the affected module boundaries before editing. |
| 7 | +- Validate incrementally. Run the smallest relevant checks early, and apply the verification standard that matches the task type. |
| 8 | +- Treat tests as part of the change. Planner, executor, storage, and behavior changes should come with regression coverage. |
| 9 | +- Keep contributions reviewable. Commits should stay scoped, and pull requests should follow the repository's expected collaboration workflow. |
| 10 | + |
| 11 | +## Task Types |
| 12 | +- Implementation tasks: the result is intended to stay in the branch, be reviewed, or be submitted. Follow the normal quality bar for edits, validation, tests, commits, and PR readiness. |
| 13 | +- Exploration tasks: the result is mainly temporary, used for investigation, debugging, measurement, or option evaluation, and is not intended to be submitted as-is. Prioritize speed and useful conclusions over polish. |
| 14 | +- If the output you plan to keep is only notes, logs, ad hoc scripts, or temporary experiments, treat it as exploration work. |
| 15 | +- If the output includes code, tests, or docs that are expected to remain in the branch for review or submission, treat it as implementation work. |
| 16 | +- For exploration tasks that do not produce submit-worthy changes, avoid spending time on low-value checks, exhaustive formatting passes, or broad test runs unless they are needed to answer the question correctly. |
| 17 | +- If a task starts as exploration and turns into a real code change that should be kept, switch back to the implementation-task standard before handoff. |
| 18 | + |
| 19 | +## Detail Index |
| 20 | +- [`agents/repository-structure.md`](agents/repository-structure.md) for workspace layout and where code, tests, tooling, and fixtures live. |
| 21 | +- [`agents/development-commands.md`](agents/development-commands.md) for setup, build, run, test, format, and lint commands. |
| 22 | +- [`agents/coding-style.md`](agents/coding-style.md) for Rust, Python, shell, naming, error handling, and observability conventions. |
| 23 | +- [`agents/debug-and-validation.md`](agents/debug-and-validation.md) for clippy expectations and testing strategy. |
| 24 | +- [`agents/commit-and-pr.md`](agents/commit-and-pr.md) for commit format, PR requirements, and the Databend PR template example. |
| 25 | +- If you discover high-value information that would materially help development or testing but cannot be found through this Detail Index and the linked documents beneath it, call that gap out explicitly instead of assuming the current documentation path is sufficient. |
| 26 | + |
| 27 | +## Default Rule |
| 28 | +If guidance in a detail file is relevant to the task, follow it. Determine the task type first, then apply the matching validation and testing rules. Exploration-task guidance is an explicit exception to the default implementation-task quality bar. |
0 commit comments