blob: 35d1a99ab31fb423666fff7ea0749c6f5d2952a7 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
use dataverse tpch;
for $l in dataset('LineItem')
for $o in dataset('Orders')
where $o.o_orderkey = $l.l_orderkey
and $l.l_commitdate < $l.l_receiptdate
and $l.l_shipdate < $l.l_commitdate
and $l.l_receiptdate >= '1994-01-01'
and $l.l_receiptdate < '1995-01-01'
and ($l.l_shipmode = 'MAIL' or $l.l_shipmode = 'SHIP')
group by $l_shipmode := $l.l_shipmode with $o
order by $l_shipmode
return {
"l_shipmode": $l_shipmode,
"high_line_count": sum(
for $i in $o
return
switch-case($i.o_orderpriority ='1-URGENT' or $i.o_orderpriority ='2-HIGH',
true, 1, false, 0)
),
"low_line_count": sum(
for $i in $o
return switch-case($i.o_orderpriority ='1-URGENT' or $i.o_orderpriority ='2-HIGH',
true, 0, false, 1)
)
}