feat(sql): allow plural 'partitions' keyword in ALTER TABLE CONVERT#6733
feat(sql): allow plural 'partitions' keyword in ALTER TABLE CONVERT#6733gggeon96 wants to merge 9 commits intoquestdb:masterfrom
Conversation
Allow both 'partition' and 'partitions' keywords in the ALTER TABLE ... CONVERT PARTITION TO PARQUET/NATIVE syntax for better SQL grammer consistency. Fixes questdb#6494
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
…nExpected Update test to expect 'partition' or 'partitions' in error message to match the updated parser behavior from issue questdb#6494.
There was a problem hiding this comment.
Pull request overview
This PR updates the SQL grammar for ALTER TABLE ... CONVERT ... to accept both PARTITION and PARTITIONS, improving usability and consistency with user expectations (Fixes #6494).
Changes:
- Updated
SqlCompilerImplto treatPARTITIONandPARTITIONSequivalently inALTER TABLE ... CONVERT .... - Updated a compiler error-message assertion to match the new accepted keywords.
- Added a unit test covering the plural
PARTITIONSkeyword for convert-to-parquet.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| core/src/main/java/io/questdb/griffin/SqlCompilerImpl.java | Extends ALTER TABLE ... CONVERT parsing to accept PARTITIONS in addition to PARTITION. |
| core/src/test/java/io/questdb/test/griffin/engine/SqlCompilerImplTest.java | Updates expected syntax error message to include both keyword forms. |
| core/src/test/java/io/questdb/test/griffin/AlterTableConvertPartitionTest.java | Adds coverage to ensure CONVERT PARTITIONS works for the WHERE form. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
core/src/test/java/io/questdb/test/griffin/AlterTableConvertPartitionTest.java
Outdated
Show resolved
Hide resolved
Allow both 'partition' and 'partitions' keywords in the ALTER TABLE ... CONVERT PARTITION TO PARQUET/NATIVE syntax for better SQL grammer consistency. Fixes questdb#6494
…nExpected Update test to expect 'partition' or 'partitions' in error message to match the updated parser behavior from issue questdb#6494.
21716ec to
a66c8c5
Compare
|
@CodeRabbit pls critically review this change and also see if claims are valid (including issue PR claims to have fixed) |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain
🏁 Script executed: Length of output: 7999 🏁 Script executed: Length of output: 23798
❌ Critical Issues1. Grammar Inconsistency Across ALTER TABLE OperationsThe implementation creates an arbitrary inconsistency: // CONVERT - now accepts BOTH (after this PR)
if (!isPartitionKeyword(tok) && !isPartitionsKeyword(tok))
// ATTACH - accepts ONLY singular (line 2124-2130)
if (isPartitionKeyword(tok))
// DETACH - accepts ONLY singular (line 2132-2138)
if (isPartitionKeyword(tok))
// DROP - accepts ONLY singular (line 2110)
else if (isPartitionKeyword(tok))
// SQUASH - accepts ONLY plural (line 2313)
if (isPartitionsKeyword(tok))Why does CONVERT get special treatment? Other operations consistently enforce singular/plural. What's the design principle here? 2. Inadequate Test CoverageThe new test only covers the WHERE clause: "alter table " + tableName + " convert " + partitionKeyword + " to parquet where timestamp > 0"But completely ignores the LIST syntax, which is heavily used:
Where are the tests for: ALTER TABLE x CONVERT PARTITIONS TO PARQUET LIST '2024-06-10'
ALTER TABLE x CONVERT PARTITIONS TO NATIVE LIST '2024-06-10', '2024-06-11'3. Semantic AmbiguityNow this is valid: -- Plural form for single partition - semantically wrong?
ALTER TABLE x CONVERT PARTITIONS TO PARQUET LIST '2024-06-10'Should plural really work when converting a single partition? Other DBs (PostgreSQL, MySQL) are strict about this for good reason - it guides users toward correct SQL. 4. Missing Design RationaleThe issue shows: This converts multiple partitions, so plural makes semantic sense. But:
🤔 Questions for the Author
✅ What's Correct
📋 Recommendations
This feels like a quick fix without considering the broader grammar design. The friction is real, but the solution creates technical debt. 🧠 Learnings used |
…om:gggeon96/questdb into feature/allow-plural-partitions-in-convert
|
Thanks for the review. Regarding the scope:
Regarding test coverage:
I'll push the additional tests shortly. Thanks! |
- Remove duplicate testConvertAllPartitionsPlural method - Add assertConvertListPartitionsWithKeyword helper method - Refactor testConvertListPartitions to use helper - Add testConvertListPartitionsPlural for LIST syntax coverage
Summary
Allow both
PARTITIONandPARTITIONSkeywords in theALTER TABLE ... CONVERT PARTITION TO PARQUET/NATIVEsyntax.Why
Currently only the singular form
PARTITIONis accepted, but users naturally expectPARTITIONS(plural) to work as well, especially when converting multiple partitions. This improves SQL grammar consistency and user experience.Changes
SqlCompilerImpl.java: Accept bothisPartitionKeyword()andisPartitionsKeyword()in the CONVERT clauseAlterTableConvertPartitionTest.java: AddedtestConvertAllPartitionsPluralto verify the fixTest
PARTITIONSkeywordFixes #6494