Skip to content

normalize CQL text support to CQL2 (#2015)#2018

Open
tomkralidis wants to merge 1 commit into
masterfrom
issue-2015
Open

normalize CQL text support to CQL2 (#2015)#2018
tomkralidis wants to merge 1 commit into
masterfrom
issue-2015

Conversation

@tomkralidis
Copy link
Copy Markdown
Member

Overview

Normalizes CQL text support for CQL2 only.

Related Issue / discussion

#2015

Additional information

Dependency policy (RFC2)

  • I have ensured that this PR meets RFC2 requirements

Updates to public demo

Contributions and licensing

(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)

  • I'd like to contribute [feature X|bugfix Y|docs|something else] to pygeoapi. I confirm that my contributions to pygeoapi will be compatible with the pygeoapi license guidelines at the time of contribution
  • I have already previously agreed to the pygeoapi Contributions and Licensing Guidelines

@tomkralidis tomkralidis added this to the 0.21.0 milestone May 23, 2025
@tomkralidis tomkralidis added bug Something isn't working OGC API - Features OGC API - Features OGC API - Records OGC API - Records labels May 23, 2025
@tomkralidis tomkralidis force-pushed the issue-2015 branch 2 times, most recently from f12bbaf to 6f733e1 Compare May 23, 2025 17:28
@tomkralidis tomkralidis modified the milestones: 0.21.0, 0.22.0 Aug 3, 2025
@tomkralidis tomkralidis modified the milestones: 0.22.0, 0.23.0 Nov 4, 2025
@tomkralidis tomkralidis modified the milestones: 0.23.0, 0.24.0 Mar 2, 2026
@tomkralidis tomkralidis force-pushed the issue-2015 branch 2 times, most recently from 1b16a59 to 96d4159 Compare March 26, 2026 23:18
@teetin
Copy link
Copy Markdown

teetin commented Apr 8, 2026

Could you also ensure that the appropriate entries to conformance page would be added if this provider is used
I assume those would be (al last,):
http://www.opengis.net/spec/cql2/1.0/conf/cql2-text
http://www.opengis.net/spec/cql2/1.0/conf/basic-cql2
for example QGIS is very strict on these and even with these additions the list is still uncomplete.

Supported filter types (cql2-text and cql2-json) should also be added to:

    LOGGER.debug('Processing filter-lang parameter')
    filter_lang = request.params.get('filter-lang')
    # Currently only cql-text is handled, but it is optional
    if filter_lang not in [None, 'cql-json', 'cql-text', 'cql2-text', 'cql2-json']:

@webb-ben
Copy link
Copy Markdown
Member

webb-ben commented May 6, 2026

@tomkralidis is this ready for review? (cc: @mikemahoney218-usgs )

@tomkralidis
Copy link
Copy Markdown
Member Author

Could you also ensure that the appropriate entries to conformance page would be added if this provider is used I assume those would be (al last,): http://www.opengis.net/spec/cql2/1.0/conf/cql2-text http://www.opengis.net/spec/cql2/1.0/conf/basic-cql2 for example QGIS is very strict on these and even with these additions the list is still uncomplete.

Supported filter types (cql2-text and cql2-json) should also be added to:

    LOGGER.debug('Processing filter-lang parameter')
    filter_lang = request.params.get('filter-lang')
    # Currently only cql-text is handled, but it is optional
    if filter_lang not in [None, 'cql-json', 'cql-text', 'cql2-text', 'cql2-json']:

Thanks @teetin; PR updated.

@tomkralidis
Copy link
Copy Markdown
Member Author

@tomkralidis is this ready for review? (cc: @mikemahoney218-usgs )

It is not ready (hence no reviewer assignment). CI (using pygeofilter main branch for testing) shows a pygeofilter error:

FAILED tests/provider/test_postgresql_provider.py::test_query_cql[connection_string-osm_id BETWEEN 80800000 AND 80900000 AND CASEI(waterway) LIKE 'sTrEam'-expected_ids2] - NotImplementedError: Failed to evaluate node of type <class 'pygeofilter.ast.Function'>

@mikemahoney218-usgs
Copy link
Copy Markdown
Contributor

Just as a note, if you pass --force-reinstall to install pygeofilter from main and then wrap the literal in CASEI, you get a different lark grammar error -- I'm guessing I missed updating that file
mikemahoney218-usgs#1

@tomkralidis
Copy link
Copy Markdown
Member Author

Thanks @mikemahoney218-usgs. Once this is addressed in pygeofilter proper, we can kick CI here again.

Copy link
Copy Markdown
Contributor

@mikemahoney218-usgs mikemahoney218-usgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got a PR at geopython/pygeofilter#142 that should let CASEI work with LIKE statements. There's a few test cases that need to get updated to make this succeed, namely:

  • Replace INTERSECTS with S_INTERSECTS and CROSSES with S_CROSSES
  • Remove references to DWITHIN which is not part of CQL2

The "build" CI job succeeds after installing that pygeofilter PR (flake8 fails, but I figured fixing that on the fork would be more confusing than clarifying) -
https://github.com/mikemahoney218-usgs/pygeoapi/actions/runs/26538484746/job/78173573168

Comment thread tests/provider/test_postgresql_provider.py Outdated
Comment thread tests/other/test_crs.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'S_INTERSECTS(geometry, POINT(1 1))',

Comment thread tests/other/test_crs.py Outdated
Comment thread tests/other/test_crs.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'some_attribute = 10 AND S_INTERSECTS(geometry, POINT(1 1))',

Comment thread tests/other/test_crs.py Outdated
Comment thread tests/other/test_crs.py Outdated
Comment thread tests/other/test_crs.py Outdated
Comment thread tests/other/test_crs.py Outdated
Comment thread tests/other/test_crs.py Outdated
Comment thread docs/source/cql2.rst Outdated
@ricardogsilva
Copy link
Copy Markdown
Member

@tomkralidis you may also be interested in this:

geopython/pygeofilter#143

pygeofilter does not currently implement the CQL2 BBOX literal correctly - fixing this would benefit pygeoapi as well IMO

Comment thread tests/provider/test_postgresql_provider.py Outdated
@tomkralidis tomkralidis requested a review from a team May 30, 2026 15:41
pip3 install -r requirements-pubsub.txt
pip3 install .
pip3 install GDAL==`gdal-config --version`
pip3 install --force-reinstall https://github.com/geopython/pygeofilter/archive/main.zip
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps wait for a new pygeofilter release?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. Will keep this PR open until the next release of pygeofilter (thus removing the above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working OGC API - Features OGC API - Features OGC API - Records OGC API - Records

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants