sql

István Karaszi 2026-02-25T17:42:01.822179Z

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
István Karaszi 2026-02-25T17:42:38.185929Z

This latter solution works without a problem using a PostgreSQL database

2026-02-25T17:48:57.593209Z

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

👍 1
István Karaszi 2026-02-25T17:50:18.814729Z

That is indeed working

2026-02-25T17:51:00.477609Z

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
István Karaszi 2026-02-25T17:52:12.544779Z

Thank you for the explanation!

István Karaszi 2026-02-25T17:52:26.867659Z

Do you know why that is different comparing to PostgreSQL?

2026-02-25T17:52:53.207979Z

I do not

2026-02-25T17:53:24.263119Z

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

István Karaszi 2026-02-25T17:53:42.993719Z

Anyways, thank you!

seancorfield 2026-02-25T21:13:13.485839Z

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.

István Karaszi 2026-02-25T21:29:26.439879Z

That was just a simple example for demonstrating the issue