Skip to content

Conversation

@git-hulk
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings January 26, 2026 10:13
@Lance726 Lance726 merged commit fbea420 into AfterShip:master Jan 26, 2026
5 checks passed
@coveralls
Copy link

Pull Request Test Coverage Report for Build 21353959011

Details

  • 13 of 13 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 51.399%

Totals Coverage Status
Change from base Build 21280479720: 0.03%
Covered Lines: 8046
Relevant Lines: 15654

💛 - Coveralls

Copy link

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

Updates ALTER TABLE parsing to support multiple TTL expressions in MODIFY TTL clauses.

Changes:

  • Parse ALTER TABLE ... MODIFY TTL using a TTLClause (list of TTLExpr) rather than a single TTLExpr.
  • Update AST shape/printing for AlterTableModifyTTL to reflect the clause-based TTL representation.
  • Add test coverage (SQL + golden JSON + format fixture) for multiple TTL expressions in MODIFY TTL.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
parser/parser_alter.go Switch MODIFY TTL parsing to build a TTLClause with multiple TTL items.
parser/ast.go Change AlterTableModifyTTL.TTL to *TTLClause and adjust String() output accordingly.
parser/testdata/dml/output/alter_table_with_modify_ttl.sql.golden.json Update expected AST JSON to match the new TTLClause structure for a single TTL item.
parser/testdata/dml/output/alter_table_modify_ttl_multiple.sql.golden.json Add golden AST JSON for a multi-item MODIFY TTL statement.
parser/testdata/dml/alter_table_modify_ttl_multiple.sql Add new SQL test input for multiple TTL expressions in MODIFY TTL.
parser/testdata/dml/format/alter_table_modify_ttl_multiple.sql Add format/roundtrip fixture for the new multi-TTL SQL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2 to +4
MODIFY TTL
toDateTime(timestamp / 1000000000) + INTERVAL 30 DAY TO DISK 'gcs',
toDateTime(timestamp / 1000000000) + INTERVAL 60 DAY;
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

This new test covers multiple TTL expressions, but it doesn’t cover the case where the last TTL expression has a TTL policy (e.g., ... + INTERVAL 60 DAY TO DISK 'gcs'). Adding such a case would help ensure the multi-item parsing/AST boundaries behave correctly for the common TO DISK/TO VOLUME variants.

Copilot uses AI. Check for mistakes.
ModifyPos Pos
StatementEnd Pos
TTL *TTLExpr
TTL *TTLClause
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

AlterTableModifyTTL.TTL changed from *TTLExpr to *TTLClause, which is a breaking change for any external consumers of this package’s AST. If this repo aims to keep API stability, consider preserving the old field (e.g., add a new TTLClause field while keeping TTLExpr for the single-item case), or provide a helper accessor/migration path and document the breaking change (potentially requiring a major version bump).

Suggested change
TTL *TTLClause
TTL *TTLClause
// TTLExpr is kept for backwards compatibility with older versions where
// TTL was of type *TTLExpr. New code should use TTL (*TTLClause).
TTLExpr *TTLExpr

Copilot uses AI. Check for mistakes.
Comment on lines +654 to +657
listEnd := ttlPos
if len(items) > 0 {
listEnd = items[len(items)-1].End()
}
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

parseTTLClause always appends the first parsed TTL expression before returning, so len(items) can’t be 0 on the success path. The fallback listEnd := ttlPos and the if len(items) > 0 branch are therefore redundant and can be simplified.

Suggested change
listEnd := ttlPos
if len(items) > 0 {
listEnd = items[len(items)-1].End()
}
listEnd := items[len(items)-1].End()

Copilot uses AI. Check for mistakes.
Comment on lines +654 to +666
listEnd := ttlPos
if len(items) > 0 {
listEnd = items[len(items)-1].End()
}
ttlClause := &TTLClause{
TTLPos: ttlPos,
ListEnd: listEnd,
Items: items,
}
return &AlterTableModifyTTL{
ModifyPos: pos,
StatementEnd: ttlExpr.End(),
TTL: ttlExpr,
StatementEnd: ttlClause.End(),
TTL: ttlClause,
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

listEnd is derived from items[len(items)-1].End(), but TTLExpr.End() currently ignores any attached TTL policy (e.g., ... TO DISK 'x', ... DELETE, etc.). If the last TTL item has a policy, AlterTableModifyTTL.StatementEnd/TTLClause.ListEnd will point before the policy tokens, making node ranges inconsistent. Consider updating TTLExpr.End() (in parser/ast.go) to return Policy.End() when Policy != nil, and then use that for ListEnd here.

Copilot uses AI. Check for mistakes.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09c27f44d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 647 to 651
case p.matchKeyword(KeywordTtl):
ttlPos := p.Pos()
_ = p.lexer.consumeToken()
ttlExpr, err := p.parseTTLExpr(p.Pos())
items, err := p.parseTTLClause(ttlPos, true)
if err != nil {

Choose a reason for hiding this comment

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

P2 Badge Stop MODIFY TTL parsing before next alter clause

With allowMultiValues set to true, parseTTLClause greedily consumes any comma as another TTL expression separator. In ALTER TABLE, commas also separate alter clauses, so a statement like ALTER TABLE t MODIFY TTL x, ADD COLUMN y Int now fails because parseTTLClause will attempt to parse ADD as part of a TTL expression and error. This makes valid multi-clause ALTER statements containing MODIFY TTL unparsable; consider stopping TTL parsing when the next token starts another alter clause (ADD/DROP/...) or only enabling multi-values when MODIFY TTL is the final clause.

Useful? React with 👍 / 👎.

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