Thomas Mueller created OAK-10261:
------------------------------------
Summary: Query with OR clause with COALESCE function incorrectly
interpreted
Key: OAK-10261
URL: https://issues.apache.org/jira/browse/OAK-10261
Project: Jackrabbit Oak
Issue Type: Improvement
Components: query
Reporter: Thomas Mueller
The "coalesce" function incorrectly asks the index to do "is not null" for the
first property:
{noformat}
SELECT a.*
FROM [dam:Asset] AS a
WHERE ((COALESCE(a.[jcr:lastModified], a.[jcr:created]) <
cast('2023-05-08T20:51:06.239+03:00' AS date))
OR (COALESCE(a.[jcr:lastModified], a.[jcr:created]) =
cast('2023-05-08T20:51:06.239+03:00' AS date)
[dam:Asset] as [asset] /* lucene:fragments-9(/oak:index/fragments-9)
+jcr:lastModified:[-9223372036854775808 TO 9223372036854775807]
*/
{noformat}
This is because the Coalesce implementation uses an incorrect
"getPropertyExistence" method. It is implemented as follows, so that it implies
the first operand is not null, which is incorrect: the first operand can be
null. Even the second operand can be null; just the combination can't be null -
but there seems to be no good reason to inform the index to do this.
{noformat}
// this is wrong:
@Override
public PropertyExistenceImpl getPropertyExistence() {
PropertyExistenceImpl pe = operand1.getPropertyExistence();
return pe != null ? pe : operand2.getPropertyExistence();
}
{noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)