Aggregate Functions in Stargate’s GraphQL API
Thursday, June 3rd, 2021,a new release of Stargate was applied to Astra. It includes an exciting new feature: aggregate functions! If you’re not familiar with aggregate functions, they are functions that look at the data as a whole and perform a function like min(), max(), sum(), count() and avg().
Until now, aggregate functions were only available using cqlsh (the CQL Shell). However, with the Stargate 1.0.25 release they are now also available using the GraphQL API. In this blog entry, I’ll walk you through the process to get early access to this exciting new functionality in Stargate, and how to setup everything you need to test your own aggregate queries.
Using cqlsh to perform an aggregate query is pretty straight forward. Assuming you have an employee table with the following sales data:
╔════╦═════════╦══════╦══════════════════════════╗
║ id ║ name ║ sale ║ rtime ║
╠════╬═════════╬══════╬══════════════════════════╣
║ 1 ║ John ║ 1000 ║ 2019-01-12T09:48:31.020Z ║
║ 2 ║ Mustafa ║ 2000 ║ 2019-02-12T09:48:31.020Z ║
║ 3 ║ Krishna ║ 2500 ║ 2019-01-12T09:48:31.020Z ║
║ 1 ║ John ║ 2200 ║ 2020-01-12T09:48:31.020Z ║
║ 1 ║ John ║ 2350 ║ 2021-01-12T09:48:31.020Z ║
║ 2 ║ Mustafa ║ 3000 ║ 2020-02-12T09:48:31.020Z ║
║ 2 ║ Mustafa ║ 300 ║ 2021-02-12T09:48:31.020Z ║
║ 3 ║ Krishna ║ 1500…