sql 2026-02-25

DuckDB querying I am trying to query data from DuckDB and trying to use db/plan! here. When I try to execute my query with (->> query hsql/format (db/execute! db)) then it works without a problem, but when I try to do: (->> query hsql/format (db/plan! db) (into [] identity)) then it returns a vector with "{row} from plan` -- missing map or reduce?“`

✅ 1

This latter solution works without a problem using a PostgreSQL database

try (map #(select-keys % (keys %))) instead of identity there

👍 1

That is indeed working

next.jdbc instead of returning realized maps returns these sort of proxy maps that inside the reducing context of plan act like a map, but out side of that don't, the select-keys things transforms them into real maps before leaving the reducing context of plan

🆒 1

Thank you for the explanation!

Do you know why that is different comparing to PostgreSQL?

could be something different in the postgres jdbc driver in how and where result sets are valid

Anyways, thank you!

I'm actually surprised it works with PG -- I would not have expected it to work with any database -- and I'll also note that there's no point in using plan here if you're just going to reduce whole rows into a vector (with into []). plan is intended specifically for eagerly consuming a result set without turning it into a whole bunch of Clojure data structures, in particular, so that you can process result sets that are very large without overflowing memory (streaming from the database). But there are a lot of situations where you can consume result sets via reduce-over-`plan` rather than calling execute! and then processing an entire vector of hash maps.

That was just a simple example for demonstrating the issue