validate() rejects documented aggregate example before global mappings and aliases are resolved
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 领域
- backend, testing-qa
调研方向
从 src/validate.rs 开始,将其对 layer 映射的准备过程与 src/execute/mod.rs 中的执行路径进行比较,尤其关注 resolve_aesthetic_aliases()。使用 doc/syntax/layer/type/range.qmd 中记录的查询进行复现。完成的标准是:查询能够无错误地通过验证,验证与执行保持一致,并且确实未映射的聚合目标仍会通过回归覆盖失败。
由索引模型根据 Issue 内容生成。
描述
Summary
At v0.4.1, validate() rejects the documented aggregate range example even though the same query executes and renders successfully.
This creates a validation/execution parity problem for integrations that call validate() before execute(): a renderable chart is suppressed with:
Layer 1: aggregate target 'x' is not mapped on this layer
The example is currently documented in doc/syntax/layer/type/range.qmd.
Tested against tag v0.4.1, commit 6fcb07fd7ba40039c61b839c9979e0cad3bceea5.
Minimal reproduction
This uses the Python bindings pinned to core ggsql = "=0.4.1", but the failing behavior comes from the core ggsql::validate path.
import ggsql
import pyarrow as pa
query = """SELECT * FROM airquality
VISUALISE Date AS x, Temp AS ymin, Temp AS ymax, Temp AS color
DRAW range
REMAPPING aggregate AS linewidth
SETTING aggregate => (
'x:first',
'ymin:first', 'ymin:min',
'ymax:last', 'ymax:max',
'color:diff'
), hinge => null
PARTITION BY Week
SCALE linewidth TO (5, 1)
SCALE BINNED color TO ('steelblue', 'firebrick')
SETTING breaks => (-20, 0, 20)"""
reader = ggsql.DuckDBReader("duckdb://memory")
reader.register(
"airquality",
pa.table(
{
"Date": [
"1973-05-01",
"1973-05-02",
"1973-05-08",
"1973-05-09",
],
"Temp": [67, 72, 68, 75],
"Week": [18, 18, 19, 19],
}
),
)
validated = ggsql.validate(query)
print(validated.valid())
print(validated.errors())
spec = reader.execute(query)
rendered = ggsql.VegaLiteWriter().render(spec)
print(len(rendered))
Actual output:
False
[{'message': "Layer 1: aggregate target 'x' is not mapped on this layer", 'location': None}]
6758
Expected:
validated.valid()isTruevalidated.errors()is empty- execution continues to produce the Vega-Lite spec
Root cause
The static validation path and execution path prepare layer mappings differently.
In src/validate.rs:
- The explicit mappings from
VISUALISE ...live inplot.global_mappings. - Validation clones the layer and merges those global mappings into
merged. mergedis used only forvalidate_mapping().validate_aggregate_setting()is then called on the originallayer, whose mappings do not containx,ymin,ymax, orcolor.
Consequently, resolve_aggregate_targets() cannot resolve the first target, x, and emits the error.
There is a second parity requirement in this particular documented example: color:diff targets an aesthetic alias. The execution path first merges globals and then runs resolve_aesthetic_aliases(), turning color into the concrete aesthetic supported by range (here stroke). The standalone validation path does not mirror this alias-resolution step.
This explains both observations:
- static validation fails before execution;
- execution succeeds because it has already merged global mappings and resolved aliases before the aggregate stat runs.
Proposed fix
Make standalone validation use the same effective layer mappings that execution uses before validating aggregate targets:
- Clone the layer.
- Merge applicable
plot.global_mappings, preserving layer precedence and annotation behavior. - Resolve aesthetic aliases on that effective layer according to the geom's supported aesthetics.
- Use the effective layer for both:
validate_mapping()validate_aggregate_setting()
Ideally, factor the merge/alias preparation into a shared helper so validation and execution cannot drift again.
Simply replacing:
layer.validate_aggregate_setting(...)
with:
merged.validate_aggregate_setting(...)
would fix the first x failure, but is not sufficient for the full documented query unless the color alias is also resolved to stroke/ fill as appropriate for the geom.
For wildcard mappings, where standalone validation lacks schema information, aggregate syntax/vocabulary/recycling can still be checked, while target-resolution checks may need to be deferred until effective mappings are knowable.
Suggested regression coverage
- The complete documented range query above returns
valid() == true. - Global
x/ymin/ymaxaggregate targets validate. - Global
colorpluscolor:diffvalidates for a geom supporting the corresponding concrete alias target. - A genuinely unmapped aggregate target remains invalid.
- Validation and execution agree for this query.
- 主要语言
- Rust
- 星标
- 562
- 派生
- 31
- 平均合并
- 2 天 7 小时
- 30 天内合并 PR
- 22
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
posit-dev/ggsql 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
posit-dev/ggsql#565 · 2 个 reaction ·
维护者通常 1 天内回复
-
Update the positron dep for the extension to 0.2.9可能已有人在做 @thomasp85 于 13 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
writer
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
plot building
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
bug plot building
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
相似的 Issue
-
C-bug
难度 2/5 1-3 小时 新手友好度 78/100
rust-lang/rust-analyzer#23501 ·
维护者通常 1 天内回复
-
bug P2 ready for work T-security T-transport
难度 2/5 1-3 小时 新手友好度 68/100
modelcontextprotocol/rust-sdk#1339 ·
维护者通常 3 天内回复
-
French BIP39 wordlist starts with a UTF-8 BOM, so generated French mnemonics carry U+FEFF and derive a non-canonical seed可能已有人在做 @Kshot3000 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 91/100
ergoplatform/sigma-rust#976 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
[Bug]: Web chat input doesn't regain focus after a reply finishes可能已有人在做 @GaijinSystems 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
zeroclaw-labs/zeroclaw#11658 ·
维护者通常 2 天内回复