cql, features-sql: composite-key result sets (inResultSetByKey) - #631
Merged
Merged
Conversation
A result set of a query expression could only be joined on a single
value: the ids of the selected features, or the values of one of their
properties. A key with several parts therefore had to be approximated by
a conjunction of one predicate per part, which selects a superset —
every combination of the part values, not only the combinations that
actually occur.
The new predicate joins on the whole key at once. Both sides name the
parts, and the parts are matched by name rather than by position:
"resultSets": { "s": { "key": { "land": "gmd_lan", "kreis": "gmd_krs" } } }
{ "op": "inResultSetByKey",
"args": [ { "land": {"property": "gkz_lan"},
"kreis": {"property": "gkz_krs"} }, "s" ] }
Names rather than positions because a key whose parts share a type — as
administrative keys do — could otherwise have two parts transposed, and
the query would run and return the wrong features with nothing to show
for it. A part that one side does not declare is reported before the
query is encoded.
The predicate is encoded as EXISTS, not as a row-constructor IN: with
IN, a null in any key part would make the negation unknown and drop the
feature, although "this key is not a member" is what the filter asks
for. EXISTS also gives the three sources of a result set — materialized
table, inlined values, re-derived producer — the same shape, and its
negation is NOT EXISTS without further handling.
The parts have to be columns of the main table on both sides; a property
in a child or junction table would encode as a semi-join subquery, which
cannot take part in a row-wise comparison. Both sides check this against
the mapping and name the offending part.
inResultSet is unchanged, so existing query expressions are unaffected;
a result set is either a set of values or a set of keys, and consuming
one as the other is rejected. The producer of a key set selects DISTINCT
keys, since the members of the set are the distinct keys rather than the
rows of the producing feature type. There is no CQL2-Text encoding; the
predicate can only be used in a query expression.
ResultSetReference is the common interface of the two predicates, so the
materializer collects, orders and rewrites both without knowing which
kind it holds.
3 tasks
azahnen
approved these changes
Sep 23, 2026
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.
Part of addressing ldproxy/ldproxy#1774.
Comments:
The predicate is encoded as EXISTS, not as a row-constructor IN: with IN, a null in any key part would make the negation unknown and drop the feature, although "this key is not a member" is what the filter asks for. EXISTS also gives the three sources of a result set — materialized table, inlined values, re-derived producer — the same shape, and its negation is NOT EXISTS without further handling.
The producer of a key set selects DISTINCT keys, since the members of the set are the distinct keys rather than the rows of the producing feature type.
ResultSetReference is the common interface of the two predicates, so the materializer collects, orders and rewrites both without knowing which kind it holds.