fdb-record-layer
fdb-record-layer copied to clipboard
Ordering can not be pushed down when `Value` references a nesting `QOV`
For example, if we have a Value
like this: $q42.0.1
then the corresponding ordering part of it will become _.0.1
, this breaks immediately when the optimiser attempts to push it down through a Value
like this: ($q1)
because the Value-simplification engine attempts to access the first field of the $q1
thinking that it is an RCV
:
https://github.com/FoundationDB/fdb-record-layer/blob/01dce3933fb4a0d5fc7294cd7c8ee9c705c26e9f/fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/simplification/ComposeFieldValueOverRecordConstructorRule.java#L94
so we get a exception.
The main reason cause of this problem is handing in the Value
almost as-is without dereferencing all QOV
s so the Value-simplification engine can follow (nested) field ordinals correctly.
https://github.com/FoundationDB/fdb-record-layer/blob/01dce3933fb4a0d5fc7294cd7c8ee9c705c26e9f/fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/cascades/values/Value.java#L534
I think we should at least throw an exception if we encounter a QOV
that does not match the condition:
value instanceof QuantifiedObjectValue && ((QuantifiedObjectValue)value).getAlias().equals(upperBaseAlias))
because of the limitation above, but ultimately we should find a way of dereferencing all QOV
s correctly before we call the simplification.