Skip to content

Commit bcbae97

Browse files
committed
fixed a bug in an old schema test
1 parent 9df5329 commit bcbae97

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

dsi/core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ def artifact_handler(self, interaction_type, query = None, **kwargs):
484484
if self.debug_level != 0:
485485
self.logger.error(f"Error ingesting data in {original_file} @ line {return_line_number} due to {errorMessage[1]}")
486486
if self.user_wrapper:
487+
if errorMessage[1].startswith("A complex schema"):
488+
raise errorMessage[0](errorMessage[1])
487489
raise errorMessage[0](f"Error ingesting data due to {errorMessage[1]}")
488490
else:
489491
raise errorMessage[0](f"Error ingesting data in {original_file} @ line {return_line_number} due to {errorMessage[1]}")

dsi/dsi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def schema(self, filename = None):
100100
if not os.path.exists(filename):
101101
sys.exit("schema() ERROR: Input schema file must have a valid filepath. Please check again.")
102102
if "dsi_relations" in self.t.active_metadata:
103-
sys.exit("schema() ERROR: Input schema file must have a valid filepath. Please check again.")
103+
sys.exit("schema() ERROR: There is already a complex schema in memory. First load all its associated files.")
104104

105105
fnull = open(os.devnull, 'w')
106106
with redirect_stdout(fnull):

dsi/tests/test_dsi.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -858,10 +858,9 @@ def test_error_schema_sqlite_backend():
858858

859859
try:
860860
test.schema(filename="examples/test/yaml1_schema.json")
861-
test.query("SELECT * FROM math") # Querying data but need to load in associated data after loading in schema
862861
assert False
863862
except SystemExit as e:
864-
expected = "ERROR: Cannot query() on an empty backend. Please ensure there is data in it."
863+
expected = "schema() ERROR: There is already a complex schema in memory. First load all its associated files."
865864
assert str(e) == expected
866865

867866
def test_query_update_schema_sqlite_backend():
@@ -1797,5 +1796,6 @@ def test_fail_overwrite_schema_duckdb_backend():
17971796
try:
17981797
test.schema(filename="examples/test/yaml1_circular_schema.json") # should not allow circular dependency overwrite
17991798
assert False
1800-
except:
1801-
assert True
1799+
except SystemExit as e:
1800+
expected = "schema() ERROR: A complex schema with a circular dependency cannot be ingested into a DuckDB backend."
1801+
assert str(e) == expected

0 commit comments

Comments
 (0)