From gfourny at inf.ethz.ch Mon Mar 4 02:56:24 2019 From: gfourny at inf.ethz.ch (Ghislain Fourny) Date: Mon, 4 Mar 2019 10:56:24 +0000 Subject: [xquery-talk] [ANN] Sparksoniq 0.9.5 "Larch" Message-ID: <619B804E-52BE-4206-BE66-A2E4388FF16D@inf.ethz.ch> Dear all, We are happy to announce the latest alpha release of Sparksoniq. Sparksoniq runs JSONiq queries on top of Spark, taking as input JSON data sets stored on distributed file systems such as (but not only) HDFS. Its goal is to increase productivity when querying heterogeneous, nested datasets that are challenging to handle with DataFrames. JSONiq is the JSON brother of XQuery (XQuery - XML + JSON) and shares 90% of its DNA. Sparksoniq is open source (Apache 2.0) and can be downloaded for free. The jar as well as the documentation can be found on http://sparksoniq.org/. Since the announcement of our initial prototype last year, the following progress was made: - Many bugfixes following user feedback. It is getting stable enough to consider soon going to beta, and was already used in large classrooms. - All FLWOR clauses are supported both in parallel and (new) locally. Locally means without invoking Spark transformations with parallelize() or json-file() calls. - FLWOR expressions can fully nest, with the only exception that those that run in parallel cannot nest with each other (because Spark jobs do not nest). E.g.: for $i in json-file("hdfs://path/to/orders.json") (: this will be executed in parallel on that large file, split after HDFS blocks :) where $i.customer eq "John Smith" return { "total": sum($i.items[].amount), "sorted-items" : [ for $j in $i.items[] order by $j.amount return $j ] } - We improved the memory footprint, in particular filtering queries are streamed through (within a task) rather than materialized. - We worked on performance: it can handle files of 10,000,000+ objects on a regular laptop for count, filtering, grouping and ordering with a local Spark execution. Performance also noticeably improved querying bigger datasets on clusters (tested with several billion objects on 64 machines). Feedback is, as always, appreciated. Kind regards Ghislain From adam.retter at googlemail.com Sun Mar 10 22:20:33 2019 From: adam.retter at googlemail.com (Adam Retter) Date: Mon, 11 Mar 2019 12:20:33 +0700 Subject: [xquery-talk] Arrow Operator to a Partially Applied Function Message-ID: Without thinking too deeply, whilst writing some XQuery recently I was initially surprised to discover that the following (simplified) query fails with the static error - [XPST0017] map:for-each(map,function): 3 arguments supplied, 2 expected. xquery version "3.1"; declare namespace map = "http://www.w3.org/2005/xpath-functions/map"; function($k, $v) { "$k=" || $k } => map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? )() After having looked into the specs in more detail, I thought I was able to derive a reason for this... i.e. the partial function application syntax is not processed until the dynamic evaluation phase. Therefore when the arrow operator is processed first during the static analysis phase, it tries to find a map:for-each function that takes 3 parameters, the first being of the function type on LHS of the arrow operator, and second being the map, and the third being the unbound parameter `?`. However, I then noticed that if I reformulatedby query with an indirection through a variable binding `$x` then it compiles and executes just fine. Presumably this indicates that my understanding above is incorrect, as whilst the variable binding may change the evaluation order, the static analysis and dynamic evaluation phases should still happen in the same order. xquery version "3.1"; declare namespace map = "http://www.w3.org/2005/xpath-functions/map"; let $x := map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? ) return function($k, $v) { "$k=" || $k } => $x() I basically get the same results on eXist-db, Saxon, and BaseX. I would appreciate if someone could help me understand what I am seeing here... Thanks Adam. -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk From contact at zadean.com Sun Mar 10 23:37:42 2019 From: contact at zadean.com (Zachary N. Dean) Date: Mon, 11 Mar 2019 07:37:42 +0100 Subject: [xquery-talk] Arrow Operator to a Partially Applied Function In-Reply-To: References: Message-ID: <043c01d4d7d4$f194dad0$d4be9070$@zadean.com> Hello Adam, I think the issue is that the Arrow Operator '=>' is simply "syntactic sugar" for using the LHS as the FIRST argument of the function call on the RHS. The Argument Placeholder '?' has no direct relation to the Arrow Operator. So, in the case of the first example: function($k, $v) { "$k=" || $k } => map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? )() Simply becomes: map:for-each( function($k, $v) { "$k=" || $k }, map { "a" : "1", "b" : "2", "c" : "3" }, ? )() So, the 3 argument map:for-each isn't found. (and the final call would have the wrong arity if it was found) Hope this helps, Zack -----Original Message----- From: talk-bounces at x-query.com On Behalf Of Adam Retter Sent: Montag, 11. M?rz 2019 06:21 To: XQuery Talk ML Cc: juri at existsolutions.com Subject: [xquery-talk] Arrow Operator to a Partially Applied Function Without thinking too deeply, whilst writing some XQuery recently I was initially surprised to discover that the following (simplified) query fails with the static error - [XPST0017] map:for-each(map,function): 3 arguments supplied, 2 expected. xquery version "3.1"; declare namespace map = "http://www.w3.org/2005/xpath-functions/map"; function($k, $v) { "$k=" || $k } => map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? )() After having looked into the specs in more detail, I thought I was able to derive a reason for this... i.e. the partial function application syntax is not processed until the dynamic evaluation phase. Therefore when the arrow operator is processed first during the static analysis phase, it tries to find a map:for-each function that takes 3 parameters, the first being of the function type on LHS of the arrow operator, and second being the map, and the third being the unbound parameter `?`. However, I then noticed that if I reformulatedby query with an indirection through a variable binding `$x` then it compiles and executes just fine. Presumably this indicates that my understanding above is incorrect, as whilst the variable binding may change the evaluation order, the static analysis and dynamic evaluation phases should still happen in the same order. xquery version "3.1"; declare namespace map = "http://www.w3.org/2005/xpath-functions/map"; let $x := map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? ) return function($k, $v) { "$k=" || $k } => $x() I basically get the same results on eXist-db, Saxon, and BaseX. I would appreciate if someone could help me understand what I am seeing here... Thanks Adam. -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk --- This email has been checked for viruses by AVG. https://www.avg.com From adam.retter at googlemail.com Sun Mar 10 23:45:24 2019 From: adam.retter at googlemail.com (Adam Retter) Date: Mon, 11 Mar 2019 13:45:24 +0700 Subject: [xquery-talk] Arrow Operator to a Partially Applied Function In-Reply-To: <043c01d4d7d4$f194dad0$d4be9070$@zadean.com> References: <043c01d4d7d4$f194dad0$d4be9070$@zadean.com> Message-ID: Thanks Zach. I suspect you are right. However I can't help wishing that the argument placeholders should be resolved before the arrow operator is applied... For the average developer, the fact that my first query raises an error seems non intuitive, especally in light of the reformulation in my second query. On Mon, 11 Mar 2019, 13:37 Zachary N. Dean, wrote: > Hello Adam, > > I think the issue is that the Arrow Operator '=>' is simply "syntactic > sugar" for using the LHS as the FIRST argument of the function call on the > RHS. > The Argument Placeholder '?' has no direct relation to the Arrow Operator. > > So, in the case of the first example: > > function($k, $v) { > "$k=" || $k > } => > map:for-each( > map { > "a" : "1", > "b" : "2", > "c" : "3" > }, > ? > )() > > Simply becomes: > > map:for-each( > function($k, $v) { > "$k=" || $k > }, > map { > "a" : "1", > "b" : "2", > "c" : "3" > }, > ? > )() > > > So, the 3 argument map:for-each isn't found. (and the final call would have > the wrong arity if it was found) > > > Hope this helps, > > Zack > > -----Original Message----- > From: talk-bounces at x-query.com On Behalf Of > Adam > Retter > Sent: Montag, 11. M?rz 2019 06:21 > To: XQuery Talk ML > Cc: juri at existsolutions.com > Subject: [xquery-talk] Arrow Operator to a Partially Applied Function > > Without thinking too deeply, whilst writing some XQuery recently I was > initially surprised to discover that the following (simplified) query fails > with the static error - [XPST0017] map:for-each(map,function): 3 arguments > supplied, 2 expected. > > > xquery version "3.1"; > declare namespace map = "http://www.w3.org/2005/xpath-functions/map"; > > function($k, $v) { > "$k=" || $k > } => > map:for-each( > map { > "a" : "1", > "b" : "2", > "c" : "3" > }, > ? > )() > > > After having looked into the specs in more detail, I thought I was able to > derive a reason for this... i.e. the partial function application syntax is > not processed until the dynamic evaluation phase. Therefore when the arrow > operator is processed first during the static analysis phase, it tries to > find a map:for-each function that takes 3 parameters, the first being of > the > function type on LHS of the arrow operator, and second being the map, and > the third being the unbound parameter `?`. > > However, I then noticed that if I reformulatedby query with an indirection > through a variable binding `$x` then it compiles and executes just fine. > Presumably this indicates that my understanding above is incorrect, as > whilst the variable binding may change the evaluation order, the static > analysis and dynamic evaluation phases should still happen in the same > order. > > > xquery version "3.1"; > declare namespace map = "http://www.w3.org/2005/xpath-functions/map"; > > let $x := > map:for-each( > map { > "a" : "1", > "b" : "2", > "c" : "3" > }, > ? > ) > return > > function($k, $v) { > "$k=" || $k > } => $x() > > > I basically get the same results on eXist-db, Saxon, and BaseX. I would > appreciate if someone could help me understand what I am seeing here... > > Thanks Adam. > > -- > Adam Retter > > skype: adam.retter > tweet: adamretter > http://www.adamretter.org.uk > _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk > > --- > This email has been checked for viruses by AVG. > https://www.avg.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From contact at zadean.com Mon Mar 11 00:21:00 2019 From: contact at zadean.com (Zachary N. Dean) Date: Mon, 11 Mar 2019 08:21:00 +0100 Subject: [xquery-talk] Arrow Operator to a Partially Applied Function In-Reply-To: References: <043c01d4d7d4$f194dad0$d4be9070$@zadean.com> Message-ID: <044601d4d7da$fd26fc60$f774f520$@zadean.com> Ahh, I see what you mean now. I guess everyone does it the same, and that is if a QName comes after the arrow, it is a function call and the argument can be placed right away. If a variable ref or parenthesis expression come after, they need to be resolved first, and then the argument set. Wrapping the map:for-each call in parenthesis does the trick there by forcing the RHS to resolve before the Arrow. function($k, $v) { "$k=" || $k } => ( map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? ) )() Makes me also wonder though if partial functions should be resolved first. Interesting! From: talk-bounces at x-query.com On Behalf Of Adam Retter Sent: Montag, 11. M?rz 2019 07:45 To: Zachary N. Dean Cc: talk at x-query.com; juri at existsolutions.com Subject: Re: [xquery-talk] Arrow Operator to a Partially Applied Function Thanks Zach. I suspect you are right. However I can't help wishing that the argument placeholders should be resolved before the arrow operator is applied... For the average developer, the fact that my first query raises an error seems non intuitive, especally in light of the reformulation in my second query. On Mon, 11 Mar 2019, 13:37 Zachary N. Dean, > wrote: Hello Adam, I think the issue is that the Arrow Operator '=>' is simply "syntactic sugar" for using the LHS as the FIRST argument of the function call on the RHS. The Argument Placeholder '?' has no direct relation to the Arrow Operator. So, in the case of the first example: function($k, $v) { "$k=" || $k } => map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? )() Simply becomes: map:for-each( function($k, $v) { "$k=" || $k }, map { "a" : "1", "b" : "2", "c" : "3" }, ? )() So, the 3 argument map:for-each isn't found. (and the final call would have the wrong arity if it was found) Hope this helps, Zack -----Original Message----- From: talk-bounces at x-query.com > On Behalf Of Adam Retter Sent: Montag, 11. M?rz 2019 06:21 To: XQuery Talk ML > Cc: juri at existsolutions.com Subject: [xquery-talk] Arrow Operator to a Partially Applied Function Without thinking too deeply, whilst writing some XQuery recently I was initially surprised to discover that the following (simplified) query fails with the static error - [XPST0017] map:for-each(map,function): 3 arguments supplied, 2 expected. xquery version "3.1"; declare namespace map = "http://www.w3.org/2005/xpath-functions/map"; function($k, $v) { "$k=" || $k } => map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? )() After having looked into the specs in more detail, I thought I was able to derive a reason for this... i.e. the partial function application syntax is not processed until the dynamic evaluation phase. Therefore when the arrow operator is processed first during the static analysis phase, it tries to find a map:for-each function that takes 3 parameters, the first being of the function type on LHS of the arrow operator, and second being the map, and the third being the unbound parameter `?`. However, I then noticed that if I reformulatedby query with an indirection through a variable binding `$x` then it compiles and executes just fine. Presumably this indicates that my understanding above is incorrect, as whilst the variable binding may change the evaluation order, the static analysis and dynamic evaluation phases should still happen in the same order. xquery version "3.1"; declare namespace map = "http://www.w3.org/2005/xpath-functions/map"; let $x := map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? ) return function($k, $v) { "$k=" || $k } => $x() I basically get the same results on eXist-db, Saxon, and BaseX. I would appreciate if someone could help me understand what I am seeing here... Thanks Adam. -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk --- This email has been checked for viruses by AVG. https://www.avg.com Virus-free. www.avg.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From John.Snelson at marklogic.com Mon Mar 11 10:22:20 2019 From: John.Snelson at marklogic.com (John Snelson) Date: Mon, 11 Mar 2019 17:22:20 +0000 Subject: [xquery-talk] Arrow Operator to a Partially Applied Function In-Reply-To: References: <043c01d4d7d4$f194dad0$d4be9070$@zadean.com> Message-ID: <97783c4a-841a-b301-5f8d-006e780a55d0@marklogic.com> Looks like a bug to me. The first argument of the partially applied "map:for-each" is the one marked with a "?". On 10/03/2019 23:45, Adam Retter wrote: Thanks Zach. I suspect you are right. However I can't help wishing that the argument placeholders should be resolved before the arrow operator is applied... For the average developer, the fact that my first query raises an error seems non intuitive, especally in light of the reformulation in my second query. On Mon, 11 Mar 2019, 13:37 Zachary N. Dean, > wrote: Hello Adam, I think the issue is that the Arrow Operator '=>' is simply "syntactic sugar" for using the LHS as the FIRST argument of the function call on the RHS. The Argument Placeholder '?' has no direct relation to the Arrow Operator. So, in the case of the first example: function($k, $v) { "$k=" || $k } => map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? )() Simply becomes: map:for-each( function($k, $v) { "$k=" || $k }, map { "a" : "1", "b" : "2", "c" : "3" }, ? )() So, the 3 argument map:for-each isn't found. (and the final call would have the wrong arity if it was found) Hope this helps, Zack -----Original Message----- From: talk-bounces at x-query.com > On Behalf Of Adam Retter Sent: Montag, 11. M?rz 2019 06:21 To: XQuery Talk ML > Cc: juri at existsolutions.com Subject: [xquery-talk] Arrow Operator to a Partially Applied Function Without thinking too deeply, whilst writing some XQuery recently I was initially surprised to discover that the following (simplified) query fails with the static error - [XPST0017] map:for-each(map,function): 3 arguments supplied, 2 expected. xquery version "3.1"; declare namespace map = "http://www.w3.org/2005/xpath-functions/map"; function($k, $v) { "$k=" || $k } => map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? )() After having looked into the specs in more detail, I thought I was able to derive a reason for this... i.e. the partial function application syntax is not processed until the dynamic evaluation phase. Therefore when the arrow operator is processed first during the static analysis phase, it tries to find a map:for-each function that takes 3 parameters, the first being of the function type on LHS of the arrow operator, and second being the map, and the third being the unbound parameter `?`. However, I then noticed that if I reformulatedby query with an indirection through a variable binding `$x` then it compiles and executes just fine. Presumably this indicates that my understanding above is incorrect, as whilst the variable binding may change the evaluation order, the static analysis and dynamic evaluation phases should still happen in the same order. xquery version "3.1"; declare namespace map = "http://www.w3.org/2005/xpath-functions/map"; let $x := map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? ) return function($k, $v) { "$k=" || $k } => $x() I basically get the same results on eXist-db, Saxon, and BaseX. I would appreciate if someone could help me understand what I am seeing here... Thanks Adam. -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk --- This email has been checked for viruses by AVG. https://www.avg.com _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk -- John Snelson, Principal Engineer http://twitter.com/jpcs MarkLogic Corporation http://www.marklogic.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at saxonica.com Mon Mar 11 10:33:16 2019 From: mike at saxonica.com (Michael Kay) Date: Mon, 11 Mar 2019 17:33:16 +0000 Subject: [xquery-talk] Arrow Operator to a Partially Applied Function In-Reply-To: <97783c4a-841a-b301-5f8d-006e780a55d0@marklogic.com> References: <043c01d4d7d4$f194dad0$d4be9070$@zadean.com> <97783c4a-841a-b301-5f8d-006e780a55d0@marklogic.com> Message-ID: <71FAF5B1-B4A4-405F-B998-B840BBFD258B@saxonica.com> > On 11 Mar 2019, at 17:22, John Snelson wrote: > > Looks like a bug to me. The first argument of the partially applied "map:for-each" is the one marked with a "?". Not sure what you mean by "bug" here, but I think it's doing what the spec says. A => B(x, ?)() means B(A, x, ?)() not B(x, ?)(A) Michael Kay Saxonica > > On 10/03/2019 23:45, Adam Retter wrote: >> Thanks Zach. I suspect you are right. However I can't help wishing that the argument placeholders should be resolved before the arrow operator is applied... >> >> For the average developer, the fact that my first query raises an error seems non intuitive, especally in light of the reformulation in my second query. >> >> On Mon, 11 Mar 2019, 13:37 Zachary N. Dean, > wrote: >> Hello Adam, >> >> I think the issue is that the Arrow Operator '=>' is simply "syntactic >> sugar" for using the LHS as the FIRST argument of the function call on the >> RHS. >> The Argument Placeholder '?' has no direct relation to the Arrow Operator. >> >> So, in the case of the first example: >> >> function($k, $v) { >> "$k=" || $k >> } => >> map:for-each( >> map { >> "a" : "1", >> "b" : "2", >> "c" : "3" >> }, >> ? >> )() >> >> Simply becomes: >> >> map:for-each( >> function($k, $v) { >> "$k=" || $k >> }, >> map { >> "a" : "1", >> "b" : "2", >> "c" : "3" >> }, >> ? >> )() >> >> >> So, the 3 argument map:for-each isn't found. (and the final call would have >> the wrong arity if it was found) >> >> >> Hope this helps, >> >> Zack >> >> -----Original Message----- >> From: talk-bounces at x-query.com > On Behalf Of Adam >> Retter >> Sent: Montag, 11. M?rz 2019 06:21 >> To: XQuery Talk ML > >> Cc: juri at existsolutions.com >> Subject: [xquery-talk] Arrow Operator to a Partially Applied Function >> >> Without thinking too deeply, whilst writing some XQuery recently I was >> initially surprised to discover that the following (simplified) query fails >> with the static error - [XPST0017] map:for-each(map,function) : 3 arguments >> supplied, 2 expected. >> >> >> xquery version "3.1"; >> declare namespace map = "http://www.w3.org/2005/xpath-functions/map "; >> >> function($k, $v) { >> "$k=" || $k >> } => >> map:for-each( >> map { >> "a" : "1", >> "b" : "2", >> "c" : "3" >> }, >> ? >> )() >> >> >> After having looked into the specs in more detail, I thought I was able to >> derive a reason for this... i.e. the partial function application syntax is >> not processed until the dynamic evaluation phase. Therefore when the arrow >> operator is processed first during the static analysis phase, it tries to >> find a map:for-each function that takes 3 parameters, the first being of the >> function type on LHS of the arrow operator, and second being the map, and >> the third being the unbound parameter `?`. >> >> However, I then noticed that if I reformulatedby query with an indirection >> through a variable binding `$x` then it compiles and executes just fine. >> Presumably this indicates that my understanding above is incorrect, as >> whilst the variable binding may change the evaluation order, the static >> analysis and dynamic evaluation phases should still happen in the same >> order. >> >> >> xquery version "3.1"; >> declare namespace map = "http://www.w3.org/2005/xpath-functions/map "; >> >> let $x := >> map:for-each( >> map { >> "a" : "1", >> "b" : "2", >> "c" : "3" >> }, >> ? >> ) >> return >> >> function($k, $v) { >> "$k=" || $k >> } => $x() >> >> >> I basically get the same results on eXist-db, Saxon, and BaseX. I would >> appreciate if someone could help me understand what I am seeing here... >> >> Thanks Adam. >> >> -- >> Adam Retter >> >> skype: adam.retter >> tweet: adamretter >> http://www.adamretter.org.uk >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk >> >> --- >> This email has been checked for viruses by AVG. >> https://www.avg.com >> >> >> >> _______________________________________________ >> talk at x-query.com >> http://x-query.com/mailman/listinfo/talk > -- > John Snelson, Principal Engineer http://twitter.com/jpcs > MarkLogic Corporation http://www.marklogic.com _______________________________________________ > talk at x-query.com > http://x-query.com/mailman/listinfo/talk -------------- next part -------------- An HTML attachment was scrubbed... URL: From John.Snelson at marklogic.com Mon Mar 11 10:34:55 2019 From: John.Snelson at marklogic.com (John Snelson) Date: Mon, 11 Mar 2019 17:34:55 +0000 Subject: [xquery-talk] Arrow Operator to a Partially Applied Function In-Reply-To: <97783c4a-841a-b301-5f8d-006e780a55d0@marklogic.com> References: <043c01d4d7d4$f194dad0$d4be9070$@zadean.com> <97783c4a-841a-b301-5f8d-006e780a55d0@marklogic.com> Message-ID: <7d8f578a-2e83-1274-8ef0-158620383a96@marklogic.com> Ah - it's a precedence problem. Try putting the partial apply in parentheses: function($k, $v) { "$k=" || $k } => (map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? ))() John On 11/03/2019 10:22, John Snelson wrote: Looks like a bug to me. The first argument of the partially applied "map:for-each" is the one marked with a "?". On 10/03/2019 23:45, Adam Retter wrote: Thanks Zach. I suspect you are right. However I can't help wishing that the argument placeholders should be resolved before the arrow operator is applied... For the average developer, the fact that my first query raises an error seems non intuitive, especally in light of the reformulation in my second query. On Mon, 11 Mar 2019, 13:37 Zachary N. Dean, > wrote: Hello Adam, I think the issue is that the Arrow Operator '=>' is simply "syntactic sugar" for using the LHS as the FIRST argument of the function call on the RHS. The Argument Placeholder '?' has no direct relation to the Arrow Operator. So, in the case of the first example: function($k, $v) { "$k=" || $k } => map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? )() Simply becomes: map:for-each( function($k, $v) { "$k=" || $k }, map { "a" : "1", "b" : "2", "c" : "3" }, ? )() So, the 3 argument map:for-each isn't found. (and the final call would have the wrong arity if it was found) Hope this helps, Zack -----Original Message----- From: talk-bounces at x-query.com > On Behalf Of Adam Retter Sent: Montag, 11. M?rz 2019 06:21 To: XQuery Talk ML > Cc: juri at existsolutions.com Subject: [xquery-talk] Arrow Operator to a Partially Applied Function Without thinking too deeply, whilst writing some XQuery recently I was initially surprised to discover that the following (simplified) query fails with the static error - [XPST0017] map:for-each(map,function): 3 arguments supplied, 2 expected. xquery version "3.1"; declare namespace map = "http://www.w3.org/2005/xpath-functions/map"; function($k, $v) { "$k=" || $k } => map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? )() After having looked into the specs in more detail, I thought I was able to derive a reason for this... i.e. the partial function application syntax is not processed until the dynamic evaluation phase. Therefore when the arrow operator is processed first during the static analysis phase, it tries to find a map:for-each function that takes 3 parameters, the first being of the function type on LHS of the arrow operator, and second being the map, and the third being the unbound parameter `?`. However, I then noticed that if I reformulatedby query with an indirection through a variable binding `$x` then it compiles and executes just fine. Presumably this indicates that my understanding above is incorrect, as whilst the variable binding may change the evaluation order, the static analysis and dynamic evaluation phases should still happen in the same order. xquery version "3.1"; declare namespace map = "http://www.w3.org/2005/xpath-functions/map"; let $x := map:for-each( map { "a" : "1", "b" : "2", "c" : "3" }, ? ) return function($k, $v) { "$k=" || $k } => $x() I basically get the same results on eXist-db, Saxon, and BaseX. I would appreciate if someone could help me understand what I am seeing here... Thanks Adam. -- Adam Retter skype: adam.retter tweet: adamretter http://www.adamretter.org.uk _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk --- This email has been checked for viruses by AVG. https://www.avg.com _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk -- John Snelson, Principal Engineer http://twitter.com/jpcs MarkLogic Corporation http://www.marklogic.com _______________________________________________ talk at x-query.com http://x-query.com/mailman/listinfo/talk -- John Snelson, Principal Engineer http://twitter.com/jpcs MarkLogic Corporation http://www.marklogic.com -------------- next part -------------- An HTML attachment was scrubbed... URL: