You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Thomas Mueller (Jira)" <ji...@apache.org> on 2023/05/24 13:03:00 UTC
[jira] [Commented] (OAK-10261) Query with OR clause with COALESCE function incorrectly interpreted
[ https://issues.apache.org/jira/browse/OAK-10261?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725793#comment-17725793 ]
Thomas Mueller commented on OAK-10261:
--------------------------------------
PR for review https://github.com/apache/jackrabbit-oak/pull/954
> 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
> Assignee: Thomas Mueller
> Priority: Major
>
> 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)