-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for Count Expressions #4530
Support for Count Expressions #4530
Conversation
ce1aef4
to
e667cfd
Compare
49fda27
to
4a8f21c
Compare
4a8f21c
to
f6fea18
Compare
f6fea18
to
0ec88af
Compare
0ec88af
to
dd84a0b
Compare
exist-core/src/main/java/org/exist/xquery/value/DoubleValue.java
Outdated
Show resolved
Hide resolved
I missed the review request; I will have a look coming days. |
4d6577e
to
caf2268
Compare
@dizzzz Not that I know of. I think I normally get notifications via email myself. |
SonarCloud Quality Gate failed. |
477e413
to
1e5993e
Compare
@adamretter would you mind changing the this PR to draft mode until it is ready? |
@reinhapa Erm... but... it is ready to be merged! |
1e5993e
to
76fb045
Compare
@adamretter could you rebase as the tests fail... |
…ording to the XQuery spec; these can be processed at parse time
… implementation - ct:order-alpha-ascending-indexes#0
76fb045
to
643be29
Compare
SonarCloud Quality Gate failed. 0 Bugs 71.0% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
@reinhapa Done :-) |
@adamretter there are a some simple code smells left, that could be easy solved. Would you mind to address those? (use of new |
This is currently passing 12 out of 13 XQTS tests. The 1 failing test is:
prod-CountClause/count-009
.Acceptance of Failing XQTS Test
The 1 failing test occurs due to the existing design and implementation of FLWOR expressions in eXist-db.
Specifically, eXist-db's implementation of the XQuery
order by
clause does not follow the W3C specification. The W3C XQuery 3.1 Order By Clause specification states:This means that any tuples in a tuple stream after an Order By Clause should be in the order defined by the order by clause. In the eXist-db implementation that is not the case. In eXist-db any expressions/clauses within a FLWOR expression that occur after the order by clause, but before the return clause, will not see an ordered tuple stream; instead they see the tuple stream prior to the order by clause. The reason for this is that in eXist-db the operation of executing the
sort
for the Order By clause is always deferred until just before the return clause of the FLWOR expression. In eXist-db this is known as apostEval
phase, see:FLWORClause#postEval(Sequence)
ForExpr#eval(Sequence, Item)
OrderByClause#postEval(Sequence)
Unfortunately at this time it appears that modifying eXist-db to correctly implement the
Order By Clause
semantics would be a huge undertaking, and may require a rewrite of all FLWOR expressions. Therefore we consider it out of scope for this PR.On an tangentially related note, we suspect there may be other problems with all other FLWOR expressions in eXist-db that implement
postEval
with regards to compliance with W3C XQuery 3.1.In Further Detail
Given the XQuery:
The result should be computed as:
However eXist-db produces the incorrect result due to its incorrect implementation of the
order by
clause:This occurs because eXist-db evaluates the query by effectively executing the following steps:
$x := 'a'
$index1 := 1
$remainder := 1
$index2 := 1
<x index1="1" index2="1">a</x>
to the result sequence.$x := 'b'
$index1 := 2
$remainder := 0
$index2 := 2
<x index1="2" index2="2">b</x>
to the result sequence.$remainder ascending
and then$index1 ascending
The problem is that eXist-db applies the sorting (i.e. the
order by
clause) after the fact.I have created a detailed UML Sequence Diagram of the above XQuery execution in eXist-db that shows the exact problem:
In case it is helpful for anyone else, the code for the UML Sequence Diagram:
This open source contribution to the eXist-db project was commissioned by the Office of the Historian, U.S. Department of State, https://history.state.gov/.