distinct-values and type coercion

Tuesday, 19 May 2020 · 2 messages
ML
Marco Lettere19 May 2020 16:12 #
Dear all, after installing Basex 9.3.3 one application of ours started failing in a particular functionality. We tracked it down to the following example code:
let $in :=
   <json type="object">
     <source type="object">
<reference>Object/20383920-5bb1-4397-8b51-b752863acddf</reference>
     </source>
   </json>
let $s as xs:string* := distinct-values($in/source/reference/string())
return $s
This code now returns the following error: [XPTY0004] Cannot treat xs:untypedAtomic* as xs:string*: distinct-values($in_0/element(source)/element(reference)). Whereas before it was automatically casting to xs:string now it seems that the type coercion in the let clause is too restrictive. This happens only with the distinct-values applied by the way. Is it correct now or was it before? For the moment we solved by removing the type enforcement in the let clause. Thank you for the clarification. Regards, Marco.
CG
Christian Grün19 May 2020 18:31 #
…confirmed and fixed, a new snapshot is available. The optimizer dropped "/string()" (as distinct-values will always atomize its argument), but as a result, the result type changed to xs:untypedAtomic*.
Quoted text · Marco Lettere · 35 lines
On Tue, May 19, 2020 at 4:12 PM Marco Lettere <m.lettere at gmail.com> wrote: > > Dear all, > > after installing Basex 9.3.3 one application of ours started failing in > a particular functionality. > > We tracked it down to the following example code: > > let $in := > <json type="object"> > <source type="object"> > <reference>Object/20383920-5bb1-4397-8b51-b752863acddf</reference> > </source> > </json> > let $s as xs:string* := distinct-values($in/source/reference/string()) > return $s > > This code now returns the following error: [XPTY0004] Cannot treat > xs:untypedAtomic* as xs:string*: > distinct-values($in_0/element(source)/element(reference)). > Whereas before it was automatically casting to xs:string now it seems > that the type coercion in the let clause is too restrictive. > > This happens only with the distinct-values applied by the way. > > Is it correct now or was it before? For the moment we solved by removing > the type enforcement in the let clause. > > Thank you for the clarification. > > Regards, > > Marco. >

⚡Generated with XQuery