- 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.
- When instructed to open a PR, you will follow the instructions in 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.
- When testing a multi-line SQL statement, use a raw string literal, i.e.
r#"..."#to preserve formatting. - You can use the following template for simple unit tests:
<dialect>().parse_sql_statements(r#"..."#).unwrap();For example: snowflake().parse_sql_statements(r#"SELECT * FROM my_table"#).unwrap();
- 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.
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- PR title should follow this format:
<DIALECT>: <SHORT DESCRIPTION>, For example,Showflake: Add support for casting to VARIANT. - Make the PR comment short, provide an example of what was not working and a short description of the fix. Be succint.