diff --git a/cratedb_toolkit/cfr/systable.py b/cratedb_toolkit/cfr/systable.py index 9fb122a4..ad9f1f0f 100644 --- a/cratedb_toolkit/cfr/systable.py +++ b/cratedb_toolkit/cfr/systable.py @@ -58,7 +58,7 @@ class ExportSettings: DATA_PATH = "data" # The filename prefix when storing tables to disk. - TABLE_FILENAME_PREFIX = "sys-" + TABLE_FILENAME_PREFIX = "sys_" class SystemTableInspector: @@ -143,7 +143,12 @@ def save(self) -> Path: # Write schema file. with open(path_table_schema, "w") as fh_schema: - print(self.inspector.ddl(tablename_in=tablename, tablename_out=tablename_out), file=fh_schema) + print( + self.inspector.ddl( + tablename_in=tablename, tablename_out=tablename_out, out_schema=self.info.cluster_name + ), + file=fh_schema, + ) # Write data file. df = self.read_table(tablename=tablename) diff --git a/tests/cfr/assets/sys-operations.jsonl b/tests/cfr/assets/sys_operations.jsonl similarity index 100% rename from tests/cfr/assets/sys-operations.jsonl rename to tests/cfr/assets/sys_operations.jsonl diff --git a/tests/cfr/assets/sys-operations.sql b/tests/cfr/assets/sys_operations.sql similarity index 65% rename from tests/cfr/assets/sys-operations.sql rename to tests/cfr/assets/sys_operations.sql index 580624a9..9117ef94 100644 --- a/tests/cfr/assets/sys-operations.sql +++ b/tests/cfr/assets/sys_operations.sql @@ -1,4 +1,4 @@ -CREATE TABLE IF NOT EXISTS "sys-operations" ( +CREATE TABLE IF NOT EXISTS "crate"."sys_operations" ( id STRING, job_id STRING, name STRING, diff --git a/tests/cfr/test_cli.py b/tests/cfr/test_cli.py index a282af29..3e0648e3 100644 --- a/tests/cfr/test_cli.py +++ b/tests/cfr/test_cli.py @@ -56,32 +56,32 @@ def test_cfr_cli_import(cratedb, tmp_path, caplog): # Blank database canvas. imported_system_tables = [ - "sys-allocations", - "sys-checks", - "sys-cluster", - "sys-health", - "sys-jobs", - "sys-jobs_log", - "sys-jobs_metrics", - "sys-node_checks", - "sys-nodes", - "sys-operations", - "sys-operations_log", - "sys-privileges", - "sys-repositories", - "sys-roles", - "sys-segments", - "sys-shards", - "sys-snapshot_restore", - "sys-snapshots", - "sys-users", + "sys_allocations", + "sys_checks", + "sys_cluster", + "sys_health", + "sys_jobs", + "sys_jobs_log", + "sys_jobs_metrics", + "sys_node_checks", + "sys_nodes", + "sys_operations", + "sys_operations_log", + "sys_privileges", + "sys_repositories", + "sys_roles", + "sys_segments", + "sys_shards", + "sys_snapshot_restore", + "sys_snapshots", + "sys_users", ] cratedb.reset(imported_system_tables) # Provision filesystem to look like a fake `sys-export` trace. assets_path = files(tests.cfr) / "assets" - sys_operations_schema = assets_path / "sys-operations.sql" - sys_operations_data = assets_path / "sys-operations.jsonl" + sys_operations_schema = assets_path / "sys_operations.sql" + sys_operations_data = assets_path / "sys_operations.jsonl" schema_path = tmp_path / "schema" data_path = tmp_path / "data" schema_path.mkdir() @@ -104,7 +104,7 @@ def test_cfr_cli_import(cratedb, tmp_path, caplog): # Verify outcome. results = cratedb.database.run_sql("SHOW TABLES", records=True) - assert results == [{"table_name": "sys-operations"}] + assert results == [{"table_name": "sys_operations"}] - cratedb.database.run_sql('REFRESH TABLE "sys-operations"') - assert cratedb.database.count_records("sys-operations") == 1 + cratedb.database.run_sql('REFRESH TABLE "sys_operations"') + assert cratedb.database.count_records("sys_operations") == 1