Skip to content

add ALTER TABLE COMPACT and the cold storage compaction and pin functions - #44

Merged
emrberk merged 3 commits into
masterfrom
rd_cold_storage_v2
Nov 30, 2026
Merged

emrberk merged 3 commits into
masterfrom
rd_cold_storage_v2

Conversation

@RaphDal

@RaphDal RaphDal commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds parser, AST, serialization, formatter and autocomplete support for the cold storage compaction statement of QuestDB Enterprise, and adds its four new functions to the grammar lists. Both come from questdb/questdb-enterprise#1322, and are documented in questdb/documentation#651.

ALTER TABLE trades COMPACT PARTITION LIST '2026-02-10';
ALTER TABLE trades COMPACT RESIDUAL PARTITION LIST '2026-02-10', '2026-02-11';
ALTER TABLE trades COMPACT BASE PARTITION WHERE timestamp < '2026-03-01';
ALTER TABLE trades COMPACT CANCEL;

SELECT * FROM cold_storage_compactions();
SELECT * FROM cold_storage_pin_owners();
SELECT * FROM cold_storage_pins('trades');
SELECT cold_storage_release_pins('<owner_id>');

Changes

  • Registers COMPACT and RESIDUAL as keywords. Both stay non-reserved, as on the server, so they still work as unquoted table and column names: the server's own tests use a table named residual. BASE and CANCEL already existed.
  • Parses ALTER TABLE t COMPACT [BASE | RESIDUAL] PARTITION { LIST 'p' [, ...] | WHERE <expr> } and ALTER TABLE t COMPACT CANCEL, following EntSqlCompilerImpl.compileCompactPartition. The forms live in a dedicated alterTableCompactAction rule, like alterTableForceAction.
  • Adds the compactPartition action, with an optional mode of base or residual and either partitions or where, and the compactCancel action, with toSql support for both.
  • Starts COMPACT ... on its own line in the formatter, like the other ALTER TABLE actions.
  • Adds cold_storage_compactions, cold_storage_pin_owners and cold_storage_pins to the table-valued functions, and cold_storage_release_pins to the scalar functions, matching how the server registers them: three cursor functions and a boolean scalar.
  • Regenerates cst-types.d.ts. This also moves doublePrecisionLiteral within PrimaryExpressionCstChildren, which the committed file had not caught up with.

Testing

  • Parse and AST coverage for every form, and rejection of COMPACT BASE without PARTITION, of PARTITION without LIST or WHERE, and of BASE and RESIDUAL together.
  • Regression coverage proving compact, base and residual remain valid identifiers, including ALTER TABLE residual COMPACT RESIDUAL ....
  • Round-trip coverage for every form.
  • Lexer coverage for the new keywords.
  • Autocomplete walkthrough from ALTER TABLE trades through COMPACT, CANCEL, BASE, RESIDUAL, PARTITION, LIST and WHERE to the table's columns.
  • Function list and autocomplete coverage for the four functions: the three table-valued ones after FROM, without cold_storage_release_pins, and cold_storage_release_pins in a select list.
  • Formatter fixtures for COMPACT BASE PARTITION WHERE ... and COMPACT CANCEL.
  • 14 server parity entries in server-queries.json, taken from DeltaCompactionRequestTest, DeltaMaintenanceTest, BaseCompactionTest and ColdStoragePinAdminTest in questdb-enterprise, each checked for parsing, round trip, autocomplete and formatting.
  • 14 documentation examples from docs(cold-storage): document late rows, compaction, pins and the version 2.0 cold storage root documentation#651 in docs-queries.json.
  • yarn test: 17,668 passed, 1 skipped (61 files)
  • yarn typecheck: clean
  • yarn lint: clean
  • yarn build: ESM and CJS builds clean

@emrberk
emrberk merged commit b09a3f8 into master Nov 30, 2026
2 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.

2 participants