Skip to content

ES: convert province by province, then merge - #338

Merged
m-mohr merged 7 commits into
mainfrom
es-per-file
Oct 30, 2026
Merged

m-mohr merged 7 commits into
mainfrom
es-per-file

Conversation

@ivorbosloper

@ivorbosloper ivorbosloper commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

The new es converters converts 50 provincial GeoPackages individually and merges the parts. The whole of Spain does not fit in memory in one run. Closes #336.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@m-mohr

m-mohr commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Does it handle collectio metadata correctly? Especially creating columns for e.g. different data colimng from there? License, variant/state/kanton, etc? Ideally it mimics what vec merge does and can be used as a generic replacement as vec merge in geopandas will be an issue anyway in the long run.

@ivorbosloper

ivorbosloper commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Good point. There's a bug in vec merge due to the "collection" properties (which are not read correctly). A constant property gets into collection, and merge_parquet keeps only what all parts agree on. So admin_province_code is lost in the full ES run and should be expanded again to a column-property. I'll fix merge_parquet in vecorel-cli to hydrate those per part, as vec merge does; this PR then only bumps the pin.

@ivorbosloper

Copy link
Copy Markdown
Collaborator Author

Fix: vecorel/cli#55. Checked on two real provinces: admin_province_code is a column again.

@ivorbosloper

Copy link
Copy Markdown
Collaborator Author

I'll wait with making this a Non-Draft PR, it needs a vecorel dependency update due to vecorel/cli#55

@m-mohr

m-mohr commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

@ivorbosloper vecorel-cli v0.4.0 has been released. I must say I forgot what the next steps were after finishing vecorel-cli...

@ivorbosloper
ivorbosloper marked this pull request as ready for review October 24, 2026 20:31
@ivorbosloper

Copy link
Copy Markdown
Collaborator Author

@m-mohr The next step was this PR: it only waited for vecorel/cli#55, which is in 0.4.0, and main already pins that. I merged main in and checked it:

  • Álava and Ávila, converted per province and merged with vecorel-cli 0.4.0, validate; admin_province_code is a column again (01 and 05), while admin:country_code, the same everywhere, stays in the collection metadata.
  • The test now merges two different provinces and checks that admin_province_code keeps both values, which is the case your question was about.

On a generic replacement for vec merge: merge_parquet already does what vec merge does with collection constants (keeps what all parts agree on, turns the rest into columns), so this mixin leaves that to it rather than repeating it.

@m-mohr

m-mohr commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Sorry, I don't understand what this PR is meant to do and the AI response doesn't help with understanding it. Could a human take over, please?

This comment was marked as resolved.

…one source'

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ivorbosloper

ivorbosloper commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator Author

Sorry, I don't understand what this PR is meant to do and the AI response doesn't help with understanding it. Could a human take over, please?

@m-mohr Yes. The es-converter memory consumption was too high, all features from 50 source files were put in one gdf. I added a simple "PerFileConverterMixin" class that only overrides the convert method. It transforms all url-sources individually to intermediate parquet files, and then uses DuckDB to merge it.

@m-mohr

m-mohr commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Is this still needed given all the upstream improvements?
We didn't do this for ch either, instead of converting the individual converters and using vec merge...

@ivorbosloper

ivorbosloper commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Is this still needed given all the upstream improvements? We didn't do this for ch either, instead of converting the individual converters and using vec merge...

We now need between 30/40 Gb, with this PR merged it peeks during sort at around 10 Gb. ch is separate converters because of license/attribution changes. jp does something similar with DuckDB converter, but using this here requires more changes.

m-mohr added a commit to vecorel/cli that referenced this pull request Oct 30, 2026
* Moves the per-file conversion from fiboa/cli#338 into vecorel-cli, as it isn't fiboa-specific and builds on `merge_parquet`.

- Added `PerFileConverterMixin`: converts each source on its own into a temporary part and merges the parts with `merge_parquet`.
- Added `get_input_urls()` to `BaseConverter`, used by both converters, so the mixin resolves the sources once and logs the input/variant warnings once instead of per part.
- Tests for the merge of two sources (incl. constants that differ per part becoming a column) and for a single source.

* Fix 7z handling

* Fix no compression handling in duckdb
@m-mohr

m-mohr commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

I've migrated the mixin to vecorel-cli and updated this PR accordingly.

@m-mohr
m-mohr merged commit bf4779b into main Oct 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ES: convert all of Spain in one run, or per file

3 participants