fdb-record-layer icon indicating copy to clipboard operation
fdb-record-layer copied to clipboard

RecordTypeKeyComparison fails if it operates on a synthetic record type

Open alecgrieser opened this issue 11 months ago • 0 comments

The RecordTypeKeyComparison operator fails if it operates on a synthetic record type because when it gets the comparand, it calls getRecordType, which ignores synthetic types. This means that if there is an index scan on a synthetic record type that ends up including the record type key in its scan range, it will fail.

One way that I think this can show up is if you had an index on something like:

concat(field("a").nest("foo"), field("b").nest("bar))

On a synthetic type with "a" and "b" constituents. If you issue a query on:

Query.and(
    Query.field("a").matches(Query.field("foo").equalsParameter("fooParam"),
    Query.field("b").matches(Query.field("bar").equalsParameter("barParam")
)

Then that can end up being planned as an index scan on [EQUALS $fooParam, EQUALS $barParam, IS syntheticType]. The IS there isn't strictly necessary (on a single type index, at least), but it's also not invalid to include it. It represents a RecordTypeKeyComparison on a synthetic type.

alecgrieser avatar Mar 15 '24 11:03 alecgrieser