Skip to content

Commit 200c61a

Browse files
committed
Export collection and set compression
1 parent 852fb6a commit 200c61a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

fiboa_cli/conversion/duckdb.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@ def convert(
6767
else:
6868
sources = "[" + ",".join([f'"{url}"' for url in urls]) + "]"
6969

70-
_collection = self.create_collection(cid)
71-
_collection.update(self.column_additions)
72-
_collection["collection"] = self.id
73-
collection = json.dumps(_collection, cls=VecorelJSONEncoder).encode("utf-8")
70+
collection = self.create_collection(cid)
71+
collection.update(self.column_additions)
72+
collection["collection"] = self.id
7473

75-
schemas = _collection.merge_schemas({})
74+
schemas = collection.merge_schemas({})
7675
props = schemas.get("properties", {})
7776
required = schemas.get("required", [])
7877
pq_fields = []
@@ -91,10 +90,12 @@ def convert(
9190
if isinstance(output_file, Path):
9291
output_file = str(output_file)
9392

94-
pq_schema = pa.schema(pq_fields)
95-
schema_bytes = pq_schema.serialize().to_pybytes()
93+
# pq_schema = pa.schema(pq_fields)
94+
# schema_bytes = pq_schema.serialize().to_pybytes()
9695
# pq_schema = pq_schema.with_metadata({"collection": collection})
9796

97+
collection_json = json.dumps(collection, cls=VecorelJSONEncoder).encode("utf-8")
98+
9899
con = duckdb.connect()
99100
con.install_extension("spatial")
100101
con.load_extension("spatial")
@@ -106,14 +107,13 @@ def convert(
106107
ORDER BY ST_Hilbert({geom_column})
107108
) TO ? (
108109
FORMAT parquet,
109-
compression 'brotli',
110+
compression '{compression}',
110111
KV_METADATA {{
111112
collection: ?,
112-
"PYARROW:schema": ?
113113
}}
114114
)
115115
""",
116-
[output_file, collection, schema_bytes],
116+
[output_file, collection_json],
117117
)
118118

119119
return output_file

0 commit comments

Comments
 (0)