Skip to content

Add LIKE/EXCEPT pattern support for DUMP TABLES filtering #436

@apstndb

Description

@apstndb

Feature Request

Add support for LIKE and EXCEPT patterns in DUMP TABLES statement to allow flexible table filtering, with future extension to named schemas.

Current State

DUMP TABLES currently accepts a comma-separated list of exact table names:

DUMP TABLES table1, table2, table3

Proposed Enhancement

Support pattern matching for table selection:

-- Export all tables matching a pattern
DUMP TABLES LIKE 'User%'

-- Export all tables except those matching a pattern
DUMP TABLES EXCEPT 'Test%', 'Tmp%'

-- Combine LIKE and EXCEPT
DUMP TABLES LIKE 'User%' EXCEPT 'UserTest%'

Future Extension: Named Schema Support

When named schemas are supported in Cloud Spanner, this can be naturally extended:

-- Export tables from specific schemas
DUMP TABLES FROM SCHEMA 'public' LIKE 'User%'
DUMP TABLES FROM SCHEMA 'analytics' EXCEPT 'Tmp%'

-- Or with schema patterns
DUMP TABLES LIKE '%.User%'  -- All User tables in any schema
DUMP TABLES LIKE 'public.%' -- All tables in public schema

Implementation Approach

The filtering can be implemented by adding WHERE conditions to the INFORMATION_SCHEMA.TABLES query:

-- Current: For table name patterns
WHERE TABLE_NAME LIKE 'User%'
WHERE TABLE_NAME NOT LIKE 'Test%'

-- Future: For schema + table patterns
WHERE TABLE_SCHEMA LIKE 'public' AND TABLE_NAME LIKE 'User%'
WHERE CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) LIKE 'public.User%'

This approach:

  • Leverages existing SQL pattern matching capabilities
  • Works naturally with the existing dependency ordering logic
  • Easily extensible when named schemas become available
  • No need for client-side pattern matching implementation
  • Consistent with SQL conventions

Use Cases

  1. Development/Production separation: Export all tables except test data
  2. Module-specific exports: Export only tables for a specific feature
  3. Schema-based exports (future): Export entire schemas or cross-schema patterns
  4. Multi-tenant scenarios (future): Export data for specific tenants using schema patterns

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions