diff --git a/CHANGES.md b/CHANGES.md index 5fbf53dd..180a5324 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,8 @@ ## Unreleased +- datasets: Fix dataset loader + ## 2024/03/07 v0.0.6 diff --git a/cratedb_toolkit/datasets/model.py b/cratedb_toolkit/datasets/model.py index 4004ebed..e0ef6f2d 100644 --- a/cratedb_toolkit/datasets/model.py +++ b/cratedb_toolkit/datasets/model.py @@ -103,10 +103,12 @@ def load( cardinality = self.db.count_records(self.table, errors="ignore") has_data = cardinality > 0 - if not has_data and not if_exists == "noop": - if self.init_sql is None: - raise ValueError("SQL for loading data is missing") - self.run_sql(self.init_sql) + if if_exists == "noop" and has_data: + return + + if self.init_sql is None: + raise ValueError("SQL for loading data is missing") + self.run_sql(self.init_sql) def run_sql(self, sql: str): for statement in sqlparse.parse(sql):