geopython / geopython/pygeofilter

cql2-text: single-letter property names fail to parse (attribute token requires 2+ chars)

Open Beginner friendly
#165 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
90
Forks
44
PR merge metrics
No merged PRs in 30d

Description

The cql2-text grammar's unquoted attribute token requires at least two characters:

https://github.com/geopython/pygeofilter/blob/master/pygeofilter/parsers/cql2_text/grammar.lark#L146

```
attribute: /[a-zA-Z][a-zA-Z_:0-9.]+/
```

Single-letter identifiers are legal CQL2 identifiers, and single-letter property names are common in GIS data (`x`, `y`, `z`, `m`), so an ordinary expression fails to parse:

```python
from pygeofilter.parsers.cql2_text import parse
parse('x = 1') # UnexpectedToken
parse('"x" = 1') # parses (double-quoted form)
```

Making the `+` a `*` in the token would accept the single-character form. (Care may be needed around the WKT/function tokens, but no keyword or function in the grammar is a single letter.)

Found while wiring pygeofilter 0.4.0 into an OGC API Features Part 3 endpoint whose queryables are derived from live table schemas; we currently pre-quote lone letters before parsing.

Contributor guide

Open the contributing guide

Research direction

The grammar is in grammar.lark at line 146; start by inspecting the attribute rule and the cql2_text.parse entry point. Update the token so a one-character unquoted identifier is accepted, then verify that both x = 1 and the existing quoted form parse successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
86/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.