where instead of when in window start clause
Monday, 17 February 2025 · 2 messages · last reply 22 Feb 2025
MH
Martin Honnen17 Feb 2025 12:33 #
I mistyped a start clause in a tumbling window expression using "where" instead of "when"
for tumbling window $w in (1 to 20)
start at $s where $s mod 3 = 1
return <window>{$w}</window>see
https://fiddle.basex.org/?share=%28%27query%21%27for+tumbling+-*w+in+%7B1+to+20%7D%5Cnstart+at4where4mod+3+%3D+1%5Cnreturn+%3C5%28%24w%29%3C%2F5.%21%27%27%7Emode%21%27XQuery+%7BBaseX%7D.Type%21%27xml%27%29*+%24-window.%27%7Econtext4*s+5-%3E%0154.-*_, but I didn't get an error but a result
<window>1</window>
<window>4</window>
<window>7</window>
<window>10</window>
<window>13</window>
<window>16</window>
<window>19</window>Shouldn't that query give a syntax error that "when" is expected instead of "where"?
Or is that a new XQuery 4 feature that the "when" clause can be omitted and the above is kind of parsed/executed as
for tumbling window $w in (1 to 20)
start at $s
where $s mod 3 = 1
return <window>{$w}</window>?
CG
Christian Grün22 Feb 2025 11:47 #
Hi Martin,
Or is that a new XQuery 4 feature that the "when" clause can be omitted …
Exactly, window clauses have become more flexible: You can now omit the 'when' condition, as well as the 'start' clause [1].
Hope this helps,
Christian
[1] https://qt4cg.org/specifications/xquery-40/xquery-40.html#id-windows
Written for BaseX 11.7. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery