<#3665 fix(targets): reuse SQLAlchemy inspector re...
# meltano-repo-activity
g
#3665 fix(targets): reuse SQLAlchemy inspector reflection cache Pull request opened by akashmalbari Closes #3478. Summary This updates
SQLConnector
to reuse a cached SQLAlchemy
Inspector
instance for repeated reflection calls instead of creating a new
sa.inspect(self._engine)
for each call. The affected methods now share the connector-level Inspector: •
table_exists()
•
schema_exists()
•
get_table_columns()
This preserves SQLAlchemy's
Inspector.info_cache
across reflection calls, allowing dialect-level reflection caching optimizations to work as intended. Cache invalidation Because the Inspector now persists across calls, this also adds a reflection cache clearing helper and clears the cache after connector-managed DDL operations such as: • creating schemas • creating tables • adding columns • renaming columns • altering column types This avoids stale reflection after the SDK itself changes the target schema. Tests Added regression coverage for: • reusing a single Inspector across repeated SQLConnector reflection calls • clearing the cached Inspector reflection cache • avoiding stale reflection state after connector-managed DDL Validation •
uv run pytest tests/sql/test_connector.py -q
•
uv run pytest tests/sql -q
•
uv sync --all-groups --all-extras --all-packages
•
uv run pytest tests -q
•
uvx nox -t typing
•
uvx pre-commit run --all-files
Summary by Sourcery Cache and reuse a SQLAlchemy Inspector within SQLConnector to enable reflection caching and invalidate it after connector-managed schema changes. Bug Fixes: • Ensure SQLConnector reuses a single SQLAlchemy Inspector instance for reflection so dialect-level reflection caches are preserved across calls. • Clear the Inspector reflection cache after connector-managed DDL operations (schema/table creation, column add/rename/type change, table recreation) to avoid stale metadata. Documentation: • Add AGENTS.md with contributor-facing guidance on development setup, commands, code style, exceptions, deprecation policy, architecture, testing, and project structure. Tests: • Add regression tests covering Inspector reuse across reflection methods, reflection cache clearing behavior, and cache invalidation after DDL operations. meltano/sdk