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>
<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


⚡Generated with XQuery