- You will write unit tests to ensure your code change is working as expected.
- You will run the commands in the Pre Commit Checks section below to ensure your change is ready for a pull request.
- You will not open a PR unless explicitly instructed to, following the Pull Request Guidelines section below.
- Refrain from adding conditions on specific dialects, such as
dialect_is!(...)ordialect_of!(... | ...). Instead, define a new function in theDialecttrait that describes the condition, so that dialects can turn this condition on more easily. - Make targeted code changes and refrain from refactoring, unless it's absolutely required.
- Keep comments and doc comments brief and non-repetitive.
- Document only what the code does not plainly state, never the trivial or self-evident.
- Never describe the change itself in comments. That belongs in the PR.
- The human must read every comment you add and confirm it is necessary in its form.
- New unit tests should be added to the
testsmodule in the corresponding dialect file (e.g.,tests/sqlparser_redshift.rsfor Redshift), and should be placed at the end of the file. - If the new functionality is gated using a dialect function, and the SQL is likely relevant in most dialects, tests should be placed under
tests/sqlparser_common.rs. - Cover both positive and negative cases: valid input parses and round-trips, invalid input fails with the expected error.
- Cover every dialect the syntax is relevant to, e.g. via
all_dialects_where(...). - When adding new syntax, run the fuzzer to check for panics (see
docs/fuzzing.md). - When testing a multi-line SQL statement, use a raw string literal, i.e.
r#"..."#to preserve formatting. - The parser builds an abstract syntax tree (AST) from the SQL statement and has functionality to display the tree as SQL. Use the following template for simple unit tests where you expect the SQL created from the AST to be the same as the input SQL:
<dialect>().verified_stmt(r#"..."#);For example: snowflake().verified_stmt(r#"SELECT * FROM my_table"#). Use one_statement_parses_to instead of verified_stmt when you expect the SQL created by the AST to differ than the input SQL. For example:
snowflake().one_statement_parses_to(
"SELECT * FROM my_table t",
"SELECT * FROM my_table AS t",
)You can try to simplify the SQL statement to identify the root cause of the parsing issue. This may involve removing certain clauses or components of the SQL statement to see if it can be parsed successfully. Additionally, you can compare the problematic SQL statement with similar statements that are parsed correctly to identify any differences that may be causing the issue.
Run the following commands before you commit to ensure the change will pass the CI process:
cargo test --all-features
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings- Keep PRs small, atomic, and self-contained: one feature or fix per PR, with its tests.
- Before opening a PR, check for an existing PR covering the same change and for open issues to reference.
- Never open a PR automatically: show the human the title, description, and diff, and only open after they have actually read them and approved.
- The human must be able to explain every line of the change.
- PR title should follow this format:
<DIALECT>: <SHORT DESCRIPTION>. For example,Snowflake: Add support for casting to VARIANT. - Keep the PR description under 20 lines: an example of what was not working and a short description of the fix.
- Verify new dialect syntax against the real engine or its official documentation, and link it in the description.
- Disclose AI assistance in the description.
- An agent SHALL NOT do or post reviews, review comments, or replies to review comments.
- Address reviewer feedback on your open PRs before opening new ones.