GithubHelp home page GithubHelp logo

alexr2d2 / duckdbex Goto Github PK

View Code? Open in Web Editor NEW
53.0 53.0 13.0 8.78 MB

The Library embeds C++ DuckDB database into you Elixir application.

License: MIT License

Elixir 0.41% Makefile 0.01% C++ 99.58% Shell 0.01%

duckdbex's People

Contributors

alexr2d2 avatar sam-terrell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

duckdbex's Issues

Update Duckdb Amalgation source code to the latest current version (0.7.0)

Currently we do not have the latest version of DuckDB in the codebase.

It would be also great to have a Makefile or a bash script to keep the update process reproducible and documented.

For example in Exqlite there is a small bash script for this:

Having the Duckdb version exposed as something accessible in Elixir would help to decide which features / bugs / etc are available to be used.

ArgumentError on mac m1

๐Ÿ‘‹

Here's what I'm running on:

$ uname -a
Darwin mac3.local 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:39:35 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T8103 arm64

Here's what I'm doing:

iex(1)> Mix.install [:duckdbex], force: true
Resolving Hex dependencies...
Resolution completed in 0.032s
New:
  cc_precompiler 0.1.7
  duckdbex 0.2.3
  elixir_make 0.7.6
* Getting duckdbex (Hex package)
* Getting cc_precompiler (Hex package)
* Getting elixir_make (Hex package)
==> elixir_make
Compiling 6 files (.ex)
Generated elixir_make app
==> cc_precompiler
Compiling 3 files (.ex)
Generated cc_precompiler app
==> duckdbex
Compiling 3 files (.ex)
Generated duckdbex app
:ok

iex(2)> {:ok, conn} = Duckdbex.open()
{:ok, #Reference<0.2113251800.2909405206.141355>}

iex(3)> Duckdbex.query(conn, "select 1 + 1")
** (ArgumentError) argument error
    (duckdbex 0.2.3) Duckdbex.NIF.query(#Reference<0.2113251800.2909405206.141355>, "select 1 + 1")
    iex:5: (file)

Integer parameter doesn't match correctly

Hello,

When I use a integer parameter in my query, the result is empty. But when I replace the value directly in the request I have results. I think the type of the parameter is not match correctly.

iex(27)> query = """
...(27)> WITH p AS (
...(27)>   SELECT pdvid,
...(27)>          ville,
...(27)>          adresse,
...(27)>          type_carburant,
...(27)>          AVG(prix) as p,
...(27)>          ST_MAXDISTANCE(ST_MAKEPOINT($1,$2), point)/1000 as d,
...(27)>          MAX(maj)
...(27)>   FROM prix
...(27)>   WHERE ST_MAXDISTANCE(ST_MAKEPOINT($1,$2), point)/1000 < $3
...(27)>   GROUP BY all
...(27)>   ORDER BY p ASC)
...(27)>   SELECT * FROM p LEFT JOIN stations ON p.pdvid = stations.id
...(27)> ;
...(27)> """
"WITH p AS (\n  SELECT pdvid,\n         ville,\n         adresse,\n         type_carburant,\n         AVG(prix) as p, \n         ST_MAXDISTANCE(ST_MAKEPOINT($1,$2), point)/1000 as d,\n         MAX(maj)\n  FROM prix\n  WHERE ST_MAXDISTANCE(ST_MAKEPOINT($1,$2), point)/1000 < $3\n  GROUP BY all\n  ORDER BY p ASC)\n  SELECT * FROM p LEFT JOIN stations ON p.pdvid = stations.id\n;\n"
iex(28)> {:ok, stmt_ref} = Duckdbex.prepare_statement(conn, query)
{:ok, #Reference<0.2394428590.1507983383.48133>}
iex(29)> {:ok, result_ref} = Duckdbex.execute_statement(stmt_ref, [5.2625, 43.6547, 10])
{:ok, #Reference<0.2394428590.1507983383.48134>}
iex(30)> result = Duckdbex.fetch_all(result_ref)
[]
iex(23)> query = """
...(23)> WITH p AS (
...(23)>   SELECT pdvid,
...(23)>          ville,
...(23)>          adresse,
...(23)>          type_carburant,
...(23)>          AVG(prix) as p,
...(23)>          ST_MAXDISTANCE(ST_MAKEPOINT($1,$2), point)/1000 as d,
...(23)>          MAX(maj)
...(23)>   FROM prix
...(23)>   WHERE ST_MAXDISTANCE(ST_MAKEPOINT($1,$2), point)/1000 < 10
...(23)>   GROUP BY all
...(23)>   ORDER BY p ASC)
...(23)>   SELECT * FROM p LEFT JOIN stations ON p.pdvid = stations.id
...(23)> ;
...(23)> """
"WITH p AS (\n  SELECT pdvid,\n         ville,\n         adresse,\n         type_carburant,\n         AVG(prix) as p, \n         ST_MAXDISTANCE(ST_MAKEPOINT($1,$2), point)/1000 as d,\n         MAX(maj)\n  FROM prix\n  WHERE ST_MAXDISTANCE(ST_MAKEPOINT($1,$2), point)/1000 < 10\n  GROUP BY all\n  ORDER BY p ASC)\n  SELECT * FROM p LEFT JOIN stations ON p.pdvid = stations.id\n;\n"
iex(24)> {:ok, stmt_ref} = Duckdbex.prepare_statement(conn, query)
{:ok, #Reference<0.2394428590.1507983383.48131>}
iex(25)> {:ok, result_ref} = Duckdbex.execute_statement(stmt_ref, [5.2625, 43.6547])
{:ok, #Reference<0.2394428590.1507983383.48132>}
iex(26)> result = Duckdbex.fetch_all(result_ref)
[
  [
    13410002,
    "Lambesc",
    "Avenue Jean Monnet",
    "E85",
    0.8570512820512819,
    0.8727622092,
    {{2023, 3, 3}, {7, 17, 32, 0}},
    "CASINO SUPERMARCHE",
    "Casino",
    13410002
  ],
...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.