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.13k stars 123 forks source link

Initial SQL support #918

Closed billylanchantin closed 5 months ago

billylanchantin commented 5 months ago

Description

This PR experiments with initial SQL support by adding Explorer.DataFrame.sql/3 for making SQL queries against dataframes.

Example

iex> df = DF.new(a: [1, 2, 3], b: ["x", "y", "y"])
iex> DF.sql(df, "select a, b from df group by b order by b")
# #Explorer.DataFrame<
#   Polars[2 x 2]
#   a list[s64] [[1], [2, 3]]
#   b string ["x", "y"]
# >

Limitations

billylanchantin commented 5 months ago

@josevalim I'm good with that! DF.sql is more powerful and has actual documentation :)

Any particular hesitation with the embedded SQL part? Or are you just favoring smaller changes since this is experimental?

josevalim commented 5 months ago

Just favoring something smaller for now. It is always easier to add stuff than to remove them. :)