Skip to content

Commit 9fe71bf

Browse files
committed
Prevent compacting on passthrough tables
1 parent 70255b6 commit 9fe71bf

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v0.4.3
2+
3+
- Fix issue where passthrough table columns could be marked for compaction
4+
15
# v0.4.2
26

37
- Refactored temporary table creation to use sqlalchemy constructs

subsetter/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.4.2"
1+
__version__ = "0.4.3"

subsetter/sampler.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ def __init__(self, source: DatabaseConfig, config: SamplerConfig) -> None:
691691
self.source_engine = source.database_engine(env_prefix="SUBSET_SOURCE_")
692692
self.compact_columns: Dict[Tuple[str, str], Set[str]] = {}
693693
self.temp_tables = TempTableCreator()
694+
self.passthrough_tables: Set[str] = set()
694695

695696
def sample(
696697
self,
@@ -699,6 +700,7 @@ def sample(
699700
truncate: bool = False,
700701
create: bool = False,
701702
) -> None:
703+
self.passthrough_tables = set(plan.passthrough)
702704
meta, _ = DatabaseMetadata.from_engine(self.source_engine, list(plan.queries))
703705
if self.config.infer_foreign_keys != "none":
704706
meta.infer_missing_foreign_keys(
@@ -740,6 +742,11 @@ def _get_compact_columns(
740742
"Table %s has columns configured for compaction but is not found",
741743
table,
742744
)
745+
elif table in self.passthrough_tables:
746+
LOGGER.warning(
747+
"Cannot compact columns on passthrough table %s",
748+
table,
749+
)
743750
else:
744751
compact_columns[table_key] = set(cols)
745752

@@ -752,6 +759,8 @@ def _get_compact_columns(
752759
for table_key, table_meta in meta.tables.items():
753760
if len(table_meta.primary_key) != 1:
754761
continue
762+
if f"{table_key[0]}.{table_key[1]}" in self.passthrough_tables:
763+
continue
755764

756765
col = table_meta.table_obj.columns[table_meta.primary_key[0]]
757766
if not issubclass(col.type.python_type, int): # type: ignore

0 commit comments

Comments
 (0)