Add CQL2 array predicates, cql-json \ e\ support, and parser validation - #161
Open
Nortaq-PlayNexus wants to merge 1 commit into
Open
Conversation
- cql2_text: support array predicates (A_EQUALS, A_CONTAINS, A_CONTAINEDBY, A_OVERLAPS) with array literals or attributes (fixes geopython#160) - cql2_text: allow single-character attribute names (fixes geopython#144) - cql-json: add ne comparison operator (fixes geopython#19) - cql-json: validate multiple predicate keys and and/or arity (fixes geopython#47) - update CHANGELOG and add tests
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.
Closes #19, #47, #144, #160
Changes
cql2_text: array predicates (#160)
A_EQUALS,A_CONTAINS,A_CONTAINEDBY, andA_OVERLAPSare now supported, with either an array literal (('a', 'b', 'c')) or an attribute on the right-hand side, matching the CQL2 spec. PreviouslyA_CONTAINS('values', ('a', 'b', 'c'))raised aLALR error (KeyError: 'COMMA').parsers/cql2_text/grammar.lark: addedarray_predicateandarray_literalrulesparsers/cql2_text/parser.py: addedbinary_array_predicateandarray_literaltransformer methods using the existingARRAY_PREDICATES_MAPcql2_text: single-character attribute names (#144)
The attribute terminal regex used
+, so names likeacould not be parsed. Changed to*([a-zA-Z][a-zA-Z_:0-9.]*) soa = 1parses correctly.cql-json:
necomparison operator (#19){"ne": [...]}now producesast.NotEqual, completing the CQL2 comparison operator set for the JSON parser.cql-json: malformed-expression validation (#47)
{"and": [...], "or": [...]}) now raiseValueError("multiple predicates ...")instead of silently picking one.and/orwith fewer than 2 operands now raiseValueError("at least 2 operands")instead of producing a wrong AST.Testing
tests/parsers/cql2_text/test_parser.pyandtests/parsers/cql_json/test_parser.py294 passedlocally (tests/parsers,tests/native,tests/test_utils.py)ruff checkclean on all changed Python files