fix(cql2-json): accept a property reference as an interval bound - #178
Open
C1-BA-B1-F3 wants to merge 1 commit into
Open
C1-BA-B1-F3 wants to merge 1 commit into
C1-BA-B1-F3 wants to merge 1 commit into
Conversation
An interval bound was assumed to be a date/time string, so
{"interval": [{"property": "start"}, {"property": "end"}]}
died in ``walk_cql_json`` with
``AttributeError: 'dict' object has no attribute 'split'``. That shape is
CQL2 conformance test 41 and is what
``T_CONTAINS(interval(a, b), interval(t1, t2))`` is written as.
Walk a non-string bound like any other expression, so it becomes an
``ast.Node`` that the evaluator resolves as usual, and widen
``values.Interval.start``/``end`` to admit an expression — the class already
carried one through ``get_sub_nodes``.
This is a parser fix: it makes the filter parse (and round-trip through the
cql2-json backend). Evaluating an interval on the left-hand side is a
separate backend gap, see the PR description.
Fixes geopython#116
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #116.
An interval bound was assumed to be a date/time string, so
{"interval": [{"property": "start"}, {"property": "end"}]}died in
walk_cql_jsonwithAttributeError: 'dict' object has no attribute 'split'. That shape is CQL2 conformance test 41 and is howT_CONTAINS(interval(a, b), interval(t1, t2))is written (the linkedpycql2schema in the issue thread allows it too).The fix walks a non-string bound like any other expression, so it becomes an
ast.Nodethat the evaluator resolves as usual, and widensvalues.Interval.start/endto admit an expression — the class already carried one throughget_sub_nodes, its annotation was just narrower than its own API.Scope — what this does and does not cover
Verified:
".."), and a function bound;to_cql2(parse(q))→{"op": "t_contains", "args": [{"interval": [{"property": "start_datetime"}, {"property": "end_datetime"}]}, ...]}.Not covered, and reproducible on this branch: evaluating an interval on the left-hand side. The SQLAlchemy backend's
filters.temporal()splits its second argument intolow, highand compares a single column against them, so a two-column interval on the left raisesFixing that means teaching the backends the interval-vs-interval relations, which is a separate change; I have kept this one to the parsing defect the issue reports. Happy to take that on as a follow-up if you want it.
Tests
4 cases added to
tests/parsers/cql2_json/test_parser.py: property/property, property/open, open/property, and a function bound. All 4 fail on the pre-fix code; the module is 45/45 after.Full suite with the
testextra (excluding the modules that need a live Elasticsearch/OpenSearch/Solr or GDAL): 320 passed / 62 skipped / 37 errors against a 316 / 62 / 37 baseline onmain— the delta is exactly the 4 new tests; the 37 errors are the network-backed backend suites.ruff/ruff formatclean;mypyunchanged frommain(same pre-existingvalues.pyshapeerrors).