Skip to content
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

max and min not working on arrays #862

Open
mstevan opened this issue Dec 30, 2020 · 2 comments
Open

max and min not working on arrays #862

mstevan opened this issue Dec 30, 2020 · 2 comments

Comments

@mstevan
Copy link
Contributor

mstevan commented Dec 30, 2020

@mstevan
test-set: max.xml, min.xml
test-cases: fn-max-19 and fn-min-19

@team
Seems that min and max function do not work on arrays

Input:
min([1,2,3,4,5])

Output:
⚠️ ️There was an error.

Code: [XPTY0004] (this code can be looked up in the documentation and specifications).

Location information: file:/Users/mstevan/Documents/:LINE:1:COLUMN:0:

Invalid return type for function min. array cannot be promoted to type atomic?.

Expected output:
1

@ghislainfourny
Copy link
Member

Thank you for looking into this.

That's because in JSONiq, arrays cannot be atomized, so the error is expected.

In XQuery they can so what happens is that [1,2,3,4,5] is converted to (1,2,3,4,5) and then min called.

@ghislainfourny
Copy link
Member

In your implementation, what you can do is add an iterator for atomizing sequences, and in the translationvisitor for the XQuery 3.1 parser, you can insert that iterator in the middle between an argument and a function call iterator whenever the type is atomic with any arity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants