Skip to content

Commit a861562

Browse files
committed
fix: default to validate=False for Altair chart creation
Boxplots (and potentially other specs) use Vega-Lite features that Altair's schema validation rejects. Disabling validation by default avoids spurious ValidationErrors while still rendering correctly.
1 parent 962dcbb commit a861562

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# Changelog
22

3-
## 0.3.0 (unreleased)
3+
## 0.3.2 (unreleased)
44

55
### Changed
66

7-
- Upgraded to ggsql Rust crate v0.3.0. See the [upstream changelog](https://github.com/posit-dev/ggsql/blob/main/CHANGELOG.md) for details on new features, bug fixes, and breaking changes.
7+
- `render_altair()` and `VegaLiteWriter.render_chart()` now default to `validate=False` when creating Altair chart objects. This avoids `ValidationError`s for valid specs (e.g., boxplots) that use Vega-Lite features not yet reflected in Altair's schema. Pass `validate=True` to re-enable.
8+
9+
## 0.3.1
10+
11+
### Changed
12+
13+
- Upgraded to ggsql Rust crate v0.3.1.
814
- Replaced polars with Arrow (via pyarrow) for the Rust↔Python data bridge. `DuckDBReader.execute_sql()`, `Spec.data()`, `Spec.layer_data()`, and `Spec.stat_data()` now return `pyarrow.Table` instead of `polars.DataFrame`. `DuckDBReader.register()` accepts `pyarrow.Table` (polars DataFrames are still accepted via automatic conversion). Custom readers returning polars DataFrames from `execute_sql()` continue to work without changes.
915
- Runtime dependency changed from `polars` to `pyarrow`.
1016

python/ggsql/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
def _json_to_altair_chart(vegalite_json: str, **kwargs: Any) -> AltairChart:
5151
"""Convert a Vega-Lite JSON string to the appropriate Altair chart type."""
52+
kwargs.setdefault("validate", False)
5253
spec = json.loads(vegalite_json)
5354

5455
if "layer" in spec:
@@ -94,7 +95,8 @@ def render_chart(self, spec: Spec, **kwargs: Any) -> AltairChart:
9495
The resolved visualization specification from ``reader.execute()``.
9596
**kwargs
9697
Additional keyword arguments passed to ``altair.Chart.from_json()``.
97-
Common options include ``validate=False`` to skip schema validation.
98+
Vega-Lite schema validation is disabled by default; pass
99+
``validate=True`` to re-enable it.
98100
99101
Returns
100102
-------
@@ -121,7 +123,8 @@ def render_altair(
121123
VISUALISE spec string (e.g., "VISUALISE x, y DRAW point")
122124
**kwargs
123125
Additional keyword arguments passed to `from_json()`.
124-
Common options include `validate=False` to skip schema validation.
126+
Vega-Lite schema validation is disabled by default; pass
127+
`validate=True` to re-enable it.
125128
126129
Returns
127130
-------

0 commit comments

Comments
 (0)