feat: first attempt at item table logic - #1
Conversation
b11ebd9 to
ce2c08e
Compare
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
gadomski
left a comment
There was a problem hiding this comment.
Sorry about getting nitpicky on the API design, but I think this is a critical PR ... if we get it right now, it'll be smooth later.
|
|
||
| @dataclass | ||
| class IcestacCatalog: | ||
| """Icestac client class for pyiceberg Catalog""" |
There was a problem hiding this comment.
I find it quite interesting that we get to share the Catalog name between STAC and iceberg. This can be convenient, and it has the potential to introduce "shadowing" to our namespace, such that we get confused about which "catalog" we're referring to.
No action required, just an observation.
There was a problem hiding this comment.
I have not thought about it this way. In Iceberg the Catalog is like a database in PostgreSQL.
There was a problem hiding this comment.
Which makes sense, if we think of a single pgstac instance as being a Catalog?
| partition_spec=PartitionSpec( | ||
| # TODO: make temporal partitioning configurable | ||
| PartitionField( | ||
| source_id=iceberg_schema.find_field("datetime").field_id, | ||
| field_id=1000, | ||
| transform=MonthTransform(), | ||
| name="datetime_month", | ||
| ) | ||
| ), |
There was a problem hiding this comment.
The fact that there's a partition_spec in Iceberg is encouraging to me. Are there other partition specs out there that we could coalesce into a generalized "STAC partition spec"?
There was a problem hiding this comment.
I think a STAC Iceberg spec should include some kind of spatial structure but I'm not sure if we would partition on a spatial key necessarily.
The pyiceberg docs show this example on how to apply a sort_key which could be used for sorting records spatially (with a Hilbert curve or something):
# Sort on the symbol
sort_order = SortOrder(SortField(source_id=2, transform='identity'))
catalog.create_table(
identifier="docs_example.bids",
schema=schema,
partition_spec=partition_spec,
sort_order=sort_order,
)|
I still want to explore ideas around the STAC PartitionSpec, but the rest of the library is looking pretty good to me. While working on the config changes I realized that most of the settings were just being passed onto pyiceberg and should therefore be delegated to |
Yup! |
|
After putting this on ice for a few months I came back to finally address @gadomski's comments. The package is set up to create a catalog structure like this:
I haven't thought much about schema migration yet but that is something that icestac is theoretically good for since Iceberg has methods for this. I need to revisit how we are representing the spatial columns and/or spatial metadata to ensure the tables are making best use of the geoparquet format and downstream capabilities. I am a bit lost with the state of |
This is a bummer, Other than that, 👍🏼 to picking reasonable defaults for now, leaving the customization knobs for later.
Agreed, it's messy, and (in my experience) often abstracted away into upstream tooling (but not always). |
Actually, I am mistaken. Hyphens are allowed in Iceberg table names but some catalog backends don't allow them (i.e. AWS Glue). The only character is that is universally not allowed is SELECT id, datetime, collection, geometry
FROM catalog.icestac."icesat2-boreal-v3-1-agb"
LIMIT 10;The table name should match collection ids exactly so clients can confidently do queries by collection without any guesswork. I suppose we could specify a slugification system for translating any collection id into a valid table name, but then client applications would need to be aware of the translation function. e.g. collection id |
|
My instinct is that it's better to keep the |
Preserve nullable STAC fields and Arrow metadata, and reject invalid or cross-collection loads. Align the HLS demo and documentation with the one-table-per-collection contract.
|
I am back again with a few updates, this time I think the item handling API might be ready to ship:
|
This is the initial attempt at icestac: the STAC extension for Apache Iceberg.
It defers almost all Iceberg operations to pyiceberg but includes some helper functions for generating Iceberg table schemas from STAC items and a function for loading items into an existing table.
At first I had a special
IcebergCatalogclass that handled some partitioning defaults and other table mechanics, but after some deliberation I decided that it would be better to keep the icestac layer as thin as possible for now and provide some working examples on how to stuff STAC items into Iceberg tables.The docker-compose.yml file will spin up a local S3 storage backend and an Iceberg REST service that you can interact with via
main.pywhich loads some HLS STAC items into a table in the local Iceberg catalog.