Skip to content

Redshift: End -- comments at a carriage return - #2987

Open
anubhavlal07 wants to merge 1 commit into
apache:mainfrom
anubhavlal07:fix/redshift-comment-cr
Open

anubhavlal07 wants to merge 1 commit into
apache:mainfrom
anubhavlal07:fix/redshift-comment-cr

Conversation

@anubhavlal07

Copy link
Copy Markdown

Dialects: Redshift, PostgreSQL

Fixes #2958

With RedshiftSqlDialect, a -- comment did not end at a lone \r, so SELECT 1 AS a --\r, 2 parsed as SELECT 1 AS a. The tokenizer stopped at \r only for PostgreSqlDialect. Redshift is based on PostgreSQL 8.0.2 (Amazon Redshift and PostgreSQL), and the PostgreSQL lexer ends -- comments at either \n or \r (scan.l).

This replaces the dialect_of!(self is PostgreSqlDialect) check with a new Dialect::single_line_comment_ends_at_carriage_return method, which defaults to false and returns true for PostgreSQL and Redshift. PostgreSQL behaves as before.

The new test in tests/sqlparser_redshift.rs checks that dialects which enable the method parse two projections, and that the others still treat the rest of the line as a comment. I also added the fuzz seed fuzz/fuzz_seeds/redshift_2958_comment_cr.sql.

I wrote this with AI assistance, then reviewed the diff and description myself.

@anubhavlal07

Copy link
Copy Markdown
Author

I've reviewed the doc comment on single_line_comment_ends_at_carriage_return. It's there because the crate forbids missing docs on public items, and it only states what the method returns.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.29%. Comparing base (96a5132) to head (1a6cc8b).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2987   +/-   ##
=======================================
  Coverage   83.28%   83.29%           
=======================================
  Files          42       42           
  Lines       35355    35364    +9     
  Branches    35355    35364    +9     
=======================================
+ Hits        29446    29455    +9     
  Misses       2458     2458           
  Partials     3451     3451           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redshift dialect: -- comment should end at a carriage return

2 participants