You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "paleolimbot (via GitHub)" <gi...@apache.org> on 2026/06/02 21:27:24 UTC
[PR] feat(rust/sedona-geoparquet,rust/sedona-datasource): Add support for partition columns and discovery [sedona-db]
paleolimbot opened a new pull request, #906:
URL: https://github.com/apache/sedona-db/pull/906
Still have to sort out some of the details here but the gist is
```python
import sedona.db
sd = sedona.db.connect()
t = sd.funcs.table.sd_random_geometry()
t.select(
grp=sd.funcs.floor(t.id / 100), geom=sd.funcs.st_setsrid(t.geometry, 3857)
).to_parquet("out_dir", partition_by="grp")
sd.read_parquet("out_dir").show(5)
# ┌──────────────────────────────────────────────┬──────┐
# │ geom ┆ grp │
# │ geometry ┆ utf8 │
# ╞══════════════════════════════════════════════╪══════╡
# │ POINT(59.63310565314948 22.488904786369556) ┆ 9 │
# ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
# │ POINT(83.12076970430842 21.796712564259458) ┆ 9 │
# ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
# │ POINT(30.891948399833048 18.511790453362643) ┆ 9 │
# ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
# │ POINT(87.62900829596556 90.36699740467581) ┆ 9 │
# ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
# │ POINT(89.95104383376538 57.37266977967324) ┆ 9 │
# └──────────────────────────────────────────────┴──────┘
```
Before this PR, the `grp` col wasn't shown (and there was no way to reconstruct it)
Closes #765.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(rust/sedona-geoparquet,rust/sedona-datasource): Add support for partition columns and discovery [sedona-db]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #906:
URL: https://github.com/apache/sedona-db/pull/906#discussion_r3359891587
##########
rust/sedona-geoparquet/src/provider.rs:
##########
@@ -227,6 +255,32 @@ impl GeoParquetReadOptions<'_> {
pub fn validate(&self) -> bool {
self.validate
}
+
+ /// Set table partition columns for hive-style partitioning
+ ///
+ /// Partition columns are extracted from directory paths like `/col=value/`.
+ /// All partition columns are assumed to be `Utf8` type.
+ ///
+ /// Pass an empty vector to explicitly disable partition auto-discovery.
+ pub fn with_table_partition_cols(mut self, cols: Vec<String>) -> Self {
+ self.inner = self.inner.table_partition_cols(
+ cols.into_iter()
+ .map(|name| (name, DataType::Utf8))
+ .collect(),
+ );
Review Comment:
`with_table_partition_cols()` sets explicit partition columns to `DataType::Utf8`, while auto-discovery uses `DataType::Utf8View`. That means the physical Arrow type of partition columns differs depending on whether the user specifies `partitioning` explicitly vs letting it be inferred, which can lead to surprising schema differences for downstream consumers. Consider using `Utf8View` for explicit partition columns as well (consistent with the inferred path).
##########
python/sedonadb/python/sedonadb/context.py:
##########
@@ -192,6 +192,7 @@ def read_parquet(
options: Optional[Dict[str, Any]] = None,
geometry_columns: Optional[Union[str, Dict[str, Any]]] = None,
validate: bool = False,
+ partitioning: Optional[Iterable[str]] = None,
) -> DataFrame:
Review Comment:
`read_parquet()` accepts a string value for `partitioning` (it is normalized with `isinstance(partitioning, str)`), but the type annotation currently excludes `str` (it’s `Optional[Iterable[str]]`). This makes the public API typing inaccurate and can confuse users/type checkers.
##########
rust/sedona-datasource/src/provider.rs:
##########
@@ -133,9 +166,22 @@ impl ReadOptions<'_> for RecordBatchReaderTableOptions {
ExternalFileFormat::new(self.spec.clone())
};
- ListingOptions::new(Arc::new(format))
+ let mut options = ListingOptions::new(Arc::new(format))
.with_file_extension(self.spec.extension())
- .with_session_config_options(config)
+ .with_session_config_options(config);
+
+ // Apply partition columns if explicitly specified (Some)
+ // None means auto-discover later, Some([]) means no partitioning
+ if let Some(ref partition_cols) = self.table_partition_cols {
+ options = options.with_table_partition_cols(
+ partition_cols
+ .iter()
+ .map(|name| (name.clone(), DataType::Utf8))
+ .collect(),
+ );
+ }
Review Comment:
Explicit partition columns are currently created as `DataType::Utf8`, but inferred partition columns use `DataType::Utf8View`. This makes the schema’s physical type depend on whether `partitioning` was provided vs inferred. Using `Utf8View` here would keep partition column types consistent across both code paths.
##########
python/sedonadb/python/sedonadb/context.py:
##########
@@ -356,6 +384,7 @@ def read_format(
spec: "ExternalFormatSpec",
table_paths: Union[str, Path, Iterable[str]],
check_extension: bool = False,
+ partitioning: Union[str, List[str], None] = None,
) -> DataFrame:
Review Comment:
`read_format()` normalizes `partitioning` with `list(partitioning)` and also accepts a string (special-cased), so restricting the type annotation to `List[str]` is inaccurate; other iterables (e.g., tuples) are accepted at runtime. Consider aligning the annotation with `read_pyogrio()` / `read_parquet()` for consistency.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(rust/sedona-geoparquet,rust/sedona-datasource): Add support for partition columns and discovery [sedona-db]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #906:
URL: https://github.com/apache/sedona-db/pull/906#discussion_r3360085810
##########
rust/sedona-geoparquet/src/provider.rs:
##########
@@ -227,6 +255,28 @@ impl GeoParquetReadOptions<'_> {
pub fn validate(&self) -> bool {
self.validate
}
+
+ /// Set table partition columns for hive-style partitioning
+ ///
+ /// Partition columns are extracted from directory paths like `/col=value/`.
+ /// All partition columns are assumed to be `Utf8` type.
+ ///
+ /// Pass an empty vector to explicitly disable partition auto-discovery.
Review Comment:
The docstring for hive partition columns says they are assumed to be `Utf8`, but this API actually accepts an explicit `(name, DataType)` per column and the auto-inferred columns are set to `DataType::Utf8View`. Updating the docs here would avoid confusion for callers and keeps behavior consistent with the implementation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(rust/sedona-geoparquet,rust/sedona-datasource): Add support for partition columns and discovery [sedona-db]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #906:
URL: https://github.com/apache/sedona-db/pull/906#discussion_r3358212216
##########
python/sedonadb/python/sedonadb/context.py:
##########
@@ -375,6 +407,14 @@ def read_format(
table_paths: A str, Path, or iterable of paths/URLs.
check_extension: When `True`, error if a non-collection path
doesn't end in the spec's `extension`. Defaults to `False`.
+ partitioning:
+ Optional list of column names for hive-style partitioning. When reading
+ from a directory with paths like `/col=value/file.ext`, partition
+ column names are auto-discovered by setting `partitioning=None`). Explicitly
+ specify column names (e.g., `["col"]`) to override auto-discovery, or pass an
+ empty list `[]` to disable partitioning entirely. The current
Review Comment:
The docstring for `read_format(..., partitioning=...)` has an extra closing parenthesis in the sentence describing `partitioning=None`, which makes the rendered docs/readability confusing.
##########
rust/sedona-geoparquet/src/provider.rs:
##########
@@ -65,6 +65,22 @@ pub async fn geoparquet_listing_table(
}
}
+ // Auto-discover partition columns only if not explicitly provided (None)
+ // If explicitly set to empty (Some([])), skip auto-discovery
+ if options.table_partition_cols().is_none() {
+ let inferred_partitions = listing_options
+ .infer_partitions(&context.state(), &table_paths[0])
Review Comment:
Partition auto-discovery currently runs whenever `table_partition_cols` is `None`, which is also the default for `GeoParquetReadOptions` (including `GeoParquetReadOptions::default()` used by Rust callers). This means hive partition discovery becomes the default behavior for Rust reads, which appears to conflict with the PR description that partition discovery is opt-in and default behavior is unchanged. Consider clarifying the intended default and, if needed, adding an explicit opt-in/opt-out API (e.g., a dedicated `with_partitioning_auto()` / `without_partitioning()` method) so defaults are unambiguous across Rust and Python bindings.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(rust/sedona-geoparquet,rust/sedona-datasource): Add support for partition columns and discovery [sedona-db]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #906:
URL: https://github.com/apache/sedona-db/pull/906#discussion_r3357755696
##########
python/sedonadb/python/sedonadb/context.py:
##########
@@ -252,6 +253,14 @@ def read_parquet(
Currently the only property that is validated is the WKB of input geometry
columns.
+ partitioning:
+ Optional list of column names for hive-style partitioning. When reading
+ from a directory with paths like `/col=value/file.parquet`, partition
+ column names are auto-discovered when `partitioning=None`). Explicitly
+ specify column names (e.g., `["col"]`) to override auto-discovery, or
Review Comment:
Docstring has a mismatched parenthesis in the `partitioning` description (`partitioning=None`) which makes the rendered docs confusing.
##########
python/sedonadb/python/sedonadb/context.py:
##########
@@ -375,6 +401,14 @@ def read_format(
table_paths: A str, Path, or iterable of paths/URLs.
check_extension: When `True`, error if a non-collection path
doesn't end in the spec's `extension`. Defaults to `False`.
+ partitioning:
+ Optional list of column names for hive-style partitioning. When reading
+ from a directory with paths like `/col=value/file.ext`, partition
+ column names are auto-discovered by default (`None`). Explicitly specify
+ column names (e.g., `["col"]`) to override auto-discovery, or pass an
+ empty list `[]` to disable partitioning entirely. The current
Review Comment:
The `partitioning` docstring here is internally inconsistent: it says auto-discovery is the default (`None`) but also says the current default is to disable partitioning. After aligning the method default to disable partitioning, the docs should describe auto-discovery only when `partitioning=None`.
##########
rust/sedona-datasource/src/provider.rs:
##########
@@ -57,11 +57,17 @@ use crate::{
/// - `true`: builds a [`SingleObjectExternalTable`] that treats each
/// URI as one opaque object, skipping listing entirely. Required
/// for directory-shaped formats like Zarr.
+///
+/// The `partitioning` parameter controls hive-style partition discovery:
+/// - `None`: auto-discover partition columns from directory structure
+/// - `Some([])`: disable partition discovery
+/// - `Some([cols])`: use explicit partition columns
Review Comment:
These Rustdoc examples use `Some([])` / `Some([cols])`, which is not valid Rust syntax and can mislead API users. Prefer `Some(vec![])` / `Some(vec![..])` (or describe it textually without bracket syntax).
##########
python/sedonadb/tests/io/test_parquet.py:
##########
@@ -755,3 +755,41 @@ def test_prune_geography_parquet():
assert matched < total, (
f"Expected pruning to reduce row groups: {matched} matched out of {total}"
)
+
+
+def test_write_partitioned_parquet(con):
+ t = con.funcs.table.sd_random_geometry(seed=3847)
+ t = t.select(
+ id=t.id,
+ geom=con.funcs.st_setsrid(t.geometry, 3857),
+ grp=con.funcs.floor(t.id / 100).cast(pa.string()),
+ )
+
+ with tempfile.TemporaryDirectory() as td:
+ out_dir = Path(td) / "out_dir"
+
+ t.to_parquet(out_dir, partition_by="grp")
+
+ # Test auto-discovery of partition columns (partitioning=None)
+ result = con.read_parquet(out_dir, partitioning=None)
+ assert result.columns == t.columns
+ geopandas.testing.assert_geodataframe_equal(
+ result.sort("id").to_pandas(),
+ t.sort("id").to_pandas(),
+ )
+
+ # The default is to discover the partitioning
Review Comment:
This comment is inaccurate: this call is explicitly specifying the partition column (`partitioning=["grp"]`), not using the default behavior. This can be confusing when reading the test.
##########
python/sedonadb/python/sedonadb/context.py:
##########
@@ -273,7 +282,11 @@ def read_parquet(
return DataFrame(
self._impl,
self._impl.read_parquet(
- [str(path) for path in table_paths], options, geometry_columns, validate
+ [str(path) for path in table_paths],
+ options,
+ geometry_columns,
+ validate,
+ None if partitioning is None else list(partitioning),
),
Review Comment:
`partitioning` is typed as an `Iterable[str]`; if a user passes a single column name as a string (e.g., `partitioning="grp"`), `list(partitioning)` will split it into characters. It’s safer to treat `str` as a single-element case (or raise a TypeError).
##########
rust/sedona/src/context.rs:
##########
@@ -390,12 +390,18 @@ impl SedonaContext {
}
/// Creates a [`DataFrame`] for reading a [ExternalFormatSpec]
+ ///
+ /// The `partitioning` parameter controls hive-style partition discovery:
+ /// - `None`: auto-discover partition columns from directory structure
+ /// - `Some([])`: disable partition discovery
+ /// - `Some([cols])`: use explicit partition columns
Review Comment:
These Rustdoc examples use `Some([])` / `Some([cols])`, which is not valid Rust syntax and can mislead API users. Prefer `Some(vec![])` / `Some(vec![..])` (or describe it textually without bracket syntax).
##########
python/sedonadb/python/sedonadb/context.py:
##########
@@ -356,6 +381,7 @@ def read_format(
spec: "ExternalFormatSpec",
table_paths: Union[str, Path, Iterable[str]],
check_extension: bool = False,
+ partitioning: Optional[List[str]] = None,
) -> DataFrame:
Review Comment:
`read_format()` currently defaults `partitioning` to `None`, which enables auto-discovery by default and contradicts both the docstring (“current default is to disable partitioning”) and the PR description (“default behaviour unchanged; use partitioning=None to auto-discover”). Align the default with `read_parquet()`/`read_pyogrio()` by using an empty iterable default, reserving `None` for auto-discovery.
##########
python/sedonadb/python/sedonadb/context.py:
##########
@@ -346,7 +368,10 @@ def read_pyogrio(
return DataFrame(
self._impl,
self._impl.read_external_format(
- spec, [str(path) for path in table_paths], False
+ spec,
+ [str(path) for path in table_paths],
+ False,
+ None if partitioning is None else list(partitioning),
),
Review Comment:
`partitioning` is an `Iterable[str]`; passing a single string (e.g., `partitioning="grp"`) will currently be split into characters via `list(partitioning)`. Treat `str` as a special case (or raise) to avoid surprising behavior.
##########
python/sedonadb/python/sedonadb/context.py:
##########
@@ -390,7 +424,10 @@ def read_format(
return DataFrame(
self._impl,
self._impl.read_external_format(
- spec, [str(path) for path in table_paths], check_extension
+ spec,
+ [str(path) for path in table_paths],
+ check_extension,
+ None if partitioning is None else list(partitioning),
),
Review Comment:
`list(partitioning)` will split a string into characters if a caller passes `partitioning="col"`. Since this is a public API, it’s safer to treat `str` as a single column name (or raise a TypeError).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat(rust/sedona-geoparquet,rust/sedona-datasource): Add support for partition columns and discovery [sedona-db]
Posted by "zhangfengcdt (via GitHub)" <gi...@apache.org>.
zhangfengcdt commented on code in PR #906:
URL: https://github.com/apache/sedona-db/pull/906#discussion_r3364015808
##########
python/sedonadb/tests/io/test_pyogrio.py:
##########
@@ -91,19 +91,24 @@ def test_read_ogr_multi_file(con):
con.read_parquet(parquet_path).to_pandas().to_file(fgb_path)
# Reading a directory while specifying the extension should work
+ # Partition columns are auto-discovered from the directory structure
con.read_pyogrio(f"{td}", extension="fgb").to_view(
"gdf_from_dir", overwrite=True
)
geopandas.testing.assert_geodataframe_equal(
- con.sql("SELECT * FROM gdf_from_dir ORDER BY idx").to_pandas(),
- gdf.filter(["idx", "wkb_geometry"]),
+ con.sql(
Review Comment:
Looks like due to the default behavior changes and now it needs to explicitly add "partition", the public constructor would be impacted. Maybe we should highlight the changes in the PR description or and change log if we don't want this change to be opt-in?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org