Why do you have to use SUM(cases)::INT instead of SUM(cases) ? The latter returns an object instead of the sum of cases. Could you provide a link to the duckDB docs which explains this?
Good question -- I actually don't see it written out in their documentation on aggregate functions: https://duckdb.org/docs/sql/aggregates. It's unclear to me why these values need to be cast as integers in the JavaScript API, but it's the practice in their examples here: https://observablehq.com/@cmudig/duckdb-client. You can see how removing it returns an Object with an undesired structure.