Skip to content

Allow both options table-included-patterns and table-excluded-patterns on ch-backup restore command#294

Open
yahor-s wants to merge 3 commits intomainfrom
ch-partial-restore
Open

Allow both options table-included-patterns and table-excluded-patterns on ch-backup restore command#294
yahor-s wants to merge 3 commits intomainfrom
ch-partial-restore

Conversation

@yahor-s
Copy link
Contributor

@yahor-s yahor-s commented Feb 19, 2026

  • Support using both table-included-patterns and table-excluded-patterns options together on the restore command. Like ch-backup restore --include-databases db1 --include-table-patterns db1.table* --exclude-table-patterns db1.table_exception
  • Remove exclusive constraint on schema_only and table_included_patterns options

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 19, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes the mutual-exclusion constraint between the table-included-patterns and table-excluded-patterns options for the ch-backup restore command, allowing them to be used together while keeping other existing option constraints intact.

Flow diagram for restore command option constraint validation

flowchart TD
  Start([Start restore CLI]) --> CheckIncludeExclude
  CheckIncludeExclude[Check table_included_patterns and table_excluded_patterns]
  CheckIncludeExclude --> BothAllowed[Both options may be provided together]
  BothAllowed --> CheckIncludeExcludeDatabases

  CheckIncludeExcludeDatabases[Constraint mutually_exclusive table_included_patterns exclude_databases]
  CheckIncludeExcludeDatabases -->|Both_set| ErrorIncludeExcludeDatabases[Error invalid combination]
  CheckIncludeExcludeDatabases -->|Valid| CheckSchemaOnlyInclude

  ErrorIncludeExcludeDatabases --> EndError[Restore command fails]

  CheckSchemaOnlyInclude[Constraint mutually_exclusive schema_only table_included_patterns]
  CheckSchemaOnlyInclude -->|Both_set| ErrorSchemaOnlyInclude[Error invalid combination]
  CheckSchemaOnlyInclude -->|Valid| CheckSchemaOnlyAccess

  ErrorSchemaOnlyInclude --> EndError

  CheckSchemaOnlyAccess[Constraint mutually_exclusive schema_only access]
  CheckSchemaOnlyAccess -->|Both_set| ErrorSchemaOnlyAccess[Error invalid combination]
  CheckSchemaOnlyAccess -->|Valid| Proceed[Run restore]

  ErrorSchemaOnlyAccess --> EndError

  Proceed --> EndSuccess([Restore completed])
Loading

File-Level Changes

Change Details Files
Allow table include and exclude patterns to be specified together on the restore CLI while preserving other option constraints.
  • Removed the mutually_exclusive constraint tying together table_included_patterns and table_excluded_patterns so they can be passed simultaneously.
  • Left existing mutually_exclusive constraints involving table_included_patterns vs exclude_databases and schema_only, and schema_only vs access unchanged.
ch_backup/cli.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Now that table_included_patterns and table_excluded_patterns can be used together, consider making the precedence/interaction explicit in the restore logic (e.g., which filter is applied first) to avoid surprising behavior for edge cases.
  • If the restore handler assumes that only one of table_included_patterns or table_excluded_patterns is present, revisit that code path to ensure it behaves correctly when both options are provided simultaneously.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Now that `table_included_patterns` and `table_excluded_patterns` can be used together, consider making the precedence/interaction explicit in the restore logic (e.g., which filter is applied first) to avoid surprising behavior for edge cases.
- If the restore handler assumes that only one of `table_included_patterns` or `table_excluded_patterns` is present, revisit that code path to ensure it behaves correctly when both options are provided simultaneously.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@yahor-s yahor-s requested a review from MedvedewEM February 19, 2026 15:01
"Examples: db1.table1 | db1.table2,db2.* | db1.prefix*,db2.*suffix | db1.*",
),
option(
"--table-excluded-patterns",
Copy link
Contributor

Choose a reason for hiding this comment

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

Add pls comment to help about precedence

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added to docs
74ad264

@yahor-s yahor-s force-pushed the ch-partial-restore branch 2 times, most recently from 74ad264 to 962dc08 Compare March 5, 2026 10:51
@yahor-s yahor-s requested a review from aalexfvk March 10, 2026 10:15
@yahor-s yahor-s force-pushed the ch-partial-restore branch from 962dc08 to b2a1b77 Compare March 10, 2026 19:13
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