Skip to content

Commit

Permalink
added array of fixed size into supported typed
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexR2D2 committed Jun 24, 2024
1 parent 058383d commit fe5b0ba
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions c_src/value_to_term.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ bool nif::value_to_term(ErlNifEnv* env, const duckdb::Value& value, ERL_NIF_TERM
sink = make_binary_term(env, varchar.c_str(), varchar.size());
return true;
}
case duckdb::LogicalTypeId::ARRAY:
case duckdb::LogicalTypeId::LIST: {
auto& list = duckdb::ListValue::GetChildren(value);
std::vector<ERL_NIF_TERM> term_array(list.size());
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Duckdbex.MixProject do
use Mix.Project

@version "0.3.0"
@version "0.3.1"
@duckdb_version "1.0.0"

def project do
Expand Down
7 changes: 7 additions & 0 deletions test/nif/types_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,13 @@ defmodule Duckdbex.Nif.QueryTest do
assert [] = NIF.fetch_all(r)
end

test "ARRAY", %{conn: conn} do
assert {:ok, _} = NIF.query(conn, "CREATE TABLE an_array(embeddings FLOAT[3])")
assert {:ok, _} = NIF.query(conn, "INSERT INTO an_array VALUES ([1, 2, 3])")
assert {:ok, r} = NIF.query(conn, "SELECT * FROM an_array")
assert [[[1.0, 2.0, 3.0]]] = NIF.fetch_all(r)
end

test "MAP", %{conn: conn} do
assert {:ok, r} = NIF.query(conn, "select map();")
assert [[%{}]] = NIF.fetch_all(r)
Expand Down

0 comments on commit fe5b0ba

Please sign in to comment.