Skip to content

Conversation

dejanmltc
Copy link
Contributor

@dejanmltc dejanmltc commented Aug 21, 2025

Reference: https://clickhouse.com/docs/sql-reference/statements/describe-table

This PR updates the SQL parser to handle the official ClickHouse
DESCRIBE TABLE <table_name> syntax.

Previously, only DESCRIBE <table_name> was supported. With this change,
the parser now also accepts DESCRIBE TABLE <table_name>, which is the
syntax described in the official documentation.

Changes:

  • Extend grammar to allow the optional TABLE keyword in DESCRIBE statements.
  • Ensure both DESCRIBE <table_name> and DESCRIBE TABLE <table_name> parse correctly.
  • Add or update tests to cover both forms.

Justification:

  • The parser should fully align with ClickHouse’s supported syntax.
  • This ensures compatibility with both the documented standard form
    (DESCRIBE TABLE) and the commonly used shorthand (DESCRIBE).

@git-hulk git-hulk requested a review from Copilot August 22, 2025 02:07
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enforces the official ClickHouse DESCRIBE TABLE syntax by requiring the TABLE keyword after DESC/DESCRIBE statements. The change ensures the parser strictly follows ClickHouse's documented syntax instead of accepting the invalid DESCRIBE <table_name> form.

  • Updated parser to require TABLE keyword after DESC/DESCRIBE
  • Added DescribeType field to track the describe statement type
  • Updated all test files to use the correct DESCRIBE TABLE syntax

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
parser/ast.go Added DescribeType field to DescribeStmt struct and updated String() method
parser/parser_table.go Added validation to require TABLE keyword after DESC/DESCRIBE
parser/testdata/ddl/describe_table.sql Updated test case to use DESCRIBE TABLE syntax
parser/testdata/ddl/desc_table.sql Updated test case to use DESC TABLE syntax
parser/testdata/ddl/format/describe_table.sql Updated expected format output for DESCRIBE TABLE
parser/testdata/ddl/format/desc_table.sql Updated expected format output for DESC TABLE
parser/testdata/ddl/output/describe_table.sql.golden.json Updated golden test output with new positions and DescribeType field
parser/testdata/ddl/output/desc_table.sql.golden.json Updated golden test output with new positions and DescribeType field

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <[email protected]>
@coveralls
Copy link

coveralls commented Aug 22, 2025

Pull Request Test Coverage Report for Build 17151399017

Details

  • 11 of 11 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 50.363%

Totals Coverage Status
Change from base Build 16988786925: 0.03%
Covered Lines: 7358
Relevant Lines: 14610

💛 - Coveralls

@git-hulk
Copy link
Member

@dejanmltc Thanks for your fix.

From the ClickHouse antlr, it looks like the keyword TABLE is optional for DESCRIBE|DESC statement. I tried it at the ClickHouse playground and confirmed it's a valid syntax by omitting the keyword TABLE: https://sql.clickhouse.com/?query=REVTQyBhbWF6b24uYW1hem9uX3Jldmlld3M.

Would you mind making TABLE an option when parsing the statement?

@dejanmltc dejanmltc changed the title Support only official DESCRIBE TABLE syntax Support DESCRIBE TABLE syntax Aug 22, 2025
@dejanmltc
Copy link
Contributor Author

@git-hulk
Thanks for the clarification!
I’ve updated the PR so that TABLE is optional in the DESCRIBE statement.
Both DESCRIBE <table_name> and DESCRIBE TABLE <table_name> should now parse correctly.

@git-hulk git-hulk merged commit d818580 into AfterShip:master Aug 22, 2025
2 checks passed
@git-hulk
Copy link
Member

@dejanmltc Thank you!

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