Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions icebug_format/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ def generate_schema_cypher(
parquet_dir: Path,
edge_relationships: dict,
node_type_to_table: dict,
storage_path: str,
) -> str:
"""
Generate schema.cypher content for ladybugdb.
Expand All @@ -207,7 +206,6 @@ def generate_schema_cypher(
parquet_dir: Path to the parquet output directory (for storage path)
edge_relationships: Dict of edge relationships from schema
node_type_to_table: Mapping of node types to table names
storage_path: Storage path string for schema.cypher

Returns:
String containing the schema.cypher content
Expand Down Expand Up @@ -252,7 +250,7 @@ def get_edge_display_name(table_name: str) -> str:
display_name = node_display_names[node_table]
lines.append(
f"CREATE NODE TABLE {display_name}({cols_str}, PRIMARY KEY({pk_col})) "
f"WITH (storage = '{storage_path}', format = 'icebug-disk');"
f"WITH (storage = '', format = 'icebug-disk');"
)
except Exception as e:
print(
Expand Down Expand Up @@ -296,7 +294,7 @@ def get_edge_display_name(table_name: str) -> str:
props_str = ", ".join(col_defs)
lines.append(
f"CREATE REL TABLE {rel_name}(FROM {src_table} TO {dst_table}"
f"{', ' + props_str if props_str else ''}) WITH (storage = '{storage_path}', format = 'icebug-disk');"
f"{', ' + props_str if props_str else ''}) WITH (storage = '', format = 'icebug-disk');"
)
except Exception as e:
print(f"Warning: Could not generate schema for rel table {rel_name}: {e}")
Expand Down Expand Up @@ -379,8 +377,7 @@ def get_display_name(table_name: str, prefix: str) -> str:
edge_tables,
parquet_dir,
edge_relationships,
node_type_to_table,
storage_path,
node_type_to_table
)
schema_file = parquet_dir / "schema.cypher"
schema_file.write_text(schema_cypher)
Expand Down
7 changes: 2 additions & 5 deletions icebug_format/graphar.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,6 @@ def insert_relation(values):

print(f"Parquet output directory: {parquet_dir}")

# Compute storage path (points to the parquet directory)
storage_path = f"./{parquet_dir.name}"

# Export node tables: nodes_<vertex_type>.parquet
for vertex_type, src_table in vertex_type_to_table.items():
csr_node_table = f"{csr_table_name}_{src_table}"
Expand Down Expand Up @@ -514,7 +511,7 @@ def insert_relation(values):
cols_str = ", ".join(col_defs)
schema_lines.append(
f"CREATE NODE TABLE {vertex_type}({cols_str}, PRIMARY KEY({pk_col})) "
f"WITH (storage = '{storage_path}', format = 'icebug-disk');"
f"WITH (storage = '', format = 'icebug-disk');"
)
except Exception as e:
print(
Expand Down Expand Up @@ -542,7 +539,7 @@ def insert_relation(values):
props_str = ", ".join(col_defs)
schema_lines.append(
f"CREATE REL TABLE {edge_type}(FROM {src_type} TO {dst_type}"
f"{', ' + props_str if props_str else ''}) WITH (storage = '{storage_path}', format = 'icebug-disk');"
f"{', ' + props_str if props_str else ''}) WITH (storage = '', format = 'icebug-disk');"
)
except Exception as e:
print(f"Warning: Could not generate schema for rel table {edge_type}: {e}")
Expand Down
19 changes: 2 additions & 17 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def test_schema_path_maps_from_to_node_types():

schema_path = Path(tmpdir) / "in_schema.cypher"
schema_path.write_text(
"CREATE REL TABLE livesin(FROM user TO city) WITH (storage='x', format='icebug-disk');\n"
"CREATE REL TABLE livesin(FROM user TO city) WITH (storage='', format='icebug-disk');\n"
)

create_csr_graph_to_duckdb(
Expand Down Expand Up @@ -399,22 +399,7 @@ def test_storage_path_appears_in_schema_cypher():
)

out_schema = (_parquet_dir(out) / "schema.cypher").read_text()
assert "./my_custom_store" in out_schema


def test_storage_path_default_uses_output_stem():
"""When storage_path is omitted the output DB stem is used as the default."""
with tempfile.TemporaryDirectory() as tmpdir:
src = str(Path(tmpdir) / "src.duckdb")
out = str(Path(tmpdir) / "out.duckdb")
_make_source_db(src, [(0, 1)])

create_csr_graph_to_duckdb(src, out, add_reverse_edges=False, memory_limit=_MEM)

out_schema = (_parquet_dir(out) / "schema.cypher").read_text()
# Default storage_path is "./out" (stem of out.duckdb)
assert "./out" in out_schema

assert "storage = ''" in out_schema

def test_default_csr_table_name_is_sql_safe():
assert default_csr_table_name("wikidata-20250625") == "wikidata_20250625"
Expand Down
Loading