Skip to content

Can't pass parameter to function #42

@mhanberg

Description

@mhanberg

Description

I am trying to dynamically load parquet files into a query. I am able to do this on the duckdb cli, but using duckdbex, I seem to get an error

Repro

file = "some.parquet"
{:ok, db} = Duckdbex.open()
{:ok, conn} = Duckdbex.connection(db)
Duckdbex.query(conn, "INSTALL 'parquet';")
Duckdbex.query(conn, "INSTALL 'core_functions';")
Duckdbex.query(conn, "LOAD 'parquet'; LOAD 'core_functions'")

{:ok, result_ref} =
  Duckdbex.query(
    conn,
    """
    SELECT
      *
    FROM
      read_parquet([$1]);
    """,
    [file]
  )

results =
  Duckdbex.fetch_all(result_ref)

results
|> IO.inspect()

yields the error

** (MatchError) no match of right hand side value: {:error, "Invalid Input Error: Values were not provided for the following prepared statement parameters: 1"}

CLI

Running a similar query on the CLI seems to work.

Image

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions