Skip to content

Commit

Permalink
datasets: Fix dataset loader
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Mar 7, 2024
1 parent 1f375f3 commit 0546cef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

## Unreleased

- datasets: Fix dataset loader


## 2024/03/07 v0.0.6

Expand Down
10 changes: 6 additions & 4 deletions cratedb_toolkit/datasets/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 0546cef

Please sign in to comment.