This example shows how to filter data with the WHERE
clause in Dozer.
Let us write a query to calculate the tips
and trip_miles
for rides that cover more than 100 miles, along with an additional filter which ensures that the result will be for hvfhs_license_num
ending with 03
only.
SELECT tips, trip_miles
INTO table1
FROM trips
WHERE trip_miles > 100
AND hvfhs_license_num LIKE '%03';
To run Dozer navigate to the join folder /sql/filter
& use the following command
dozer run
To remove the cache directory, use
dozer clean
To run with Dozer live, replace run
with live
dozer live
Dozer live automatically deletes the cache upon stopping the program.
Dozer API lets us use filter
,limit
,order_by
and skip
at the endpoints. For this example lets order the data in descending order of tips
.
Execute the following commands over bash to get the results from REST
and gRPC
APIs.
REST
curl -X POST http://localhost:8080/tip_amount/query \
--header 'Content-Type: application/json' \
--data-raw '{"$order_by": {"tips": "desc"}}'
gRPC
grpcurl -d '{"endpoint": "tip_amount", "query": "{\"$order_by\": {\"tips\": \"desc\"}}"}' \
-plaintext localhost:50051 \
dozer.common.CommonGrpcService/query