Slice with a stride and no upper bound (`arr[1: :4]`) is displayed as `arr[1::4]`, which doesn't parse
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
问题出在 upper_bound 缺失但设置了 stride 时 Subscript::Slice 的输出方式。请从 src/ast/mod.rs 中的 Display 实现开始,那里的两个冒号是相邻书写的。检查解析器对 [1: :4] 和 [1:-:4] 的 slice 处理,确定哪种写法必须能够往返转换。完成的标准是:issue 中的三个复现查询都能重新解析,并且在 tests/sqlparser_common.rs 中现有 slice 测试旁边添加了一个往返转换测试。
由索引模型根据 Issue 内容生成。
描述
Subscript::Slice with upper_bound: None and a stride prints the two colons next to each other, and the tokenizer then reads :: (cast):
SELECT ([1, 2, 3, 4, 5, 6, 7, 8, 9])[1: :4]
-> displays as: SELECT ([1, 2, 3, 4, 5, 6, 7, 8, 9])[1::4]
-> reparse: Expected: a data type name, found: 4 at Line: 1, Column: 41
SELECT ([1, 2, 3, 4, 5, 6, 7, 8, 9])[: :4]
-> displays as: SELECT ([1, 2, 3, 4, 5, 6, 7, 8, 9])[::4]
-> reparse: Expected: an expression, found: :: at Line: 1, Column: 38
SELECT ([1, 2, 3, 4, 5, 6, 7, 8, 9])[1:-:4]
-> round-trips (fine)
DuckDB documents [1:-:4] for this (https://duckdb.org/docs/stable/sql/functions/list#slicing), but it also runs [1: :4] (returns [1, 5, 9]), and the parser accepts it. Something like [1: :4] in Display would round-trip.
Tested with DuckDbDialect on main ce12f1f6 (also 0.63.0 and 0.58.0).
Found with a property-based fuzzer (round trip check); I used AI assistance for triage and verified every case above.
- 主要语言
- Rust
- 星标
- 3.5k
- 派生
- 801
- 平均合并
- 2 天 19 小时
- 30 天内合并 PR
- 108
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/datafusion-sqlparser-rs 的其他 Issue
-
DuckDB PostgreSQL Prolific Author
难度 2/5 1-3 小时 新手友好度 72/100
apache/datafusion-sqlparser-rs#2803 ·
维护者通常 1 天内回复
-
Databricks Prolific Author Spark
难度 2/5 1-3 小时 新手友好度 68/100
apache/datafusion-sqlparser-rs#2801 ·
维护者通常 1 天内回复
-
PostgreSQL: support FOR NO KEY UPDATE and FOR KEY SHARE row-locking clauses可能重新可做 关联的 PR 已关闭且未合并。 未关闭PostgreSQL
难度 2/5 1-3 小时 新手友好度 76/100
apache/datafusion-sqlparser-rs#2778 ·
维护者通常 1 天内回复
-
`SHOW ... ILIKE '<pattern>'` is displayed without quotes可能重新可做 关联的 PR 已关闭且未合并。 未关闭Prolific Author
难度 2/5 1-3 小时 新手友好度 75/100
apache/datafusion-sqlparser-rs#2759 ·
维护者通常 1 天内回复
-
Should `DELETE + LIMIT` be supported by the generic dialect ?可能重新可做 关联的 PR 已关闭且未合并。 未关闭DuckDB MySQL PostgreSQL
难度 2/5 1-3 小时 新手友好度 68/100
apache/datafusion-sqlparser-rs#2615 ·
维护者通常 1 天内回复
查看 apache/datafusion-sqlparser-rs 的全部 Issue
相似的 Issue
-
🐞 bug 🧩 bevy_gantz_egui
难度 2/5 1-3 小时 新手友好度 82/100
nannou-org/gantz#500 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
metasequoiaime/msime#10989 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
fritzprix/libr-agent#2612 ·
维护者通常 1 天内回复
-
crate: spate-core priority: low
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
NSPG13/agent-bounties#1749 ·
维护者通常 1 天内回复