Skip to content

Fix coordinate-bound support and safe partition pruning - #248

Open
ghostiee-11 wants to merge 1 commit into
xqlsystems:mainfrom
ghostiee-11:fix/coordinate-bounds-121
Open

Fix coordinate-bound support and safe partition pruning#248
ghostiee-11 wants to merge 1 commit into
xqlsystems:mainfrom
ghostiee-11:fix/coordinate-bounds-121

Conversation

@ghostiee-11

@ghostiee-11 ghostiee-11 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Adds exact coordinate bounds for numeric, boolean, string, binary, timestamp, and duration types while keeping pruning and statistics conservative and overflow-safe.
Closes #121.

@ghostiee-11

Copy link
Copy Markdown
Contributor Author

@alxmrs Can you review this :)

@alxmrs alxmrs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for supporting all these types.

Comment thread Cargo.toml
pyo3 = { version = "0.28.0", features = ["extension-module", "abi3-py310"] }
# platform works on all CPython >= 3.10 (matching `requires-python`). Maturin
# enables `pyo3/extension-module` through pyproject.toml for wheel builds; it
# must stay disabled for ordinary Cargo test binaries so they link libpython.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this.

Comment thread src/lib.rs

// TODO(alxmrs, Claude): Support every valid xarray coordinate type.
/// Scalar value for dimension bounds, supporting common xarray coordinate types.
/// Scalar value for orderable xarray dimension bounds.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niice

Comment thread src/lib.rs
DurationSecond(i64),
DurationMillisecond(i64),
DurationMicrosecond(i64),
DurationNanosecond(i64),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/lib.rs

// Incompatible types
_ => None,
fn integer_bound(bound: &ScalarBound) -> Option<IntegerBound> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we promote to 128 for comparisons, then return back?

Comment thread src/lib.rs
let val = obj.extract::<i64>()?;
Ok(ScalarBound::Int64(val))
}
"bool" => Ok(ScalarBound::Boolean(obj.extract::<bool>()?)),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice

Comment thread src/lib.rs
TimeUnit::Second if v % 1_000_000_000 == 0 => Some(v / 1_000_000_000),
_ => None,
}?;
(ScalarBound::Utf8(v), DataType::Utf8) => Some(ScalarValue::Utf8(Some(v.clone()))),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

Comment thread tests/test_df.py


def test_partition_metadata_skips_out_of_ns_datetime():
# datetime64 coordinates outside the datetime64[ns] range (pre-1678 /

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to see this deleted.

Comment thread tests/test_reader.py
assert result["x"].tolist() == [6, 7]
assert tracker.iteration_count == 1

@pytest.mark.parametrize("dtype", ["float32", "float64"])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you import half floats (float16)? If so, it might be good to test.

Comment thread xarray_sql/df.py
if cft.is_cftime_index(ds, coord_name):
units, calendar = cft.encoding(ds, coord_name)
columns.append(cft.arrow_field(coord_name, units, calendar))
elif isinstance(coord_var.dtype, pd.CategoricalDtype):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy we're covering this case.

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.

Support all xarray coordinate types in ScalarBound

2 participants