techascent / tmducken

tech.ml.dataset integration with duckdb
MIT License
58 stars 5 forks source link

Querying tables defined via schema fails #36

Closed cnuernber closed 1 month ago

cnuernber commented 2 months ago

See zulip thread - https://clojurians.zulipchat.com/#narrow/stream/236259-tech.2Eml.2Edataset.2Edev/topic/duckdb.2Finsert-dataset!.20table.20schema.20support

(deftest basic-datatype-test
  (try
    (let [ds (supported-datatype-ds)]
      (duckdb/run-query! @conn* "CREATE SCHEMA foo")
      (duckdb/create-table! @conn* ds)
      (tap> (ds/rows (duckdb/sql->dataset @conn* "select * from information_schema.tables"
                                          {:key-fn keyword})))
      (duckdb/insert-dataset! @conn* ds)
      (let [sql-ds (duckdb/sql->dataset @conn* "select * from foo.testtable"
                                        {:key-fn keyword})]
        (doseq [column (vals ds)]
          (is (= (vec column)
                 (vec (sql-ds (:name (meta column)))))))))
    (finally
      (try (duckdb/run-query! @conn* "DROP SCHEMA foo CASCADE")
           #_(duckdb/drop-table! @conn* "foo.testtable")
           (catch Throwable e nil)))))