Skip to content

Conversation

@davemarco
Copy link
Contributor

@davemarco davemarco commented Oct 29, 2025

Description

Modifies grammar to support parsing SELECT, WHERE and ORDER BY. Will be used for syntax highlighting in future PR.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Not yet since unused

Summary by CodeRabbit

  • Chores
    • Improved SQL parsing: better support for lists of selected fields, standalone boolean expressions, and sorting item lists — resulting in more reliable query validation, clearer error feedback, and smoother editing of SELECT and ORDER BY clauses in the UI.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 29, 2025

Walkthrough

Five new parser rules were added to the SQL grammar file to support standalone parsing of SQL fragments, including select item lists, sort item lists, and boolean expressions with explicit end-of-file markers.

Changes

Cohort / File(s) Change Summary
SQL Grammar Parser Rules
components/webui/client/src/sql-parser/Sql.g4
Added five new parser rules: selectItemList (comma-separated select items), standaloneSelectItemList (selectItemList + EOF), standaloneBooleanExpression (booleanExpression + EOF), sortItemList (comma-separated sort items), and standaloneSortItemList (sortItemList + EOF)

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Grammar additions follow consistent patterns and are straightforward rule definitions
  • Changes are entirely contained within a single grammar file
  • No complex logic or control flow modifications to evaluate

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat(webui): Modify ANTLR grammar to support parsing individual SQL fields" is directly aligned with the changeset. The PR adds five new parser rules (selectItemList, standaloneSelectItemList, standaloneBooleanExpression, sortItemList, and standaloneSortItemList) to the SQL grammar file, which precisely enables parsing of individual SQL fields such as SELECT, WHERE, and ORDER BY clauses. The title is specific, concise, avoids vague terminology, and clearly communicates the primary purpose of the changes using conventional commit format.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@davemarco davemarco changed the title feat(webui): Add Antlr for individual fields in form feat(webui): Modify ANTLR grammar to support parsing individual SQL fields. Oct 29, 2025
@davemarco davemarco requested a review from hoophalab October 29, 2025 18:12
@davemarco davemarco marked this pull request as ready for review October 29, 2025 18:12
@davemarco davemarco requested a review from a team as a code owner October 29, 2025 18:12
hoophalab
hoophalab previously approved these changes Oct 30, 2025
Copy link
Contributor

@hoophalab hoophalab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

junhaoliao
junhaoliao previously approved these changes Oct 30, 2025
Copy link
Member

@junhaoliao junhaoliao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deferring to @hoophalab 's review

@davemarco davemarco dismissed stale reviews from junhaoliao and hoophalab via b5bb540 October 31, 2025 17:29
@davemarco davemarco requested a review from junhaoliao October 31, 2025 17:29
@davemarco
Copy link
Contributor Author

File was missing a new line, please re approve

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5712c89 and b5bb540.

📒 Files selected for processing (1)
  • components/webui/client/src/sql-parser/Sql.g4 (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: package-image
  • GitHub Check: lint-check (macos-15)
  • GitHub Check: lint-check (ubuntu-24.04)
🔇 Additional comments (2)
components/webui/client/src/sql-parser/Sql.g4 (2)

13-15: LGTM: Appropriate for parsing WHERE clause fragments.

The rule correctly uses EOF to parse boolean expressions in isolation, suitable for WHERE clause syntax highlighting. The structure is consistent with the other standalone rules.


1-3: All referenced parser rules are correctly defined in SqlBase.

Verification confirmed that selectItem, booleanExpression, and sortItem are all properly defined in the imported SqlBase.g4 grammar. The new parser rules in Sql.g4 correctly reference these existing rules through the import statement.

Comment on lines +5 to +11
selectItemList
: selectItem (',' selectItem)*
;

standaloneSelectItemList
: selectItemList EOF
;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider adding documentation comments.

The grammar rules are well-structured for parsing SELECT clause fragments. However, adding comments would improve maintainability and clarify the intended usage for future syntax highlighting.

Consider adding documentation:

+// Parse a comma-separated list of SELECT items (e.g., "col1, col2, func(col3)")
 selectItemList
     : selectItem (',' selectItem)*
     ;
 
+// Standalone entry point for parsing SELECT items in isolation
 standaloneSelectItemList
     : selectItemList EOF
     ;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
selectItemList
: selectItem (',' selectItem)*
;
standaloneSelectItemList
: selectItemList EOF
;
// Parse a comma-separated list of SELECT items (e.g., "col1, col2, func(col3)")
selectItemList
: selectItem (',' selectItem)*
;
// Standalone entry point for parsing SELECT items in isolation
standaloneSelectItemList
: selectItemList EOF
;
🤖 Prompt for AI Agents
In components/webui/client/src/sql-parser/Sql.g4 around lines 5 to 11, the
grammar rules selectItemList and standaloneSelectItemList lack documentation;
add brief ANTLR comments immediately above each rule (using // or /* */)
describing the rule's purpose, intended input and output shape, examples of
valid snippets (e.g., "a, b AS alias"), and any edge-cases (e.g., trailing
commas disallowed), so future maintainers can quickly understand usage and
constraints.

Comment on lines +17 to +23
sortItemList
: sortItem (',' sortItem)*
;

standaloneSortItemList
: sortItemList EOF
;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

LGTM: Consistent pattern for ORDER BY clause parsing.

The rules follow the same pattern as the SELECT item rules, providing a clean, consistent approach for parsing ORDER BY clause fragments with proper EOF handling.

Consider adding documentation similar to the SELECT rules:

+// Parse a comma-separated list of ORDER BY sort items (e.g., "col1 ASC, col2 DESC")
 sortItemList
     : sortItem (',' sortItem)*
     ;
 
+// Standalone entry point for parsing ORDER BY items in isolation
 standaloneSortItemList
     : sortItemList EOF
     ;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
sortItemList
: sortItem (',' sortItem)*
;
standaloneSortItemList
: sortItemList EOF
;
// Parse a comma-separated list of ORDER BY sort items (e.g., "col1 ASC, col2 DESC")
sortItemList
: sortItem (',' sortItem)*
;
// Standalone entry point for parsing ORDER BY items in isolation
standaloneSortItemList
: sortItemList EOF
;
🤖 Prompt for AI Agents
In components/webui/client/src/sql-parser/Sql.g4 around lines 17 to 23, add a
short grammar comment/documentation for sortItemList and standaloneSortItemList
mirroring the SELECT item rules: describe that sortItemList parses one or more
sortItem separated by commas and is used inside ORDER BY clauses, and that
standaloneSortItemList enforces end-of-input (EOF) for parsing isolated ORDER BY
fragments; include a brief example of usage and note why the EOF rule exists for
standalone parsing to aid future maintainers.

Copy link
Member

@junhaoliao junhaoliao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deferring to @hoophalab 's review

@davemarco davemarco merged commit b7c4763 into y-scope:main Nov 5, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants