elixir-explorer / explorer

Series (one-dimensional) and dataframes (two-dimensional) for fast and elegant data exploration in Elixir
https://hexdocs.pm/explorer
MIT License
1.12k stars 123 forks source link

Duckdb select statement only works on non first line in the cell #949

Closed kuatroka closed 3 months ago

kuatroka commented 3 months ago

There seems to be a bug when running the SQL in a smart cell connected to duckdb. The SQL breaks if executed on the very first line of the cell. All other cell work fine. See the gif duckdb_livebook

josevalim commented 3 months ago

Can you please click on <> and show us the generated code for both cases?

josevalim commented 3 months ago

Also, does it work if you use {{file}} instead?

kuatroka commented 3 months ago

Can you please click on <> and show us the generated code for both cases?

When I type on the line 1, the code is:

result =
  Explorer.DataFrame.from_query!(conn, "select * from read_parquet('\#{file}')", [])

When I type on the line 2, the code is:

result =
  Explorer.DataFrame.from_query!(
    conn,
    """

    select * from read_parquet('#{file}')
    """,
    []
  )

Also, does it work if you use {{file}} instead?

With this syntax everything works on both lines. I didn't know about this syntax. I was following Elixir syntax for referencing variables in text I found somewhere online

josevalim commented 3 months ago

Closing on https://github.com/livebook-dev/kino_db/pull/74.